@ -4,22 +4,28 @@
< div ref = "imageWrapper" class = "csc-pbx-device-image" :style ="imageWrapperStyles" >
< div ref = "imageWrapper" class = "csc-pbx-device-image" :style ="imageWrapperStyles" >
< img ref = "image" :src ="imageUrl" @load ="imageLoaded" :style ="imageStyles" / >
< img ref = "image" :src ="imageUrl" @load ="imageLoaded" :style ="imageStyles" / >
< / div >
< / div >
< div :class ="spotClasses(index)" v -for = " ( key , index ) in keys "
< div :class ="spotClasses(index)" v -for = " ( key , index ) in keys " :key ="index"
: key = "index" : style = "spotPosition(key)" >
: style = "spotPosition(key)" @ click = "openKeyOverlay(key, index)" > { { index + 1 } } < / div >
< span > { { index + 1 } } < / span >
< / div >
< q -popover ref = "keyPopover" >
< div v-show ="keyOverlayActive" class="csc-pbx-device-config-key-overlay animate-fade" >
< div class = "csc-pbx-key-popover" >
< div class = "title" >
< q -field v-if ="getLineByKey(index) !== null" :icon="getIconByKey(index)" >
< q -icon name = "touch_app" size = "32px" / > Key { { selectedKeyIndex + 1 } }
< q -input :value ="getLineByKey(index).subscriber.display_name" readonly : float -label = " ' Key ' + ( index + 1 ) " / >
< / div >
< / q - f i e l d >
< q -field :label ="selectedKeyLabel" :icon ="selectedKeyIcon" >
< q -field v -else >
< q -select ref = "selectSubscriber" :value ="selectedKeySubscriber" :options ="groupsAndSeatsOptions"
< q -input value = "Empty" readonly : float -label = " ' Key ' + ( index + 1 ) " / >
@ change = "keySubscriberChanged" / >
< / q - f i e l d >
< / q - f i e l d >
< q -btn icon = "clear" :small ="!isMobile" class = "absolute-top-right"
< q -field label = "Type" >
@ click = "$refs.keyPopover[index].close()" flat round color = "primary" / >
< q -select ref = "selectType" v -model = " selectedKeyType " :options ="typeOptions"
< / div >
@ change = "keyTypeChanged" / >
< / q - p o p o v e r >
< / q - f i e l d >
< div class = "row justify-center actions" >
< div class = "column" >
< q -btn icon = "clear" :small ="!isMobile" @click ="closeKeyOverlay()" flat color = "negative" > Close < / q - b t n >
< / div >
< / div >
< / div >
< q -btn icon = "clear" :small ="!isMobile" class = "absolute-top-right"
@ click = "closeKeyOverlay()" flat round color = "primary" / >
< / div >
< / div >
< q -window -resize -observable @resize ="windowResize" / >
< q -window -resize -observable @resize ="windowResize" / >
< / div >
< / div >
@ -28,7 +34,7 @@
< script >
< script >
import _ from 'lodash'
import _ from 'lodash'
import { QList , QItem , QItemMain , QItemTile , QTabs , QTab , Platform ,
import { QList , QItem , QItemMain , QItemTile , QTabs , QTab , Platform , QSelect , QInnerLoading , QSpinnerMat ,
QTabPane , QChip , QWindowResizeObservable , QModal , QBtn , QPopover , QIcon , QField , QInput } from 'quasar-framework'
QTabPane , QChip , QWindowResizeObservable , QModal , QBtn , QPopover , QIcon , QField , QInput } from 'quasar-framework'
import { BoundingBox2D } from '../../../helpers/graphics'
import { BoundingBox2D } from '../../../helpers/graphics'
@ -37,9 +43,11 @@
props : [
props : [
'device' ,
'device' ,
'loading' ,
'loading' ,
'subscribers' ,
'groupsAndSeatsOptions'
] ,
] ,
components : {
components : {
QList , QItem , QItemMain , QItemTile , QTabs , QTab , Platform ,
QList , QItem , QItemMain , QItemTile , QTabs , QTab , Platform , QSelect , QInnerLoading , QSpinnerMat ,
QTabPane , QChip , QWindowResizeObservable , QModal , QBtn , QPopover , QIcon , QField , QInput
QTabPane , QChip , QWindowResizeObservable , QModal , QBtn , QPopover , QIcon , QField , QInput
} ,
} ,
data ( ) {
data ( ) {
@ -53,10 +61,76 @@
modalOpened : false ,
modalOpened : false ,
selectedKey : null ,
selectedKey : null ,
selectedKeyIndex : null ,
selectedKeyIndex : null ,
selectedLine : null
selectedLine : null ,
keyOverlayActive : false ,
selectedKeyTypeData : null ,
selectedLineIndex : null
}
}
} ,
} ,
computed : {
computed : {
selectedKeyIcon ( ) {
if ( this . selectedLine !== null ) {
let subscriber = this . subscribers ( this . selectedLine . subscriber _id ) ;
if ( subscriber !== null && subscriber . is _pbx _group === true ) {
return 'group' ;
}
else if ( subscriber !== null ) {
return 'person' ;
}
else {
return '' ;
}
}
return '' ;
} ,
selectedKeyLabel ( ) {
if ( this . selectedLine !== null ) {
let subscriber = this . subscribers ( this . selectedLine . subscriber _id ) ;
if ( subscriber !== null && subscriber . is _pbx _group === true ) {
return this . $t ( 'pbxConfig.keyGroupLabel' ) ;
}
else if ( subscriber !== null ) {
return this . $t ( 'pbxConfig.keySeatLabel' ) ;
}
else {
return this . $t ( 'pbxConfig.keyBothLabel' ) ;
}
}
return this . $t ( 'pbxConfig.keyBothLabel' ) ;
} ,
selectedKeySubscriber ( ) {
if ( this . selectedLine !== null ) {
return this . selectedLine . subscriber _id ;
}
return null ;
} ,
selectedKeyType : {
get ( ) {
if ( this . selectedLine !== null ) {
return this . selectedLine . type ;
}
return 'private' ;
} ,
set ( type ) {
this . selectedKeyTypeData = type ;
}
} ,
typeOptions ( ) {
return [
{
label : this . $t ( 'pbxConfig.keyTypeShared' ) ,
value : 'shared'
} ,
{
label : this . $t ( 'pbxConfig.keyTypeBLF' ) ,
value : 'blf'
} ,
{
label : this . $t ( 'pbxConfig.keyTypePrivate' ) ,
value : 'private'
}
] ;
} ,
isMobile ( ) {
isMobile ( ) {
return Platform . is . mobile ;
return Platform . is . mobile ;
} ,
} ,
@ -86,28 +160,31 @@
mounted ( ) {
mounted ( ) {
this . boundingBox = BoundingBox2D . createFromPoints ( this . keys ) ;
this . boundingBox = BoundingBox2D . createFromPoints ( this . keys ) ;
this . boundingBox . addMargin ( 40 ) ;
this . boundingBox . addMargin ( 40 ) ;
this . loadGroupsAndSeats ( ) ;
} ,
} ,
methods : {
methods : {
getLineIndexByKey ( keyIndex ) {
let lineIndex = null ;
let lines = _ . get ( this . device , 'lines' , [ ] ) ;
if ( lines . length > 0 ) {
lines . forEach ( ( $line , index ) => {
if ( $line . key _num === keyIndex ) {
lineIndex = index ;
}
} ) ;
}
return lineIndex ;
} ,
getLineByKey ( key ) {
getLineByKey ( key ) {
let line = null ;
let line = null ;
this . device . lines . forEach ( ( $line ) => {
this . device . lines . forEach ( ( $line ) => {
if ( $line . key _num === key ) {
if ( $line . key _num === key ) {
line = $line ;
line = $line ;
}
}
} ) ;
} ) ;
return line ;
return line ;
} ,
} ,
openModal ( key , index ) {
this . $refs . modal . open ( ) ;
this . selectedKey = key ;
this . selectedKeyIndex = index + 1 ;
this . selectedLine = this . getLineByKey ( index ) ;
} ,
closeModal ( ) {
this . $refs . modal . close ( ) ;
this . selectedKey = null ;
this . selectedKeyIndex = null ;
} ,
windowResize ( ) {
windowResize ( ) {
this . resize ( ) ;
this . resize ( ) ;
this . placeImage ( ) ;
this . placeImage ( ) ;
@ -199,18 +276,90 @@
}
}
return classes ;
return classes ;
} ,
} ,
getIconByKey ( key ) {
subscriberChanged ( subscriberId ) {
let line = this . getLineByKey ( key ) ;
let clonedKey = _ . clone ( this . selectedKey ) ;
if ( line !== null && line . subscriber . is _pbx _group === true ) {
clonedKey . subscriber _id = subscriberId ;
return 'group' ;
this . $emit ( 'keyChanged' , {
key : clonedKey ,
keyIndex : this . selectedKeyIndex
} ) ;
} ,
openKeyOverlay ( key , index ) {
this . selectedKey = key ;
this . selectedKeyIndex = index ;
this . selectedLine = this . getLineByKey ( index ) ;
this . keyOverlayActive = true ;
} ,
closeKeyOverlay ( ) {
this . keyOverlayActive = false ;
} ,
loadGroupsAndSeats ( ) {
this . $emit ( 'loadGroupsAndSeats' ) ;
} ,
keySubscriberChanged ( subscriberId ) {
let newLines = [ ] ;
let lines = _ . clone ( _ . get ( this . device , 'lines' , [ ] ) ) ;
let lineIndex = this . getLineIndexByKey ( this . selectedKeyIndex ) ;
let changed = false ;
if ( _ . isNumber ( lineIndex ) && lineIndex < lines . length && subscriberId === null ) {
delete lines [ lineIndex ] ;
changed = true ;
}
}
else if ( line !== null && line . subscriber . is _pbx _group === false ) {
else if ( _ . isNumber ( lineIndex ) && lineIndex < lines . length ) {
return 'person' ;
_ . set ( lines , lineIndex + '.subscriber_id' , subscriberId ) ;
changed = true ;
}
}
else {
else if ( subscriberId !== null ) {
return ''
newLines . push ( {
extension _unit : 0 ,
key _num : this . selectedKeyIndex ,
subscriber _id : subscriberId ,
linerange : _ . get ( this . device , 'profile.model.linerange.0.name' ) ,
type : this . $refs . selectType . value
} ) ;
changed = true ;
}
lines . forEach ( ( line ) => {
newLines . push ( {
extension _unit : line . extension _unit ,
key _num : line . key _num ,
subscriber _id : line . subscriber _id ,
linerange : line . linerange ,
type : line . type
} ) ;
} ) ;
if ( changed === true && newLines . length > 0 ) {
this . $emit ( 'keysChanged' , newLines ) ;
}
} ,
keyTypeChanged ( type ) {
let newLines = [ ] ;
let lines = _ . clone ( _ . get ( this . device , 'lines' , [ ] ) ) ;
let lineIndex = this . getLineIndexByKey ( this . selectedKeyIndex ) ;
let changed = false ;
if ( _ . isNumber ( lineIndex ) && _ . isObject ( lines [ lineIndex ] ) ) {
_ . set ( lines , lineIndex + '.type' , type ) ;
changed = true ;
}
if ( changed === true ) {
lines . forEach ( ( line ) => {
newLines . push ( {
extension _unit : line . extension _unit ,
key _num : line . key _num ,
subscriber _id : line . subscriber _id ,
linerange : line . linerange ,
type : line . type
} ) ;
} ) ;
this . $emit ( 'keysChanged' , newLines ) ;
}
}
}
}
} ,
watch : {
device ( ) {
this . openKeyOverlay ( this . selectedKey , this . selectedKeyIndex ) ;
this . $forceUpdate ( ) ;
}
}
}
}
}
< / script >
< / script >
@ -219,6 +368,27 @@
@ import '../../../themes/quasar.variables' ;
@ import '../../../themes/quasar.variables' ;
$spotSize = 25 px
$spotSize = 25 px
. csc - pbx - device - config - key - overlay
. title
. q - icon
margin - right 8 px
font - size 18 px
font - weight 400
letter - spacing normal
line - height 1.8 rem
margin - bottom 32 px
text - align center
position absolute
top 0
left 0
right 0
bottom 0
background - color rgba ( 250 , 250 , 250 , 0.95 )
z - index 10
padding 48 px
. csc - pbx - device - key - details
. csc - pbx - device - key - details
padding 50 px
padding 50 px
position relative
position relative
@ -227,6 +397,8 @@
position relative
position relative
. spot - modal - content
. spot - modal - content
position relative
position relative
. actions
padding 32 px
. csc - pbx - device - image
. csc - pbx - device - image
position relative
position relative
@ -244,6 +416,9 @@
letter - spacing normal
letter - spacing normal
line - height 1.8 rem
line - height 1.8 rem
. csc - pbx - device - loader
z - index 20
. csc - pbx - device - button - spot
. csc - pbx - device - button - spot
border - radius : 50 % ;
border - radius : 50 % ;
width $spotSize
width $spotSize