|
|
@ -18,6 +18,10 @@ const ForwardGroup = {
|
|
|
|
timeout: {
|
|
|
|
timeout: {
|
|
|
|
name: 'csc-timeout',
|
|
|
|
name: 'csc-timeout',
|
|
|
|
mapping: 'cft'
|
|
|
|
mapping: 'cft'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offline: {
|
|
|
|
|
|
|
|
name: 'csc-offline',
|
|
|
|
|
|
|
|
mapping: 'cfo'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -26,7 +30,8 @@ export default {
|
|
|
|
state: {
|
|
|
|
state: {
|
|
|
|
mappings: [],
|
|
|
|
mappings: [],
|
|
|
|
forwardGroups: [],
|
|
|
|
forwardGroups: [],
|
|
|
|
destinationInCreation: false
|
|
|
|
destinationInCreation: false,
|
|
|
|
|
|
|
|
selectedDestType: null
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
getters: {
|
|
|
|
primaryNumber(state, getters, rootState, rootGetters) {
|
|
|
|
primaryNumber(state, getters, rootState, rootGetters) {
|
|
|
@ -52,6 +57,12 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
destinationInCreation(state){
|
|
|
|
destinationInCreation(state){
|
|
|
|
return state.destinationInCreation;
|
|
|
|
return state.destinationInCreation;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
selectedDestType(state){
|
|
|
|
|
|
|
|
return state.selectedDestType;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
groupsCount(state){
|
|
|
|
|
|
|
|
return state.forwardGroups.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
mutations: {
|
|
|
@ -82,10 +93,16 @@ export default {
|
|
|
|
state.mappings = mappings;
|
|
|
|
state.mappings = mappings;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
loadForwardGroups(state, forwardGroups){
|
|
|
|
loadForwardGroups(state, forwardGroups){
|
|
|
|
|
|
|
|
if(forwardGroups[0] && (forwardGroups[0].name.includes('unconditional') || forwardGroups[0].name.includes('timeout'))){
|
|
|
|
|
|
|
|
forwardGroups.push(forwardGroups.shift())
|
|
|
|
|
|
|
|
}
|
|
|
|
state.forwardGroups = forwardGroups;
|
|
|
|
state.forwardGroups = forwardGroups;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setDestinationInCreation(state, isInCreation){
|
|
|
|
setDestinationInCreation(state, isInCreation){
|
|
|
|
state.destinationInCreation = isInCreation;
|
|
|
|
state.destinationInCreation = isInCreation;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setSelectedDestType(state, destType){
|
|
|
|
|
|
|
|
state.selectedDestType = destType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
actions: {
|
|
|
@ -134,22 +151,10 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
createEmptyForwardGroup(context, groupName){
|
|
|
|
|
|
|
|
const destination = {
|
|
|
|
|
|
|
|
"announcement_id": null,
|
|
|
|
|
|
|
|
"simple_destination": " ",
|
|
|
|
|
|
|
|
"destination": " ",
|
|
|
|
|
|
|
|
"priority": 1,
|
|
|
|
|
|
|
|
"timeout": 5
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
context.state.tempForwardGroups.push({
|
|
|
|
|
|
|
|
name: groupName,
|
|
|
|
|
|
|
|
destinations:[destination]
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
async addForwardGroup(context, data) {
|
|
|
|
async addForwardGroup(context, data) {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
const newForwardGroupId = await addNewDestinationsetWithName(ForwardGroup[data.name] ? ForwardGroup[data.name].name : data.name);
|
|
|
|
const newForwardGroupId = await addNewDestinationsetWithName(ForwardGroup[data.name] ? ForwardGroup[data.name].name : data.name);
|
|
|
|
|
|
|
|
|
|
|
|
const destination = {
|
|
|
|
const destination = {
|
|
|
|
"announcement_id": null,
|
|
|
|
"announcement_id": null,
|
|
|
|
"simple_destination": data.destination || " ",
|
|
|
|
"simple_destination": data.destination || " ",
|
|
|
@ -183,7 +188,7 @@ export default {
|
|
|
|
async deleteForwardGroup(context, group) {
|
|
|
|
async deleteForwardGroup(context, group) {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
const subscriberId = localStorage.getItem('subscriberId');
|
|
|
|
const subscriberId = localStorage.getItem('subscriberId');
|
|
|
|
const groupMappingId = group.name === 'csc-unconditional' ? 'cfu' : 'cft';
|
|
|
|
const groupMappingId = await context.dispatch('getMappingIdByGroupName', group.name);
|
|
|
|
await deleteDestinationsetById(group.id);
|
|
|
|
await deleteDestinationsetById(group.id);
|
|
|
|
await addNewMapping({
|
|
|
|
await addNewMapping({
|
|
|
|
mappings: [],
|
|
|
|
mappings: [],
|
|
|
@ -203,8 +208,8 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return forwardGroups.length > 0 ? forwardGroups[0] : null;
|
|
|
|
return forwardGroups.length > 0 ? forwardGroups[0] : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addTempDestination(context, groupName){
|
|
|
|
addTempGroup(context, groupName){
|
|
|
|
context.state.forwardGroups.push({
|
|
|
|
const data = {
|
|
|
|
id: "temp-" + ForwardGroup[groupName].name,
|
|
|
|
id: "temp-" + ForwardGroup[groupName].name,
|
|
|
|
name: ForwardGroup[groupName].name,
|
|
|
|
name: ForwardGroup[groupName].name,
|
|
|
|
destinations: [{
|
|
|
|
destinations: [{
|
|
|
@ -214,7 +219,14 @@ export default {
|
|
|
|
"priority": 1,
|
|
|
|
"priority": 1,
|
|
|
|
"timeout": 5
|
|
|
|
"timeout": 5
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
if(!groupName.includes('timeout') && !groupName.includes('unconditional')){
|
|
|
|
|
|
|
|
context.state.forwardGroups.unshift(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
context.state.forwardGroups.push(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async addDestination(context, data){
|
|
|
|
async addDestination(context, data){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
@ -258,8 +270,8 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async replaceDestinations(context, data){
|
|
|
|
async replaceDestinations(context, data){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
let group = context.state.forwardGroups.find((group)=>{
|
|
|
|
let group = context.state.forwardGroups.find(($group)=>{
|
|
|
|
return group.name === ForwardGroup[data.groupName].name;
|
|
|
|
return $group.name === ForwardGroup[data.groupName].name;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await addDestinationToDestinationset({
|
|
|
|
await addDestinationToDestinationset({
|
|
|
|
id: group.id,
|
|
|
|
id: group.id,
|
|
|
@ -272,19 +284,22 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async removeDestination(context, data){
|
|
|
|
async removeDestination(context, data){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
let destinations, group = context.state.forwardGroups.find((group)=>{
|
|
|
|
let destinations, group = context.state.forwardGroups.find((group)=>{
|
|
|
|
return group.id === data.forwardGroupId;
|
|
|
|
return group.id === data.forwardGroupId;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
destinations = group.destinations.filter(($destination) => {
|
|
|
|
destinations = group.destinations.filter(($destination) => {
|
|
|
|
return $destination.destination !== data.destination.destination;
|
|
|
|
return $destination.destination !== data.destination.destination;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await addDestinationToDestinationset({
|
|
|
|
await addDestinationToDestinationset({
|
|
|
|
id: group.id,
|
|
|
|
id: group.id,
|
|
|
|
data: destinations
|
|
|
|
data: destinations
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if(destinations.length < 1){
|
|
|
|
if(destinations.length < 1){
|
|
|
|
context.dispatch('deleteForwardGroup', group);
|
|
|
|
await context.dispatch('deleteForwardGroup', group);
|
|
|
|
context.dispatch('loadForwardGroups', group);
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
catch(err){
|
|
|
@ -347,28 +362,30 @@ export default {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
let unconditionalGroup = await context.dispatch('getForwardGroupByName', 'unconditional')
|
|
|
|
let unconditionalGroup = await context.dispatch('getForwardGroupByName', 'unconditional')
|
|
|
|
let timeoutGroup = await context.dispatch('getForwardGroupByName', 'timeout');
|
|
|
|
let timeoutGroup = await context.dispatch('getForwardGroupByName', 'timeout');
|
|
|
|
|
|
|
|
|
|
|
|
if(noSelfNumber){
|
|
|
|
if(noSelfNumber){
|
|
|
|
if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){
|
|
|
|
if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){
|
|
|
|
|
|
|
|
const destinations = [...timeoutGroup.destinations]
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
name: 'unconditional'
|
|
|
|
name: 'unconditional'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await context.dispatch('loadMappings');
|
|
|
|
await context.dispatch('loadMappings');
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
//unconditionalGroup = await context.dispatch('getForwardGroupByName', 'unconditional');
|
|
|
|
|
|
|
|
await context.dispatch('replaceDestinations', {
|
|
|
|
await context.dispatch('replaceDestinations', {
|
|
|
|
groupName: 'unconditional',
|
|
|
|
groupName: 'unconditional',
|
|
|
|
destinations: timeoutGroup.destinations
|
|
|
|
destinations: destinations
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await context.dispatch('deleteForwardGroup', timeoutGroup);
|
|
|
|
await context.dispatch('deleteForwardGroup', timeoutGroup);
|
|
|
|
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
await context.dispatch('addTempDestination', 'temp-unconditional')
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
|
|
|
|
await context.dispatch('addTempGroup', 'unconditional');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
if(unconditionalGroup && !unconditionalGroup.id.toString().includes('temp')){
|
|
|
|
if(unconditionalGroup && !unconditionalGroup.id.toString().includes('temp')){
|
|
|
|
|
|
|
|
const destinations = [...unconditionalGroup.destinations]
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
await context.dispatch('addForwardGroup', {
|
|
|
|
name: 'timeout'
|
|
|
|
name: 'timeout'
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -376,14 +393,18 @@ export default {
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
await context.dispatch('replaceDestinations', {
|
|
|
|
await context.dispatch('replaceDestinations', {
|
|
|
|
groupName: 'timeout',
|
|
|
|
groupName: 'timeout',
|
|
|
|
destinations: unconditionalGroup.destinations
|
|
|
|
destinations: destinations
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await context.dispatch('deleteForwardGroup', unconditionalGroup);
|
|
|
|
await context.dispatch('deleteForwardGroup', unconditionalGroup);
|
|
|
|
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
await context.dispatch('addTempDestination', 'temp-timeout')
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
|
|
|
|
await context.dispatch('addTempGroup', 'timeout');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await context.dispatch('loadForwardGroups');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
catch(err){
|
|
|
@ -431,6 +452,9 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setDestinationInCreation(context, isInCreation){
|
|
|
|
setDestinationInCreation(context, isInCreation){
|
|
|
|
context.commit('setDestinationInCreation', isInCreation);
|
|
|
|
context.commit('setDestinationInCreation', isInCreation);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setSelectedDestType(context, destType){
|
|
|
|
|
|
|
|
context.commit('setSelectedDestType', destType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|