Change-Id: I236db3253a156a6e6e0e152113b7b1887a0d4655changes/30/16130/2
parent
5bbe25c032
commit
3b8f5a4d10
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
import Vue from 'vue';
|
||||||
|
import { enableBlockIn, disableBlockIn, getPreferences } from './subscriber';
|
||||||
|
|
||||||
|
export function enableIncomingCallBlocking(id) {
|
||||||
|
return enableBlockIn(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function disableIncomingCallBlocking(id) {
|
||||||
|
return disableBlockIn(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getIncomingCallBlocking(id) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
getPreferences(id).then((result)=>{
|
||||||
|
resolve({
|
||||||
|
enabled: result.block_in_mode
|
||||||
|
});
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
export function getPreferences(id) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
Vue.http.get('/api/subscriberpreferences/' + id).then((result)=>{
|
||||||
|
resolve(JSON.parse(result.body));
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setPreference(id, field, value) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
var pref = {};
|
||||||
|
pref[field] = value;
|
||||||
|
Vue.http.put('/api/subscriberpreferences/' + id, pref).then((result)=>{
|
||||||
|
resolve();
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setBlockInMode(id, value) {
|
||||||
|
return setPreference(id, 'block_in_mode', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enableBlockIn(id) {
|
||||||
|
return setBlockInMode(id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function disableBlockIn(id) {
|
||||||
|
return setBlockInMode(id, false);
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { enableIncomingCallBlocking,
|
||||||
|
disableIncomingCallBlocking,
|
||||||
|
getIncomingCallBlocking
|
||||||
|
} from '../api/call-blocking';
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state: {
|
||||||
|
incomingEnabled: false,
|
||||||
|
incomingList: []
|
||||||
|
},
|
||||||
|
getters: {},
|
||||||
|
mutations: {
|
||||||
|
enableIncoming (state) {
|
||||||
|
state.incomingEnabled = true;
|
||||||
|
},
|
||||||
|
disableIncoming (state) {
|
||||||
|
state.incomingEnabled = false;
|
||||||
|
},
|
||||||
|
loadIncoming(state, options) {
|
||||||
|
state.incomingEnabled = options.enabled;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
toggleIncoming(context, enabled) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
if(enabled) {
|
||||||
|
enableIncomingCallBlocking(localStorage.getItem('subscriberId')).then(()=>{
|
||||||
|
context.commit('enableIncoming');
|
||||||
|
resolve();
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
disableIncomingCallBlocking(localStorage.getItem('subscriberId')).then(()=>{
|
||||||
|
context.commit('disableIncoming');
|
||||||
|
resolve();
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
loadIncoming(context) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
getIncomingCallBlocking(localStorage.getItem('subscriberId')).then((result)=>{
|
||||||
|
context.commit('loadIncoming', result);
|
||||||
|
resolve();
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in new issue