TT#20519 PBXConfig: As a Customer, I want to add new PBX Devices

Change-Id: I3195e88a56b20b70f05893c57809b974f8bc7ebe
changes/27/21727/4
Hans-Peter Herzog 7 years ago
parent 7c22a93be4
commit 0c98a79946

@ -51,8 +51,7 @@ export function getAllGroupsAndSeats(options) {
options = options || {}; options = options || {};
options = _.merge(options, { options = _.merge(options, {
params: { params: {
all: true, all: true
is_pbx_pilot: 0
} }
}); });
getSubscribers(options).then((res)=>{ getSubscribers(options).then((res)=>{
@ -188,23 +187,25 @@ export function getSeatList(page) {
}); });
} }
export function getDeviceList(page) { export function getDeviceList(options) {
return getDevices({ return new Promise((resolve, reject)=>{
params: { let params = {
page: page, page: options.page,
profile_id: options.profile_id,
order_by: PBX_CONFIG_ORDER_BY, order_by: PBX_CONFIG_ORDER_BY,
order_by_direction: PBX_CONFIG_ORDER_DIRECTION order_by_direction: PBX_CONFIG_ORDER_DIRECTION
};
if(params.profile_id === null) {
delete params['profile_id'];
} }
return getDevices({
params: params
}).then((devices)=>{
resolve(devices);
}).catch((err)=>{
reject(err);
});
}); });
}
export function filterDeviceList(params) {
let defaultParams = {
order_by: PBX_CONFIG_ORDER_BY,
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
};
let mergedParams = _.merge(defaultParams, params);
return getDevices({ params: mergedParams });
} }
export function addGroup(group) { export function addGroup(group) {
@ -352,18 +353,15 @@ export function getProfile(id, join) {
}).then(($profile)=> { }).then(($profile)=> {
profile = $profile; profile = $profile;
if(join === true) { if(join === true) {
return Promise.all([ return getModelFull(profile.device_id);
getModel(profile.device_id),
getModelFrontImage(profile.device_id)
]);
} }
else { else {
resolve(profile); resolve(profile);
} }
}).then((res)=>{ }).then((model)=>{
profile.model = res[0]; profile.model = model;
profile.modelFrontImage = res[1]; profile.modelFrontImage = model.frontImageBlob;
profile.modelFrontImageUrl = URL.createObjectURL(profile.modelFrontImage); profile.modelFrontImageUrl = model.frontImageUrl;
resolve(profile); resolve(profile);
}).catch((err)=>{ }).catch((err)=>{
reject(err); reject(err);
@ -393,13 +391,48 @@ export function getModelFrontImage(id) {
type: 'front' type: 'front'
} }
}).then((res)=>{ }).then((res)=>{
resolve(res.body); resolve({
id: id,
url: URL.createObjectURL(res.body),
blob: res.body
});
}).catch((err)=>{
reject(err);
});
});
}
export function getModelFull(id) {
return new Promise((resolve, reject)=>{
Promise.all([
getModel(id),
getModelFrontImage(id)
]).then((res)=>{
let model = res[0];
model.frontImageBlob = res[1].blob;
model.frontImageUrl = res[1].url;
resolve(model);
}).catch((err)=>{ }).catch((err)=>{
reject(err); reject(err);
}); });
}); });
} }
export function createDevice(device) {
return new Promise((resolve, reject)=>{
Vue.http.post('api/pbxdevices/', device).then((res)=>{
resolve(res);
}).catch((err)=>{
if(err.status >= 400) {
reject(new Error(err.body.message));
}
else {
reject(err);
}
});
});
}
export function removeDevice(id) { export function removeDevice(id) {
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
Vue.http.delete('api/pbxdevices/' + id).then(()=>{ Vue.http.delete('api/pbxdevices/' + id).then(()=>{

@ -58,7 +58,6 @@
}, },
isLoading() { isLoading() {
let getter = this.playVoiceMailState; let getter = this.playVoiceMailState;
//console.log(getter(this.id));
return getter(this.id) === 'requesting'; return getter(this.id) === 'requesting';
}, },
...mapGetters('conversations', [ ...mapGetters('conversations', [

@ -0,0 +1,95 @@
<template>
<div class="row justify-center">
<div v-if="formEnabled" class="col col-md-6 col-sm-12">
<q-field>
<q-input v-model="data.station_name" :disabled="loading" :readonly="loading" autofocus
:float-label="$t('pbxConfig.deviceStationName')" clearable />
</q-field>
<q-field>
<q-input v-model="data.identifier" :disabled="loading" :readonly="loading"
:float-label="$t('pbxConfig.deviceIdentifier')" clearable />
</q-field>
<q-field>
<csc-pbx-model-select :profiles="profiles" :modelImages="modelImages"
@opened="modelSelectOpened()" @select="selectProfile" />
</q-field>
<div class="row justify-center form-actions">
<q-btn v-if="!loading" flat color="secondary"
icon="clear" @click="cancel()">{{ $t('buttons.cancel') }}</q-btn>
<q-btn v-if="!loading" flat color="primary"
icon="done" @click="save()">{{ $t('buttons.save') }}</q-btn>
</div>
</div>
<div v-else class="row justify-center">
<q-btn color="primary" icon="add" flat @click="enableForm()">Add device</q-btn>
</div>
<q-inner-loading v-show="loading" :visible="loading">
<q-spinner-mat size="60px" color="primary" />
</q-inner-loading>
</div>
</template>
<script>
import { QCard, QCardTitle, QCardMain, QCardActions, QCardSeparator, QBtn,
QInnerLoading, QSpinnerMat, QField, QInput, QSelect, QIcon, QItem, QItemMain } from 'quasar-framework'
import CscPbxModelSelect from './CscPbxModelSelect'
export default {
name: 'csc-pbx-device-add-form',
props: [
'profiles',
'modelImages',
'loading'
],
components: {
CscPbxModelSelect, QCard, QCardTitle, QCardMain, QCardActions, QCardSeparator, QBtn,
QInnerLoading, QSpinnerMat, QField, QInput, QSelect, QIcon, QItem, QItemMain
},
data () {
return {
formEnabled: false,
data: this.getDefaults()
}
},
methods: {
getDefaults() {
return {
station_name: '',
identifier: '',
profile_id: null,
lines: null
}
},
enableForm(){
this.reset();
this.formEnabled = true;
},
disableForm(){
this.formEnabled = false;
},
cancel() {
this.disableForm();
},
save() {
this.$emit('save', this.data);
},
reset() {
this.data = this.getDefaults();
},
modelSelectOpened() {
this.$emit('modelSelectOpened');
},
selectProfile(profile) {
this.data.profile_id = profile.id;
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../../themes/quasar.variables.styl';
.form-actions
margin-top 16px
margin-bottom 8px
</style>

@ -71,7 +71,10 @@
selectedKeyIcon() { selectedKeyIcon() {
if(this.selectedLine !== null) { if(this.selectedLine !== null) {
let subscriber = this.subscribers(this.selectedLine.subscriber_id); let subscriber = this.subscribers(this.selectedLine.subscriber_id);
if(subscriber !== null && subscriber.is_pbx_group === true) { if(subscriber !== null && subscriber.is_pbx_pilot === true) {
return 'person_outlined';
}
else if(subscriber !== null && subscriber.is_pbx_group === true) {
return 'group'; return 'group';
} }
else if (subscriber !== null){ else if (subscriber !== null){
@ -86,7 +89,10 @@
selectedKeyLabel() { selectedKeyLabel() {
if(this.selectedLine !== null) { if(this.selectedLine !== null) {
let subscriber = this.subscribers(this.selectedLine.subscriber_id); let subscriber = this.subscribers(this.selectedLine.subscriber_id);
if(subscriber !== null && subscriber.is_pbx_group === true) { if(subscriber !== null && subscriber.is_pbx_pilot === true) {
return this.$t('pbxConfig.keyPilotLabel');
}
else if(subscriber !== null && subscriber.is_pbx_group === true) {
return this.$t('pbxConfig.keyGroupLabel'); return this.$t('pbxConfig.keyGroupLabel');
} }
else if (subscriber !== null){ else if (subscriber !== null){
@ -328,7 +334,7 @@
type: line.type type: line.type
}); });
}); });
if(changed === true && newLines.length > 0) { if(changed === true) {
this.$emit('keysChanged', newLines); this.$emit('keysChanged', newLines);
} }
}, },

@ -3,23 +3,31 @@
:title="$t('pbxConfig.devicesTitle')" :title="$t('pbxConfig.devicesTitle')"
class="csc-list-page" class="csc-list-page"
> >
<q-select <q-list
v-model="profile" no-border
:float-label="$t('pbxConfig.filterPhoneModel')" separator
:options="profileOptions" sparse
@change="filterByProfile" multiline
:after="modelButtons"
:class="{ 'filter-model-select': this.platform.mobile }"
/>
<div
v-if="isListLoadingVisible"
class="row justify-center"
> >
<q-spinner-dots <q-item>
color="primary" <q-item-main>
:size="40" <csc-pbx-device-add-form
ref="deviceAddForm"
:profiles="profiles"
:modelImages="modelImages"
:loading="createDeviceRequesting"
@remove="removeDevice"
@modelSelectOpened="modelSelectOpened()"
@save="saveDevice"
/> />
</div> <csc-pbx-model-select
:erasable="true"
:profiles="profiles"
:modelImages="modelImages"
:label="$t('pbxConfig.filterPhoneModel')"
@opened="modelSelectOpened()"
@select="filterByProfile"
@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"
@ -30,22 +38,23 @@
@change="changePage" @change="changePage"
/> />
</div> </div>
<q-list <div v-if="isListLoadingVisible"
no-border class="row justify-center"
separator
sparse
multiline
> >
<q-item> </q-item> <q-spinner-dots
<csc-pbx-device color="primary"
v-for="device in devices" :size="40"
/>
</div>
</q-item-main>
</q-item>
<csc-pbx-device v-for="device in devices"
:key="device.id" :key="device.id"
:device="device" :device="device"
@remove="removeDevice"
:modelOptions="modelOptions"
:loading="isDeviceLoading(device.id)" :loading="isDeviceLoading(device.id)"
:groupsAndSeatsOptions="groupsAndSeatsOptions" :groupsAndSeatsOptions="groupsAndSeatsOptions"
:subscribers="getGroupOrSeatById" :subscribers="getGroupOrSeatById"
@remove="removeDevice"
@loadGroupsAndSeats="loadGroupsAndSeats()" @loadGroupsAndSeats="loadGroupsAndSeats()"
@deviceKeysChanged="deviceKeysChanged" @deviceKeysChanged="deviceKeysChanged"
/> />
@ -63,19 +72,10 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import CscPage from '../../CscPage' import CscPage from '../../CscPage'
import CscPbxDevice from './CscPbxDevice' import CscPbxDevice from './CscPbxDevice'
import { import CscPbxDeviceAddForm from './CscPbxDeviceAddForm'
showGlobalError, import CscPbxModelSelect from './CscPbxModelSelect'
showToast import { QSpinnerDots, QPagination, QList, Dialog, QItem, QItemMain, QBtn, QSelect } from 'quasar-framework'
} from '../../../helpers/ui' import { showToast, showGlobalError } from '../../../helpers/ui'
import {
QSpinnerDots,
QPagination,
QList,
Dialog,
QItem,
QBtn,
QSelect
} from 'quasar-framework'
export default { export default {
data () { data () {
@ -86,23 +86,26 @@
}, },
mounted() { mounted() {
this.listDevices(); this.listDevices();
this.$store.dispatch('pbxConfig/listProfiles'); this.$store.dispatch('pbxConfig/loadProfiles');
}, },
components: { components: {
CscPage, CscPage,
CscPbxDevice, CscPbxDevice,
CscPbxDeviceAddForm,
CscPbxModelSelect,
QSpinnerDots, QSpinnerDots,
QPagination, QPagination,
QList, QList,
Dialog, Dialog,
QItem, QItem,
QBtn, QBtn,
QSelect QSelect,
QItemMain
}, },
computed: { computed: {
...mapGetters('pbxConfig', [ ...mapGetters('pbxConfig', [
'devices', 'devices',
'modelOptions', 'profiles',
'isListRequesting', 'isListRequesting',
'isListLoadingVisible', 'isListLoadingVisible',
'listCurrentPage', 'listCurrentPage',
@ -113,9 +116,15 @@
'groupsAndSeats', 'groupsAndSeats',
'getGroupOrSeatById', 'getGroupOrSeatById',
'updatedDeviceKey', 'updatedDeviceKey',
'createDeviceRequesting',
'createDeviceSucceeded',
'createDeviceFailed',
'createDeviceError',
'createDeviceItem',
'profileOptions', 'profileOptions',
'listProfilesState', 'listProfilesState',
'listProfilesError' 'listProfilesError',
'modelImages'
]), ]),
noDeviceMessage() { noDeviceMessage() {
if (this.profile) { if (this.profile) {
@ -124,41 +133,42 @@
else { else {
return this.$t('pbxConfig.noDevices'); return this.$t('pbxConfig.noDevices');
} }
},
modelButtons() {
let self = this;
let buttons = [];
if (this.profile) {
buttons = [{
icon: 'clear',
error: false,
handler (event) {
event.stopPropagation();
self.resetFilter();
}
}];
}
return buttons;
} }
}, },
methods: { methods: {
filterByProfile(profile) {
this.profile = profile;
this.$store.dispatch('pbxConfig/listDevices', {
page: this.listCurrentPage,
profile_id: profile.id
});
},
resetFilter() { resetFilter() {
this.profile = null; this.profile = null;
this.listDevices(); this.$store.dispatch('pbxConfig/listDevices', {
}, page: 1,
filterByProfile(profile) { profile_id: null
this.$store.dispatch('pbxConfig/filterDevices', {
profile_id: profile
}); });
}, },
changePage(page) { changePage(page) {
let profileId = null;
if(this.profile !== null) {
profileId = this.profile.id;
}
this.$store.dispatch('pbxConfig/listDevices', { this.$store.dispatch('pbxConfig/listDevices', {
page: page page: page,
profile_id: profileId
}); });
}, },
loadDevice(id) { loadDevice(id) {
this.$store.dispatch('pbxConfig/loadDevice', id); this.$store.dispatch('pbxConfig/loadDevice', id);
}, },
modelSelectOpened() {
this.$store.dispatch('pbxConfig/loadProfiles');
},
saveDevice(device) {
this.$store.dispatch('pbxConfig/createDevice', device);
},
removeDevice(device) { removeDevice(device) {
var store = this.$store; var store = this.$store;
var i18n = this.$i18n; var i18n = this.$i18n;
@ -204,6 +214,19 @@
})); }));
} }
}, },
createDeviceSucceeded(succeeded) {
if(succeeded) {
this.$refs.deviceAddForm.disableForm();
showToast(this.$t('pbxConfig.toasts.createdDevice',{
name: this.createDeviceItem.station_name
}));
}
},
createDeviceFailed(failed) {
if(failed) {
showGlobalError(this.createDeviceError);
}
},
listProfilesState(state) { listProfilesState(state) {
if (state === 'failed') { if (state === 'failed') {
showGlobalError(this.listProfilesError); showGlobalError(this.listProfilesError);

@ -0,0 +1,111 @@
<template>
<div class="csc-pbx-model-select">
<div>
<q-input
:value="selectedProfile.name"
readonly
class="cursor-pointer"
:float-label="label"
:after="clearButton"
/>
<q-popover ref="popover" fit @open="opened()">
<q-list no-borders class="csc-pbx-model-list" highlight inset-separator>
<q-item v-for="(profile, index) in profiles" :key="profile.id"
@click="selectProfile(profile)" class="cursor-pointer">
<q-item-side>
<q-item-tile avatar>
<img :src="frontImageUrl(profile.device_id)" />
</q-item-tile>
</q-item-side>
<q-item-main>
<q-item-tile>{{ profile.name }}</q-item-tile>
</q-item-main>
</q-item>
</q-list>
</q-popover>
</div>
<div v-if="selectedProfile.device_id != null" class="csc-pbx-model-image">
<img :src="frontImageUrl(selectedProfile.device_id)" />
</div>
</div>
</template>
<script>
import { QInput, QPopover, QList, QItem, QItemMain, QItemTile, QItemSide } from 'quasar-framework'
import _ from 'lodash';
export default {
name: 'csc-pbx-model-select',
props: [
'profiles',
'modelImages',
'loading',
'label',
'erasable'
],
components: {
QInput, QPopover, QList, QItem, QItemMain, QItemTile, QItemSide
},
data () {
return {
selectedProfile: this.getDefaults()
}
},
computed: {
clearButton() {
let self = this;
let buttons = [];
if (this.selectedProfile.device_id !== null && this.erasable === true) {
buttons = [{
icon: 'clear',
error: false,
handler (event) {
event.stopPropagation();
self.reset();
}
}];
}
return buttons;
}
},
methods: {
opened() {
this.$emit('opened');
},
selectProfile(profile) {
this.selectedProfile = profile;
this.$refs.popover.close();
this.$emit("select", profile);
},
frontImageUrl(id) {
return _.get(this.modelImages, id + '.url', null);
},
reset() {
this.selectedProfile = this.getDefaults();
this.$emit('reseted');
},
getDefaults() {
return {
name: '',
device_id: null
}
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
.csc-pbx-model-list
.q-item-avatar
img
border-radius 0
.csc-pbx-model-image
margin-top 16px
text-align center
img
width: 50%
</style>

@ -0,0 +1,11 @@
import Vue from 'vue'
export function reactiveSet(object, name, value) {
Vue.delete(object, name);
Vue.set(object, name, value);
}
export function reactiveDelete(object, name) {
Vue.delete(object, name);
}

@ -294,7 +294,8 @@
"addedSeatToast": "Added seat {seat}", "addedSeatToast": "Added seat {seat}",
"removedSeatToast": "Removed seat {seat}", "removedSeatToast": "Removed seat {seat}",
"removedDeviceToast": "Removed device {name}", "removedDeviceToast": "Removed device {name}",
"updatedDeviceKeys": "Updated keys of device {name}" "updatedDeviceKeys": "Updated keys of device {name}",
"createdDevice": "Created device {name} successfully"
}, },
"removeDevice": "Remove device", "removeDevice": "Remove device",
"removeDeviceTitle": "Remove device", "removeDeviceTitle": "Remove device",
@ -302,7 +303,8 @@
"keyEmptyLabel": "Unassigned", "keyEmptyLabel": "Unassigned",
"keyGroupLabel": "Group", "keyGroupLabel": "Group",
"keySeatLabel": "Seat", "keySeatLabel": "Seat",
"keyBothLabel": "Group/Seat", "keyPilotLabel": "Pilot",
"keyBothLabel": "Group/Seat/Pilot",
"keyTypeShared": "Shared", "keyTypeShared": "Shared",
"keyTypeBLF": "Busy Lamp Field", "keyTypeBLF": "Busy Lamp Field",
"keyTypePrivate": "Private", "keyTypePrivate": "Private",

@ -3,10 +3,25 @@
import _ from 'lodash'; import _ from 'lodash';
import { assignNumbers } from '../../api/user'; import { assignNumbers } from '../../api/user';
import { addGroup, removeGroup, addSeat, removeSeat, setGroupName, import { addGroup, removeGroup, addSeat, removeSeat, setGroupName,
setGroupExtension, setGroupHuntPolicy, setGroupHuntTimeout, updateDeviceKeys,
updateGroupSeats, setSeatName, setSeatExtension, removeDevice, getAllGroupsAndSeats, setGroupExtension,
updateSeatGroups, getGroupList, getSeatList, getDeviceList, filterDeviceList, setGroupHuntPolicy,
getProfiles, getDevice } from '../../api/pbx-config' setGroupHuntTimeout,
createDevice,
removeDevice,
updateGroupSeats,
setSeatName,
setSeatExtension,
getProfiles,
getModelFrontImage,
updateDeviceKeys,
updateSeatGroups,
getGroupList,
getSeatList,
getDeviceList,
getDevice,
getAllGroupsAndSeats
} from '../../api/pbx-config'
export default { export default {
listGroups(context, options) { listGroups(context, options) {
@ -187,11 +202,15 @@ export default {
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
let silent = _.get(options, 'silent', false); let silent = _.get(options, 'silent', false);
let page = _.get(options, 'page', 1); let page = _.get(options, 'page', 1);
let profile_id = _.get(options, 'profile_id', null);
context.commit('deviceListRequesting', { context.commit('deviceListRequesting', {
silent: silent, silent: silent,
page: page page: page
}); });
getDeviceList(page).then((devices)=>{ getDeviceList({
page: page,
profile_id: profile_id
}).then((devices)=>{
context.commit('deviceListSucceeded', devices); context.commit('deviceListSucceeded', devices);
devices.items.forEach((device)=>{ devices.items.forEach((device)=>{
context.dispatch('loadDevice', device.id); context.dispatch('loadDevice', device.id);
@ -214,6 +233,35 @@ export default {
context.commit('deviceFailed', deviceId, err.message); context.commit('deviceFailed', deviceId, err.message);
}); });
}, },
loadProfiles(context) {
if(!context.getters.hasProfiles) {
getProfiles({ all: true }).then((profiles)=>{
context.commit('profilesSucceeded', profiles);
profiles.items.forEach((profile)=>{
context.dispatch('loadModelImage', profile.device_id);
});
}).catch((err)=>{
context.commit('profilesFailed', err.message);
});
}
},
loadModelImage(context, modelId) {
context.commit('modelImageRequesting', modelId);
getModelFrontImage(modelId).then((modelImage)=>{
context.commit('modelImageSucceeded', modelImage);
}).catch((err)=>{
context.commit('modelImageFailed', modelId, err.message);
});
},
createDevice(context, device) {
context.commit('createDeviceRequesting', device);
createDevice(device).then(()=>{
context.commit('createDeviceSucceeded');
context.dispatch('listDevices');
}).catch((err)=>{
context.commit('createDeviceFailed', err.message);
});
},
removeDevice(context, device) { removeDevice(context, device) {
context.commit('deviceRequesting', device.id); context.commit('deviceRequesting', device.id);
removeDevice(device.id).then(()=>{ removeDevice(device.id).then(()=>{
@ -239,26 +287,18 @@ export default {
}).catch((err)=>{ }).catch((err)=>{
context.commit('updateDeviceKeyFailed', data.device.id, err); context.commit('updateDeviceKeyFailed', data.device.id, err);
}); });
},
filterDevices(context, params) {
context.commit('deviceListRequesting', {
silent: false
});
filterDeviceList(params).then((devices)=>{
context.commit('deviceListSucceeded', devices);
devices.items.forEach((device)=>{
context.dispatch('loadDevice', device.id);
});
}).catch((err)=>{
context.commit('deviceListFailed', err.message);
});
},
listProfiles(context) {
context.commit('listProfilesRequesting');
getProfiles({ all: true }).then((profiles)=>{
context.commit('listProfilesSucceeded', profiles);
}).catch((err)=>{
context.commit('listProfilesFailed', err.message);
});
} }
// filterDevices(context, params) {
// context.commit('deviceListRequesting', {
// silent: false
// });
// filterDeviceList(params).then((devices)=>{
// context.commit('deviceListSucceeded', devices);
// devices.items.forEach((device)=>{
// context.dispatch('loadDevice', device.id);
// });
// }).catch((err)=>{
// context.commit('deviceListFailed', err.message);
// });
// }
} }

@ -134,16 +134,6 @@ export default {
devices(state) { devices(state) {
return state.devicesOrdered; return state.devicesOrdered;
}, },
modelOptions(state) {
let modelOptions = [];
state.modelsOrdered.forEach((model)=>{
modelOptions.push({
label: model.vendor + " " + model.model,
value: model.id
});
});
return modelOptions;
},
listCurrentPage(state) { listCurrentPage(state) {
return state.listCurrentPage; return state.listCurrentPage;
}, },
@ -176,6 +166,15 @@ export default {
lastRemovedSeat(state) { lastRemovedSeat(state) {
return state.lastRemovedSeat; return state.lastRemovedSeat;
}, },
profiles(state) {
return state.profilesOrdered;
},
models(state) {
return state.models;
},
hasProfiles(state) {
return state.profilesOrdered.length > 0;
},
deviceRemoved(state) { deviceRemoved(state) {
return state.deviceRemoved; return state.deviceRemoved;
}, },
@ -191,8 +190,15 @@ export default {
} }
]; ];
state.groupsAndSeats.forEach((item)=>{ state.groupsAndSeats.forEach((item)=>{
let icon = 'person';
if(item.is_pbx_pilot) {
icon = 'person_outlined';
}
else if (item.is_pbx_group){
icon = 'group';
}
options.push({ options.push({
icon: (item.is_pbx_group === true)? 'group' : 'person', icon: icon,
label: item.display_name, label: item.display_name,
value: item.id value: item.id
}); });
@ -213,6 +219,21 @@ export default {
updatedDeviceKey(state) { updatedDeviceKey(state) {
return state.updatedDeviceKey; return state.updatedDeviceKey;
}, },
createDeviceRequesting(state) {
return state.createDeviceState === RequestState.requesting;
},
createDeviceSucceeded(state) {
return state.createDeviceState === RequestState.succeeded;
},
createDeviceFailed(state) {
return state.createDeviceState === RequestState.failed;
},
createDeviceError(state) {
return state.createDeviceError;
},
createDeviceItem(state) {
return state.createDeviceItem;
},
profileOptions(state) { profileOptions(state) {
let profileOptions = []; let profileOptions = [];
state.profilesOrdered.forEach((profile) => { state.profilesOrdered.forEach((profile) => {
@ -228,5 +249,8 @@ export default {
}, },
listProfilesError(state) { listProfilesError(state) {
return state.listError; return state.listError;
},
modelImages(state) {
return state.modelImages;
} }
} }

@ -3,6 +3,7 @@
import Vue from 'vue' import Vue from 'vue'
import _ from 'lodash' import _ from 'lodash'
import { RequestState } from '../common' import { RequestState } from '../common'
import { reactiveSet } from '../../helpers/store-helper'
export default { export default {
listRequesting(state, options) { listRequesting(state, options) {
@ -148,8 +149,6 @@ export default {
state.listLoadingSilently = _.get(options, 'silent', false); state.listLoadingSilently = _.get(options, 'silent', false);
state.listState = RequestState.requesting; state.listState = RequestState.requesting;
state.listError = null; state.listError = null;
state.devices = {};
state.devicesOrdered = [];
}, },
deviceListSucceeded(state, data) { deviceListSucceeded(state, data) {
state.listState = RequestState.succeeded; state.listState = RequestState.succeeded;
@ -166,12 +165,13 @@ export default {
state.listError = error; state.listError = error;
}, },
deviceRequesting(state, deviceId) { deviceRequesting(state, deviceId) {
Vue.set(state.deviceStates, deviceId + "", RequestState.requesting); reactiveSet(state.deviceStates, deviceId + "", RequestState.requesting);
}, },
deviceSucceeded(state, device) { deviceSucceeded(state, device) {
Vue.set(state.deviceStates, device.id + "", RequestState.succeeded); let deviceId = device.id + "";
Vue.set(state.deviceErrors, device.id + "", null); reactiveSet(state.deviceStates, deviceId, RequestState.succeeded);
Vue.set(state.devices, device.id + "", device); reactiveSet(state.deviceErrors, deviceId, null);
reactiveSet(state.devices, deviceId, device);
for(let i = 0; i <= state.devicesOrdered.length; i++) { for(let i = 0; i <= state.devicesOrdered.length; i++) {
if(state.devicesOrdered[i].id === device.id) { if(state.devicesOrdered[i].id === device.id) {
state.devicesOrdered[i] = device; state.devicesOrdered[i] = device;
@ -179,12 +179,14 @@ export default {
} }
}, },
deviceFailed(state, deviceId, error) { deviceFailed(state, deviceId, error) {
Vue.set(state.deviceStates, deviceId + "", RequestState.failed); deviceId = deviceId + "";
Vue.set(state.deviceErrors, deviceId + "", error); reactiveSet(state.deviceStates, deviceId, RequestState.failed);
reactiveSet(state.deviceErrors, deviceId, error);
}, },
deviceRemoved(state, device) { deviceRemoved(state, device) {
Vue.set(state.deviceStates, device.id + "", 'deleted'); let deviceId = device.id + "";
Vue.set(state.deviceErrors, device.id + "", null); reactiveSet(state.deviceStates, deviceId, 'deleted');
reactiveSet(state.deviceErrors, deviceId, null);
state.deviceRemoved = device; state.deviceRemoved = device;
}, },
lastAddedGroup(state, group) { lastAddedGroup(state, group) {
@ -202,6 +204,34 @@ export default {
lastUpdatedField(state, group) { lastUpdatedField(state, group) {
state.lastUpdatedField = group; state.lastUpdatedField = group;
}, },
profilesRequesting(state) {
state.profilesRequesting = true;
state.profilesRequestError = null;
},
profilesSucceeded(state, profiles) {
state.profilesOrdered = profiles.items;
state.profilesOrdered.forEach((profile)=>{
state.profiles[profile.id + ""] = profile;
});
state.profilesRequesting = false;
state.profilesRequestError = null;
},
profilesFailed(state, error) {
state.profilesRequesting = false;
state.profilesRequestError = error;
},
modelImageRequesting(state, modelId) {
reactiveSet(state.modelImageStates, modelId, RequestState.requesting);
},
modelImageSucceeded(state, modelImage) {
reactiveSet(state.modelImageStates, modelImage.id, RequestState.succeeded);
reactiveSet(state.modelImageErrors, modelImage.id, null);
reactiveSet(state.modelImages, modelImage.id, modelImage);
},
modelImageFailed(state, modelId, error) {
reactiveSet(state.modelImageStates, modelId, RequestState.succeeded);
reactiveSet(state.modelImageErrors, modelId, error);
},
groupsAndSeatsRequesting(state) { groupsAndSeatsRequesting(state) {
state.groupsAndSeatsState = RequestState.requesting; state.groupsAndSeatsState = RequestState.requesting;
state.groupsAndSeats = []; state.groupsAndSeats = [];
@ -227,6 +257,18 @@ export default {
Vue.set(state.deviceErrors, deviceId + "", error); Vue.set(state.deviceErrors, deviceId + "", error);
state.updatedDeviceKey = null; state.updatedDeviceKey = null;
}, },
createDeviceRequesting(state, device) {
state.createDeviceState = RequestState.requesting;
state.createDeviceItem = device;
state.createDeviceError = null;
},
createDeviceSucceeded(state) {
state.createDeviceState = RequestState.succeeded;
},
createDeviceFailed(state, error) {
state.createDeviceState = RequestState.failed;
state.createDeviceError = error;
},
listProfilesRequesting(state) { listProfilesRequesting(state) {
state.listProfilesState = RequestState.requesting; state.listProfilesState = RequestState.requesting;
state.listProfilesError = null; state.listProfilesError = null;

@ -14,8 +14,8 @@ export default {
devices: {}, devices: {},
profilesOrdered: [], profilesOrdered: [],
profiles: {}, profiles: {},
modelsOrdered: [],
models: {}, models: {},
modelsOrdered: [],
listState: RequestState.initiated, listState: RequestState.initiated,
listError: null, listError: null,
listLoadingSilently: false, listLoadingSilently: false,
@ -46,6 +46,12 @@ export default {
groupsAndSeatsState: RequestState.initiated, groupsAndSeatsState: RequestState.initiated,
groupsAndSeatsError: null, groupsAndSeatsError: null,
updatedDeviceKey: null, updatedDeviceKey: null,
createDeviceState: RequestState.initiated,
createDeviceItem: null,
createDeviceError: null,
listProfilesState: RequestState.initiated, listProfilesState: RequestState.initiated,
listProfilesError: null listProfilesError: null,
modelImageStates: {},
modelImageErrors: {},
modelImages: {},
} }

Loading…
Cancel
Save