From 60fd754bba01e1c5bdb04fb608622895cb6a77c0 Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Fri, 8 Jun 2018 14:01:03 +0200 Subject: [PATCH] TT#37652 PBXConfig: As a Customer, I want to change the MAC address of a PBXDevice Change-Id: I9152172cecaa629911021258b46a22c98dc602b0 --- src/api/pbx-config.js | 8 ++++ .../pages/PbxConfiguration/CscPbxDevice.vue | 43 +++++++++++++++++-- .../pages/PbxConfiguration/CscPbxDevices.vue | 25 ++++++++--- src/locales/en.json | 1 + src/store/pbx-config/actions.js | 12 +++++- src/store/pbx-config/getters.js | 3 ++ src/store/pbx-config/mutations.js | 36 +++++++++++++--- src/store/pbx-config/state.js | 1 + 8 files changed, 112 insertions(+), 17 deletions(-) diff --git a/src/api/pbx-config.js b/src/api/pbx-config.js index be9e905f..1eb034f0 100644 --- a/src/api/pbx-config.js +++ b/src/api/pbx-config.js @@ -463,3 +463,11 @@ export function setStationName(options) { value: options.station_name }); } + +export function setIdentifier(deviceId, identifier) { + return patchReplace({ + path: 'api/pbxdevices/' + deviceId, + fieldPath: 'identifier', + value: identifier + }); +} diff --git a/src/components/pages/PbxConfiguration/CscPbxDevice.vue b/src/components/pages/PbxConfiguration/CscPbxDevice.vue index 96db8efb..d6d029f6 100644 --- a/src/components/pages/PbxConfiguration/CscPbxDevice.vue +++ b/src/components/pages/PbxConfiguration/CscPbxDevice.vue @@ -46,7 +46,8 @@ > @@ -178,12 +179,39 @@ deviceModel() { return { id: this.changes.id, - station_name: this.changes.stationName + station_name: this.changes.stationName, + identifier: this.device.identifier } }, stationNameHasChanges() { return this.stationName !== this.changes.stationName; - } + }, + identifierHasChanges() { + return this.device.identifier !== this.changes.identifier; + }, + identifierButtons() { + let buttons = []; + let self = this; + if(this.identifierHasChanges) { + buttons.push({ + icon: 'check', + error: false, + handler (event) { + event.stopPropagation(); + self.saveIdentifier(); + } + }, { + icon: 'clear', + error: false, + handler (event) { + event.stopPropagation(); + self.resetIdentifier(); + } + } + ); + } + return buttons; + }, }, mounted() { this.$emit('loaded'); @@ -207,7 +235,8 @@ getDevice() { return { id: this.device.id, - stationName: this.device.station_name + stationName: this.device.station_name, + identifier: this.device.identifier } }, resetStationName() { @@ -215,6 +244,12 @@ }, saveStationName() { this.$emit('save-station-name', this.deviceModel); + }, + resetIdentifier() { + this.changes.identifier = this.device.identifier; + }, + saveIdentifier() { + this.$emit('save-identifier', this.deviceModel); } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxDevices.vue b/src/components/pages/PbxConfiguration/CscPbxDevices.vue index 0cccab26..12900fe4 100644 --- a/src/components/pages/PbxConfiguration/CscPbxDevices.vue +++ b/src/components/pages/PbxConfiguration/CscPbxDevices.vue @@ -26,7 +26,8 @@ :label="$t('pbxConfig.filterPhoneModel')" @opened="modelSelectOpened()" @select="filterByProfile" - @reseted="resetFilter" /> + @reseted="resetFilter" + />
{ context.commit('updateStationNameFailed', err.message); }); + }, + setIdentifier(context, device) { + context.commit('updateIdentifierRequesting', device); + setIdentifier(device.id, device.identifier).then(() => { + context.commit('updateIdentifierSucceeded'); + context.dispatch('loadDevice', device.id); + }).catch((err) => { + context.commit('updateIdentifierFailed', err.message); + }); } } diff --git a/src/store/pbx-config/getters.js b/src/store/pbx-config/getters.js index 3fb1c6ce..3f7e06e5 100644 --- a/src/store/pbx-config/getters.js +++ b/src/store/pbx-config/getters.js @@ -264,5 +264,8 @@ export default { }, updatedDeviceError(state) { return state.updatedDeviceError; + }, + updatedDeviceProperty(state) { + return state.updatedDeviceProperty; } } diff --git a/src/store/pbx-config/mutations.js b/src/store/pbx-config/mutations.js index f9a74d1e..6c9f9eaa 100644 --- a/src/store/pbx-config/mutations.js +++ b/src/store/pbx-config/mutations.js @@ -5,6 +5,23 @@ import _ from 'lodash' import { RequestState } from '../common' import { reactiveSet } from '../../helpers/store-helper' +function updateDevicePropertyRequesting(state, deviceId, property) { + state.updatedDevice = deviceId; + state.updatedDeviceState = RequestState.requesting; + state.updatedDeviceError = null; + state.updatedDeviceProperty = property; +} + +function updateDevicePropertySucceeded(state) { + state.updatedDeviceState = RequestState.succeeded; + state.updatedDeviceError = null; +} + +function updateDevicePropertyFailed(state, error) { + state.updatedDeviceState = RequestState.failed; + state.updatedDeviceError = error; +} + export default { listRequesting(state, options) { options = options || {}; @@ -287,16 +304,21 @@ export default { state.listProfilesError = error; }, updateStationNameRequesting(state, deviceId) { - state.updatedDevice = deviceId; - state.updatedDeviceState = RequestState.requesting; - state.updatedDeviceError = null; + updateDevicePropertyRequesting(state, deviceId, 'station_name'); }, updateStationNameSucceeded(state) { - state.updatedDeviceState = RequestState.succeeded; - state.updatedDeviceError = null; + updateDevicePropertySucceeded(state); }, updateStationNameFailed(state, error) { - state.updatedDeviceState = RequestState.failed; - state.updatedDeviceError = error; + updateDevicePropertyFailed(state, error); + }, + updateIdentifierRequesting(state, deviceId) { + updateDevicePropertyRequesting(state, deviceId, 'identifier'); + }, + updateIdentifierSucceeded(state) { + updateDevicePropertySucceeded(state); + }, + updateIdentifierFailed(state, error) { + updateDevicePropertyFailed(state, error); } } diff --git a/src/store/pbx-config/state.js b/src/store/pbx-config/state.js index e5418685..76bdb798 100644 --- a/src/store/pbx-config/state.js +++ b/src/store/pbx-config/state.js @@ -52,6 +52,7 @@ export default { listProfilesState: RequestState.initiated, listProfilesError: null, updatedDevice: null, + updatedDeviceProperty: null, updatedDeviceState: RequestState.initiated, updatedDeviceError: null, modelImageStates: {},