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 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 <q-input
v-model="device.identifier" v-model="device.identifier"
readonly :after="identifierButtons"
@keyup.enter="saveIdentifier"
/> />
</q-field> </q-field>
<q-field :label="$t('pbxConfig.deviceModel')"> <q-field :label="$t('pbxConfig.deviceModel')">
@ -178,12 +179,39 @@
deviceModel() { deviceModel() {
return { return {
id: this.changes.id, id: this.changes.id,
station_name: this.changes.stationName station_name: this.changes.stationName,
identifier: this.device.identifier
} }
}, },
stationNameHasChanges() { stationNameHasChanges() {
return this.stationName !== this.changes.stationName; 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() { mounted() {
this.$emit('loaded'); this.$emit('loaded');
@ -207,7 +235,8 @@
getDevice() { getDevice() {
return { return {
id: this.device.id, id: this.device.id,
stationName: this.device.station_name stationName: this.device.station_name,
identifier: this.device.identifier
} }
}, },
resetStationName() { resetStationName() {
@ -215,6 +244,12 @@
}, },
saveStationName() { saveStationName() {
this.$emit('save-station-name', this.deviceModel); this.$emit('save-station-name', this.deviceModel);
},
resetIdentifier() {
this.changes.identifier = this.device.identifier;
},
saveIdentifier() {
this.$emit('save-identifier', this.deviceModel);
} }
}, },
watch: { watch: {

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

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

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

@ -5,6 +5,23 @@ import _ from 'lodash'
import { RequestState } from '../common' import { RequestState } from '../common'
import { reactiveSet } from '../../helpers/store-helper' 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 { export default {
listRequesting(state, options) { listRequesting(state, options) {
options = options || {}; options = options || {};
@ -287,16 +304,21 @@ export default {
state.listProfilesError = error; state.listProfilesError = error;
}, },
updateStationNameRequesting(state, deviceId) { updateStationNameRequesting(state, deviceId) {
state.updatedDevice = deviceId; updateDevicePropertyRequesting(state, deviceId, 'station_name');
state.updatedDeviceState = RequestState.requesting;
state.updatedDeviceError = null;
}, },
updateStationNameSucceeded(state) { updateStationNameSucceeded(state) {
state.updatedDeviceState = RequestState.succeeded; updateDevicePropertySucceeded(state);
state.updatedDeviceError = null;
}, },
updateStationNameFailed(state, error) { updateStationNameFailed(state, error) {
state.updatedDeviceState = RequestState.failed; updateDevicePropertyFailed(state, error);
state.updatedDeviceError = 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, listProfilesState: RequestState.initiated,
listProfilesError: null, listProfilesError: null,
updatedDevice: null, updatedDevice: null,
updatedDeviceProperty: null,
updatedDeviceState: RequestState.initiated, updatedDeviceState: RequestState.initiated,
updatedDeviceError: null, updatedDeviceError: null,
modelImageStates: {}, modelImageStates: {},

Loading…
Cancel
Save