diff --git a/src/api/pbx-devices.js b/src/api/pbx-devices.js new file mode 100644 index 00000000..c47f4c80 --- /dev/null +++ b/src/api/pbx-devices.js @@ -0,0 +1,69 @@ +'use strict'; + +import _ from 'lodash'; +import Vue from 'vue'; +import { getJsonBody } from './utils' + +export function getAllDevices(options) { + return new Promise((resolve, reject)=>{ + let rows = _.get(options, 'rows', 25); + let page = _.get(options, 'page', 1); + Vue.http.get('/api/pbxdevices/', null, { + params: { + rows: rows, + page: page + } + }).then((result)=>{ + let body = getJsonBody(result.body); + let totalCount = body.totalCount; + let lastPage = Math.ceil(totalCount / rows); + let items = _.get(body, '_embedded.ngcp:pbxdevices'); + resolve({ + lastPage: lastPage, + items: items + }); + }).catch((err)=>{ + reject(err); + }); + }); +} + +export function getAllProfiles() { + return new Promise((resolve, reject)=>{ + Vue.http.get('/api/pbxdeviceprofiles/').then((result)=>{ + let body = getJsonBody(result.body); + resolve(_.get(body, '_embedded.ngcp:pbxdeviceprofiles')); + }).catch((err)=>{ + reject(err); + }); + }); +} + +export function getAllModels() { + return new Promise((resolve, reject)=>{ + Vue.http.get('/api/pbxdevicemodels/').then((result)=>{ + let body = getJsonBody(result.body); + resolve(_.get(body, '_embedded.ngcp:pbxdevicemodels')); + }).catch((err)=>{ + reject(err); + }); + }); +} + +export function getDeviceList() { + return new Promise((resolve, reject)=>{ + Promise.all([ + getAllDevices(), + getAllProfiles(), + getAllModels() + ]).then((results)=>{ + resolve({ + devices: results[0], + profiles: results[1], + models: results[2] + }); + }).catch((err)=>{ + reject(err); + }); + }); +} diff --git a/src/components/CscPage.vue b/src/components/CscPage.vue index c0b6eaf7..8b6dd765 100644 --- a/src/components/CscPage.vue +++ b/src/components/CscPage.vue @@ -47,7 +47,7 @@ .page { position: relative; - padding: 30px; + padding: 60px; padding-top: 100px; margin: 0px; } @@ -61,6 +61,7 @@ .page .page-title { padding: 30px; + padding-left: 60px; z-index: 1000; right: 0; background: -moz-linear-gradient(top, rgba(255,255,255,1) 44%, rgba(255,255,255,0.86) 71%, rgba(255,255,255,0) 100%); diff --git a/src/components/pages/PbxConfiguration/CscPbxDevice.vue b/src/components/pages/PbxConfiguration/CscPbxDevice.vue new file mode 100644 index 00000000..6bace9ec --- /dev/null +++ b/src/components/pages/PbxConfiguration/CscPbxDevice.vue @@ -0,0 +1,71 @@ + + + + + {{ device.station_name }} + + + + + + + + + + + + + + + + + + + diff --git a/src/components/pages/PbxConfiguration/CscPbxDevices.vue b/src/components/pages/PbxConfiguration/CscPbxDevices.vue new file mode 100644 index 00000000..aad41f3f --- /dev/null +++ b/src/components/pages/PbxConfiguration/CscPbxDevices.vue @@ -0,0 +1,44 @@ + + + + + + + + {{ $t('pbxConfig.noDevices') }} + + + + + + + diff --git a/src/components/pages/PbxConfiguration/CscPbxGroup.vue b/src/components/pages/PbxConfiguration/CscPbxGroup.vue index c0ea34d1..f9716d4e 100644 --- a/src/components/pages/PbxConfiguration/CscPbxGroup.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroup.vue @@ -1,12 +1,13 @@ - - - - {{ group.display_name }} - + + + + {{ group.display_name }} + {{ $t('pbxConfig.extension') }}: {{ group.pbx_extension }} - + + @@ -36,10 +37,6 @@ :after="seatButtons" @change="seatChange" /> - - Delete - @@ -130,7 +127,7 @@ return this.loading; }, titleIcon() { - if(this.expanded) { + if(!this.expanded) { return 'keyboard arrow down'; } else { @@ -301,12 +298,7 @@ }, methods: { toggleMain() { - if(this.expanded) { - this.expanded = false; - } - else { - this.expanded = true; - } + this.expanded = !this.expanded; }, remove() { this.$emit('remove', this.groupModel); @@ -395,13 +387,5 @@ diff --git a/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue b/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue index 447b5b6a..ee707804 100644 --- a/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue @@ -1,5 +1,5 @@ - + {{ $t('pbxConfig.addGroup') }} diff --git a/src/components/pages/PbxConfiguration/Groups.vue b/src/components/pages/PbxConfiguration/CscPbxGroups.vue similarity index 91% rename from src/components/pages/PbxConfiguration/Groups.vue rename to src/components/pages/PbxConfiguration/CscPbxGroups.vue index 1d234045..5a2c770c 100644 --- a/src/components/pages/PbxConfiguration/Groups.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroups.vue @@ -1,25 +1,22 @@ - + - - - - {{ $t('pbxConfig.addGroup') }} - - - - - - - - + + {{ $t('pbxConfig.addGroup') }} + + + + + + {{ $t('pbxConfig.noGroups') }} + @@ -95,10 +92,10 @@ 'updateItemId', 'isRemoving', 'removeItemId', - 'isListRequesting', 'listState', 'listError', - 'listLoadingSilently' + 'isListRequesting', + 'isListLoadingVisible' ]) }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSeat.vue b/src/components/pages/PbxConfiguration/CscPbxSeat.vue index c4fe0404..564fdb2a 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeat.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeat.vue @@ -1,12 +1,13 @@ - - - - {{ seat.display_name }} + + + + {{ seat.display_name }} {{ $t('pbxConfig.extension') }}: {{ seat.pbx_extension }} - + + @@ -28,10 +29,6 @@ :after="groupButtons" @change="groupChange" /> - - Delete - @@ -113,7 +110,7 @@ return this.loading; }, titleIcon() { - if(this.expanded) { + if(!this.expanded) { return 'keyboard arrow down'; } else { @@ -232,12 +229,7 @@ }, methods: { toggleMain() { - if(this.expanded) { - this.expanded = false; - } - else { - this.expanded = true; - } + this.expanded = !this.expanded; }, remove() { this.$emit('remove', this.seatModel); @@ -309,13 +301,5 @@ diff --git a/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue b/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue index 30d0e6a5..a5ed98cb 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue @@ -1,5 +1,5 @@ - + {{ $t('pbxConfig.addSeat') }} diff --git a/src/components/pages/PbxConfiguration/Seats.vue b/src/components/pages/PbxConfiguration/CscPbxSeats.vue similarity index 89% rename from src/components/pages/PbxConfiguration/Seats.vue rename to src/components/pages/PbxConfiguration/CscPbxSeats.vue index b85c6efc..729979bd 100644 --- a/src/components/pages/PbxConfiguration/Seats.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeats.vue @@ -1,24 +1,21 @@ - + - - - - {{ $t('pbxConfig.addSeat') }} - - - - - - - - + + {{ $t('pbxConfig.addSeat') }} + + + + + + {{ $t('pbxConfig.noSeats') }} + @@ -62,10 +59,10 @@ 'updateItemId', 'isRemoving', 'removeItemId', - 'isListRequesting', 'listState', 'listError', - 'listLoadingSilently' + 'isListRequesting', + 'isListLoadingVisible' ]), groupOptions() { let groups = []; diff --git a/src/components/pages/PbxConfiguration/Devices.vue b/src/components/pages/PbxConfiguration/Devices.vue deleted file mode 100644 index 945245f9..00000000 --- a/src/components/pages/PbxConfiguration/Devices.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/src/locales/en.json b/src/locales/en.json index 952ccd98..4b4db8a1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -249,6 +249,15 @@ "addSeat": "Add Seat", "removeSeat": "Remove seat", "removeSeatTitle": "Remove seat", - "removeSeatText": "You are about to remove seat \"{seat}\"" + "removeSeatText": "You are about to remove seat \"{seat}\"", + "devicesTitle": "Devices", + "deviceStationName": "Station name", + "deviceIdentifier": "MAC address", + "deviceModel": "Model", + "groupsTitle": "Groups", + "seatsTitle": "Seats", + "noDevices": "No devices created yet", + "noGroups": "No groups created yet", + "noSeats": "No seats created yet" } } diff --git a/src/routes.js b/src/routes.js index a0e18c4c..bba6d323 100644 --- a/src/routes.js +++ b/src/routes.js @@ -9,9 +9,9 @@ import CallBlockingIncoming from './components/pages/CallBlocking/Incoming' import CallBlockingOutgoing from './components/pages/CallBlocking/Outgoing' import CallBlockingPrivacy from './components/pages/CallBlocking/Privacy' import Reminder from './components/pages/Reminder'; -import PbxConfigurationGroups from './components/pages/PbxConfiguration/Groups' -import PbxConfigurationSeats from './components/pages/PbxConfiguration/Seats' -import PbxConfigurationDevices from './components/pages/PbxConfiguration/Devices' +import PbxConfigurationGroups from './components/pages/PbxConfiguration/CscPbxGroups' +import PbxConfigurationSeats from './components/pages/PbxConfiguration/CscPbxSeats' +import PbxConfigurationDevices from './components/pages/PbxConfiguration/CscPbxDevices' import Login from './components/Login' import Error404 from './components/Error404' diff --git a/src/store/pbx-config/actions.js b/src/store/pbx-config/actions.js index 8cfecbc3..82e080cd 100644 --- a/src/store/pbx-config/actions.js +++ b/src/store/pbx-config/actions.js @@ -5,6 +5,7 @@ import { getPbxConfiguration, addGroup, removeGroup, addSeat, removeSeat, setGroupName, setGroupExtension, setGroupHuntPolicy, setGroupHuntTimeout, updateGroupSeats, setSeatName, setSeatExtension, updateSeatGroups } from '../../api/pbx-config' +import { getDeviceList } from '../../api/pbx-devices' export default { listGroups(context, silent) { @@ -159,5 +160,17 @@ export default { }).catch((err)=>{ context.commit('removeItemFailed', err.message); }); + }, + listDevices(context) { + return new Promise((resolve, reject)=>{ + context.commit('deviceListRequesting'); + getDeviceList().then((result)=>{ + context.commit('deviceListSucceeded', result); + resolve(); + }).catch((err)=>{ + context.commit('deviceListFailed', err.message); + reject(err); + }); + }); } } diff --git a/src/store/pbx-config/getters.js b/src/store/pbx-config/getters.js index b6c8996b..78ecdd55 100644 --- a/src/store/pbx-config/getters.js +++ b/src/store/pbx-config/getters.js @@ -40,6 +40,12 @@ export default { isListRequesting(state) { return state.listState === RequestState.requesting; }, + isListLoadingSilently(state) { + return (state.listLoadingSilently === true); + }, + isListLoadingVisible(state, getters) { + return getters.isListRequesting && !getters.isListLoadingSilently; + }, listState(state) { return state.listState; }, @@ -99,5 +105,18 @@ export default { }, removeError(state) { return state.removeError; + }, + devices(state) { + return state.devicesOrdered; + }, + modelOptions(state) { + let modelOptions = []; + state.modelsOrdered.forEach((model)=>{ + modelOptions.push({ + label: model.vendor + " " + model.model, + value: model.id + }); + }); + return modelOptions; } } diff --git a/src/store/pbx-config/mutations.js b/src/store/pbx-config/mutations.js index bbe66711..67d28764 100644 --- a/src/store/pbx-config/mutations.js +++ b/src/store/pbx-config/mutations.js @@ -106,5 +106,35 @@ export default { delete state.groupsOrdered[index]; } }); + }, + deviceListRequesting(state, silent) { + state.listState = RequestState.requesting; + state.listError = null; + state.listLoadingSilently = silent; + }, + deviceListSucceeded(state, data) { + state.listState = RequestState.succeeded; + state.listError = null; + state.devicesOrdered = data.devices.items; + state.profilesOrdered = data.profiles; + state.modelsOrdered = data.models; + state.devicesOrdered.forEach((device)=>{ + state.profilesOrdered.forEach((profile)=>{ + if(device.profile_id === profile.id) { + device.profile = profile; + } + }); + }); + state.devicesOrdered.forEach((device)=>{ + state.modelsOrdered.forEach((model)=>{ + if(device.profile.device_id === model.id) { + device.model = model; + } + }); + }); + }, + deviceListFailed(state, error) { + state.listState = RequestState.failed; + state.listError = error; } } diff --git a/src/store/pbx-config/state.js b/src/store/pbx-config/state.js index a865fca5..15f5e9fe 100644 --- a/src/store/pbx-config/state.js +++ b/src/store/pbx-config/state.js @@ -10,6 +10,12 @@ export default { seatsOrdered: [], numbers: [], numbersMap : {}, + devicesOrdered: [], + devices: {}, + profilesOrdered: [], + profiles: {}, + modelsOrdered: [], + models: {}, listState: RequestState.initiated, listError: null, listLoadingSilently: false, diff --git a/src/themes/app.common.styl b/src/themes/app.common.styl new file mode 100644 index 00000000..177e017d --- /dev/null +++ b/src/themes/app.common.styl @@ -0,0 +1,32 @@ + +@import 'quasar.variables' + + +.csc-no-entities + margin 15px + color $secondary + +.csc-important + font-weight bold + +.csc-entity + position relative + + .q-btn + .on-left + margin 0 + + .csc-entity-title .q-chip-main { + color white + } + + .csc-entity-title-text + padding-left 6px + + .q-card-title + color $secondary + + .q-card-title-extra + .q-btn + padding-left 8px + padding-right 8px