TT#37653 PBXConfig: As a Customer, I want to change the phone model of a PBXDevice

Change-Id: I54b4ef7898718768362eb28382607ead1115ed76
changes/30/21930/1
Hans-Peter Herzog 7 years ago
parent 57957c8957
commit 1064711d99

@ -471,3 +471,25 @@ export function setIdentifier(deviceId, identifier) {
value: identifier value: identifier
}); });
} }
export function setProfile(deviceId, profileId) {
return new Promise((resolve, reject)=>{
Promise.resolve().then(()=>{
return patchReplace({
path: 'api/pbxdevices/' + deviceId,
fieldPath: 'lines',
value: []
});
}).then(()=>{
return patchReplace({
path: 'api/pbxdevices/' + deviceId,
fieldPath: 'profile_id',
value: profileId
});
}).then(()=>{
resolve();
}).catch((err)=>{
reject(err);
});
});
}

@ -50,8 +50,19 @@
@keyup.enter="saveIdentifier" @keyup.enter="saveIdentifier"
/> />
</q-field> </q-field>
<q-field :label="$t('pbxConfig.deviceModel')"> <q-field
<p>{{ name }}</p> :label="$t('pbxConfig.deviceModel')"
>
<csc-pbx-model-select
:selected-id="profileId"
:preview="false"
:erasable="false"
:readonly="true"
:profiles="profiles"
:modelImages="modelImages"
@opened="modelSelectOpened()"
@select="selectProfile"
/>
</q-field> </q-field>
<csc-pbx-device-config <csc-pbx-device-config
:device="device" :device="device"
@ -104,10 +115,28 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { QCard, QCardTitle, QCardMain, QCollapsible, import {
QIcon, QField, QInput, QSelect, QBtn, QInnerLoading, QSpinnerMat, QCardMedia, QCard,
QItem, QItemMain, QItemSide, QItemTile, Platform } from 'quasar-framework' QCardTitle,
QCardMain,
QCollapsible,
QIcon,
QField,
QInput,
QSelect,
QBtn,
QInnerLoading,
QSpinnerMat,
QCardMedia,
QItem,
QItemMain,
QItemSide,
QItemTile,
Platform
} from 'quasar-framework'
import CscPbxDeviceConfig from './CscPbxDeviceConfig' import CscPbxDeviceConfig from './CscPbxDeviceConfig'
import CscPbxModelSelect from './CscPbxModelSelect'
export default { export default {
name: 'csc-pbx-device', name: 'csc-pbx-device',
props: [ props: [
@ -115,12 +144,30 @@
'loading', 'loading',
'modelOptions', 'modelOptions',
'groupsAndSeatsOptions', 'groupsAndSeatsOptions',
'subscribers' 'subscribers',
'profiles',
'modelImages'
], ],
components: { components: {
CscPbxDeviceConfig, QCard, QCardTitle, QCardMain, QCollapsible, CscPbxDeviceConfig,
QIcon, QField, QInput, QSelect, QBtn, QInnerLoading, QSpinnerMat, QCardMedia, CscPbxModelSelect,
QItem, QItemMain, QItemSide, QItemTile, Platform QCard,
QCardTitle,
QCardMain,
QCollapsible,
QIcon,
QField,
QInput,
QSelect,
QBtn,
QInnerLoading,
QSpinnerMat,
QCardMedia,
QItem,
QItemMain,
QItemSide,
QItemTile,
Platform
}, },
data () { data () {
return { return {
@ -212,6 +259,9 @@
} }
return buttons; return buttons;
}, },
profileId() {
return _.get(this.device, 'profile.device_id', null);
}
}, },
mounted() { mounted() {
this.$emit('loaded'); this.$emit('loaded');
@ -250,7 +300,14 @@
}, },
saveIdentifier() { saveIdentifier() {
this.$emit('save-identifier', this.deviceModel); this.$emit('save-identifier', this.deviceModel);
} },
selectProfile(profile) {
this.$emit('update-profile', {
profile: profile,
device: this.device
});
},
modelSelectOpened() {}
}, },
watch: { watch: {
device() { device() {

@ -71,8 +71,21 @@
<script> <script>
import { QCard, QCardTitle, QCardMain, QCardActions, QCardSeparator, QBtn, import {
QInnerLoading, QSpinnerMat, QField, QInput, QSelect, QIcon, QItem, QItemMain } from 'quasar-framework' QCard,
QCardTitle,
QCardMain,
QCardActions,
QCardSeparator,
QBtn,
QInnerLoading,
QSpinnerMat,
QField,
QInput,
QSelect,
QIcon,
QItem,
QItemMain } from 'quasar-framework'
import CscPbxModelSelect from './CscPbxModelSelect' import CscPbxModelSelect from './CscPbxModelSelect'
export default { export default {

@ -21,11 +21,11 @@
</q-field> </q-field>
<div class="row justify-center actions"> <div class="row justify-center actions">
<div class="column"> <div class="column">
<q-btn icon="clear" :small="!isMobile" @click="closeKeyOverlay()" flat color="negative">Close</q-btn> <q-btn icon="clear" :big="isMobile" @click="closeKeyOverlay()" flat color="negative">Close</q-btn>
</div> </div>
</div> </div>
<q-btn icon="clear" :small="!isMobile" class="absolute-top-right" <q-btn icon="clear" :big="isMobile" class="absolute-top-right"
@click="closeKeyOverlay()" flat round color="primary" /> @click="closeKeyOverlay()" flat color="primary" />
</div> </div>
<q-window-resize-observable @resize="windowResize" /> <q-window-resize-observable @resize="windowResize" />
</div> </div>

@ -19,15 +19,20 @@
@modelSelectOpened="modelSelectOpened()" @modelSelectOpened="modelSelectOpened()"
@save="saveDevice" @save="saveDevice"
/> />
<csc-pbx-model-select <div
:erasable="true" class="row justify-center"
:profiles="profiles" >
:modelImages="modelImages" <csc-pbx-model-select
:label="$t('pbxConfig.filterPhoneModel')" class="col col-md-6 col-sm-12"
@opened="modelSelectOpened()" :erasable="true"
@select="filterByProfile" :profiles="profiles"
@reseted="resetFilter" :modelImages="modelImages"
/> :label="$t('pbxConfig.filterPhoneModel')"
@opened="modelSelectOpened()"
@select="filterByProfile"
@reseted="resetFilter"
/>
</div>
<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"
@ -56,11 +61,14 @@
:loading="isDeviceLoading(device.id)" :loading="isDeviceLoading(device.id)"
:groupsAndSeatsOptions="groupsAndSeatsOptions" :groupsAndSeatsOptions="groupsAndSeatsOptions"
:subscribers="getGroupOrSeatById" :subscribers="getGroupOrSeatById"
:profiles="profiles"
:modelImages="modelImages"
@remove="removeDevice" @remove="removeDevice"
@loadGroupsAndSeats="loadGroupsAndSeats()" @loadGroupsAndSeats="loadGroupsAndSeats()"
@deviceKeysChanged="deviceKeysChanged" @deviceKeysChanged="deviceKeysChanged"
@save-station-name="setStationName" @save-station-name="setStationName"
@save-identifier="setIdentifier" @save-identifier="setIdentifier"
@update-profile="updateProfile"
/> />
</q-list> </q-list>
<div <div
@ -211,7 +219,10 @@
}, },
setIdentifier(device) { setIdentifier(device) {
this.$store.dispatch('pbxConfig/setIdentifier', device); this.$store.dispatch('pbxConfig/setIdentifier', device);
} },
updateProfile(data) {
this.$store.dispatch('pbxConfig/setProfile', data);
},
}, },
watch: { watch: {
deviceRemoved(device) { deviceRemoved(device) {
@ -249,7 +260,12 @@
updatedDeviceSucceeded(succeeded) { updatedDeviceSucceeded(succeeded) {
if(succeeded === true) { if(succeeded === true) {
switch (this.updatedDeviceProperty) { switch (this.updatedDeviceProperty) {
case 'staion_name': case 'profile_id':
showToast(this.$t('pbxConfig.toasts.updatedProfile', {
name: this.updatedDevice.station_name
}));
break;
case 'station_name':
showToast(this.$t('pbxConfig.toasts.updatedStationName', { showToast(this.$t('pbxConfig.toasts.updatedStationName', {
name: this.updatedDevice.station_name name: this.updatedDevice.station_name
})); }));

@ -24,7 +24,7 @@
</q-list> </q-list>
</q-popover> </q-popover>
</div> </div>
<div v-if="selectedProfile.device_id != null" class="csc-pbx-model-image"> <div v-if="selectedProfile.device_id != null && preview" class="csc-pbx-model-image">
<img :src="frontImageUrl(selectedProfile.device_id)" class="csc-pbx-model-select-preview" /> <img :src="frontImageUrl(selectedProfile.device_id)" class="csc-pbx-model-select-preview" />
</div> </div>
</div> </div>
@ -37,13 +37,41 @@
export default { export default {
name: 'csc-pbx-model-select', name: 'csc-pbx-model-select',
props: [ props: {
'profiles', profiles: {
'modelImages', type: Array,
'loading', default(){
'label', return [];
'erasable' }
], },
modelImages: {
type: Object,
default(){
return {};
}
},
loading: {
type: Boolean,
default: false
},
label: String,
erasable: {
type: Boolean,
default: true
},
readonly: {
type: Boolean,
default: false
},
selectedId: {
type: Number,
default: null
},
preview: {
type: Boolean,
default: true
}
},
components: { components: {
QInput, QPopover, QList, QItem, QItemMain, QItemTile, QItemSide QInput, QPopover, QList, QItem, QItemMain, QItemTile, QItemSide
}, },
@ -74,7 +102,9 @@
this.$emit('opened'); this.$emit('opened');
}, },
selectProfile(profile) { selectProfile(profile) {
this.selectedProfile = profile; if(this.readonly === false) {
this.selectedProfile = profile;
}
this.$refs.popover.close(); this.$refs.popover.close();
this.$emit("select", profile); this.$emit("select", profile);
}, },
@ -90,6 +120,21 @@
name: '', name: '',
device_id: null device_id: null
} }
},
selectById(id) {
this.profiles.forEach(($profile)=>{
if(id === $profile.id) {
this.selectedProfile = $profile;
}
});
}
},
mounted(){
this.selectById(this.selectedId);
},
watch: {
selectedId(id) {
this.selectedId(id);
} }
} }
} }

@ -299,6 +299,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}",
"updatedProfile": "Updated model of device {name}",
"updatedIdentifier": "Updated identifier to {identifier}", "updatedIdentifier": "Updated identifier to {identifier}",
"createdDevice": "Created device {name} successfully" "createdDevice": "Created device {name} successfully"
}, },

@ -27,7 +27,8 @@ import {
getDevice, getDevice,
getAllGroupsAndSeats, getAllGroupsAndSeats,
setStationName, setStationName,
setIdentifier setIdentifier,
setProfile
} from '../../api/pbx-config' } from '../../api/pbx-config'
export default { export default {
@ -320,5 +321,14 @@ export default {
}).catch((err) => { }).catch((err) => {
context.commit('updateIdentifierFailed', err.message); context.commit('updateIdentifierFailed', err.message);
}); });
},
setProfile(context, data) {
context.commit('updateProfileRequesting', data.device);
setProfile(data.device.id, data.profile.id).then(() => {
context.commit('updateProfileSucceeded');
context.dispatch('loadDevice', data.device.id);
}).catch((err) => {
context.commit('updateProfileFailed', err.message);
});
} }
} }

@ -320,5 +320,14 @@ export default {
}, },
updateIdentifierFailed(state, error) { updateIdentifierFailed(state, error) {
updateDevicePropertyFailed(state, error); updateDevicePropertyFailed(state, error);
},
updateProfileRequesting(state, deviceId) {
updateDevicePropertyRequesting(state, deviceId, 'profile_id');
},
updateProfileSucceeded(state) {
updateDevicePropertySucceeded(state);
},
updateProfileFailed(state, error) {
updateDevicePropertyFailed(state, error);
} }
} }

Loading…
Cancel
Save