@ -1,20 +1,60 @@
< template >
< csc -page :title ="$t('pbxConfig.devicesTitle')" class = "csc-list-page" >
< div v-if ="isListLoadingVisible" class="row justify-center" >
< q -spinner -dots color = "primary" :size ="40" / >
< csc -page
: title = "$t('pbxConfig.devicesTitle')"
class = "csc-list-page"
>
< q -select
v - model = "profile"
: float - label = "$t('pbxConfig.filterPhoneModel')"
: options = "profileOptions"
@ change = "filterByProfile"
: after = "modelButtons"
: class = "{ 'filter-model-select': this.platform.mobile }"
/ >
< div
v - if = "isListLoadingVisible"
class = "row justify-center"
>
< q -spinner -dots
color = "primary"
: size = "40"
/ >
< / div >
< div v-if ="devices.length > 0 && !isListRequesting && listLastPage > 1" class="row justify-center" >
< q -pagination :value ="listCurrentPage" :max ="listLastPage" @change ="changePage" / >
< div
v - if = "devices.length > 0 && !isListRequesting && listLastPage > 1"
class = "row justify-center"
>
< q -pagination
: value = "listCurrentPage"
: max = "listLastPage"
@ change = "changePage"
/ >
< / div >
< q -list no -border separator sparse multiline >
< q -list
no - border
separator
sparse
multiline
>
< q -item > < / q - i t e m >
< csc -pbx -device v -for = " device in devices " :key ="device.id" :device ="device" @remove ="removeDevice"
: modelOptions = "modelOptions" : loading = "isDeviceLoading(device.id)"
: groupsAndSeatsOptions = "groupsAndSeatsOptions" : subscribers = "getGroupOrSeatById"
@ loadGroupsAndSeats = "loadGroupsAndSeats()" @ deviceKeysChanged = "deviceKeysChanged" / >
< csc -pbx -device
v - for = "device in devices"
: key = "device.id"
: device = "device"
@ remove = "removeDevice"
: modelOptions = "modelOptions"
: loading = "isDeviceLoading(device.id)"
: groupsAndSeatsOptions = "groupsAndSeatsOptions"
: subscribers = "getGroupOrSeatById"
@ loadGroupsAndSeats = "loadGroupsAndSeats()"
@ deviceKeysChanged = "deviceKeysChanged"
/ >
< / q - l i s t >
< div v-if ="devices.length === 0 && !isListRequesting" class="row justify-center csc-no-entities" >
{ { $t ( 'pbxConfig.noDevices' ) } }
< div
v - if = "devices.length === 0 && !isListRequesting"
class = "row justify-center csc-no-entities"
>
{ { noDeviceMessage } }
< / div >
< / c s c - p a g e >
< / template >
@ -23,18 +63,30 @@
import { mapGetters } from 'vuex'
import CscPage from '../../CscPage'
import CscPbxDevice from './CscPbxDevice'
import { QSpinnerDots , QPagination , QList , Dialog , QItem } from 'quasar-framework'
import { showToast } from '../../../helpers/ui'
import {
showGlobalError ,
showToast
} from '../../../helpers/ui'
import {
QSpinnerDots ,
QPagination ,
QList ,
Dialog ,
QItem ,
QBtn ,
QSelect
} from 'quasar-framework'
export default {
data ( ) {
return {
profile : null ,
platform : this . $q . platform . is
}
} ,
mounted ( ) {
this . $store . dispatch ( 'pbxConfig/listDevices' , {
page : 1
} ) ;
this . listDevices ( ) ;
this . $store . dispatch ( 'pbxConfig/listProfiles' ) ;
} ,
components : {
CscPage ,
@ -43,7 +95,9 @@
QPagination ,
QList ,
Dialog ,
QItem
QItem ,
QBtn ,
QSelect
} ,
computed : {
... mapGetters ( 'pbxConfig' , [
@ -58,10 +112,45 @@
'groupsAndSeatsOptions' ,
'groupsAndSeats' ,
'getGroupOrSeatById' ,
'updatedDeviceKey'
] )
'updatedDeviceKey' ,
'profileOptions' ,
'listProfilesState' ,
'listProfilesError'
] ) ,
noDeviceMessage ( ) {
if ( this . profile ) {
return this . $t ( 'pbxConfig.noModel' ) ;
}
else {
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 : {
resetFilter ( ) {
this . profile = null ;
this . listDevices ( ) ;
} ,
filterByProfile ( profile ) {
this . $store . dispatch ( 'pbxConfig/filterDevices' , {
profile _id : profile
} ) ;
} ,
changePage ( page ) {
this . $store . dispatch ( 'pbxConfig/listDevices' , {
page : page
@ -93,6 +182,11 @@
} ,
deviceKeysChanged ( data ) {
this . $store . dispatch ( 'pbxConfig/updateDeviceKeys' , data ) ;
} ,
listDevices ( ) {
this . $store . dispatch ( 'pbxConfig/listDevices' , {
page : 1
} ) ;
}
} ,
watch : {
@ -109,11 +203,19 @@
name : data . device . station _name
} ) ) ;
}
} ,
listProfilesState ( state ) {
if ( state === 'failed' ) {
showGlobalError ( this . listProfilesError ) ;
}
}
}
}
< / script >
< style lang = "stylus" rel = "stylesheet/stylus" >
@ import '../../../themes/app.common' ;
. filter - model - select
margin 16 px 16 px 8 px 16 px
< / style >