|
|
@ -22,6 +22,10 @@ const ForwardGroup = {
|
|
|
|
offline: {
|
|
|
|
offline: {
|
|
|
|
name: 'csc-offline',
|
|
|
|
name: 'csc-offline',
|
|
|
|
mapping: 'cfo'
|
|
|
|
mapping: 'cfo'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
busy: {
|
|
|
|
|
|
|
|
name: 'csc-busy',
|
|
|
|
|
|
|
|
mapping: 'cfb'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -63,6 +67,30 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
groupsCount(state){
|
|
|
|
groupsCount(state){
|
|
|
|
return state.forwardGroups.length;
|
|
|
|
return state.forwardGroups.length;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
timeoutGroupExists(state){
|
|
|
|
|
|
|
|
const group = state.forwardGroups.filter(($group)=>{
|
|
|
|
|
|
|
|
return $group.name === 'csc-timeout'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return group && group.length > 0;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
unconditionalGroupExists(state){
|
|
|
|
|
|
|
|
const group = state.forwardGroups.filter(($group)=>{
|
|
|
|
|
|
|
|
return $group.name === 'csc-unconditional'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return group && group.length > 0;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offlineGroupExists(state){
|
|
|
|
|
|
|
|
const group = state.forwardGroups.filter(($group)=>{
|
|
|
|
|
|
|
|
return $group.name === 'csc-offline'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return group && group.length > 0;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
busyGroupExists(state){
|
|
|
|
|
|
|
|
const group = state.forwardGroups.filter(($group)=>{
|
|
|
|
|
|
|
|
return $group.name === 'csc-busy'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return group && group.length > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
mutations: {
|
|
|
@ -96,7 +124,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < forwardGroups.length; i++) {
|
|
|
|
for (let i = 0; i < forwardGroups.length; i++) {
|
|
|
|
const group = forwardGroups[i];
|
|
|
|
const group = forwardGroups[i];
|
|
|
|
if (!group.name.includes('unconditional') && !group.name.includes('timeout')){
|
|
|
|
if (group.name.includes('unconditional') || group.name.includes('timeout')){
|
|
|
|
forwardGroups.splice(i, 1);
|
|
|
|
forwardGroups.splice(i, 1);
|
|
|
|
forwardGroups.unshift(group);
|
|
|
|
forwardGroups.unshift(group);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -211,6 +239,13 @@ export default {
|
|
|
|
forwardGroups = forwardGroups.filter(($forwardGroup) => {
|
|
|
|
forwardGroups = forwardGroups.filter(($forwardGroup) => {
|
|
|
|
return ForwardGroup[name] ? $forwardGroup.name === ForwardGroup[name].name : $forwardGroup.name === name;
|
|
|
|
return ForwardGroup[name] ? $forwardGroup.name === ForwardGroup[name].name : $forwardGroup.name === name;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return forwardGroups.length > 0 ? forwardGroups : null;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
getForwardGroupById(context, id){
|
|
|
|
|
|
|
|
let forwardGroups = context.getters.forwardGroups;
|
|
|
|
|
|
|
|
forwardGroups = forwardGroups.filter(($forwardGroup) => {
|
|
|
|
|
|
|
|
return $forwardGroup.id === id ;
|
|
|
|
|
|
|
|
});
|
|
|
|
return forwardGroups.length > 0 ? forwardGroups[0] : null;
|
|
|
|
return forwardGroups.length > 0 ? forwardGroups[0] : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addTempGroup(context, groupName){
|
|
|
|
addTempGroup(context, groupName){
|
|
|
@ -225,7 +260,7 @@ export default {
|
|
|
|
"timeout": 5
|
|
|
|
"timeout": 5
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if(!groupName.includes('timeout') && !groupName.includes('unconditional')){
|
|
|
|
if(groupName.includes('timeout') || groupName.includes('unconditional')){
|
|
|
|
context.state.forwardGroups.unshift(data);
|
|
|
|
context.state.forwardGroups.unshift(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
@ -365,10 +400,11 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async forwardAllCalls(context, noSelfNumber){
|
|
|
|
async forwardAllCalls(context, noSelfNumber){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
let unconditionalGroup = await context.dispatch('getForwardGroupByName', 'unconditional')
|
|
|
|
let unconditionalGroups = await context.dispatch('getForwardGroupByName', 'unconditional')
|
|
|
|
let timeoutGroup = await context.dispatch('getForwardGroupByName', 'timeout');
|
|
|
|
let timeoutGroups = await context.dispatch('getForwardGroupByName', 'timeout');
|
|
|
|
|
|
|
|
|
|
|
|
if(noSelfNumber){
|
|
|
|
if(noSelfNumber && timeoutGroups){
|
|
|
|
|
|
|
|
for(let timeoutGroup of timeoutGroups){
|
|
|
|
if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){
|
|
|
|
if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){
|
|
|
|
const destinations = [...timeoutGroup.destinations]
|
|
|
|
const destinations = [...timeoutGroup.destinations]
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
@ -388,8 +424,11 @@ export default {
|
|
|
|
await context.dispatch('addTempGroup', 'unconditional');
|
|
|
|
await context.dispatch('addTempGroup', 'unconditional');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
if(unconditionalGroup && !unconditionalGroup.id.toString().includes('temp')){
|
|
|
|
if(unconditionalGroups ){
|
|
|
|
|
|
|
|
for(let unconditionalGroup of unconditionalGroups){
|
|
|
|
|
|
|
|
if(!unconditionalGroup.id.toString().includes('temp')){
|
|
|
|
const destinations = [...unconditionalGroup.destinations]
|
|
|
|
const destinations = [...unconditionalGroup.destinations]
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
name: 'timeout'
|
|
|
|
name: 'timeout'
|
|
|
@ -407,9 +446,8 @@ export default {
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
await context.dispatch('addTempGroup', 'timeout');
|
|
|
|
await context.dispatch('addTempGroup', 'timeout');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
catch(err){
|
|
|
@ -426,22 +464,29 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mappingId;
|
|
|
|
return mappingId;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async isGroupEnabled(context, groupName){
|
|
|
|
async isGroupEnabled(context, data){
|
|
|
|
const mappingId = await context.dispatch('getMappingIdByGroupName', groupName);
|
|
|
|
const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName);
|
|
|
|
return mappingId
|
|
|
|
if(mappingId && context.state.mappings[mappingId]){
|
|
|
|
&& context.state.mappings[mappingId]
|
|
|
|
let groupProps = await context.state.mappings[mappingId].filter(($group)=>{
|
|
|
|
&& context.state.mappings[mappingId][0] // IMPROVE remove hardcoded [0]
|
|
|
|
return $group.destinationset_id === data.id;
|
|
|
|
? context.state.mappings[mappingId][0].enabled
|
|
|
|
});
|
|
|
|
: true;
|
|
|
|
if(groupProps){
|
|
|
|
|
|
|
|
return groupProps[0].enabled;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async enableGroup(context, data){
|
|
|
|
async enableGroup(context, data){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
if(!data.id.toString().includes('temp-')){
|
|
|
|
if(!data.id.toString().includes('temp-')){
|
|
|
|
const subscriberId = localStorage.getItem('subscriberId');
|
|
|
|
const subscriberId = localStorage.getItem('subscriberId');
|
|
|
|
const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName);
|
|
|
|
const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName);
|
|
|
|
let groupMappings = context.state.mappings[mappingId];
|
|
|
|
const groupMappings = await context.state.mappings[mappingId];
|
|
|
|
groupMappings[0].enabled = data.enabled; // IMPROVE remove hardcoded [0]
|
|
|
|
for(let group of groupMappings){
|
|
|
|
|
|
|
|
if(group.destinationset_id === data.id){
|
|
|
|
|
|
|
|
group.enabled = data.enabled;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
await addNewMapping({
|
|
|
|
await addNewMapping({
|
|
|
|
mappings: groupMappings,
|
|
|
|
mappings: groupMappings,
|
|
|
|
group: mappingId,
|
|
|
|
group: mappingId,
|
|
|
|