Setup Circle CI, add brakeman config (#13)
* Add circle ci config * Change config to fix tests * Update config * Fix eslint command, add brakeman
This commit is contained in:
parent
6e4fec2b55
commit
2c144d5ad3
39 changed files with 847 additions and 616 deletions
82
.circleci/config.yml
Normal file
82
.circleci/config.yml
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
# Ruby CircleCI 2.0 configuration file
|
||||||
|
#
|
||||||
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
||||||
|
#
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
# specify the version you desire here
|
||||||
|
- image: circleci/ruby:2.6.0-node-browsers
|
||||||
|
|
||||||
|
# Specify service dependencies here if necessary
|
||||||
|
# CircleCI maintains a library of pre-built images
|
||||||
|
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||||
|
- image: circleci/postgres:9.4
|
||||||
|
|
||||||
|
working_directory: ~/build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Which bundler?
|
||||||
|
command: bundle -v
|
||||||
|
|
||||||
|
# Restore bundle cache
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
|
||||||
|
- chatwoot-bundle-v2-
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Bundle Install
|
||||||
|
command: bundle check || bundle install
|
||||||
|
|
||||||
|
# Store bundle cache
|
||||||
|
- save_cache:
|
||||||
|
key: chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
|
||||||
|
paths:
|
||||||
|
- vendor/bundle
|
||||||
|
|
||||||
|
# Only necessary if app uses webpacker or yarn in some other way
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- chatwoot-yarn-{{ checksum "yarn.lock" }}
|
||||||
|
- chatwoot-yarn-
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: yarn
|
||||||
|
command: yarn install --cache-folder ~/.cache/yarn
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: eslint
|
||||||
|
command: yarn run eslint
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: brakeman
|
||||||
|
command: brakeman
|
||||||
|
|
||||||
|
# Store yarn / webpacker cache
|
||||||
|
- save_cache:
|
||||||
|
key: chatwoot-yarn-{{ checksum "yarn.lock" }}
|
||||||
|
paths:
|
||||||
|
- ~/.cache/yarn
|
||||||
|
|
||||||
|
# Database setup
|
||||||
|
- run: yarn install --check-files
|
||||||
|
- run: bundle exec rake db:create
|
||||||
|
- run: bundle exec rake db:schema:load
|
||||||
|
|
||||||
|
|
||||||
|
# Run rails tests
|
||||||
|
- type: shell
|
||||||
|
command: |
|
||||||
|
bin/rails test $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings)
|
||||||
|
|
||||||
|
# collect reports
|
||||||
|
- store_test_results:
|
||||||
|
path: /tmp/test-results
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/test-results
|
||||||
|
destination: test-results
|
3
Gemfile
3
Gemfile
|
@ -53,6 +53,9 @@ gem 'webpacker'
|
||||||
# for starting different server processes
|
# for starting different server processes
|
||||||
gem 'foreman'
|
gem 'foreman'
|
||||||
|
|
||||||
|
# static analysis
|
||||||
|
gem 'brakeman'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'byebug', platform: :mri
|
gem 'byebug', platform: :mri
|
||||||
gem 'letter_opener'
|
gem 'letter_opener'
|
||||||
|
|
|
@ -148,6 +148,7 @@ GEM
|
||||||
bindex (0.8.1)
|
bindex (0.8.1)
|
||||||
bootsnap (1.4.4)
|
bootsnap (1.4.4)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
|
brakeman (4.6.1)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (11.0.1)
|
byebug (11.0.1)
|
||||||
capybara (3.28.0)
|
capybara (3.28.0)
|
||||||
|
@ -434,6 +435,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
acts-as-taggable-on!
|
acts-as-taggable-on!
|
||||||
bootsnap
|
bootsnap
|
||||||
|
brakeman
|
||||||
byebug
|
byebug
|
||||||
carrierwave-aws
|
carrierwave-aws
|
||||||
chargebee (~> 2)
|
chargebee (~> 2)
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Api::V1::WebhooksController < ApplicationController
|
||||||
private
|
private
|
||||||
def login_from_basic_auth
|
def login_from_basic_auth
|
||||||
authenticate_or_request_with_http_basic do |username, password|
|
authenticate_or_request_with_http_basic do |username, password|
|
||||||
username == '' && password == ''
|
username == ENV['CHARGEBEE_WEBHOOK_USERNAME'] && password == ENV['CHARGEBEE_WEBHOOK_PASSWORD']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
import endPoints from './endPoints';
|
import endPoints from './endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
getAgents() {
|
getAgents() {
|
||||||
const urlData = endPoints('fetchAgents');
|
const urlData = endPoints('fetchAgents');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -23,52 +23,56 @@ export default {
|
||||||
addAgent(agentInfo) {
|
addAgent(agentInfo) {
|
||||||
const urlData = endPoints('addAgent');
|
const urlData = endPoints('addAgent');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, agentInfo)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, agentInfo)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
editAgent(agentInfo) {
|
editAgent(agentInfo) {
|
||||||
const urlData = endPoints('editAgent')(agentInfo.id);
|
const urlData = endPoints('editAgent')(agentInfo.id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.put(urlData.url, agentInfo)
|
axios
|
||||||
.then((response) => {
|
.put(urlData.url, agentInfo)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
deleteAgent(agentId) {
|
deleteAgent(agentId) {
|
||||||
const urlData = endPoints('deleteAgent')(agentId);
|
const urlData = endPoints('deleteAgent')(agentId);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.delete(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.delete(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
getLabels() {
|
getLabels() {
|
||||||
const urlData = endPoints('fetchLabels');
|
const urlData = endPoints('fetchLabels');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -76,13 +80,14 @@ export default {
|
||||||
getInboxes() {
|
getInboxes() {
|
||||||
const urlData = endPoints('fetchInboxes');
|
const urlData = endPoints('fetchInboxes');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -90,13 +95,14 @@ export default {
|
||||||
deleteInbox(id) {
|
deleteInbox(id) {
|
||||||
const urlData = endPoints('inbox').delete(id);
|
const urlData = endPoints('inbox').delete(id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.delete(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.delete(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -104,13 +110,14 @@ export default {
|
||||||
listInboxAgents(id) {
|
listInboxAgents(id) {
|
||||||
const urlData = endPoints('inbox').agents.get(id);
|
const urlData = endPoints('inbox').agents.get(id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -118,16 +125,17 @@ export default {
|
||||||
updateInboxAgents(inboxId, agentList) {
|
updateInboxAgents(inboxId, agentList) {
|
||||||
const urlData = endPoints('inbox').agents.post();
|
const urlData = endPoints('inbox').agents.post();
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, {
|
axios
|
||||||
user_ids: agentList,
|
.post(urlData.url, {
|
||||||
inbox_id: inboxId,
|
user_ids: agentList,
|
||||||
})
|
inbox_id: inboxId,
|
||||||
.then((response) => {
|
})
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,78 +9,89 @@ import Cookies from 'js-cookie';
|
||||||
import endPoints from './endPoints';
|
import endPoints from './endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
login(creds) {
|
login(creds) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post('auth/sign_in', creds)
|
axios
|
||||||
.then((response) => {
|
.post('auth/sign_in', creds)
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
.then(response => {
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
resolve();
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
})
|
});
|
||||||
.catch((error) => {
|
Cookies.set('user', response.data.data, {
|
||||||
reject(error.response);
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
});
|
});
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error.response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
register(creds) {
|
register(creds) {
|
||||||
const urlData = endPoints('register');
|
const urlData = endPoints('register');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, {
|
axios
|
||||||
account_name: creds.name,
|
.post(urlData.url, {
|
||||||
email: creds.email,
|
account_name: creds.name,
|
||||||
})
|
email: creds.email,
|
||||||
.then((response) => {
|
})
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
.then(response => {
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
resolve(response);
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
})
|
});
|
||||||
.catch((error) => {
|
Cookies.set('user', response.data.data, {
|
||||||
reject(error);
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
});
|
});
|
||||||
|
resolve(response);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
validityCheck() {
|
validityCheck() {
|
||||||
const urlData = endPoints('validityCheck');
|
const urlData = endPoints('validityCheck');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
if (error.response.status === 401) {
|
.catch(error => {
|
||||||
Cookies.remove('auth_data');
|
if (error.response.status === 401) {
|
||||||
Cookies.remove('user');
|
Cookies.remove('auth_data');
|
||||||
window.location = '/login';
|
Cookies.remove('user');
|
||||||
}
|
window.location = '/login';
|
||||||
reject(error);
|
}
|
||||||
});
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
const urlData = endPoints('logout');
|
const urlData = endPoints('logout');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.delete(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.delete(urlData.url)
|
||||||
Cookies.remove('auth_data');
|
.then(response => {
|
||||||
Cookies.remove('user');
|
Cookies.remove('auth_data');
|
||||||
window.location = '/u/login';
|
Cookies.remove('user');
|
||||||
resolve(response);
|
window.location = '/u/login';
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(error);
|
.catch(error => {
|
||||||
});
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !(!Cookies.getJSON('auth_data'));
|
return !!Cookies.getJSON('auth_data');
|
||||||
},
|
},
|
||||||
|
|
||||||
isAdmin() {
|
isAdmin() {
|
||||||
|
@ -111,47 +122,54 @@ export default {
|
||||||
|
|
||||||
verifyPasswordToken({ confirmationToken }) {
|
verifyPasswordToken({ confirmationToken }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post('auth/confirmation', {
|
axios
|
||||||
confirmation_token: confirmationToken,
|
.post('auth/confirmation', {
|
||||||
})
|
confirmation_token: confirmationToken,
|
||||||
.then((response) => {
|
})
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(error.response);
|
.catch(error => {
|
||||||
});
|
reject(error.response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setNewPassword({ resetPasswordToken, password, confirmPassword }) {
|
setNewPassword({ resetPasswordToken, password, confirmPassword }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.put('auth/password', {
|
axios
|
||||||
reset_password_token: resetPasswordToken,
|
.put('auth/password', {
|
||||||
password_confirmation: confirmPassword,
|
reset_password_token: resetPasswordToken,
|
||||||
password,
|
password_confirmation: confirmPassword,
|
||||||
})
|
password,
|
||||||
.then((response) => {
|
})
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
.then(response => {
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
resolve(response);
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
})
|
});
|
||||||
.catch((error) => {
|
Cookies.set('user', response.data.data, {
|
||||||
reject(error.response);
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
});
|
});
|
||||||
|
resolve(response);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error.response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
resetPassword({ email }) {
|
resetPassword({ email }) {
|
||||||
const urlData = endPoints('resetPassword');
|
const urlData = endPoints('resetPassword');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, { email })
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, { email })
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(error.response);
|
.catch(error => {
|
||||||
});
|
reject(error.response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,13 +6,14 @@ export default {
|
||||||
getSubscription() {
|
getSubscription() {
|
||||||
const urlData = endPoints('subscriptions').get();
|
const urlData = endPoints('subscriptions').get();
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(error);
|
.catch(error => {
|
||||||
});
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
import endPoints from './endPoints';
|
import endPoints from './endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
getAllCannedResponses() {
|
getAllCannedResponses() {
|
||||||
const urlData = endPoints('cannedResponse').get();
|
const urlData = endPoints('cannedResponse').get();
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -24,13 +24,14 @@ export default {
|
||||||
let urlData = endPoints('cannedResponse').get();
|
let urlData = endPoints('cannedResponse').get();
|
||||||
urlData = `${urlData.url}?search=${searchKey}`;
|
urlData = `${urlData.url}?search=${searchKey}`;
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData)
|
axios
|
||||||
.then((response) => {
|
.get(urlData)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -38,52 +39,56 @@ export default {
|
||||||
addCannedResponse(cannedResponseObj) {
|
addCannedResponse(cannedResponseObj) {
|
||||||
const urlData = endPoints('cannedResponse').post();
|
const urlData = endPoints('cannedResponse').post();
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, cannedResponseObj)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, cannedResponseObj)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
editCannedResponse(cannedResponseObj) {
|
editCannedResponse(cannedResponseObj) {
|
||||||
const urlData = endPoints('cannedResponse').put(cannedResponseObj.id);
|
const urlData = endPoints('cannedResponse').put(cannedResponseObj.id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.put(urlData.url, cannedResponseObj)
|
axios
|
||||||
.then((response) => {
|
.put(urlData.url, cannedResponseObj)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
deleteCannedResponse(responseId) {
|
deleteCannedResponse(responseId) {
|
||||||
const urlData = endPoints('cannedResponse').delete(responseId);
|
const urlData = endPoints('cannedResponse').delete(responseId);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.delete(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.delete(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
getLabels() {
|
getLabels() {
|
||||||
const urlData = endPoints('fetchLabels');
|
const urlData = endPoints('fetchLabels');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -91,15 +96,16 @@ export default {
|
||||||
getInboxes() {
|
getInboxes() {
|
||||||
const urlData = endPoints('fetchInboxes');
|
const urlData = endPoints('fetchInboxes');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
console.log('fetch inboxes success');
|
.then(response => {
|
||||||
resolve(response);
|
console.log('fetch inboxes success');
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
console.log('fetch inboxes failure');
|
.catch(error => {
|
||||||
reject(Error(error));
|
console.log('fetch inboxes failure');
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,13 +9,14 @@ export default {
|
||||||
createChannel(channel, channelParams) {
|
createChannel(channel, channelParams) {
|
||||||
const urlData = endPoints('createChannel')(channel, channelParams);
|
const urlData = endPoints('createChannel')(channel, channelParams);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -25,13 +26,14 @@ export default {
|
||||||
urlData.params.inbox_id = inboxId;
|
urlData.params.inbox_id = inboxId;
|
||||||
urlData.params.user_ids = agentsId;
|
urlData.params.user_ids = agentsId;
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -40,13 +42,14 @@ export default {
|
||||||
const urlData = endPoints('fetchFacebookPages');
|
const urlData = endPoints('fetchFacebookPages');
|
||||||
urlData.params.omniauth_token = token;
|
urlData.params.omniauth_token = token;
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,11 +32,17 @@ const endPoints = {
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMessage(conversationId, message) {
|
sendMessage(conversationId, message) {
|
||||||
return { url: `api/v1/conversations/${conversationId}/messages.json`, params: { message } };
|
return {
|
||||||
|
url: `api/v1/conversations/${conversationId}/messages.json`,
|
||||||
|
params: { message },
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
addPrivateNote(conversationId, message) {
|
addPrivateNote(conversationId, message) {
|
||||||
return { url: `api/v1/conversations/${conversationId}/messages.json?`, params: { message, private: 'true' } };
|
return {
|
||||||
|
url: `api/v1/conversations/${conversationId}/messages.json?`,
|
||||||
|
params: { message, private: 'true' },
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchLabels: {
|
fetchLabels: {
|
||||||
|
@ -64,7 +70,10 @@ const endPoints = {
|
||||||
},
|
},
|
||||||
|
|
||||||
createChannel(channel, channelParams) {
|
createChannel(channel, channelParams) {
|
||||||
return { url: `api/v1/callbacks/register_${channel}_page.json`, params: channelParams };
|
return {
|
||||||
|
url: `api/v1/callbacks/register_${channel}_page.json`,
|
||||||
|
params: channelParams,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
addAgentsToChannel: {
|
addAgentsToChannel: {
|
||||||
|
@ -78,7 +87,9 @@ const endPoints = {
|
||||||
},
|
},
|
||||||
|
|
||||||
assignAgent(conversationId, AgentId) {
|
assignAgent(conversationId, AgentId) {
|
||||||
return { url: `/api/v1/conversations/${conversationId}/assignments?assignee_id=${AgentId}` };
|
return {
|
||||||
|
url: `/api/v1/conversations/${conversationId}/assignments?assignee_id=${AgentId}`,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
fbMarkSeen: {
|
fbMarkSeen: {
|
||||||
|
@ -171,6 +182,6 @@ const endPoints = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (page) => {
|
export default page => {
|
||||||
return endPoints[page];
|
return endPoints[page];
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
import endPoints from '../endPoints';
|
import endPoints from '../endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
fetchConversation(id) {
|
fetchConversation(id) {
|
||||||
const urlData = endPoints('conversations')(id);
|
const urlData = endPoints('conversations')(id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -23,13 +23,14 @@ export default {
|
||||||
toggleStatus(id) {
|
toggleStatus(id) {
|
||||||
const urlData = endPoints('resolveConversation')(id);
|
const urlData = endPoints('resolveConversation')(id);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -37,13 +38,14 @@ export default {
|
||||||
assignAgent([id, agentId]) {
|
assignAgent([id, agentId]) {
|
||||||
const urlData = endPoints('assignAgent')(id, agentId);
|
const urlData = endPoints('assignAgent')(id, agentId);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -51,16 +53,17 @@ export default {
|
||||||
markSeen({ inboxId, senderId }) {
|
markSeen({ inboxId, senderId }) {
|
||||||
const urlData = endPoints('fbMarkSeen');
|
const urlData = endPoints('fbMarkSeen');
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, {
|
axios
|
||||||
inbox_id: inboxId,
|
.post(urlData.url, {
|
||||||
sender_id: senderId,
|
inbox_id: inboxId,
|
||||||
})
|
sender_id: senderId,
|
||||||
.then((response) => {
|
})
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -68,16 +71,17 @@ export default {
|
||||||
fbTyping({ flag, inboxId, senderId }) {
|
fbTyping({ flag, inboxId, senderId }) {
|
||||||
const urlData = endPoints('fbTyping')(flag);
|
const urlData = endPoints('fbTyping')(flag);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, {
|
axios
|
||||||
inbox_id: inboxId,
|
.post(urlData.url, {
|
||||||
sender_id: senderId,
|
inbox_id: inboxId,
|
||||||
})
|
sender_id: senderId,
|
||||||
.then((response) => {
|
})
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -86,13 +90,14 @@ export default {
|
||||||
const urlData = endPoints('markMessageRead')(id);
|
const urlData = endPoints('markMessageRead')(id);
|
||||||
urlData.params.agent_last_seen_at = lastSeen;
|
urlData.params.agent_last_seen_at = lastSeen;
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import endPoints from '../endPoints';
|
import endPoints from '../endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
fetchAllConversations(params, callback) {
|
fetchAllConversations(params, callback) {
|
||||||
const urlData = endPoints('getInbox');
|
const urlData = endPoints('getInbox');
|
||||||
|
|
||||||
|
@ -19,15 +18,15 @@ export default {
|
||||||
conversation_status_id: params.convStatus,
|
conversation_status_id: params.convStatus,
|
||||||
assignee_type_id: params.assigneeStatus,
|
assignee_type_id: params.assigneeStatus,
|
||||||
};
|
};
|
||||||
axios.get(urlData.url, {
|
axios
|
||||||
params: urlData.params,
|
.get(urlData.url, {
|
||||||
})
|
params: urlData.params,
|
||||||
.then((response) => {
|
})
|
||||||
callback(response);
|
.then(response => {
|
||||||
})
|
callback(response);
|
||||||
.catch((error) => {
|
})
|
||||||
console.log(error);
|
.catch(error => {
|
||||||
});
|
console.log(error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
import endPoints from '../endPoints';
|
import endPoints from '../endPoints';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
sendMessage([conversationId, message]) {
|
sendMessage([conversationId, message]) {
|
||||||
const urlData = endPoints('sendMessage')(conversationId, message);
|
const urlData = endPoints('sendMessage')(conversationId, message);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -23,13 +23,14 @@ export default {
|
||||||
addPrivateNote([conversationId, message]) {
|
addPrivateNote([conversationId, message]) {
|
||||||
const urlData = endPoints('addPrivateNote')(conversationId, message);
|
const urlData = endPoints('addPrivateNote')(conversationId, message);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.post(urlData.url, urlData.params)
|
axios
|
||||||
.then((response) => {
|
.post(urlData.url, urlData.params)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
@ -38,17 +39,17 @@ export default {
|
||||||
const urlData = endPoints('conversations')(id);
|
const urlData = endPoints('conversations')(id);
|
||||||
urlData.params.before = before;
|
urlData.params.before = before;
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url, {
|
axios
|
||||||
params: urlData.params,
|
.get(urlData.url, {
|
||||||
})
|
params: urlData.params,
|
||||||
.then((response) => {
|
})
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,26 +6,28 @@ export default {
|
||||||
getAccountReports(metric, from, to) {
|
getAccountReports(metric, from, to) {
|
||||||
const urlData = endPoints('reports').account(metric, from, to);
|
const urlData = endPoints('reports').account(metric, from, to);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
getAccountSummary(accountId, from, to) {
|
getAccountSummary(accountId, from, to) {
|
||||||
const urlData = endPoints('reports').accountSummary(accountId, from, to);
|
const urlData = endPoints('reports').accountSummary(accountId, from, to);
|
||||||
const fetchPromise = new Promise((resolve, reject) => {
|
const fetchPromise = new Promise((resolve, reject) => {
|
||||||
axios.get(urlData.url)
|
axios
|
||||||
.then((response) => {
|
.get(urlData.url)
|
||||||
resolve(response);
|
.then(response => {
|
||||||
})
|
resolve(response);
|
||||||
.catch((error) => {
|
})
|
||||||
reject(Error(error));
|
.catch(error => {
|
||||||
});
|
reject(Error(error));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,18 +9,24 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render(h) {
|
render(h) {
|
||||||
const Tabs = this.$slots.default.filter(node =>
|
const Tabs = this.$slots.default
|
||||||
node.componentOptions && node.componentOptions.tag === 'woot-tabs-item'
|
.filter(
|
||||||
).map((node, index) => {
|
node =>
|
||||||
const data = node.componentOptions.propsData;
|
node.componentOptions &&
|
||||||
data.index = index;
|
node.componentOptions.tag === 'woot-tabs-item'
|
||||||
return node;
|
)
|
||||||
});
|
.map((node, index) => {
|
||||||
|
const data = node.componentOptions.propsData;
|
||||||
|
data.index = index;
|
||||||
|
return node;
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<ul class={{
|
<ul
|
||||||
tabs: true,
|
class={{
|
||||||
}}>
|
tabs: true,
|
||||||
{ Tabs }
|
}}
|
||||||
|
>
|
||||||
|
{Tabs}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
count(newValue, oldValue) {
|
count(newValue, oldValue) {
|
||||||
let animationFrame;
|
let animationFrame;
|
||||||
const animate = (time) => {
|
const animate = time => {
|
||||||
TWEEN.update(time);
|
TWEEN.update(time);
|
||||||
animationFrame = window.requestAnimationFrame(animate);
|
animationFrame = window.requestAnimationFrame(animate);
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ export default {
|
||||||
new TWEEN.Tween({ tweeningNumber: oldValue })
|
new TWEEN.Tween({ tweeningNumber: oldValue })
|
||||||
.easing(TWEEN.Easing.Quadratic.Out)
|
.easing(TWEEN.Easing.Quadratic.Out)
|
||||||
.to({ tweeningNumber: newValue }, 500)
|
.to({ tweeningNumber: newValue }, 500)
|
||||||
.onUpdate(function () {
|
.onUpdate(function() {
|
||||||
that.animatedNumber = this.tweeningNumber.toFixed(0);
|
that.animatedNumber = this.tweeningNumber.toFixed(0);
|
||||||
})
|
})
|
||||||
.onComplete(() => {
|
.onComplete(() => {
|
||||||
|
@ -65,18 +65,22 @@ export default {
|
||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
return (
|
return (
|
||||||
<li class={{
|
<li
|
||||||
'tabs-title': true,
|
class={{
|
||||||
'is-active': this.active,
|
'tabs-title': true,
|
||||||
'uk-disabled': this.disabled,
|
'is-active': this.active,
|
||||||
}}>
|
'uk-disabled': this.disabled,
|
||||||
<a on-click={(event) => {
|
}}
|
||||||
event.preventDefault();
|
>
|
||||||
if (!this.disabled) {
|
<a
|
||||||
this.$parent.$emit('change', this.index);
|
on-click={event => {
|
||||||
}
|
event.preventDefault();
|
||||||
}}>
|
if (!this.disabled) {
|
||||||
{ `${this.name} (${this.getItemCount})` }
|
this.$parent.$emit('change', this.index);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`${this.name} (${this.getItemCount})`}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Bar } from 'vue-chartjs';
|
import { Bar } from 'vue-chartjs';
|
||||||
|
|
||||||
const fontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
const fontFamily =
|
||||||
|
'-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||||
|
|
||||||
export default Bar.extend({
|
export default Bar.extend({
|
||||||
props: ['collection'],
|
props: ['collection'],
|
||||||
|
|
|
@ -3,17 +3,14 @@ import constants from '../constants';
|
||||||
import Auth from '../api/auth';
|
import Auth from '../api/auth';
|
||||||
import router from '../routes';
|
import router from '../routes';
|
||||||
|
|
||||||
const parseErrorCode = (error) => {
|
const parseErrorCode = error => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
// If auth failed
|
// If auth failed
|
||||||
|
|
||||||
} else if (error.response.status === 500) {
|
} else if (error.response.status === 500) {
|
||||||
// If server failed
|
// If server failed
|
||||||
|
|
||||||
} else if (error.response.status === 422) {
|
} else if (error.response.status === 422) {
|
||||||
// If request params are errored
|
// If request params are errored
|
||||||
|
|
||||||
} else if (error.response.status === 901 || error.response.status === 902) {
|
} else if (error.response.status === 901 || error.response.status === 902) {
|
||||||
let name = 'billing_deactivated';
|
let name = 'billing_deactivated';
|
||||||
if (Auth.isAdmin()) {
|
if (Auth.isAdmin()) {
|
||||||
|
@ -26,13 +23,12 @@ const parseErrorCode = (error) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Something happened in setting up the request that triggered an Error
|
// Something happened in setting up the request that triggered an Error
|
||||||
|
|
||||||
}
|
}
|
||||||
// Do something with request error
|
// Do something with request error
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (axios) => {
|
export default axios => {
|
||||||
const wootApi = axios.create();
|
const wootApi = axios.create();
|
||||||
wootApi.defaults.baseURL = constants.apiURL;
|
wootApi.defaults.baseURL = constants.apiURL;
|
||||||
// Add Auth Headers to requests if logged in
|
// Add Auth Headers to requests if logged in
|
||||||
|
@ -40,6 +36,9 @@ export default (axios) => {
|
||||||
Object.assign(wootApi.defaults.headers.common, Auth.getAuthData());
|
Object.assign(wootApi.defaults.headers.common, Auth.getAuthData());
|
||||||
}
|
}
|
||||||
// Response parsing interceptor
|
// Response parsing interceptor
|
||||||
wootApi.interceptors.response.use(response => response, error => parseErrorCode(error));
|
wootApi.interceptors.response.use(
|
||||||
|
response => response,
|
||||||
|
error => parseErrorCode(error)
|
||||||
|
);
|
||||||
return wootApi;
|
return wootApi;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
/* global location */
|
|
||||||
import Pusher from 'pusher-js';
|
import Pusher from 'pusher-js';
|
||||||
import AuthAPI from '../api/auth';
|
import AuthAPI from '../api/auth';
|
||||||
import CONSTANTS from '../constants';
|
import CONSTANTS from '../constants';
|
||||||
|
@ -8,7 +7,6 @@ import CONSTANTS from '../constants';
|
||||||
const ding = require('../assets/audio/ding.mp3');
|
const ding = require('../assets/audio/ding.mp3');
|
||||||
|
|
||||||
class VuePusher {
|
class VuePusher {
|
||||||
|
|
||||||
constructor(apiKey, options) {
|
constructor(apiKey, options) {
|
||||||
this.app = options.app;
|
this.app = options.app;
|
||||||
this.pusher = new Pusher(apiKey, options);
|
this.pusher = new Pusher(apiKey, options);
|
||||||
|
@ -28,7 +26,7 @@ class VuePusher {
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvent(channel) {
|
bindEvent(channel) {
|
||||||
channel.bind('message.created', (data) => {
|
channel.bind('message.created', data => {
|
||||||
// Play sound if incoming
|
// Play sound if incoming
|
||||||
if (!data.message_type) {
|
if (!data.message_type) {
|
||||||
new Audio(ding).play();
|
new Audio(ding).play();
|
||||||
|
@ -36,15 +34,15 @@ class VuePusher {
|
||||||
this.app.$store.dispatch('addMessage', data);
|
this.app.$store.dispatch('addMessage', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('conversation.created', (data) => {
|
channel.bind('conversation.created', data => {
|
||||||
this.app.$store.dispatch('addConversation', data);
|
this.app.$store.dispatch('addConversation', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('status_change:conversation', (data) => {
|
channel.bind('status_change:conversation', data => {
|
||||||
this.app.$store.dispatch('addConversation', data);
|
this.app.$store.dispatch('addConversation', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('assignee.changed', (payload) => {
|
channel.bind('assignee.changed', payload => {
|
||||||
if (!payload.meta) return;
|
if (!payload.meta) return;
|
||||||
const { assignee } = payload.meta;
|
const { assignee } = payload.meta;
|
||||||
const { id } = payload;
|
const { id } = payload;
|
||||||
|
@ -61,19 +59,22 @@ class VuePusher {
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('page:reload', () => {
|
channel.bind('page:reload', () => {
|
||||||
location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint no-param-reassign: ["error", { "props": false }]*/
|
/* eslint no-param-reassign: ["error", { "props": false }] */
|
||||||
export default {
|
export default {
|
||||||
init() {
|
init() {
|
||||||
// Log only if env is testing or development.
|
// Log only if env is testing or development.
|
||||||
Pusher.logToConsole = CONSTANTS.PUSHER.logToConsole;
|
Pusher.logToConsole = CONSTANTS.PUSHER.logToConsole;
|
||||||
// Init Pusher
|
// Init Pusher
|
||||||
const options = { encrypted: true, app: window.WOOT, cluster: CONSTANTS.PUSHER.cluster };
|
const options = {
|
||||||
|
encrypted: true,
|
||||||
|
app: window.WOOT,
|
||||||
|
cluster: CONSTANTS.PUSHER.cluster,
|
||||||
|
};
|
||||||
const pusher = new VuePusher(CONSTANTS.PUSHER.token, options);
|
const pusher = new VuePusher(CONSTANTS.PUSHER.token, options);
|
||||||
// Add to global Obj
|
// Add to global Obj
|
||||||
if (AuthAPI.isLoggedIn()) {
|
if (AuthAPI.isLoggedIn()) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
/* eslint no-param-reassign: 0 */
|
/* eslint no-param-reassign: 0 */
|
||||||
export default (Vuex) => {
|
export default Vuex => {
|
||||||
const wootState = new Vuex.Store({
|
const wootState = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import en from './locale/en/';
|
import en from './locale/en';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...en,
|
...en,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable */
|
||||||
import { default as _agentMgmt } from './agentMgmt.json';
|
import { default as _agentMgmt } from './agentMgmt.json';
|
||||||
import { default as _billing } from './billing.json';
|
import { default as _billing } from './billing.json';
|
||||||
import { default as _cannedMgmt } from './cannedMgmt.json';
|
import { default as _cannedMgmt } from './cannedMgmt.json';
|
||||||
|
|
|
@ -1,31 +1,28 @@
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
/* global axios */
|
|
||||||
/* global moment */
|
|
||||||
/* eslint no-undef: "error" */
|
/* eslint no-undef: "error" */
|
||||||
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
lastMessage(m) {
|
lastMessage(m) {
|
||||||
return m.messages.last();
|
return m.messages.last();
|
||||||
},
|
},
|
||||||
unreadMessagesCount(m) {
|
unreadMessagesCount(m) {
|
||||||
return m.messages.filter(chat =>
|
return m.messages.filter(
|
||||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
chat =>
|
||||||
(chat.message_type === 0 && chat.private !== true)
|
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
||||||
|
(chat.message_type === 0 && chat.private !== true)
|
||||||
).length;
|
).length;
|
||||||
},
|
},
|
||||||
readMessages(m) {
|
readMessages(m) {
|
||||||
return m.messages.filter(chat =>
|
return m.messages.filter(
|
||||||
chat.created_at * 1000 <= m.agent_last_seen_at * 1000
|
chat => chat.created_at * 1000 <= m.agent_last_seen_at * 1000
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
unReadMessages(m) {
|
unReadMessages(m) {
|
||||||
return m.messages.filter(chat =>
|
return m.messages.filter(
|
||||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000
|
chat => chat.created_at * 1000 > m.agent_last_seen_at * 1000
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
/* global axios */
|
|
||||||
/* eslint no-undef: "error" */
|
/* eslint no-undef: "error" */
|
||||||
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
messageStamp(time) {
|
messageStamp(time) {
|
||||||
const createdAt = time * 1000;
|
const createdAt = time * 1000;
|
||||||
|
@ -25,5 +23,4 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default {
|
||||||
name: 'inbox_dashboard',
|
name: 'inbox_dashboard',
|
||||||
roles: ['administrator', 'agent'],
|
roles: ['administrator', 'agent'],
|
||||||
component: ConversationView,
|
component: ConversationView,
|
||||||
props: (route) => {
|
props: route => {
|
||||||
return { inboxId: route.params.inbox_id };
|
return { inboxId: route.params.inbox_id };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ export default {
|
||||||
name: 'inbox_conversation',
|
name: 'inbox_conversation',
|
||||||
roles: ['administrator', 'agent'],
|
roles: ['administrator', 'agent'],
|
||||||
component: ConversationView,
|
component: ConversationView,
|
||||||
props: (route) => {
|
props: route => {
|
||||||
return { conversationId: route.params.conversation_id };
|
return { conversationId: route.params.conversation_id };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,10 +7,7 @@ export default {
|
||||||
{
|
{
|
||||||
path: '/u/',
|
path: '/u/',
|
||||||
component: AppContainer,
|
component: AppContainer,
|
||||||
children: [
|
children: [...conversation.routes, ...settings.routes],
|
||||||
...conversation.routes,
|
|
||||||
...settings.routes,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,9 +16,7 @@ export default {
|
||||||
headerTitle: 'INBOX_MGMT.HEADER',
|
headerTitle: 'INBOX_MGMT.HEADER',
|
||||||
headerButtonText: 'SETTINGS.INBOXES.NEW_INBOX',
|
headerButtonText: 'SETTINGS.INBOXES.NEW_INBOX',
|
||||||
icon: 'ion-archive',
|
icon: 'ion-archive',
|
||||||
newButtonRoutes: [
|
newButtonRoutes: ['settings_inbox_list'],
|
||||||
'settings_inbox_list',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -53,7 +51,7 @@ export default {
|
||||||
name: 'settings_inboxes_page_channel',
|
name: 'settings_inboxes_page_channel',
|
||||||
component: channelFactory.create(),
|
component: channelFactory.create(),
|
||||||
roles: ['administrator'],
|
roles: ['administrator'],
|
||||||
props: (route) => {
|
props: route => {
|
||||||
return { channel_name: route.params.sub_page };
|
return { channel_name: route.params.sub_page };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,13 +23,13 @@ window.roleWiseRoutes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// generateRoleWiseRoute - updates window object with agent/admin route
|
// generateRoleWiseRoute - updates window object with agent/admin route
|
||||||
const generateRoleWiseRoute = (route) => {
|
const generateRoleWiseRoute = route => {
|
||||||
route.forEach((element) => {
|
route.forEach(element => {
|
||||||
if (element.children) {
|
if (element.children) {
|
||||||
generateRoleWiseRoute(element.children);
|
generateRoleWiseRoute(element.children);
|
||||||
}
|
}
|
||||||
if (element.roles) {
|
if (element.roles) {
|
||||||
element.roles.forEach((roleEl) => {
|
element.roles.forEach(roleEl => {
|
||||||
window.roleWiseRoutes[roleEl].push(element.name);
|
window.roleWiseRoutes[roleEl].push(element.name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,7 @@ const router = new VueRouter({
|
||||||
routes, // short for routes: routes
|
routes, // short for routes: routes
|
||||||
});
|
});
|
||||||
|
|
||||||
const unProtectedRoutes = [
|
const unProtectedRoutes = ['login', 'auth_signup', 'auth_reset_password'];
|
||||||
'login',
|
|
||||||
'auth_signup',
|
|
||||||
'auth_reset_password',
|
|
||||||
];
|
|
||||||
|
|
||||||
const authIgnoreRoutes = [
|
const authIgnoreRoutes = [
|
||||||
'auth_confirmation',
|
'auth_confirmation',
|
||||||
|
@ -57,7 +53,6 @@ const authIgnoreRoutes = [
|
||||||
'auth_password_edit',
|
'auth_password_edit',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
const redirectUser = (to, from, next) => {
|
const redirectUser = (to, from, next) => {
|
||||||
// If auth ignore go to page
|
// If auth ignore go to page
|
||||||
if (authIgnoreRoutes.indexOf(to.name) > -1) {
|
if (authIgnoreRoutes.indexOf(to.name) > -1) {
|
||||||
|
@ -68,7 +63,8 @@ const redirectUser = (to, from, next) => {
|
||||||
const currentUser = auth.getCurrentUser();
|
const currentUser = auth.getCurrentUser();
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
// Check if next route is accessible by given role
|
// Check if next route is accessible by given role
|
||||||
const isAccessible = window.roleWiseRoutes[currentUser.role].indexOf(to.name) > -1;
|
const isAccessible =
|
||||||
|
window.roleWiseRoutes[currentUser.role].indexOf(to.name) > -1;
|
||||||
if (!isAccessible) {
|
if (!isAccessible) {
|
||||||
return next('/u/dashboard');
|
return next('/u/dashboard');
|
||||||
}
|
}
|
||||||
|
@ -76,7 +72,8 @@ const redirectUser = (to, from, next) => {
|
||||||
// If unprotected and loggedIn -> redirect
|
// If unprotected and loggedIn -> redirect
|
||||||
if (unProtectedRoutes.indexOf(to.name) !== -1 && isLoggedIn) {
|
if (unProtectedRoutes.indexOf(to.name) !== -1 && isLoggedIn) {
|
||||||
return next('/u/dashboard');
|
return next('/u/dashboard');
|
||||||
} else if (unProtectedRoutes.indexOf(to.name) === -1 && !isLoggedIn) {
|
}
|
||||||
|
if (unProtectedRoutes.indexOf(to.name) === -1 && !isLoggedIn) {
|
||||||
return next('/u/login');
|
return next('/u/login');
|
||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import Login from './Login';
|
import Login from './Login';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
routes: [{
|
routes: [
|
||||||
path: '/u/login', name: 'login', component: Login,
|
{
|
||||||
}],
|
path: '/u/login',
|
||||||
|
name: 'login',
|
||||||
|
component: Login,
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,44 +24,51 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
fetchAgents({ commit }) {
|
fetchAgents({ commit }) {
|
||||||
commit(types.default.SET_AGENT_FETCHING_STATUS, true);
|
commit(types.default.SET_AGENT_FETCHING_STATUS, true);
|
||||||
Account.getAgents().then((response) => {
|
Account.getAgents()
|
||||||
commit(types.default.SET_AGENT_FETCHING_STATUS, false);
|
.then(response => {
|
||||||
commit(types.default.SET_AGENTS, response);
|
commit(types.default.SET_AGENT_FETCHING_STATUS, false);
|
||||||
}).catch();
|
commit(types.default.SET_AGENTS, response);
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
},
|
},
|
||||||
addAgent({ commit }, agentInfo) {
|
addAgent({ commit }, agentInfo) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.addAgent(agentInfo).then((response) => {
|
Account.addAgent(agentInfo)
|
||||||
commit(types.default.ADD_AGENT, response);
|
.then(response => {
|
||||||
resolve();
|
commit(types.default.ADD_AGENT, response);
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editAgent({ commit }, agentInfo) {
|
editAgent({ commit }, agentInfo) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.editAgent(agentInfo).then((response) => {
|
Account.editAgent(agentInfo)
|
||||||
commit(types.default.EDIT_AGENT, response, agentInfo.id);
|
.then(response => {
|
||||||
resolve();
|
commit(types.default.EDIT_AGENT, response, agentInfo.id);
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteAgent({ commit }, agentId) {
|
deleteAgent({ commit }, agentId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.deleteAgent(agentId).then((response) => {
|
Account.deleteAgent(agentId)
|
||||||
if (response.status === 200) {
|
.then(response => {
|
||||||
commit(types.default.DELETE_AGENT, agentId);
|
if (response.status === 200) {
|
||||||
}
|
commit(types.default.DELETE_AGENT, agentId);
|
||||||
resolve();
|
}
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
|
|
@ -37,12 +37,16 @@ const getters = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubscription(_state) {
|
getSubscription(_state) {
|
||||||
return _state.currentUser.subscription === undefined ? null : _state.currentUser.subscription;
|
return _state.currentUser.subscription === undefined
|
||||||
|
? null
|
||||||
|
: _state.currentUser.subscription;
|
||||||
},
|
},
|
||||||
|
|
||||||
getTrialLeft(_state) {
|
getTrialLeft(_state) {
|
||||||
const createdAt = _state.currentUser.subscription === undefined ?
|
const createdAt =
|
||||||
moment() : _state.currentUser.subscription.expiry * 1000;
|
_state.currentUser.subscription === undefined
|
||||||
|
? moment()
|
||||||
|
: _state.currentUser.subscription.expiry * 1000;
|
||||||
const daysLeft = moment(createdAt).diff(moment(), 'days');
|
const daysLeft = moment(createdAt).diff(moment(), 'days');
|
||||||
return daysLeft < 0 ? 0 : daysLeft;
|
return daysLeft < 0 ? 0 : daysLeft;
|
||||||
},
|
},
|
||||||
|
@ -52,17 +56,18 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
login({ commit }, credentials) {
|
login({ commit }, credentials) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
authAPI.login(credentials)
|
authAPI
|
||||||
.then(() => {
|
.login(credentials)
|
||||||
commit(types.default.SET_CURRENT_USER);
|
.then(() => {
|
||||||
window.axios = createAxios(axios);
|
commit(types.default.SET_CURRENT_USER);
|
||||||
window.pusher = vuePusher.init(Vue);
|
window.axios = createAxios(axios);
|
||||||
router.replace({ name: 'home' });
|
window.pusher = vuePusher.init(Vue);
|
||||||
resolve();
|
router.replace({ name: 'home' });
|
||||||
})
|
resolve();
|
||||||
.catch((error) => {
|
})
|
||||||
reject(error);
|
.catch(error => {
|
||||||
});
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
validityCheck(context) {
|
validityCheck(context) {
|
||||||
|
|
|
@ -23,13 +23,21 @@ const actions = {
|
||||||
fetchSubscription({ commit }) {
|
fetchSubscription({ commit }) {
|
||||||
commit(types.default.TOGGLE_SUBSCRIPTION_LOADING, true);
|
commit(types.default.TOGGLE_SUBSCRIPTION_LOADING, true);
|
||||||
Billing.getSubscription()
|
Billing.getSubscription()
|
||||||
.then((billingDetails) => {
|
.then(billingDetails => {
|
||||||
commit(types.default.SET_SUBSCRIPTION, billingDetails.data);
|
commit(types.default.SET_SUBSCRIPTION, billingDetails.data);
|
||||||
commit(types.default.TOGGLE_SUBSCRIPTION_LOADING, false, billingDetails.status);
|
commit(
|
||||||
|
types.default.TOGGLE_SUBSCRIPTION_LOADING,
|
||||||
|
false,
|
||||||
|
billingDetails.status
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
const { response } = error;
|
const { response } = error;
|
||||||
commit(types.default.TOGGLE_SUBSCRIPTION_LOADING, false, response.status);
|
commit(
|
||||||
|
types.default.TOGGLE_SUBSCRIPTION_LOADING,
|
||||||
|
false,
|
||||||
|
response.status
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,51 +21,60 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
fetchCannedResponse({ commit }) {
|
fetchCannedResponse({ commit }) {
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, true);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, true);
|
||||||
CannedApi.getAllCannedResponses().then((response) => {
|
CannedApi.getAllCannedResponses()
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
.then(response => {
|
||||||
commit(types.default.SET_CANNED, response);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
||||||
}).catch();
|
commit(types.default.SET_CANNED, response);
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
},
|
},
|
||||||
searchCannedResponse({ commit }, { searchKey }) {
|
searchCannedResponse({ commit }, { searchKey }) {
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, true);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, true);
|
||||||
CannedApi.searchCannedResponse({ searchKey }).then((response) => {
|
CannedApi.searchCannedResponse({ searchKey })
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
.then(response => {
|
||||||
commit(types.default.SET_CANNED, response);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
||||||
}).catch();
|
commit(types.default.SET_CANNED, response);
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
},
|
},
|
||||||
addCannedResponse({ commit }, cannedObj) {
|
addCannedResponse({ commit }, cannedObj) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
CannedApi.addCannedResponse(cannedObj).then((response) => {
|
CannedApi.addCannedResponse(cannedObj)
|
||||||
commit(types.default.ADD_CANNED, response);
|
.then(response => {
|
||||||
resolve();
|
commit(types.default.ADD_CANNED, response);
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editCannedResponse({ commit }, cannedObj) {
|
editCannedResponse({ commit }, cannedObj) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
CannedApi.editCannedResponse(cannedObj).then((response) => {
|
CannedApi.editCannedResponse(cannedObj)
|
||||||
commit(types.default.EDIT_CANNED, response, cannedObj.id);
|
.then(response => {
|
||||||
resolve();
|
commit(types.default.EDIT_CANNED, response, cannedObj.id);
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteCannedResponse({ commit }, responseId) {
|
deleteCannedResponse({ commit }, responseId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
CannedApi.deleteCannedResponse(responseId.id).then((response) => {
|
CannedApi.deleteCannedResponse(responseId.id)
|
||||||
if (response.status === 200) {
|
.then(response => {
|
||||||
commit(types.default.DELETE_CANNED, responseId);
|
if (response.status === 200) {
|
||||||
}
|
commit(types.default.DELETE_CANNED, responseId);
|
||||||
resolve();
|
}
|
||||||
}).catch((response) => {
|
resolve();
|
||||||
reject(response);
|
})
|
||||||
});
|
.catch(response => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
@ -96,7 +105,9 @@ const mutations = {
|
||||||
|
|
||||||
// Delete CannedResponse
|
// Delete CannedResponse
|
||||||
[types.default.DELETE_CANNED](_state, { id }) {
|
[types.default.DELETE_CANNED](_state, { id }) {
|
||||||
_state.cannedResponse = _state.cannedResponse.filter(agent => agent.id !== id);
|
_state.cannedResponse = _state.cannedResponse.filter(
|
||||||
|
agent => agent.id !== id
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,10 @@
|
||||||
|
|
||||||
// const chatType = 'all';
|
// const chatType = 'all';
|
||||||
// initial state
|
// initial state
|
||||||
const state = {
|
const state = {};
|
||||||
};
|
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
state,
|
state,
|
||||||
|
|
|
@ -41,32 +41,42 @@ const getters = {
|
||||||
getMineChats(_state) {
|
getMineChats(_state) {
|
||||||
const currentUserID = authAPI.getCurrentUser().id;
|
const currentUserID = authAPI.getCurrentUser().id;
|
||||||
return _state.allConversations.filter(chat =>
|
return _state.allConversations.filter(chat =>
|
||||||
(chat.meta.assignee === null ?
|
chat.meta.assignee === null
|
||||||
false : chat.status === _state.chatStatusFilter && chat.meta.assignee.id === currentUserID)
|
? false
|
||||||
|
: chat.status === _state.chatStatusFilter &&
|
||||||
|
chat.meta.assignee.id === currentUserID
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getUnAssignedChats(_state) {
|
getUnAssignedChats(_state) {
|
||||||
return _state.allConversations.filter(chat =>
|
return _state.allConversations.filter(
|
||||||
chat.meta.assignee === null && chat.status === _state.chatStatusFilter
|
chat =>
|
||||||
|
chat.meta.assignee === null && chat.status === _state.chatStatusFilter
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getAllStatusChats(_state) {
|
getAllStatusChats(_state) {
|
||||||
return _state.allConversations.filter(chat =>
|
return _state.allConversations.filter(
|
||||||
chat.status === _state.chatStatusFilter
|
chat => chat.status === _state.chatStatusFilter
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getChatListLoadingStatus(_state) {
|
getChatListLoadingStatus(_state) {
|
||||||
return _state.listLoadingStatus;
|
return _state.listLoadingStatus;
|
||||||
},
|
},
|
||||||
getAllMessagesLoaded(_state) {
|
getAllMessagesLoaded(_state) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
return chat.allMessagesLoaded === undefined ? false : chat.allMessagesLoaded;
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
|
return chat.allMessagesLoaded === undefined
|
||||||
|
? false
|
||||||
|
: chat.allMessagesLoaded;
|
||||||
},
|
},
|
||||||
getUnreadCount(_state) {
|
getUnreadCount(_state) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
return chat.messages.filter(chatMessage =>
|
c => c.id === _state.selectedChat.id
|
||||||
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
);
|
||||||
(chatMessage.message_type === 0 && chatMessage.private !== true)
|
return chat.messages.filter(
|
||||||
|
chatMessage =>
|
||||||
|
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
||||||
|
(chatMessage.message_type === 0 && chatMessage.private !== true)
|
||||||
).length;
|
).length;
|
||||||
},
|
},
|
||||||
getChatStatusFilter(_state) {
|
getChatStatusFilter(_state) {
|
||||||
|
@ -79,12 +89,15 @@ const getters = {
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {
|
||||||
|
|
||||||
fetchAllConversations({ commit }, fetchParams) {
|
fetchAllConversations({ commit }, fetchParams) {
|
||||||
commit(types.default.SET_LIST_LOADING_STATUS);
|
commit(types.default.SET_LIST_LOADING_STATUS);
|
||||||
ChatList.fetchAllConversations(fetchParams, (response) => {
|
ChatList.fetchAllConversations(fetchParams, response => {
|
||||||
commit(types.default.SET_ALL_CONVERSATION, { chats: response.data.data.payload });
|
commit(types.default.SET_ALL_CONVERSATION, {
|
||||||
commit(types.default.SET_CONV_TAB_META, { meta: response.data.data.meta });
|
chats: response.data.data.payload,
|
||||||
|
});
|
||||||
|
commit(types.default.SET_CONV_TAB_META, {
|
||||||
|
meta: response.data.data.meta,
|
||||||
|
});
|
||||||
commit(types.default.CLEAR_LIST_LOADING_STATUS);
|
commit(types.default.CLEAR_LIST_LOADING_STATUS);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -98,25 +111,28 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchPreviousMessages({ commit }, data) {
|
fetchPreviousMessages({ commit }, data) {
|
||||||
const donePromise = new Promise((resolve) => {
|
const donePromise = new Promise(resolve => {
|
||||||
messageApi.fetchPreviousMessages(data).then((response) => {
|
messageApi
|
||||||
commit(types.default.SET_PREVIOUS_CONVERSATIONS, {
|
.fetchPreviousMessages(data)
|
||||||
id: data.id,
|
.then(response => {
|
||||||
data: response.data.payload,
|
commit(types.default.SET_PREVIOUS_CONVERSATIONS, {
|
||||||
|
id: data.id,
|
||||||
|
data: response.data.payload,
|
||||||
|
});
|
||||||
|
if (response.data.payload.length < 20) {
|
||||||
|
commit(types.default.SET_ALL_MESSAGES_LOADED);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
});
|
});
|
||||||
if (response.data.payload.length < 20) {
|
|
||||||
commit(types.default.SET_ALL_MESSAGES_LOADED);
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
}).catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return donePromise;
|
return donePromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
setActiveChat(store, data) {
|
setActiveChat(store, data) {
|
||||||
const commit = store.commit;
|
const { commit } = store;
|
||||||
const localDispatch = store.dispatch;
|
const localDispatch = store.dispatch;
|
||||||
let donePromise = null;
|
let donePromise = null;
|
||||||
|
|
||||||
|
@ -124,19 +140,21 @@ const actions = {
|
||||||
commit(types.default.CLEAR_ALL_MESSAGES_LOADED);
|
commit(types.default.CLEAR_ALL_MESSAGES_LOADED);
|
||||||
|
|
||||||
if (data.dataFetched === undefined) {
|
if (data.dataFetched === undefined) {
|
||||||
donePromise = new Promise((resolve) => {
|
donePromise = new Promise(resolve => {
|
||||||
localDispatch('fetchPreviousMessages', {
|
localDispatch('fetchPreviousMessages', {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
before: data.messages[0].id,
|
before: data.messages[0].id,
|
||||||
}).then(() => {
|
})
|
||||||
Vue.set(data, 'dataFetched', true);
|
.then(() => {
|
||||||
resolve();
|
Vue.set(data, 'dataFetched', true);
|
||||||
}).catch((error) => {
|
resolve();
|
||||||
console.log(error);
|
})
|
||||||
});
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
donePromise = new Promise((resolve) => {
|
donePromise = new Promise(resolve => {
|
||||||
commit(types.default.SET_CHAT_META, { id: data.id });
|
commit(types.default.SET_CHAT_META, { id: data.id });
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -145,8 +163,8 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
assignAgent({ commit }, data) {
|
assignAgent({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.assignAgent(data).then((response) => {
|
ConversationApi.assignAgent(data).then(response => {
|
||||||
commit(types.default.ASSIGN_AGENT, response.data);
|
commit(types.default.ASSIGN_AGENT, response.data);
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
});
|
});
|
||||||
|
@ -154,9 +172,12 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleStatus({ commit }, data) {
|
toggleStatus({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.toggleStatus(data).then((response) => {
|
ConversationApi.toggleStatus(data).then(response => {
|
||||||
commit(types.default.RESOLVE_CONVERSATION, response.data.payload.current_status);
|
commit(
|
||||||
|
types.default.RESOLVE_CONVERSATION,
|
||||||
|
response.data.payload.current_status
|
||||||
|
);
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -167,20 +188,26 @@ const actions = {
|
||||||
// },
|
// },
|
||||||
|
|
||||||
sendMessage({ commit }, data) {
|
sendMessage({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
messageApi.sendMessage(data).then((response) => {
|
messageApi
|
||||||
commit(types.default.SEND_MESSAGE, response);
|
.sendMessage(data)
|
||||||
resolve();
|
.then(response => {
|
||||||
}).catch();
|
commit(types.default.SEND_MESSAGE, response);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
addPrivateNote({ commit }, data) {
|
addPrivateNote({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
messageApi.addPrivateNote(data).then((response) => {
|
messageApi
|
||||||
commit(types.default.SEND_MESSAGE, response);
|
.addPrivateNote(data)
|
||||||
resolve();
|
.then(response => {
|
||||||
}).catch();
|
commit(types.default.SEND_MESSAGE, response);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -192,22 +219,25 @@ const actions = {
|
||||||
commit(types.default.ADD_CONVERSATION, conversation);
|
commit(types.default.ADD_CONVERSATION, conversation);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
toggleTyping({ commit }, data) {
|
toggleTyping({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.fbTyping(data).then(() => {
|
ConversationApi.fbTyping(data)
|
||||||
commit(types.default.FB_TYPING, data);
|
.then(() => {
|
||||||
resolve();
|
commit(types.default.FB_TYPING, data);
|
||||||
}).catch();
|
resolve();
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
markSeen({ commit }, data) {
|
markSeen({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.markSeen(data).then((response) => {
|
ConversationApi.markSeen(data)
|
||||||
commit(types.default.MARK_SEEN, response);
|
.then(response => {
|
||||||
resolve();
|
commit(types.default.MARK_SEEN, response);
|
||||||
}).catch();
|
resolve();
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -215,10 +245,12 @@ const actions = {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
commit(types.default.MARK_MESSAGE_READ, data);
|
commit(types.default.MARK_MESSAGE_READ, data);
|
||||||
}, 4000);
|
}, 4000);
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.markMessageRead(data).then(() => {
|
ConversationApi.markMessageRead(data)
|
||||||
resolve();
|
.then(() => {
|
||||||
}).catch();
|
resolve();
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -237,8 +269,6 @@ const actions = {
|
||||||
|
|
||||||
// mutations
|
// mutations
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
|
||||||
|
|
||||||
[types.default.SET_ALL_CONVERSATION](_state, data) {
|
[types.default.SET_ALL_CONVERSATION](_state, data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
_state.allConversations.push(...data.chats);
|
_state.allConversations.push(...data.chats);
|
||||||
|
@ -258,12 +288,16 @@ const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.SET_ALL_MESSAGES_LOADED](_state) {
|
[types.default.SET_ALL_MESSAGES_LOADED](_state) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
Vue.set(chat, 'allMessagesLoaded', true);
|
Vue.set(chat, 'allMessagesLoaded', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.CLEAR_ALL_MESSAGES_LOADED](_state) {
|
[types.default.CLEAR_ALL_MESSAGES_LOADED](_state) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
Vue.set(chat, 'allMessagesLoaded', false);
|
Vue.set(chat, 'allMessagesLoaded', false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -311,7 +345,9 @@ const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.ASSIGN_AGENT](_state, assignee) {
|
[types.default.ASSIGN_AGENT](_state, assignee) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
chat.meta.assignee = assignee;
|
chat.meta.assignee = assignee;
|
||||||
if (assignee === null) {
|
if (assignee === null) {
|
||||||
Object.assign(_state.selectedChat.meta.assignee, assignee);
|
Object.assign(_state.selectedChat.meta.assignee, assignee);
|
||||||
|
@ -319,13 +355,17 @@ const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.RESOLVE_CONVERSATION](_state, status) {
|
[types.default.RESOLVE_CONVERSATION](_state, status) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
chat.status = status;
|
chat.status = status;
|
||||||
_state.selectedChat.status = status;
|
_state.selectedChat.status = status;
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.SEND_MESSAGE](_state, response) {
|
[types.default.SEND_MESSAGE](_state, response) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === _state.selectedChat.id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === _state.selectedChat.id
|
||||||
|
);
|
||||||
const previousMessageIds = chat.messages.map(m => m.id);
|
const previousMessageIds = chat.messages.map(m => m.id);
|
||||||
if (!previousMessageIds.includes(response.data.id)) {
|
if (!previousMessageIds.includes(response.data.id)) {
|
||||||
chat.messages.push(response.data);
|
chat.messages.push(response.data);
|
||||||
|
@ -333,7 +373,9 @@ const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.ADD_MESSAGE](_state, message) {
|
[types.default.ADD_MESSAGE](_state, message) {
|
||||||
const [chat] = _state.allConversations.filter(c => c.id === message.conversation_id);
|
const [chat] = _state.allConversations.filter(
|
||||||
|
c => c.id === message.conversation_id
|
||||||
|
);
|
||||||
if (!chat) return;
|
if (!chat) return;
|
||||||
const previousMessageIds = chat.messages.map(m => m.id);
|
const previousMessageIds = chat.messages.map(m => m.id);
|
||||||
if (!previousMessageIds.includes(message.id)) {
|
if (!previousMessageIds.includes(message.id)) {
|
||||||
|
|
|
@ -35,24 +35,30 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
fetchAccountReport({ commit }, reportObj) {
|
fetchAccountReport({ commit }, reportObj) {
|
||||||
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, true);
|
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, true);
|
||||||
Report.getAccountReports(reportObj.metric, reportObj.from, reportObj.to)
|
Report.getAccountReports(
|
||||||
.then((accountReport) => {
|
reportObj.metric,
|
||||||
let { data } = accountReport;
|
reportObj.from,
|
||||||
data = data.filter(el => moment() > moment.unix(el.timestamp));
|
reportObj.to
|
||||||
if (reportObj.metric === 'avg_first_response_time' || reportObj.metric === 'avg_resolution_time') {
|
).then(accountReport => {
|
||||||
data = data.map((element) => {
|
let { data } = accountReport;
|
||||||
/* eslint-disable operator-assignment*/
|
data = data.filter(el => moment() > moment.unix(el.timestamp));
|
||||||
element.value = (element.value / 3600).toFixed(2);
|
if (
|
||||||
return element;
|
reportObj.metric === 'avg_first_response_time' ||
|
||||||
});
|
reportObj.metric === 'avg_resolution_time'
|
||||||
}
|
) {
|
||||||
commit(types.default.SET_ACCOUNT_REPORTS, data);
|
data = data.map(element => {
|
||||||
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, false);
|
/* eslint-disable operator-assignment */
|
||||||
});
|
element.value = (element.value / 3600).toFixed(2);
|
||||||
|
return element;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
commit(types.default.SET_ACCOUNT_REPORTS, data);
|
||||||
|
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, false);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fetchAccountSummary({ commit }, reportObj) {
|
fetchAccountSummary({ commit }, reportObj) {
|
||||||
Report.getAccountSummary(1, reportObj.from, reportObj.to)
|
Report.getAccountSummary(1, reportObj.from, reportObj.to)
|
||||||
.then((accountSummary) => {
|
.then(accountSummary => {
|
||||||
commit(types.default.SET_ACCOUNT_SUMMARY, accountSummary.data);
|
commit(types.default.SET_ACCOUNT_SUMMARY, accountSummary.data);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
@ -73,13 +79,17 @@ const mutations = {
|
||||||
// Average First Response Time
|
// Average First Response Time
|
||||||
let avgFirstResTimeInHr = 0;
|
let avgFirstResTimeInHr = 0;
|
||||||
if (summaryData.avg_first_response_time) {
|
if (summaryData.avg_first_response_time) {
|
||||||
avgFirstResTimeInHr = (summaryData.avg_first_response_time / 3600).toFixed(2);
|
avgFirstResTimeInHr = (
|
||||||
|
summaryData.avg_first_response_time / 3600
|
||||||
|
).toFixed(2);
|
||||||
avgFirstResTimeInHr = `${avgFirstResTimeInHr} Hr`;
|
avgFirstResTimeInHr = `${avgFirstResTimeInHr} Hr`;
|
||||||
}
|
}
|
||||||
// Average Resolution Time
|
// Average Resolution Time
|
||||||
let avgResolutionTimeInHr = 0;
|
let avgResolutionTimeInHr = 0;
|
||||||
if (summaryData.avg_resolution_time) {
|
if (summaryData.avg_resolution_time) {
|
||||||
avgResolutionTimeInHr = (summaryData.avg_resolution_time / 3600).toFixed(2);
|
avgResolutionTimeInHr = (summaryData.avg_resolution_time / 3600).toFixed(
|
||||||
|
2
|
||||||
|
);
|
||||||
avgResolutionTimeInHr = `${avgResolutionTimeInHr} Hr`;
|
avgResolutionTimeInHr = `${avgResolutionTimeInHr} Hr`;
|
||||||
}
|
}
|
||||||
_state.accountSummary.avg_first_response_time = avgFirstResTimeInHr;
|
_state.accountSummary.avg_first_response_time = avgFirstResTimeInHr;
|
||||||
|
|
|
@ -27,28 +27,32 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
// Fetch Labels
|
// Fetch Labels
|
||||||
fetchLabels({ commit }) {
|
fetchLabels({ commit }) {
|
||||||
Account.getLabels().then((response) => {
|
Account.getLabels()
|
||||||
commit(types.default.SET_LABELS, response.data);
|
.then(response => {
|
||||||
}).catch();
|
commit(types.default.SET_LABELS, response.data);
|
||||||
|
})
|
||||||
|
.catch();
|
||||||
},
|
},
|
||||||
// Fetch Inboxes
|
// Fetch Inboxes
|
||||||
fetchInboxes({ commit }) {
|
fetchInboxes({ commit }) {
|
||||||
commit(types.default.INBOXES_LOADING, true);
|
commit(types.default.INBOXES_LOADING, true);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.getInboxes().then((response) => {
|
Account.getInboxes()
|
||||||
commit(types.default.INBOXES_LOADING, false);
|
.then(response => {
|
||||||
commit(types.default.SET_INBOXES, response.data);
|
commit(types.default.INBOXES_LOADING, false);
|
||||||
resolve();
|
commit(types.default.SET_INBOXES, response.data);
|
||||||
}).catch((error) => {
|
resolve();
|
||||||
commit(types.default.INBOXES_LOADING, false);
|
})
|
||||||
reject(error);
|
.catch(error => {
|
||||||
});
|
commit(types.default.INBOXES_LOADING, false);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteInbox({ commit }, id) {
|
deleteInbox({ commit }, id) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.deleteInbox(id)
|
Account.deleteInbox(id)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
commit(types.default.DELETE_INBOX, id);
|
commit(types.default.DELETE_INBOX, id);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -56,48 +60,50 @@ const actions = {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addInboxItem({ commit }, { channel, params }) {
|
addInboxItem({ commit }, { channel, params }) {
|
||||||
const donePromise = new Promise((resolve) => {
|
const donePromise = new Promise(resolve => {
|
||||||
ChannelApi.createChannel(channel, params).then((response) => {
|
ChannelApi.createChannel(channel, params)
|
||||||
commit(types.default.SET_INBOX_ITEM, response);
|
.then(response => {
|
||||||
resolve(response);
|
commit(types.default.SET_INBOX_ITEM, response);
|
||||||
}).catch((error) => {
|
resolve(response);
|
||||||
console.log(error);
|
})
|
||||||
});
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return donePromise;
|
return donePromise;
|
||||||
},
|
},
|
||||||
listInboxAgents({ commit }, { inboxId }) {
|
listInboxAgents(_, { inboxId }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.listInboxAgents(inboxId)
|
Account.listInboxAgents(inboxId)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateInboxAgents({ commit }, { inboxId, agentList }) {
|
updateInboxAgents(_, { inboxId, agentList }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Account.updateInboxAgents(inboxId, agentList)
|
Account.updateInboxAgents(inboxId, agentList)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -105,7 +111,6 @@ const actions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
|
||||||
// Set Labels
|
// Set Labels
|
||||||
[types.default.SET_LABELS](_state, data) {
|
[types.default.SET_LABELS](_state, data) {
|
||||||
let payload = data.data.payload.labels;
|
let payload = data.data.payload.labels;
|
||||||
|
@ -116,7 +121,7 @@ const mutations = {
|
||||||
// Identify menuItem to update
|
// Identify menuItem to update
|
||||||
// May have more than one object to update
|
// May have more than one object to update
|
||||||
// Iterate it accordingly. Updating commmon sidebar now.
|
// Iterate it accordingly. Updating commmon sidebar now.
|
||||||
const menuItems = _state.menuGroup.common.menuItems;
|
const { menuItems } = _state.menuGroup.common;
|
||||||
// Update children for key `label`
|
// Update children for key `label`
|
||||||
menuItems.labels.children = payload;
|
menuItems.labels.children = payload;
|
||||||
},
|
},
|
||||||
|
@ -126,7 +131,7 @@ const mutations = {
|
||||||
},
|
},
|
||||||
// Set Inboxes
|
// Set Inboxes
|
||||||
[types.default.SET_INBOXES](_state, data) {
|
[types.default.SET_INBOXES](_state, data) {
|
||||||
let payload = data.data.payload;
|
let { payload } = data.data;
|
||||||
payload = payload.map(item => ({
|
payload = payload.map(item => ({
|
||||||
channel_id: item.id,
|
channel_id: item.id,
|
||||||
label: item.name,
|
label: item.name,
|
||||||
|
@ -138,13 +143,13 @@ const mutations = {
|
||||||
// Identify menuItem to update
|
// Identify menuItem to update
|
||||||
// May have more than one object to update
|
// May have more than one object to update
|
||||||
// Iterate it accordingly. Updating commmon sidebar now.
|
// Iterate it accordingly. Updating commmon sidebar now.
|
||||||
const menuItems = _state.menuGroup.common.menuItems;
|
const { menuItems } = _state.menuGroup.common;
|
||||||
// Update children for key `inbox`
|
// Update children for key `inbox`
|
||||||
menuItems.inbox.children = payload;
|
menuItems.inbox.children = payload;
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.SET_INBOX_ITEM](_state, { data }) {
|
[types.default.SET_INBOX_ITEM](_state, { data }) {
|
||||||
const menuItems = _state.menuGroup.common.menuItems;
|
const { menuItems } = _state.menuGroup.common;
|
||||||
// Update children for key `inbox`
|
// Update children for key `inbox`
|
||||||
menuItems.inbox.children.push({
|
menuItems.inbox.children.push({
|
||||||
channel_id: data.id,
|
channel_id: data.id,
|
||||||
|
@ -157,13 +162,11 @@ const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.DELETE_INBOX](_state, id) {
|
[types.default.DELETE_INBOX](_state, id) {
|
||||||
const menuItems = _state.menuGroup.common.menuItems;
|
const { menuItems } = _state.menuGroup.common;
|
||||||
let inboxList = menuItems.inbox.children;
|
let inboxList = menuItems.inbox.children;
|
||||||
inboxList = inboxList.filter(inbox => inbox.channel_id !== id);
|
inboxList = inboxList.filter(inbox => inbox.channel_id !== id);
|
||||||
menuItems.inbox.children = inboxList;
|
menuItems.inbox.children = inboxList;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -72,5 +72,8 @@
|
||||||
"eslint --fix",
|
"eslint --fix",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"eslint": "eslint app/javascript"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ AWS_REGION: ''
|
||||||
#chargebee
|
#chargebee
|
||||||
CHARGEBEE_API_KEY: ''
|
CHARGEBEE_API_KEY: ''
|
||||||
CHARGEBEE_SITE: ''
|
CHARGEBEE_SITE: ''
|
||||||
|
CHARGEBEE_WEBHOOK_USERNAME: ''
|
||||||
|
CHARGEBEE_WEBHOOK_PASSWORD: ''
|
||||||
|
|
||||||
#sentry
|
#sentry
|
||||||
SENTRY_DSN: ''
|
SENTRY_DSN: ''
|
||||||
|
|
Loading…
Reference in a new issue