TT#37652 PBXConfig: As a Customer, I want to change the MAC address of a PBXDevice

Change-Id: I9152172cecaa629911021258b46a22c98dc602b0
changes/42/21742/1
Hans-Peter Herzog 7 years ago
parent 7cb906c7be
commit 60fd754bba

@ -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
});
}

@ -46,7 +46,8 @@
>
<q-input
v-model="device.identifier"
readonly
:after="identifierButtons"
@keyup.enter="saveIdentifier"
/>
</q-field>
<q-field :label="$t('pbxConfig.deviceModel')">
@ -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: {

@ -26,7 +26,8 @@
:label="$t('pbxConfig.filterPhoneModel')"
@opened="modelSelectOpened()"
@select="filterByProfile"
@reseted="resetFilter" />
@reseted="resetFilter"
/>
<div
v-if="devices.length > 0 && !isListRequesting && listLastPage > 1"
class="row justify-center"
@ -59,6 +60,7 @@
@loadGroupsAndSeats="loadGroupsAndSeats()"
@deviceKeysChanged="deviceKeysChanged"
@save-station-name="setStationName"
@save-identifier="setIdentifier"
/>
</q-list>
<div
@ -129,7 +131,8 @@
'modelImages',
'updatedDevice',
'updatedDeviceSucceeded',
'updatedDeviceError'
'updatedDeviceError',
'updatedDeviceProperty'
]),
noDeviceMessage() {
if (this.profile) {
@ -205,6 +208,9 @@
},
setStationName(device) {
this.$store.dispatch('pbxConfig/setStationName', device);
},
setIdentifier(device) {
this.$store.dispatch('pbxConfig/setIdentifier', device);
}
},
watch: {
@ -242,9 +248,18 @@
},
updatedDeviceSucceeded(succeeded) {
if(succeeded === true) {
showToast(this.$t('pbxConfig.toasts.updatedStationName', {
name: this.updatedDevice.station_name
}));
switch (this.updatedDeviceProperty) {
case 'staion_name':
showToast(this.$t('pbxConfig.toasts.updatedStationName', {
name: this.updatedDevice.station_name
}));
break;
case 'identifier':
showToast(this.$t('pbxConfig.toasts.updatedIdentifier', {
identifier: this.updatedDevice.identifier
}));
break;
}
}
},
updatedDeviceError(err) {

@ -296,6 +296,7 @@
"removedDeviceToast": "Removed device {name}",
"updatedDeviceKeys": "Updated keys of device {name}",
"updatedStationName": "Updated station name to {name}",
"updatedIdentifier": "Updated identifier to {identifier}",
"createdDevice": "Created device {name} successfully"
},
"removeDevice": "Remove device",

@ -26,7 +26,8 @@ import {
getDeviceList,
getDevice,
getAllGroupsAndSeats,
setStationName
setStationName,
setIdentifier
} from '../../api/pbx-config'
export default {
@ -310,5 +311,14 @@ export default {
}).catch((err) => {
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);
});
}
}

@ -264,5 +264,8 @@ export default {
},
updatedDeviceError(state) {
return state.updatedDeviceError;
},
updatedDeviceProperty(state) {
return state.updatedDeviceProperty;
}
}

@ -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);
}
}

@ -52,6 +52,7 @@ export default {
listProfilesState: RequestState.initiated,
listProfilesError: null,
updatedDevice: null,
updatedDeviceProperty: null,
updatedDeviceState: RequestState.initiated,
updatedDeviceError: null,
modelImageStates: {},

Loading…
Cancel
Save