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,15 +5,15 @@
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,11 +23,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,11 +37,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -49,11 +51,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -62,11 +65,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -76,11 +80,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -90,11 +95,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -104,11 +110,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -118,14 +125,15 @@ 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
|
||||||
|
.post(urlData.url, {
|
||||||
user_ids: agentList,
|
user_ids: agentList,
|
||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,17 +9,21 @@ 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)
|
||||||
|
.then(response => {
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
|
Cookies.set('user', response.data.data, {
|
||||||
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error.response);
|
reject(error.response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,17 +32,22 @@ export default {
|
||||||
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
|
||||||
|
.post(urlData.url, {
|
||||||
account_name: creds.name,
|
account_name: creds.name,
|
||||||
email: creds.email,
|
email: creds.email,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
|
Cookies.set('user', response.data.data, {
|
||||||
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -47,11 +56,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
Cookies.remove('auth_data');
|
Cookies.remove('auth_data');
|
||||||
Cookies.remove('user');
|
Cookies.remove('user');
|
||||||
|
@ -65,14 +75,15 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
Cookies.remove('auth_data');
|
Cookies.remove('auth_data');
|
||||||
Cookies.remove('user');
|
Cookies.remove('user');
|
||||||
window.location = '/u/login';
|
window.location = '/u/login';
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -80,7 +91,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !(!Cookies.getJSON('auth_data'));
|
return !!Cookies.getJSON('auth_data');
|
||||||
},
|
},
|
||||||
|
|
||||||
isAdmin() {
|
isAdmin() {
|
||||||
|
@ -111,13 +122,14 @@ export default {
|
||||||
|
|
||||||
verifyPasswordToken({ confirmationToken }) {
|
verifyPasswordToken({ confirmationToken }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post('auth/confirmation', {
|
axios
|
||||||
|
.post('auth/confirmation', {
|
||||||
confirmation_token: confirmationToken,
|
confirmation_token: confirmationToken,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error.response);
|
reject(error.response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -125,18 +137,23 @@ export default {
|
||||||
|
|
||||||
setNewPassword({ resetPasswordToken, password, confirmPassword }) {
|
setNewPassword({ resetPasswordToken, password, confirmPassword }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.put('auth/password', {
|
axios
|
||||||
|
.put('auth/password', {
|
||||||
reset_password_token: resetPasswordToken,
|
reset_password_token: resetPasswordToken,
|
||||||
password_confirmation: confirmPassword,
|
password_confirmation: confirmPassword,
|
||||||
password,
|
password,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
const expiryDate = moment.unix(response.headers.expiry);
|
const expiryDate = moment.unix(response.headers.expiry);
|
||||||
Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') });
|
Cookies.set('auth_data', response.headers, {
|
||||||
Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') });
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
|
Cookies.set('user', response.data.data, {
|
||||||
|
expires: expiryDate.diff(moment(), 'days'),
|
||||||
|
});
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error.response);
|
reject(error.response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -145,11 +162,12 @@ export default {
|
||||||
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 })
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error.response);
|
reject(error.response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,11 +6,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,11 +24,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -38,11 +39,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -51,11 +53,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -64,11 +67,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -77,11 +81,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -91,12 +96,13 @@ 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)
|
||||||
|
.then(response => {
|
||||||
console.log('fetch inboxes success');
|
console.log('fetch inboxes success');
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.log('fetch inboxes failure');
|
console.log('fetch inboxes failure');
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,11 +9,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,11 +26,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -40,11 +42,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,15 +5,15 @@
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,11 +23,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,11 +38,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -51,14 +53,15 @@ 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
|
||||||
|
.post(urlData.url, {
|
||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
sender_id: senderId,
|
sender_id: senderId,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -68,14 +71,15 @@ 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
|
||||||
|
.post(urlData.url, {
|
||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
sender_id: senderId,
|
sender_id: senderId,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -86,11 +90,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
.get(urlData.url, {
|
||||||
params: urlData.params,
|
params: urlData.params,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
callback(response);
|
callback(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,11 +23,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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
|
||||||
|
.get(urlData.url, {
|
||||||
params: urlData.params,
|
params: urlData.params,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return fetchPromise;
|
return fetchPromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,11 +6,12 @@ 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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -19,11 +20,12 @@ export default {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(Error(error));
|
reject(Error(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,17 +9,23 @@ 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 =>
|
||||||
|
node.componentOptions &&
|
||||||
|
node.componentOptions.tag === 'woot-tabs-item'
|
||||||
|
)
|
||||||
|
.map((node, index) => {
|
||||||
const data = node.componentOptions.propsData;
|
const data = node.componentOptions.propsData;
|
||||||
data.index = index;
|
data.index = index;
|
||||||
return node;
|
return node;
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<ul class={{
|
<ul
|
||||||
|
class={{
|
||||||
tabs: true,
|
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);
|
||||||
};
|
};
|
||||||
|
@ -65,17 +65,21 @@ export default {
|
||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
return (
|
return (
|
||||||
<li class={{
|
<li
|
||||||
|
class={{
|
||||||
'tabs-title': true,
|
'tabs-title': true,
|
||||||
'is-active': this.active,
|
'is-active': this.active,
|
||||||
'uk-disabled': this.disabled,
|
'uk-disabled': this.disabled,
|
||||||
}}>
|
}}
|
||||||
<a on-click={(event) => {
|
>
|
||||||
|
<a
|
||||||
|
on-click={event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!this.disabled) {
|
if (!this.disabled) {
|
||||||
this.$parent.$emit('change', this.index);
|
this.$parent.$emit('change', this.index);
|
||||||
}
|
}
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
{`${this.name} (${this.getItemCount})`}
|
{`${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,10 +59,9 @@ 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 }] */
|
||||||
|
@ -73,7 +70,11 @@ export default {
|
||||||
// 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 =>
|
||||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
||||||
(chat.message_type === 0 && chat.private !== true)
|
(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()
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_AGENT_FETCHING_STATUS, false);
|
commit(types.default.SET_AGENT_FETCHING_STATUS, false);
|
||||||
commit(types.default.SET_AGENTS, response);
|
commit(types.default.SET_AGENTS, response);
|
||||||
}).catch();
|
})
|
||||||
|
.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)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.ADD_AGENT, response);
|
commit(types.default.ADD_AGENT, response);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.EDIT_AGENT, response, agentInfo.id);
|
commit(types.default.EDIT_AGENT, response, agentInfo.id);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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)
|
||||||
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
commit(types.default.DELETE_AGENT, agentId);
|
commit(types.default.DELETE_AGENT, agentId);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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,7 +56,8 @@ 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
|
||||||
|
.login(credentials)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
commit(types.default.SET_CURRENT_USER);
|
commit(types.default.SET_CURRENT_USER);
|
||||||
window.axios = createAxios(axios);
|
window.axios = createAxios(axios);
|
||||||
|
@ -60,7 +65,7 @@ const actions = {
|
||||||
router.replace({ name: 'home' });
|
router.replace({ name: 'home' });
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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()
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
||||||
commit(types.default.SET_CANNED, response);
|
commit(types.default.SET_CANNED, response);
|
||||||
}).catch();
|
})
|
||||||
|
.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 })
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
commit(types.default.SET_CANNED_FETCHING_STATUS, false);
|
||||||
commit(types.default.SET_CANNED, response);
|
commit(types.default.SET_CANNED, response);
|
||||||
}).catch();
|
})
|
||||||
|
.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)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.ADD_CANNED, response);
|
commit(types.default.ADD_CANNED, response);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.EDIT_CANNED, response, cannedObj.id);
|
commit(types.default.EDIT_CANNED, response, cannedObj.id);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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)
|
||||||
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
commit(types.default.DELETE_CANNED, responseId);
|
commit(types.default.DELETE_CANNED, responseId);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch(response => {
|
||||||
reject(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,30 +41,40 @@ 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 =>
|
||||||
chat.meta.assignee === null && chat.status === _state.chatStatusFilter
|
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
|
||||||
|
);
|
||||||
|
return chat.messages.filter(
|
||||||
|
chatMessage =>
|
||||||
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
||||||
(chatMessage.message_type === 0 && chatMessage.private !== true)
|
(chatMessage.message_type === 0 && chatMessage.private !== true)
|
||||||
).length;
|
).length;
|
||||||
|
@ -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,8 +111,10 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchPreviousMessages({ commit }, data) {
|
fetchPreviousMessages({ commit }, data) {
|
||||||
const donePromise = new Promise((resolve) => {
|
const donePromise = new Promise(resolve => {
|
||||||
messageApi.fetchPreviousMessages(data).then((response) => {
|
messageApi
|
||||||
|
.fetchPreviousMessages(data)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_PREVIOUS_CONVERSATIONS, {
|
commit(types.default.SET_PREVIOUS_CONVERSATIONS, {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
data: response.data.payload,
|
data: response.data.payload,
|
||||||
|
@ -108,7 +123,8 @@ const actions = {
|
||||||
commit(types.default.SET_ALL_MESSAGES_LOADED);
|
commit(types.default.SET_ALL_MESSAGES_LOADED);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch(error => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -116,7 +132,7 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
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(() => {
|
})
|
||||||
|
.then(() => {
|
||||||
Vue.set(data, 'dataFetched', true);
|
Vue.set(data, 'dataFetched', true);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch(error => {
|
||||||
console.log(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
|
||||||
|
.sendMessage(data)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SEND_MESSAGE, response);
|
commit(types.default.SEND_MESSAGE, response);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch();
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
addPrivateNote({ commit }, data) {
|
addPrivateNote({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
messageApi.addPrivateNote(data).then((response) => {
|
messageApi
|
||||||
|
.addPrivateNote(data)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SEND_MESSAGE, response);
|
commit(types.default.SEND_MESSAGE, response);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch();
|
})
|
||||||
|
.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)
|
||||||
|
.then(() => {
|
||||||
commit(types.default.FB_TYPING, data);
|
commit(types.default.FB_TYPING, data);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch();
|
})
|
||||||
|
.catch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
markSeen({ commit }, data) {
|
markSeen({ commit }, data) {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
ConversationApi.markSeen(data).then((response) => {
|
ConversationApi.markSeen(data)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.MARK_SEEN, response);
|
commit(types.default.MARK_SEEN, response);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch();
|
})
|
||||||
|
.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)
|
||||||
|
.then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
}).catch();
|
})
|
||||||
|
.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,12 +35,18 @@ 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,
|
||||||
|
reportObj.from,
|
||||||
|
reportObj.to
|
||||||
|
).then(accountReport => {
|
||||||
let { data } = accountReport;
|
let { data } = accountReport;
|
||||||
data = data.filter(el => moment() > moment.unix(el.timestamp));
|
data = data.filter(el => moment() > moment.unix(el.timestamp));
|
||||||
if (reportObj.metric === 'avg_first_response_time' || reportObj.metric === 'avg_resolution_time') {
|
if (
|
||||||
data = data.map((element) => {
|
reportObj.metric === 'avg_first_response_time' ||
|
||||||
|
reportObj.metric === 'avg_resolution_time'
|
||||||
|
) {
|
||||||
|
data = data.map(element => {
|
||||||
/* eslint-disable operator-assignment */
|
/* eslint-disable operator-assignment */
|
||||||
element.value = (element.value / 3600).toFixed(2);
|
element.value = (element.value / 3600).toFixed(2);
|
||||||
return element;
|
return element;
|
||||||
|
@ -52,7 +58,7 @@ const actions = {
|
||||||
},
|
},
|
||||||
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,19 +27,23 @@ const getters = {
|
||||||
const actions = {
|
const actions = {
|
||||||
// Fetch Labels
|
// Fetch Labels
|
||||||
fetchLabels({ commit }) {
|
fetchLabels({ commit }) {
|
||||||
Account.getLabels().then((response) => {
|
Account.getLabels()
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_LABELS, response.data);
|
commit(types.default.SET_LABELS, response.data);
|
||||||
}).catch();
|
})
|
||||||
|
.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()
|
||||||
|
.then(response => {
|
||||||
commit(types.default.INBOXES_LOADING, false);
|
commit(types.default.INBOXES_LOADING, false);
|
||||||
commit(types.default.SET_INBOXES, response.data);
|
commit(types.default.SET_INBOXES, response.data);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch(error => {
|
||||||
commit(types.default.INBOXES_LOADING, false);
|
commit(types.default.INBOXES_LOADING, false);
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
|
@ -48,7 +52,7 @@ const actions = {
|
||||||
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)
|
||||||
|
.then(response => {
|
||||||
commit(types.default.SET_INBOX_ITEM, response);
|
commit(types.default.SET_INBOX_ITEM, response);
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch(error => {
|
||||||
console.log(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