- Migrated external lib injection in boot files - Replaced vue-resource by axios - Applied more restrictive linting rules for Vue.js - Replaced npm by yarn - Removed old chrome release from test environment - Refactor Voicebox Settings - Refactor SpeedDial - Refactor Reminder - Refactor Call Blocking - Refactor Call Forward - Integrate jest test framework - Remove mocha test runner - Refactor User Settings - Refactor PBX Configuration - Refactor Call Change-Id: I9b2ea327e7959fb5e78d1bd53a4156ecb1c5f191mr9.1.1
@ -1,5 +1,19 @@
|
||||
{
|
||||
"presets": [["es2015", {"modules": false}], "stage-2"],
|
||||
"plugins": ["transform-runtime"],
|
||||
"comments": false
|
||||
"plugins": ["@babel/plugin-syntax-dynamic-import"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["dynamic-import-node"],
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"modules": "commonjs",
|
||||
"targets": {
|
||||
"node": "current"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
build/*.js
|
||||
config/*.js
|
||||
dist/*.js
|
||||
/dist
|
||||
/src-bex/www
|
||||
/src-capacitor
|
||||
/src-cordova
|
||||
/.quasar
|
||||
/node_modules
|
||||
|
@ -1,38 +1,89 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
sourceType: 'module'
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended'
|
||||
],
|
||||
plugins: [
|
||||
'html',
|
||||
'import'
|
||||
],
|
||||
globals: {
|
||||
'cdk': true,
|
||||
'cordova': true,
|
||||
'DEV': true,
|
||||
'PROD': true,
|
||||
'__THEME': true
|
||||
},
|
||||
rules: {
|
||||
'arrow-parens': 0,
|
||||
'one-var': 0,
|
||||
'import/first': 0,
|
||||
'import/named': 2,
|
||||
'import/namespace': 2,
|
||||
'import/default': 2,
|
||||
'import/export': 2,
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||
'brace-style': [2, 'stroustrup', {'allowSingleLine': true}],
|
||||
"no-console": 0
|
||||
}
|
||||
};
|
||||
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
|
||||
// This option interrupts the configuration hierarchy at this file
|
||||
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
|
||||
root: true,
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
||||
sourceType: 'module' // Allows for the use of imports
|
||||
},
|
||||
|
||||
env: {
|
||||
browser: true
|
||||
},
|
||||
|
||||
// Rules order is important, please avoid shuffling them
|
||||
extends: [
|
||||
// Base ESLint recommended rules
|
||||
// 'eslint:recommended',
|
||||
|
||||
// Uncomment any of the lines below to choose desired strictness,
|
||||
// but leave only one uncommented!
|
||||
// See https://eslint.vuejs.org/rules/#available-rules
|
||||
'plugin:vue/essential', // Priority A: Essential (Error Prevention)
|
||||
'plugin:vue/strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
|
||||
'plugin:vue/recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
|
||||
'standard'
|
||||
],
|
||||
|
||||
plugins: [
|
||||
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
|
||||
// required to lint *.vue files
|
||||
'vue',
|
||||
|
||||
],
|
||||
|
||||
globals: {
|
||||
'ga': true, // Google Analytics
|
||||
'cordova': true,
|
||||
'__statics': true,
|
||||
'process': true,
|
||||
'Capacitor': true,
|
||||
'chrome': true
|
||||
},
|
||||
|
||||
// add your custom rules here
|
||||
rules: {
|
||||
// allow async-await
|
||||
'generator-star-spacing': 'off',
|
||||
// allow paren-less arrow functions
|
||||
'arrow-parens': 'off',
|
||||
'one-var': 'off',
|
||||
|
||||
'import/first': 'off',
|
||||
'import/named': 'error',
|
||||
'import/namespace': 'error',
|
||||
'import/default': 'error',
|
||||
'import/export': 'error',
|
||||
'import/extensions': 'off',
|
||||
'import/no-unresolved': 'off',
|
||||
'import/no-extraneous-dependencies': 'off',
|
||||
'prefer-promise-reject-errors': 'off',
|
||||
'no-tabs': 'off',
|
||||
'no-trailing-spaces': 'off',
|
||||
// allow debugger during development only
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'indent': [
|
||||
'error',
|
||||
'tab'
|
||||
],
|
||||
'vue/script-indent': [
|
||||
'error',
|
||||
'tab'
|
||||
],
|
||||
'vue/html-indent': [
|
||||
'error',
|
||||
'tab'
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.vue"],
|
||||
"rules": {
|
||||
"indent": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,19 +1,38 @@
|
||||
.DS_Store
|
||||
.thumbs.db
|
||||
.vscode
|
||||
node_modules/
|
||||
dist/
|
||||
npm-debug.log*
|
||||
cordova/platforms
|
||||
cordova/plugins
|
||||
node_modules
|
||||
|
||||
# Quasar core related directories
|
||||
.quasar
|
||||
/dist
|
||||
|
||||
# Cordova related directories and files
|
||||
/src-cordova/node_modules
|
||||
/src-cordova/platforms
|
||||
/src-cordova/plugins
|
||||
/src-cordova/www
|
||||
|
||||
# Junit reports
|
||||
t/TESTS*
|
||||
# Capacitor related directories and files
|
||||
/src-capacitor/www
|
||||
/src-capacitor/node_modules
|
||||
|
||||
# BEX related directories and files
|
||||
/src-bex/www
|
||||
/src-bex/js/core
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# IntelliJ
|
||||
# Editor directories and files
|
||||
.idea
|
||||
*.iml
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
|
||||
csc/
|
||||
/src/config.js
|
||||
|
||||
src/config.js
|
||||
/junit.xml
|
||||
/test/jest/coverage
|
||||
|
@ -1,2 +0,0 @@
|
||||
save-prefix =
|
||||
registry = https://npm-registry.sipwise.com/
|
@ -0,0 +1,8 @@
|
||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
// to edit target browsers: use "browserslist" field in package.json
|
||||
require('autoprefixer')
|
||||
]
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
const fs = require('fs-extra')
|
||||
let extend = undefined
|
||||
|
||||
/**
|
||||
* The .babelrc file has been created to assist Jest for transpiling.
|
||||
* You should keep your application's babel rules in this file.
|
||||
*/
|
||||
|
||||
if (fs.existsSync('./.babelrc')) {
|
||||
extend = './.babelrc'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@quasar/babel-preset-app'
|
||||
],
|
||||
extends: extend
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
var
|
||||
ExtractTextPlugin = require('extract-text-webpack-plugin'),
|
||||
autoprefixer = require('autoprefixer'),
|
||||
purify = require('purify-css'),
|
||||
glob = require('glob'),
|
||||
path = require('path'),
|
||||
fs = require('fs')
|
||||
|
||||
module.exports.postcss = [autoprefixer()]
|
||||
|
||||
module.exports.styleLoaders = function (options) {
|
||||
options = options || {}
|
||||
|
||||
function generateLoaders (loaders) {
|
||||
if (options.postcss) {
|
||||
loaders.splice(1, 0, 'postcss')
|
||||
}
|
||||
|
||||
var sourceLoader = loaders.map(function (loader) {
|
||||
var extraParamChar
|
||||
if (/\?/.test(loader)) {
|
||||
loader = loader.replace(/\?/, '-loader?')
|
||||
extraParamChar = '&'
|
||||
}
|
||||
else {
|
||||
loader = loader + '-loader'
|
||||
extraParamChar = '?'
|
||||
}
|
||||
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
|
||||
}).join('!')
|
||||
|
||||
if (options.extract) {
|
||||
return ExtractTextPlugin.extract({
|
||||
use: sourceLoader,
|
||||
fallback: 'vue-style-loader'
|
||||
})
|
||||
}
|
||||
else {
|
||||
return ['vue-style-loader', sourceLoader].join('!')
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
css: generateLoaders(['css']),
|
||||
less: generateLoaders(['css', 'less']),
|
||||
sass: generateLoaders(['css', 'sass?indentedSyntax']),
|
||||
scss: generateLoaders(['css', 'sass']),
|
||||
styl: generateLoaders(['css', 'stylus']),
|
||||
stylus: generateLoaders(['css', 'stylus'])
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.styleRules = function (options) {
|
||||
var output = []
|
||||
var loaders = exports.styleLoaders(options)
|
||||
for (var extension in loaders) {
|
||||
var loader = loaders[extension]
|
||||
output.push({
|
||||
test: new RegExp('\\.' + extension + '$'),
|
||||
loader: loader
|
||||
})
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
function getSize (size) {
|
||||
return (size / 1024).toFixed(2) + 'kb'
|
||||
}
|
||||
|
||||
module.exports.purify = function(cb) {
|
||||
var css = glob.sync(path.join(__dirname, '../dist/**/*.css'))
|
||||
var js = glob.sync(path.join(__dirname, '../dist/**/*.js'))
|
||||
|
||||
Promise.all(css.map(function (file) {
|
||||
return new Promise(function (resolve) {
|
||||
console.log('\n Purifying ' + path.relative(path.join(__dirname, '../dist'), file).bold + '...')
|
||||
purify(js, [file], {minify: true}, function (purified) {
|
||||
var oldSize = fs.statSync(file).size
|
||||
fs.writeFileSync(file, purified)
|
||||
var newSize = fs.statSync(file).size
|
||||
|
||||
console.log(
|
||||
' * Reduced size by ' + ((1 - newSize / oldSize) * 100).toFixed(2) + '%, from ' +
|
||||
getSize(oldSize) + ' to ' + getSize(newSize) + '.'
|
||||
)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}))
|
||||
.then(cb)
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
var
|
||||
config = require('../config'),
|
||||
theme = process.argv[2] || config.defaultTheme
|
||||
|
||||
module.exports = {
|
||||
dev: process.env.NODE_ENV === 'development',
|
||||
prod: process.env.NODE_ENV === 'production',
|
||||
|
||||
platform: {
|
||||
theme: theme,
|
||||
cordovaAssets: './cordova/platforms/' + (theme === 'mat' ? 'android' : 'ios') + '/platform_www'
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
/* eslint-disable */
|
||||
require('eventsource-polyfill')
|
||||
require('webpack-hot-middleware/client?noInfo=true&reload=true')
|
@ -1,68 +0,0 @@
|
||||
process.env.NODE_ENV = 'production'
|
||||
|
||||
require('colors')
|
||||
|
||||
var
|
||||
shell = require('shelljs'),
|
||||
path = require('path'),
|
||||
env = require('./env-utils'),
|
||||
css = require('./css-utils'),
|
||||
config = require('../config'),
|
||||
webpack = require('webpack'),
|
||||
webpackConfig = require('./webpack.prod.conf'),
|
||||
targetPath = path.join(__dirname, '../dist')
|
||||
|
||||
console.log(' WARNING!'.bold)
|
||||
console.log(' Do NOT use VueRouter\'s "history" mode if')
|
||||
console.log(' building for Cordova or Electron.\n')
|
||||
|
||||
require('./script.clean.js')
|
||||
console.log((' Building Quasar App with "' + env.platform.theme + '" theme...\n').bold)
|
||||
|
||||
shell.mkdir('-p', targetPath)
|
||||
shell.cp('-R', 'src/statics', targetPath)
|
||||
|
||||
function finalize () {
|
||||
console.log((
|
||||
'\n Build complete with "' + env.platform.theme.bold + '" theme in ' +
|
||||
'"/dist"'.bold + ' folder.\n').cyan)
|
||||
|
||||
console.log(' Built files are meant to be served over an HTTP server.'.bold)
|
||||
console.log(' Opening index.html over file:// won\'t work.'.bold)
|
||||
}
|
||||
|
||||
webpackConfig.watch = (process.env['CSC_WATCH'])? true : false;
|
||||
webpackConfig.watchOptions = {
|
||||
ignored: [
|
||||
'build',
|
||||
'config',
|
||||
'debian',
|
||||
'dist',
|
||||
'node_modules',
|
||||
't',
|
||||
'templates'
|
||||
]
|
||||
}
|
||||
|
||||
webpack(webpackConfig, function (err, stats) {
|
||||
if (err) throw err
|
||||
|
||||
process.stdout.write(stats.toString({
|
||||
colors: true,
|
||||
modules: false,
|
||||
children: false,
|
||||
chunks: false,
|
||||
chunkModules: false
|
||||
}) + '\n')
|
||||
|
||||
if (stats.hasErrors()) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (config.build.purifyCSS) {
|
||||
css.purify(finalize)
|
||||
}
|
||||
else {
|
||||
finalize()
|
||||
}
|
||||
})
|
@ -1,7 +0,0 @@
|
||||
var
|
||||
shell = require('shelljs'),
|
||||
path = require('path')
|
||||
|
||||
shell.rm('-rf', path.resolve(__dirname, '../dist/*'))
|
||||
shell.rm('-rf', path.resolve(__dirname, '../dist/.*'))
|
||||
console.log(' Cleaned build artifacts.\n')
|
@ -1,86 +0,0 @@
|
||||
process.env.NODE_ENV = 'development'
|
||||
|
||||
require('colors')
|
||||
|
||||
var
|
||||
path = require('path'),
|
||||
express = require('express'),
|
||||
webpack = require('webpack'),
|
||||
env = require('./env-utils'),
|
||||
config = require('../config'),
|
||||
opn = require('opn'),
|
||||
proxyMiddleware = require('http-proxy-middleware'),
|
||||
webpackConfig = require('./webpack.dev.conf'),
|
||||
app = express(),
|
||||
port = process.env.PORT || config.dev.port,
|
||||
uri = 'http://localhost:' + port
|
||||
|
||||
console.log(' Starting dev server with "' + (process.argv[2] || env.platform.theme).bold + '" theme...')
|
||||
console.log(' Will listen at ' + uri.bold)
|
||||
if (config.dev.openBrowser) {
|
||||
console.log(' Browser will open when build is ready.\n')
|
||||
}
|
||||
|
||||
var compiler = webpack(webpackConfig)
|
||||
|
||||
// Define HTTP proxies to your custom API backend
|
||||
// https://github.com/chimurai/http-proxy-middleware
|
||||
var proxyTable = config.dev.proxyTable
|
||||
|
||||
var devMiddleware = require('webpack-dev-middleware')(compiler, {
|
||||
publicPath: webpackConfig.output.publicPath,
|
||||
quiet: true
|
||||
})
|
||||
|
||||
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
|
||||
log: function () {}
|
||||
})
|
||||
|
||||
// force page reload when html-webpack-plugin template changes
|
||||
compiler.plugin('compilation', function (compilation) {
|
||||
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
|
||||
hotMiddleware.publish({ action: 'reload' })
|
||||
cb()
|
||||
})
|
||||
})
|
||||
|
||||
// proxy requests like API. See /config/index.js -> dev.proxyTable
|
||||
// https://github.com/chimurai/http-proxy-middleware
|
||||
Object.keys(proxyTable).forEach(function (context) {
|
||||
var options = proxyTable[context]
|
||||
if (typeof options === 'string') {
|
||||
options = { target: options }
|
||||
}
|
||||
app.use(proxyMiddleware(context, options))
|
||||
})
|
||||
|
||||
// handle fallback for HTML5 history API
|
||||
app.use(require('connect-history-api-fallback')())
|
||||
|
||||
// serve webpack bundle output
|
||||
app.use(devMiddleware)
|
||||
|
||||
// enable hot-reload and state-preserving
|
||||
// compilation error display
|
||||
app.use(hotMiddleware)
|
||||
|
||||
// serve pure static assets
|
||||
var staticsPath = path.posix.join(webpackConfig.output.publicPath, 'statics/')
|
||||
app.use(staticsPath, express.static('./src/statics'))
|
||||
|
||||
// try to serve Cordova statics for Play App
|
||||
app.use(express.static(env.platform.cordovaAssets))
|
||||
|
||||
module.exports = app.listen(port, function (err) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// open browser if set so in /config/index.js
|
||||
if (config.dev.openBrowser) {
|
||||
devMiddleware.waitUntilValid(function () {
|
||||
opn(uri)
|
||||
})
|
||||
}
|
||||
})
|
@ -1,108 +0,0 @@
|
||||
var
|
||||
path = require('path'),
|
||||
webpack = require('webpack'),
|
||||
config = require('../config'),
|
||||
cssUtils = require('./css-utils'),
|
||||
env = require('./env-utils'),
|
||||
merge = require('webpack-merge'),
|
||||
projectRoot = path.resolve(__dirname, '../'),
|
||||
ProgressBarPlugin = require('progress-bar-webpack-plugin'),
|
||||
useCssSourceMap =
|
||||
(env.dev && config.dev.cssSourceMap) ||
|
||||
(env.prod && config.build.productionSourceMap)
|
||||
|
||||
function resolve (dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: './src/main.js'
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../dist'),
|
||||
publicPath: config[env.prod ? 'build' : 'dev'].publicPath,
|
||||
filename: 'js/[name].[hash].js',
|
||||
chunkFilename: 'js/[id].[chunkhash].js'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.vue', '.json'],
|
||||
modules: [
|
||||
resolve('src'),
|
||||
resolve('node_modules')
|
||||
],
|
||||
alias: config.aliases
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
enforce: 'pre',
|
||||
test: /\.(vue|js)$/,
|
||||
loader: 'eslint-loader',
|
||||
include: projectRoot,
|
||||
exclude: /node_modules/,
|
||||
options: {
|
||||
formatter: require('eslint-friendly-formatter')
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
include: projectRoot,
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
postcss: cssUtils.postcss,
|
||||
loaders: merge({js: 'babel-loader'}, cssUtils.styleLoaders({
|
||||
sourceMap: useCssSourceMap,
|
||||
extract: env.prod
|
||||
}))
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'img/[name].[hash:7].[ext]'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'fonts/[name].[hash:7].[ext]'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': config[env.prod ? 'build' : 'dev'].env,
|
||||
'DEV': env.dev,
|
||||
'PROD': env.prod,
|
||||
'__THEME': '"' + env.platform.theme + '"'
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
minimize: env.prod,
|
||||
options: {
|
||||
context: path.resolve(__dirname, '../src'),
|
||||
postcss: cssUtils.postcss
|
||||
}
|
||||
}),
|
||||
new ProgressBarPlugin({
|
||||
format: config.progressFormat
|
||||
})
|
||||
],
|
||||
performance: {
|
||||
hints: false
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
var
|
||||
config = require('../config'),
|
||||
webpack = require('webpack'),
|
||||
merge = require('webpack-merge'),
|
||||
cssUtils = require('./css-utils'),
|
||||
baseWebpackConfig = require('./webpack.base.conf'),
|
||||
HtmlWebpackPlugin = require('html-webpack-plugin'),
|
||||
FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||
|
||||
// add hot-reload related code to entry chunks
|
||||
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
|
||||
baseWebpackConfig.entry[name] = ['./build/hot-reload.js', baseWebpackConfig.entry[name]]
|
||||
})
|
||||
|
||||
module.exports = merge(baseWebpackConfig, {
|
||||
// eval-source-map is faster for development
|
||||
devtool: '#cheap-module-eval-source-map',
|
||||
devServer: {
|
||||
historyApiFallback: true,
|
||||
noInfo: true
|
||||
},
|
||||
module: {
|
||||
rules: cssUtils.styleRules({
|
||||
sourceMap: config.dev.cssSourceMap,
|
||||
postcss: true
|
||||
})
|
||||
},
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NoEmitOnErrorsPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'src/index.html',
|
||||
inject: true
|
||||
}),
|
||||
new FriendlyErrorsPlugin({
|
||||
clearConsole: config.dev.clearConsoleOnRebuild
|
||||
})
|
||||
],
|
||||
performance: {
|
||||
hints: false
|
||||
}
|
||||
})
|
@ -1,78 +0,0 @@
|
||||
var
|
||||
path = require('path'),
|
||||
config = require('../config'),
|
||||
cssUtils = require('./css-utils'),
|
||||
webpack = require('webpack'),
|
||||
merge = require('webpack-merge'),
|
||||
baseWebpackConfig = require('./webpack.base.conf'),
|
||||
ExtractTextPlugin = require('extract-text-webpack-plugin'),
|
||||
HtmlWebpackPlugin = require('html-webpack-plugin'),
|
||||
OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
|
||||
module.exports = merge(baseWebpackConfig, {
|
||||
module: {
|
||||
rules: cssUtils.styleRules({
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
extract: true,
|
||||
postcss: true
|
||||
})
|
||||
},
|
||||
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
minimize: true,
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
}),
|
||||
// Compress extracted CSS. We are using this plugin so that possible
|
||||
// duplicated CSS from different components can be deduped.
|
||||
new OptimizeCSSPlugin({
|
||||
cssProcessorOptions: {
|
||||
safe: true
|
||||
}
|
||||
}),
|
||||
// extract css into its own file
|
||||
new ExtractTextPlugin({
|
||||
filename: '[name].[contenthash].css'
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: path.resolve(__dirname, '../dist/index.html'),
|
||||
template: 'src/index.html',
|
||||
inject: true,
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
removeAttributeQuotes: true
|
||||
// more options:
|
||||
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||
},
|
||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||
chunksSortMode: 'dependency'
|
||||
}),
|
||||
// split vendor js into its own file
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
minChunks: function (module, count) {
|
||||
// any required modules inside node_modules are extracted to vendor
|
||||
return (
|
||||
module.resource &&
|
||||
/\.js$/.test(module.resource) &&
|
||||
(
|
||||
module.resource.indexOf('quasar') > -1 ||
|
||||
module.resource.indexOf(
|
||||
path.join(__dirname, '../node_modules')
|
||||
) === 0
|
||||
)
|
||||
)
|
||||
}
|
||||
}),
|
||||
// extract webpack runtime and module manifest to its own file in order to
|
||||
// prevent vendor hash from being updated whenever app bundle is updated
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'manifest',
|
||||
chunks: ['vendor']
|
||||
})
|
||||
]
|
||||
})
|
@ -1,6 +0,0 @@
|
||||
var merge = require('webpack-merge')
|
||||
var prodEnv = require('./prod.env')
|
||||
|
||||
module.exports = merge(prodEnv, {
|
||||
NODE_ENV: '"development"'
|
||||
})
|
@ -1,65 +0,0 @@
|
||||
var path = require('path')
|
||||
|
||||
module.exports = {
|
||||
// Webpack aliases
|
||||
aliases: {
|
||||
'quasar-frameworks': path.resolve(__dirname, '../node_modules/quasar-framework/'),
|
||||
quasar: path.resolve(__dirname, '../node_modules/quasar-framework/'),
|
||||
src: path.resolve(__dirname, '../src'),
|
||||
assets: path.resolve(__dirname, '../src/assets'),
|
||||
'@': path.resolve(__dirname, '../src/components'),
|
||||
variables: path.resolve(__dirname, '../src/themes/quasar.variables.styl')
|
||||
},
|
||||
|
||||
// Progress Bar Webpack plugin format
|
||||
// https://github.com/clessg/progress-bar-webpack-plugin#options
|
||||
progressFormat: ' [:bar] ' + ':percent'.bold + ' (:msg)',
|
||||
|
||||
// Default theme to build with ('ios' or 'mat')
|
||||
defaultTheme: 'mat',
|
||||
|
||||
build: {
|
||||
env: require('./prod.env'),
|
||||
publicPath: '',
|
||||
productionSourceMap: (process.env['CSC_SOURCE_MAP'])? true : false,
|
||||
|
||||
// Remove unused CSS
|
||||
// Disable it if it has side-effects for your specific app
|
||||
purifyCSS: true
|
||||
},
|
||||
dev: {
|
||||
env: require('./dev.env'),
|
||||
cssSourceMap: true,
|
||||
// auto open browser or not
|
||||
openBrowser: false,
|
||||
publicPath: '/',
|
||||
port: 8080,
|
||||
|
||||
// If for example you are using Quasar Play
|
||||
// to generate a QR code then on each dev (re)compilation
|
||||
// you need to avoid clearing out the console, so set this
|
||||
// to "false", otherwise you can set it to "true" to always
|
||||
// have only the messages regarding your last (re)compilation.
|
||||
clearConsoleOnRebuild: false,
|
||||
|
||||
// Proxy your API if using any.
|
||||
// Also see /build/script.dev.js and search for "proxy api requests"
|
||||
// https://github.com/chimurai/http-proxy-middleware
|
||||
proxyTable: {}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* proxyTable example:
|
||||
*
|
||||
proxyTable: {
|
||||
// proxy all requests starting with /api
|
||||
'/api': {
|
||||
target: 'https://some.address.com/api',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/api': ''
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
NODE_ENV: '"production"'
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
module.exports = {
|
||||
globals: {
|
||||
__DEV__: true
|
||||
},
|
||||
setupFilesAfterEnv: [
|
||||
'<rootDir>/test/jest/jest.setup.js'
|
||||
],
|
||||
// noStackTrace: true,
|
||||
// bail: true,
|
||||
// cache: false,
|
||||
// verbose: true,
|
||||
// watch: true,
|
||||
collectCoverage: true,
|
||||
coverageDirectory: '<rootDir>/test/jest/coverage',
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/src/**/*.vue',
|
||||
'<rootDir>/src/**/*.js',
|
||||
'<rootDir>/src/**/*.ts',
|
||||
'<rootDir>/src/**/*.jsx'
|
||||
],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
// branches: 50,
|
||||
// functions: 50,
|
||||
// lines: 50,
|
||||
// statements: 50
|
||||
}
|
||||
},
|
||||
testMatch: [
|
||||
'<rootDir>/test/jest/__tests__/**/*.spec.js',
|
||||
'<rootDir>/test/jest/__tests__/**/*.test.js',
|
||||
'<rootDir>/src/**/__tests__/*_jest.spec.js'
|
||||
],
|
||||
moduleFileExtensions: [
|
||||
'vue',
|
||||
'js',
|
||||
'json'
|
||||
],
|
||||
moduleNameMapper: {
|
||||
'^vue$': '<rootDir>/node_modules/vue/dist/vue.common.js',
|
||||
'^test-utils$': '<rootDir>/node_modules/@vue/test-utils/dist/vue-test-utils.js',
|
||||
'^quasar$': '<rootDir>/node_modules/quasar/dist/quasar.common.js',
|
||||
'^~/(.*)$': '<rootDir>/$1',
|
||||
'^src/(.*)$': '<rootDir>/src/$1',
|
||||
'.*css$': '<rootDir>/test/jest/utils/stub.css'
|
||||
},
|
||||
transform: {
|
||||
'.*\\.vue$': 'vue-jest',
|
||||
'.*\\.js$': 'babel-jest',
|
||||
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub'
|
||||
// use these if NPM is being flaky
|
||||
// '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
|
||||
// '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'<rootDir>/node_modules/(?!quasar/lang)'
|
||||
],
|
||||
snapshotSerializers: [
|
||||
'<rootDir>/node_modules/jest-serializer-vue'
|
||||
],
|
||||
reporters: ['default', 'jest-junit']
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"src/*": [
|
||||
"src/*"
|
||||
],
|
||||
"app/*": [
|
||||
"*"
|
||||
],
|
||||
"components/*": [
|
||||
"src/components/*"
|
||||
],
|
||||
"layouts/*": [
|
||||
"src/layouts/*"
|
||||
],
|
||||
"pages/*": [
|
||||
"src/pages/*"
|
||||
],
|
||||
"assets/*": [
|
||||
"src/assets/*"
|
||||
],
|
||||
"boot/*": [
|
||||
"src/boot/*"
|
||||
],
|
||||
"vue$": [
|
||||
"node_modules/vue/dist/vue.esm.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
".quasar",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var webpackCsc = require('./build/webpack.base.conf');
|
||||
|
||||
webpackCsc.module.rules.shift();
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
files: [
|
||||
'./t/**/*.js'
|
||||
],
|
||||
frameworks: ['mocha'],
|
||||
plugins : [
|
||||
'karma-mocha',
|
||||
'karma-webpack',
|
||||
'karma-chrome-launcher',
|
||||
'karma-firefox-launcher',
|
||||
'karma-junit-reporter',
|
||||
],
|
||||
browsers: ['ChromeWebRTC', 'FirefoxWebRTC'],
|
||||
customLaunchers: {
|
||||
ChromeWebRTC: {
|
||||
base: 'Chrome',
|
||||
flags: [
|
||||
'--disable-web-security',
|
||||
'--use-fake-device-for-media-stream',
|
||||
'--use-fake-ui-for-media-stream',
|
||||
'--ignore-certificate-errors',
|
||||
'--no-sandbox',
|
||||
'--disable-gpu'
|
||||
]
|
||||
},
|
||||
FirefoxWebRTC: {
|
||||
base: 'Firefox',
|
||||
prefs: {
|
||||
'media.navigator.permission.disabled': true,
|
||||
'media.navigator.streams.fake': true
|
||||
}
|
||||
}
|
||||
},
|
||||
reporters: [
|
||||
'progress',
|
||||
'junit'
|
||||
],
|
||||
junitReporter: {
|
||||
outputDir: './t/'
|
||||
},
|
||||
preprocessors: {
|
||||
'./src/**/*.js': ['webpack'],
|
||||
'./t/**/*.js': ['webpack']
|
||||
},
|
||||
webpack: {
|
||||
module: webpackCsc.module,
|
||||
plugins: webpackCsc.plugins
|
||||
}
|
||||
});
|
||||
};
|
@ -1,93 +1,71 @@
|
||||
{
|
||||
"name": "ngcp-csc-ui",
|
||||
"productName": "Customer Self-Care Web UI",
|
||||
"version": "0.3.1",
|
||||
"description": "Customer Self-Care Web UI",
|
||||
"version": "0.0.1",
|
||||
"description": "A Quasar Framework app",
|
||||
"productName": "Customer Self-Care Web Interface",
|
||||
"author": "Hans-Peter Herzog <hherzog@sipwise.com>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "node build/script.clean.js",
|
||||
"dev": "node build/script.dev.js",
|
||||
"build": "node build/script.build.js mat",
|
||||
"dev-build": "CSC_SOURCE_MAP=1 CSC_WATCH=1 node build/script.build.js mat",
|
||||
"test": "karma start ./karma.js --single-run",
|
||||
"dev-test": "karma start ./karma.js",
|
||||
"dev-docker": "docker pull docker.mgm.sipwise.com/ngcp-csc-ui-env-buster; docker run --rm -p 8080:8080 -i -t -v $(pwd):/code:rw docker.mgm.sipwise.com/ngcp-csc-ui-env-buster:latest env/run_csc_ui $1"
|
||||
"lint": "eslint --ext .js,.vue ./",
|
||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||
"build": "./node_modules/@quasar/cli/bin/quasar build",
|
||||
"dev": "./node_modules/@quasar/cli/bin/quasar dev",
|
||||
"dev:docker": "docker pull docker.mgm.sipwise.com/ngcp-csc-ui-env-buster; docker run --rm -p 8080:8080 -i -t -v $(pwd):/code:rw docker.mgm.sipwise.com/ngcp-csc-ui-env-buster:latest env/run_csc_ui $1",
|
||||
"test:unit": "jest --updateSnapshot",
|
||||
"test:unit:coverage": "jest --coverage",
|
||||
"test:unit:watch": "jest --watch",
|
||||
"test:unit:watchAll": "jest --watchAll",
|
||||
"serve:test:coverage": "quasar serve test/jest/coverage/lcov-report/ --port 8788",
|
||||
"concurrently:dev:jest": "concurrently \"quasar dev\" \"jest --watch\""
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.25.0",
|
||||
"quasar-extras": "0.x",
|
||||
"quasar-framework": "0.14.9",
|
||||
"uuid": "3.2.1",
|
||||
"vue": "^2.5.0",
|
||||
"vue-i18n": "7.3.2",
|
||||
"vue-password-strength-meter": "1.7.2",
|
||||
"vue-resource": "1.3.4",
|
||||
"vue-router": "^2.5.0",
|
||||
"vuelidate": "0.7.4",
|
||||
"vuex": "2.5.0",
|
||||
"vuex-router-sync": "4.3.2",
|
||||
"zxcvbn": "4.4.2"
|
||||
"@quasar/extras": "^1.9.5",
|
||||
"axios": "^0.18.1",
|
||||
"core-js": "^3.6.5",
|
||||
"file-saver": "^2.0.2",
|
||||
"jest-junit": "^11.1.0",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"load-script": "^1.0.0",
|
||||
"lodash": "^4.17.20",
|
||||
"moment": "^2.27.0",
|
||||
"quasar": "^1.14.0",
|
||||
"vue-i18n": "^8.0.0",
|
||||
"vue-password-strength-meter": "^1.7.2",
|
||||
"vue-resource": "^1.5.1",
|
||||
"vue-scrollto": "^2.18.2",
|
||||
"vuelidate": "^0.7.5",
|
||||
"zxcvbn": "^4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^6.4.0",
|
||||
"babel-core": "^6.0.0",
|
||||
"babel-eslint": "^7.0.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-plugin-transform-runtime": "^6.0.0",
|
||||
"babel-preset-es2015": "^6.0.0",
|
||||
"babel-preset-stage-2": "^6.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"colors": "^1.1.2",
|
||||
"connect-history-api-fallback": "^1.1.0",
|
||||
"crypto-browserify": "3.12.0",
|
||||
"css-loader": "^0.28.7",
|
||||
"es6-promise": "^4.1.1",
|
||||
"eslint": "^4.8.0",
|
||||
"eslint-config-standard": "^10.2.1",
|
||||
"eslint-friendly-formatter": "^3.0.0",
|
||||
"eslint-loader": "^1.9.0",
|
||||
"eslint-plugin-html": "^3.2.2",
|
||||
"eslint-plugin-import": "^2.7.0",
|
||||
"eslint-plugin-node": "^5.2.0",
|
||||
"eslint-plugin-promise": "^3.5.0",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"express": "^4.16.1",
|
||||
"extract-text-webpack-plugin": "^3.0.0",
|
||||
"file-loader": "^0.11.1",
|
||||
"file-saver": "1.3.3",
|
||||
"friendly-errors-webpack-plugin": "^1.1.3",
|
||||
"glob": "^7.1.2",
|
||||
"google-libphonenumber": "3.0.7",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"http-proxy-middleware": "0.19.1",
|
||||
"json-loader": "^0.5.7",
|
||||
"karma": "^1.7.1",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-firefox-launcher": "^1.0.1",
|
||||
"karma-junit-reporter": "^1.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-webpack": "^2.0.4",
|
||||
"load-script": "1.0.0",
|
||||
"lodash": "4.17.15",
|
||||
"mocha": "^4.0.0",
|
||||
"moment": "2.22.2",
|
||||
"opn": "^5.0.0",
|
||||
"optimize-css-assets-webpack-plugin": "^3.2.0",
|
||||
"postcss-loader": "^1.0.0",
|
||||
"progress-bar-webpack-plugin": "^1.10.0",
|
||||
"purify-css": "^1.2.6",
|
||||
"shelljs": "^0.7.0",
|
||||
"stylus": "^0.54.5",
|
||||
"stylus-loader": "^3.0.1",
|
||||
"url-loader": "^0.5.7",
|
||||
"vue-loader": "^13.0.5",
|
||||
"vue-scrollto": "2.11.0",
|
||||
"vue-style-loader": "^3.0.3",
|
||||
"vue-template-compiler": "^2.5.0",
|
||||
"webpack": "^3.6.0",
|
||||
"webpack-dev-middleware": "^1.12.0",
|
||||
"webpack-hot-middleware": "^2.19.1",
|
||||
"webpack-merge": "^4.1.0"
|
||||
"@quasar/app": "^2.1.0",
|
||||
"@quasar/cli": "^1.1.0",
|
||||
"@quasar/quasar-app-extension-testing": "^1.0.0",
|
||||
"@quasar/quasar-app-extension-testing-unit-jest": "^1.0.1",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-standard": "^14.1.0",
|
||||
"eslint-loader": "^3.0.3",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^6.1.2",
|
||||
"parseuri": "^0.0.6"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 10 Chrome versions",
|
||||
"last 10 Firefox versions",
|
||||
"last 4 Edge versions",
|
||||
"last 7 Safari versions",
|
||||
"last 8 Android versions",
|
||||
"last 8 ChromeAndroid versions",
|
||||
"last 8 FirefoxAndroid versions",
|
||||
"last 10 iOS versions",
|
||||
"last 5 Opera versions"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.18.1",
|
||||
"npm": ">= 6.13.4",
|
||||
"yarn": ">= 1.21.1"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,17 @@
|
||||
|
||||
self.addEventListener('notificationclick', function (event) {
|
||||
event.notification.close()
|
||||
var promiseChain = clients.matchAll({
|
||||
type: 'window',
|
||||
includeUncontrolled: true
|
||||
}).then((windowClients) => {
|
||||
var matchingClient = null
|
||||
for (var i = 0; i < windowClients.length; i++) {
|
||||
var windowClient = windowClients[i]
|
||||
if (windowClient.url === event.notification.data.url) {
|
||||
return windowClient.focus()
|
||||
}
|
||||
}
|
||||
})
|
||||
event.waitUntil(promiseChain)
|
||||
})
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* This file runs in a Node context (it's NOT transpiled by Babel), so use only
|
||||
* the ES6 features that are supported by your Node version. https://node.green/
|
||||
*/
|
||||
|
||||
// Configuration for your app
|
||||
// https://quasar.dev/quasar-cli/quasar-conf-js
|
||||
/* eslint-env node */
|
||||
|
||||
module.exports = function (/* ctx */) {
|
||||
return {
|
||||
// https://quasar.dev/quasar-cli/supporting-ts
|
||||
supportTS: false,
|
||||
|
||||
// https://quasar.dev/quasar-cli/prefetch-feature
|
||||
// preFetch: true,
|
||||
|
||||
// app boot file (/src/boot)
|
||||
// --> boot files are part of "main.js"
|
||||
// https://quasar.dev/quasar-cli/boot-files
|
||||
boot: [
|
||||
'config',
|
||||
'filters',
|
||||
'vuelidate',
|
||||
'i18n',
|
||||
// 'axios',
|
||||
'vue-resource',
|
||||
'routes',
|
||||
'components',
|
||||
'vue-scrollto',
|
||||
'constants'
|
||||
],
|
||||
|
||||
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
|
||||
css: [
|
||||
'app.fonts.styl',
|
||||
'app.common.styl',
|
||||
'app.styl'
|
||||
],
|
||||
|
||||
// https://github.com/quasarframework/quasar/tree/dev/extras
|
||||
extras: [
|
||||
// 'ionicons-v4',
|
||||
// 'mdi-v5',
|
||||
'fontawesome-v5',
|
||||
// 'eva-icons',
|
||||
// 'themify',
|
||||
// 'line-awesome',
|
||||
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
|
||||
|
||||
'roboto-font', // optional, you are not bound to it
|
||||
'material-icons' // optional, you are not bound to it
|
||||
],
|
||||
|
||||
// Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build
|
||||
build: {
|
||||
vueRouterMode: 'hash', // available values: 'hash', 'history'
|
||||
|
||||
// transpile: false,
|
||||
|
||||
// Add dependencies for transpiling with Babel (Array of string/regex)
|
||||
// (from node_modules, which are by default not transpiled).
|
||||
// Applies only if "transpile" is set to true.
|
||||
// transpileDependencies: [],
|
||||
|
||||
// rtl: false, // https://quasar.dev/options/rtl-support
|
||||
// preloadChunks: true,
|
||||
// showProgress: false,
|
||||
// gzip: true,
|
||||
// analyze: true,
|
||||
|
||||
// Options below are automatically set depending on the env, set them if you want to override
|
||||
// extractCSS: false,
|
||||
|
||||
// https://quasar.dev/quasar-cli/handling-webpack
|
||||
extendWebpack (cfg) {
|
||||
cfg.module.rules.push({
|
||||
enforce: 'pre',
|
||||
test: /\.(js|vue)$/,
|
||||
loader: 'eslint-loader',
|
||||
exclude: /node_modules/
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-devServer
|
||||
devServer: {
|
||||
https: false,
|
||||
port: 8080,
|
||||
open: true // opens browser window automatically
|
||||
},
|
||||
|
||||
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-framework
|
||||
framework: {
|
||||
iconSet: 'material-icons', // Quasar icon set
|
||||
lang: 'en-us', // Quasar language pack
|
||||
config: {},
|
||||
|
||||
// Possible values for "importStrategy":
|
||||
// * 'auto' - (DEFAULT) Auto-import needed Quasar components & directives
|
||||
// * 'all' - Manually specify what to import
|
||||
importStrategy: 'auto',
|
||||
|
||||
// For special cases outside of where "auto" importStrategy can have an impact
|
||||
// (like functional components as one of the examples),
|
||||
// you can manually specify Quasar components/directives to be available everywhere:
|
||||
//
|
||||
// components: [],
|
||||
// directives: [],
|
||||
|
||||
// Quasar plugins
|
||||
plugins: [
|
||||
'Notify',
|
||||
'Dialog',
|
||||
'SessionStorage',
|
||||
'LocalStorage',
|
||||
'Dark'
|
||||
]
|
||||
},
|
||||
|
||||
// animations: 'all', // --- includes all animations
|
||||
// https://quasar.dev/options/animations
|
||||
animations: [],
|
||||
|
||||
// https://quasar.dev/quasar-cli/developing-ssr/configuring-ssr
|
||||
ssr: {
|
||||
pwa: false
|
||||
},
|
||||
|
||||
// https://quasar.dev/quasar-cli/developing-pwa/configuring-pwa
|
||||
pwa: {
|
||||
workboxPluginMode: 'GenerateSW', // 'GenerateSW' or 'InjectManifest'
|
||||
workboxOptions: {}, // only for GenerateSW
|
||||
manifest: {
|
||||
name: 'Customer Self-Care Web Interface',
|
||||
short_name: 'Customer Self-Care Web Interface',
|
||||
description: 'A Quasar Framework app',
|
||||
display: 'standalone',
|
||||
orientation: 'portrait',
|
||||
background_color: '#ffffff',
|
||||
theme_color: '#027be3',
|
||||
icons: [
|
||||
{
|
||||
src: 'icons/icon-128x128.png',
|
||||
sizes: '128x128',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'icons/icon-192x192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'icons/icon-256x256.png',
|
||||
sizes: '256x256',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'icons/icon-384x384.png',
|
||||
sizes: '384x384',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'icons/icon-512x512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// Full list of options: https://quasar.dev/quasar-cli/developing-cordova-apps/configuring-cordova
|
||||
cordova: {
|
||||
// noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
|
||||
},
|
||||
|
||||
// Full list of options: https://quasar.dev/quasar-cli/developing-capacitor-apps/configuring-capacitor
|
||||
capacitor: {
|
||||
hideSplashscreen: true
|
||||
},
|
||||
|
||||
// Full list of options: https://quasar.dev/quasar-cli/developing-electron-apps/configuring-electron
|
||||
electron: {
|
||||
bundler: 'packager', // 'packager' or 'builder'
|
||||
|
||||
packager: {
|
||||
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
|
||||
|
||||
// OS X / Mac App Store
|
||||
// appBundleId: '',
|
||||
// appCategoryType: '',
|
||||
// osxSign: '',
|
||||
// protocol: 'myapp://path',
|
||||
|
||||
// Windows only
|
||||
// win32metadata: { ... }
|
||||
},
|
||||
|
||||
builder: {
|
||||
// https://www.electron.build/configuration/configuration
|
||||
|
||||
appId: 'ngcp-csc-ui'
|
||||
},
|
||||
|
||||
// More info: https://quasar.dev/quasar-cli/developing-electron-apps/node-integration
|
||||
nodeIntegration: true,
|
||||
|
||||
extendWebpack (/* cfg */) {
|
||||
// do something with Electron main process Webpack cfg
|
||||
// chainWebpack also available besides this extendWebpack
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"@quasar/testing": {
|
||||
"harnesses": [
|
||||
"unit-jest"
|
||||
]
|
||||
},
|
||||
"@quasar/testing-unit-jest": {
|
||||
"babel": "babelrc",
|
||||
"options": [
|
||||
"scripts",
|
||||
"SFC"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"unit-jest": {
|
||||
"runnerCommand": "jest"
|
||||
}
|
||||
}
|
@ -1,223 +1,219 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue'
|
||||
|
||||
import {
|
||||
enableBlockIn,
|
||||
disableBlockIn,
|
||||
getPreferences,
|
||||
addToBlockInList,
|
||||
editBlockInList,
|
||||
removeFromBlockInList,
|
||||
enableBlockOut,
|
||||
disableBlockOut,
|
||||
addToBlockOutList,
|
||||
editBlockOutList,
|
||||
removeFromBlockOutList,
|
||||
enablePrivacy,
|
||||
disablePrivacy
|
||||
} from './subscriber';
|
||||
|
||||
export function enableIncomingCallBlocking(id) {
|
||||
return enableBlockIn(id);
|
||||
}
|
||||
|
||||
export function disableIncomingCallBlocking(id) {
|
||||
return disableBlockIn(id);
|
||||
}
|
||||
|
||||
export function getIncomingCallBlocking(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getPreferences(id).then((result)=>{
|
||||
resolve({
|
||||
enabled: result.block_in_mode,
|
||||
list: result.block_in_list,
|
||||
blockAnonymous: result.block_in_clir
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function addNumberToIncomingList(id, number) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
if(_.isEmpty(number)) {
|
||||
reject(new Error('Number may not be empty'));
|
||||
}
|
||||
else {
|
||||
addToBlockInList(id, number).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function editNumberFromIncomingList(id, index, number) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
editBlockInList(id, index, number).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeNumberFromIncomingList(id, index) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
removeFromBlockInList(id, index).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function enableOutgoingCallBlocking(id) {
|
||||
return enableBlockOut(id);
|
||||
}
|
||||
|
||||
export function disableOutgoingCallBlocking(id) {
|
||||
return disableBlockOut(id);
|
||||
}
|
||||
|
||||
export function getOutgoingCallBlocking(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getPreferences(id).then((result)=>{
|
||||
resolve({
|
||||
enabled: result.block_out_mode,
|
||||
list: result.block_out_list
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function addNumberToOutgoingList(id, number) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
if(_.isEmpty(number)) {
|
||||
reject(new Error('Number may not be empty'));
|
||||
}
|
||||
else {
|
||||
addToBlockOutList(id, number).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function editNumberFromOutgoingList(id, index, number) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
editBlockOutList(id, index, number).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeNumberFromOutgoingList(id, index) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
removeFromBlockOutList(id, index).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function enablePrivacyCallBlocking(id) {
|
||||
return enablePrivacy(id);
|
||||
}
|
||||
|
||||
export function disablePrivacyCallBlocking(id) {
|
||||
return disablePrivacy(id);
|
||||
}
|
||||
|
||||
export function getPrivacyCallBlocking(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getPreferences(id).then((result)=>{
|
||||
resolve(result.clir);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeNumberFromList(id, field, value) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return getPreferences(id);
|
||||
}).then((result)=>{
|
||||
var prefs = _.cloneDeep(result);
|
||||
delete prefs._links;
|
||||
prefs[field] = _.get(prefs, field, []).filter((number) => {
|
||||
return number !== value;
|
||||
});
|
||||
return Vue.http.put('api/subscriberpreferences/' + id, prefs);
|
||||
}).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeFromIncomingListByNumber(id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeNumberFromList(id, 'block_in_list', number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeFromOutgoingListByNumber(id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeNumberFromList(id, 'block_out_list', number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function toggleNumberInBothLists(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getPreferences(options.id);
|
||||
}).then((result) => {
|
||||
let prefs = _.cloneDeep(result);
|
||||
delete prefs._links;
|
||||
prefs['block_in_list'] = _.get(prefs, 'block_in_list', []);
|
||||
prefs['block_out_list'] = _.get(prefs, 'block_out_list', []);
|
||||
if (options.block_in_list === 'add') {
|
||||
prefs['block_in_list'] = [options.number].concat(prefs['block_in_list']);
|
||||
}
|
||||
else if (options.block_in_list === 'remove') {
|
||||
prefs['block_in_list'] = prefs['block_in_list'].filter((number) => {
|
||||
return number !== options.number;
|
||||
});
|
||||
}
|
||||
if (options.block_out_list === 'add') {
|
||||
prefs['block_out_list'] = [options.number].concat(prefs['block_out_list']);
|
||||
}
|
||||
else if (options.block_out_list === 'remove') {
|
||||
prefs['block_out_list'] = prefs['block_out_list'].filter((number) => {
|
||||
return number !== options.number;
|
||||
});
|
||||
}
|
||||
return Vue.http.put('api/subscriberpreferences/' + options.id, prefs);
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
enableBlockIn,
|
||||
disableBlockIn,
|
||||
getPreferences,
|
||||
addToBlockInList,
|
||||
editBlockInList,
|
||||
removeFromBlockInList,
|
||||
enableBlockOut,
|
||||
disableBlockOut,
|
||||
addToBlockOutList,
|
||||
editBlockOutList,
|
||||
removeFromBlockOutList,
|
||||
enablePrivacy,
|
||||
disablePrivacy
|
||||
} from './subscriber'
|
||||
|
||||
export function enableIncomingCallBlocking (id) {
|
||||
return enableBlockIn(id)
|
||||
}
|
||||
|
||||
export function disableIncomingCallBlocking (id) {
|
||||
return disableBlockIn(id)
|
||||
}
|
||||
|
||||
export function getIncomingCallBlocking (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getPreferences(id).then((result) => {
|
||||
resolve({
|
||||
enabled: result.block_in_mode,
|
||||
list: result.block_in_list,
|
||||
blockAnonymous: result.block_in_clir
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function addNumberToIncomingList (id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (_.isEmpty(number)) {
|
||||
reject(new Error('Number may not be empty'))
|
||||
} else {
|
||||
addToBlockInList(id, number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function editNumberFromIncomingList (id, index, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
editBlockInList(id, index, number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeNumberFromIncomingList (id, index) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeFromBlockInList(id, index).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function enableOutgoingCallBlocking (id) {
|
||||
return enableBlockOut(id)
|
||||
}
|
||||
|
||||
export function disableOutgoingCallBlocking (id) {
|
||||
return disableBlockOut(id)
|
||||
}
|
||||
|
||||
export function getOutgoingCallBlocking (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getPreferences(id).then((result) => {
|
||||
resolve({
|
||||
enabled: result.block_out_mode,
|
||||
list: result.block_out_list
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function addNumberToOutgoingList (id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (_.isEmpty(number)) {
|
||||
reject(new Error('Number may not be empty'))
|
||||
} else {
|
||||
addToBlockOutList(id, number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function editNumberFromOutgoingList (id, index, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
editBlockOutList(id, index, number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeNumberFromOutgoingList (id, index) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeFromBlockOutList(id, index).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function enablePrivacyCallBlocking (id) {
|
||||
return enablePrivacy(id)
|
||||
}
|
||||
|
||||
export function disablePrivacyCallBlocking (id) {
|
||||
return disablePrivacy(id)
|
||||
}
|
||||
|
||||
export function getPrivacyCallBlocking (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getPreferences(id).then((result) => {
|
||||
resolve(result.clir)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeNumberFromList (id, field, value) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getPreferences(id)
|
||||
}).then((result) => {
|
||||
var prefs = _.cloneDeep(result)
|
||||
delete prefs._links
|
||||
prefs[field] = _.get(prefs, field, []).filter((number) => {
|
||||
return number !== value
|
||||
})
|
||||
return Vue.http.put('api/subscriberpreferences/' + id, prefs)
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeFromIncomingListByNumber (id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeNumberFromList(id, 'block_in_list', number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeFromOutgoingListByNumber (id, number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
removeNumberFromList(id, 'block_out_list', number).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function toggleNumberInBothLists (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getPreferences(options.id)
|
||||
}).then((result) => {
|
||||
const prefs = _.cloneDeep(result)
|
||||
delete prefs._links
|
||||
prefs.block_in_list = _.get(prefs, 'block_in_list', [])
|
||||
prefs.block_out_list = _.get(prefs, 'block_out_list', [])
|
||||
if (options.block_in_list === 'add') {
|
||||
prefs.block_in_list = [options.number].concat(prefs.block_in_list)
|
||||
} else if (options.block_in_list === 'remove') {
|
||||
prefs.block_in_list = prefs.block_in_list.filter((number) => {
|
||||
return number !== options.number
|
||||
})
|
||||
}
|
||||
if (options.block_out_list === 'add') {
|
||||
prefs.block_out_list = [options.number].concat(prefs.block_out_list)
|
||||
} else if (options.block_out_list === 'remove') {
|
||||
prefs.block_out_list = prefs.block_out_list.filter((number) => {
|
||||
return number !== options.number
|
||||
})
|
||||
}
|
||||
return Vue.http.put('api/subscriberpreferences/' + options.id, prefs)
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,228 +1,223 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
getJsonBody
|
||||
} from './utils';
|
||||
getJsonBody
|
||||
} from './utils'
|
||||
|
||||
export const LIST_DEFAULT_PAGE = 1;
|
||||
export const LIST_DEFAULT_ROWS = 25;
|
||||
export const LIST_ALL_ROWS = 1000;
|
||||
export const LIST_DEFAULT_PAGE = 1
|
||||
export const LIST_DEFAULT_ROWS = 25
|
||||
export const LIST_ALL_ROWS = 1000
|
||||
|
||||
const PATCH_HEADERS = {
|
||||
'Content-Type': 'application/json-patch+json',
|
||||
'Prefer': 'return=minimal'
|
||||
};
|
||||
'Content-Type': 'application/json-patch+json',
|
||||
Prefer: 'return=minimal'
|
||||
}
|
||||
|
||||
const GET_HEADERS = {
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
Accept: 'application/json'
|
||||
}
|
||||
|
||||
export class ApiResponseError extends Error {
|
||||
constructor (code, message) {
|
||||
super()
|
||||
this.code = code
|
||||
this.status = code
|
||||
this.message = message
|
||||
}
|
||||
}
|
||||
|
||||
export function getList (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge({
|
||||
all: false,
|
||||
params: {
|
||||
page: LIST_DEFAULT_PAGE,
|
||||
rows: LIST_DEFAULT_ROWS
|
||||
},
|
||||
headers: GET_HEADERS
|
||||
}, options)
|
||||
Promise.resolve().then(() => {
|
||||
if (options.all === true) {
|
||||
options.params.rows = LIST_ALL_ROWS
|
||||
}
|
||||
return Vue.http.get(options.path, {
|
||||
params: options.params,
|
||||
headers: options.headers
|
||||
})
|
||||
}).then((res) => {
|
||||
const body = getJsonBody(res.body)
|
||||
if (options.all === true && body.total_count > LIST_ALL_ROWS) {
|
||||
return Vue.http.get(options.path, {
|
||||
params: _.merge(options.params, {
|
||||
rows: body.total_count
|
||||
}),
|
||||
headers: options.headers
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve(res)
|
||||
}
|
||||
}).then((res) => {
|
||||
const body = getJsonBody(res.body)
|
||||
const totalCount = _.get(body, 'total_count', 0)
|
||||
let lastPage = Math.ceil(totalCount / options.params.rows)
|
||||
if (options.all === true) {
|
||||
lastPage = 1
|
||||
}
|
||||
if (lastPage === 0) {
|
||||
lastPage = null
|
||||
}
|
||||
const items = _.get(body, options.root, [])
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
items[i] = normalizeEntity(items[i])
|
||||
}
|
||||
resolve({
|
||||
items: items,
|
||||
lastPage: lastPage
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function get (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge({
|
||||
headers: GET_HEADERS
|
||||
}, options)
|
||||
const requestOptions = {
|
||||
headers: options.headers,
|
||||
params: options.params
|
||||
}
|
||||
if (options.blob === true) {
|
||||
requestOptions.responseType = 'blob'
|
||||
}
|
||||
return Vue.http.get(options.path, requestOptions).then((result) => {
|
||||
let body = null
|
||||
if (options.blob === true) {
|
||||
body = URL.createObjectURL(result.body)
|
||||
} else {
|
||||
body = normalizeEntity(getJsonBody(result.body))
|
||||
}
|
||||
resolve(body)
|
||||
}).catch((err) => {
|
||||
const code = _.get(err, 'body.code', null)
|
||||
const message = _.get(err, 'body.message', null)
|
||||
if (code !== null && message !== null) {
|
||||
reject(new ApiResponseError(err.body.code, err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function patch (operation, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge({
|
||||
headers: PATCH_HEADERS
|
||||
}, options)
|
||||
const body = {
|
||||
op: operation,
|
||||
path: '/' + options.fieldPath
|
||||
}
|
||||
if (options.value !== undefined) {
|
||||
body.value = options.value
|
||||
}
|
||||
Vue.http.patch(options.path, [body], {
|
||||
headers: options.headers
|
||||
}).then((result) => {
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
const code = _.get(err, 'body.code', null)
|
||||
const message = _.get(err, 'body.message', null)
|
||||
if (code !== null && message !== null) {
|
||||
reject(new ApiResponseError(err.body.code, err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function patchReplace (options) {
|
||||
return patch('replace', options)
|
||||
}
|
||||
|
||||
export function patchAdd (options) {
|
||||
return patch('add', options)
|
||||
}
|
||||
|
||||
export function patchRemove (options) {
|
||||
return patch('remove', options)
|
||||
}
|
||||
|
||||
export function patchFull (operation, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
headers: {
|
||||
Prefer: 'return=representation'
|
||||
}
|
||||
})
|
||||
patch(operation, options).then((result) => {
|
||||
resolve(getJsonBody(result.body))
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function patchReplaceFull (options) {
|
||||
return patchFull('replace', options)
|
||||
}
|
||||
|
||||
export function patchAddFull (options) {
|
||||
return patchFull('add', options)
|
||||
}
|
||||
|
||||
export function patchRemoveFull (options) {
|
||||
return patchFull('remove', options)
|
||||
}
|
||||
|
||||
export function getFieldList (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge({
|
||||
headers: GET_HEADERS
|
||||
}, options)
|
||||
Vue.http.get(options.path, {
|
||||
headers: options.headers
|
||||
}).then((result) => {
|
||||
const fieldList = getJsonBody(result.body)[options.field]
|
||||
resolve(fieldList)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function normalizeEntity (entity) {
|
||||
if (entity && entity._links) {
|
||||
delete entity._links
|
||||
}
|
||||
return entity
|
||||
}
|
||||
|
||||
constructor(code, message) {
|
||||
super();
|
||||
this.code = code;
|
||||
this.status = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
export function getList(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {};
|
||||
options = _.merge({
|
||||
all: false,
|
||||
params: {
|
||||
page: LIST_DEFAULT_PAGE,
|
||||
rows: LIST_DEFAULT_ROWS
|
||||
},
|
||||
headers: GET_HEADERS
|
||||
}, options);
|
||||
Promise.resolve().then(() => {
|
||||
if(options.all === true) {
|
||||
options.params.rows = LIST_ALL_ROWS;
|
||||
}
|
||||
return Vue.http.get(options.path, {
|
||||
params: options.params,
|
||||
headers: options.headers
|
||||
});
|
||||
}).then((res) => {
|
||||
let body = getJsonBody(res.body);
|
||||
if(options.all === true && body.total_count > LIST_ALL_ROWS) {
|
||||
return Vue.http.get(options.path, {
|
||||
params: _.merge(options.params, {
|
||||
rows: body.total_count
|
||||
}),
|
||||
headers: options.headers
|
||||
});
|
||||
}
|
||||
else {
|
||||
return Promise.resolve(res);
|
||||
}
|
||||
}).then((res) => {
|
||||
let body = getJsonBody(res.body);
|
||||
let totalCount = _.get(body, 'total_count', 0);
|
||||
let lastPage = Math.ceil( totalCount / options.params.rows );
|
||||
if(options.all === true) {
|
||||
lastPage = 1;
|
||||
}
|
||||
if(lastPage === 0) {
|
||||
lastPage = null;
|
||||
}
|
||||
let items = _.get(body, options.root, []);
|
||||
for(let i = 0; i < items.length; i++) {
|
||||
items[i] = normalizeEntity(items[i]);
|
||||
}
|
||||
resolve({
|
||||
items: items,
|
||||
lastPage: lastPage
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function get(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {};
|
||||
options = _.merge({
|
||||
headers: GET_HEADERS
|
||||
}, options);
|
||||
let requestOptions ={
|
||||
headers: options.headers,
|
||||
params: options.params
|
||||
};
|
||||
if(options.blob === true) {
|
||||
requestOptions.responseType = 'blob';
|
||||
}
|
||||
return Vue.http.get(options.path, requestOptions).then((result) => {
|
||||
let body = null;
|
||||
if(options.blob === true) {
|
||||
body = URL.createObjectURL(result.body);
|
||||
}
|
||||
else {
|
||||
body = normalizeEntity(getJsonBody(result.body));
|
||||
}
|
||||
resolve(body);
|
||||
}).catch((err) => {
|
||||
let code = _.get(err, 'body.code', null);
|
||||
let message = _.get(err, 'body.message', null);
|
||||
if(code !== null && message !== null) {
|
||||
reject(new ApiResponseError(err.body.code, err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function patch(operation, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {};
|
||||
options = _.merge({
|
||||
headers: PATCH_HEADERS
|
||||
}, options);
|
||||
let body = {
|
||||
op: operation,
|
||||
path: '/'+ options.fieldPath
|
||||
};
|
||||
if(options.value !== void(0)) {
|
||||
body.value = options.value;
|
||||
}
|
||||
Vue.http.patch(options.path, [body], {
|
||||
headers: options.headers
|
||||
}).then((result) => {
|
||||
resolve(result);
|
||||
}).catch((err) => {
|
||||
let code = _.get(err, 'body.code', null);
|
||||
let message = _.get(err, 'body.message', null);
|
||||
if(code !== null && message !== null) {
|
||||
reject(new ApiResponseError(err.body.code, err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function patchReplace(options) {
|
||||
return patch('replace', options);
|
||||
}
|
||||
|
||||
export function patchAdd(options) {
|
||||
return patch('add', options);
|
||||
}
|
||||
|
||||
export function patchRemove(options) {
|
||||
return patch('remove', options);
|
||||
}
|
||||
|
||||
export function patchFull(operation, options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
headers: {
|
||||
Prefer: 'return=representation'
|
||||
}
|
||||
});
|
||||
patch(operation, options).then((result)=>{
|
||||
resolve(getJsonBody(result.body));
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function patchReplaceFull(options) {
|
||||
return patchFull('replace', options);
|
||||
}
|
||||
|
||||
export function patchAddFull(options) {
|
||||
return patchFull('add', options);
|
||||
}
|
||||
|
||||
export function patchRemoveFull(options) {
|
||||
return patchFull('remove', options);
|
||||
}
|
||||
|
||||
export function getFieldList(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {};
|
||||
options = _.merge({
|
||||
headers: GET_HEADERS
|
||||
}, options);
|
||||
Vue.http.get(options.path, {
|
||||
headers: options.headers
|
||||
}).then((result) => {
|
||||
let fieldList = getJsonBody(result.body)[options.field];
|
||||
resolve(fieldList);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function normalizeEntity(entity) {
|
||||
if(entity && entity._links) {
|
||||
delete entity._links;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
export function getAsBlob(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
blob: true
|
||||
});
|
||||
get(options).then((body)=>{
|
||||
resolve(body);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getAsBlob (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
blob: true
|
||||
})
|
||||
get(options).then((body) => {
|
||||
resolve(body)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue'
|
||||
|
||||
export function createFax(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var formData = new FormData();
|
||||
var fields = _.clone(options);
|
||||
delete fields.file;
|
||||
var json = JSON.stringify(fields);
|
||||
formData.append('json', json);
|
||||
if (options.file) {
|
||||
formData.append('faxfile', options.file);
|
||||
}
|
||||
Vue.http.post('api/faxes/', formData).then(() => {
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createFax (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var formData = new FormData()
|
||||
var fields = _.clone(options)
|
||||
delete fields.file
|
||||
var json = JSON.stringify(fields)
|
||||
formData.append('json', json)
|
||||
if (options.file) {
|
||||
formData.append('faxfile', options.file)
|
||||
}
|
||||
Vue.http.post('api/faxes/', formData).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,114 +1,106 @@
|
||||
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
saveAs
|
||||
saveAs
|
||||
} from 'file-saver'
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
getIncomingCallBlocking,
|
||||
getOutgoingCallBlocking
|
||||
getIncomingCallBlocking,
|
||||
getOutgoingCallBlocking
|
||||
} from './call-blocking'
|
||||
import {
|
||||
getList
|
||||
getList
|
||||
} from './common'
|
||||
|
||||
export function getConversations(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let type = _.get(options, 'type', null);
|
||||
let from = _.get(options, 'from', null);
|
||||
let to = _.get(options, 'to', null);
|
||||
let params ={
|
||||
subscriber_id: _.get(options, 'subscriberId'),
|
||||
order_by: _.get(options, 'order_by', 'timestamp'),
|
||||
order_by_direction: 'desc',
|
||||
no_count: true,
|
||||
tz: 'UTC',
|
||||
page: _.get(options, 'page', 1),
|
||||
rows: _.get(options, 'rows', 25)
|
||||
};
|
||||
if (type !== null) {
|
||||
params.type = type;
|
||||
}
|
||||
if (from !== null){
|
||||
params.from = from;
|
||||
}
|
||||
if (to !== null){
|
||||
params.to = to;
|
||||
}
|
||||
getList({
|
||||
path: 'api/conversations/',
|
||||
root: '_embedded.ngcp:conversations',
|
||||
params: params,
|
||||
all: false
|
||||
}).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getConversations (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const type = _.get(options, 'type', null)
|
||||
const params = {
|
||||
subscriber_id: _.get(options, 'subscriberId'),
|
||||
order_by: _.get(options, 'order_by', 'timestamp'),
|
||||
order_by_direction: 'desc',
|
||||
no_count: true,
|
||||
tz: 'UTC',
|
||||
page: _.get(options, 'page', 1),
|
||||
rows: _.get(options, 'rows', 25)
|
||||
}
|
||||
if (type !== null) {
|
||||
params.type = type
|
||||
}
|
||||
getList({
|
||||
path: 'api/conversations/',
|
||||
root: '_embedded.ngcp:conversations',
|
||||
params: params,
|
||||
all: false
|
||||
}).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function downloadVoiceMail(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.get('api/voicemailrecordings/' + id, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
return res.blob();
|
||||
}).then(voicemail => {
|
||||
saveAs((voicemail), "voicemail-" + id + '.wav');
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function downloadVoiceMail (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.get('api/voicemailrecordings/' + id, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
return res.blob()
|
||||
}).then(voicemail => {
|
||||
saveAs((voicemail), 'voicemail-' + id + '.wav')
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function downloadFax(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.get('api/faxrecordings/' + id, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
return res.blob();
|
||||
}).then(fax => {
|
||||
saveAs((fax), "fax-" + id + '.tif');
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function downloadFax (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.get('api/faxrecordings/' + id, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
return res.blob()
|
||||
}).then(fax => {
|
||||
saveAs((fax), 'fax-' + id + '.tif')
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function playVoiceMail(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let params = { format: options.format };
|
||||
Vue.http.get(`api/voicemailrecordings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body));
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function playVoiceMail (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = { format: options.format }
|
||||
Vue.http.get(`api/voicemailrecordings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body))
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getIncomingBlocked(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getIncomingCallBlocking(id).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getIncomingBlocked (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getIncomingCallBlocking(id).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getOutgoingBlocked(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getOutgoingCallBlocking(id).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getOutgoingBlocked (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getOutgoingCallBlocking(id).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteVoicemail(id) {
|
||||
const res = await Vue.http.delete('api/voicemails/' + id)
|
||||
return res.status >= 200
|
||||
export async function deleteVoicemail (id) {
|
||||
const res = await Vue.http.delete('api/voicemails/' + id)
|
||||
return res.status >= 200
|
||||
}
|
||||
|
@ -1,235 +1,233 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
getSubscribers
|
||||
} from './subscriber';
|
||||
import uuid from 'uuid';
|
||||
getSubscribers
|
||||
} from './subscriber'
|
||||
import uuid from 'uuid'
|
||||
import {
|
||||
getList,
|
||||
get,
|
||||
patchAdd,
|
||||
patchRemove
|
||||
getList,
|
||||
get,
|
||||
patchAdd,
|
||||
patchRemove
|
||||
} from './common'
|
||||
|
||||
export const createId = uuid.v4;
|
||||
export const PBX_CONFIG_ORDER_BY = 'create_timestamp';
|
||||
export const PBX_CONFIG_ORDER_DIRECTION = 'desc';
|
||||
|
||||
export function getPilot(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 0,
|
||||
is_pbx_pilot: 1,
|
||||
rows: 1
|
||||
}
|
||||
});
|
||||
getSubscribers(options).then((subscribers)=>{
|
||||
if (subscribers.items.length === 1) {
|
||||
resolve(subscribers.items[0]);
|
||||
}
|
||||
else {
|
||||
resolve(null);
|
||||
}
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export const createId = uuid.v4
|
||||
export const PBX_CONFIG_ORDER_BY = 'create_timestamp'
|
||||
export const PBX_CONFIG_ORDER_DIRECTION = 'desc'
|
||||
|
||||
export function getPilot (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 0,
|
||||
is_pbx_pilot: 1,
|
||||
rows: 1
|
||||
}
|
||||
})
|
||||
getSubscribers(options).then((subscribers) => {
|
||||
if (subscribers.items.length === 1) {
|
||||
resolve(subscribers.items[0])
|
||||
} else {
|
||||
resolve(null)
|
||||
}
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getProfiles(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/pbxdeviceprofiles/',
|
||||
root: '_embedded.ngcp:pbxdeviceprofiles'
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getProfiles (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/pbxdeviceprofiles/',
|
||||
root: '_embedded.ngcp:pbxdeviceprofiles'
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getAllProfiles() {
|
||||
return getProfiles({
|
||||
all: true
|
||||
});
|
||||
export function getAllProfiles () {
|
||||
return getProfiles({
|
||||
all: true
|
||||
})
|
||||
}
|
||||
|
||||
export function getModel(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return get({
|
||||
path: 'api/pbxdevicemodels/' + id
|
||||
});
|
||||
}).then((model)=> {
|
||||
resolve(model);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getModel (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return get({
|
||||
path: 'api/pbxdevicemodels/' + id
|
||||
})
|
||||
}).then((model) => {
|
||||
resolve(model)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getModelFrontImage(id) {
|
||||
return new Promise((resolve)=>{
|
||||
Vue.http.get('api/pbxdevicemodelimages/' + id, {
|
||||
responseType: 'blob',
|
||||
params: {
|
||||
type: 'front'
|
||||
}
|
||||
}).then((res)=>{
|
||||
resolve({
|
||||
id: id,
|
||||
url: URL.createObjectURL(res.body),
|
||||
blob: res.body
|
||||
});
|
||||
}).catch(()=>{
|
||||
resolve({
|
||||
id: id,
|
||||
url: null,
|
||||
blob: null
|
||||
});
|
||||
});
|
||||
});
|
||||
export function getModelFrontImage (id) {
|
||||
return new Promise((resolve) => {
|
||||
Vue.http.get('api/pbxdevicemodelimages/' + id, {
|
||||
responseType: 'blob',
|
||||
params: {
|
||||
type: 'front'
|
||||
}
|
||||
}).then((res) => {
|
||||
resolve({
|
||||
id: id,
|
||||
url: URL.createObjectURL(res.body),
|
||||
blob: res.body
|
||||
})
|
||||
}).catch(() => {
|
||||
resolve({
|
||||
id: id,
|
||||
url: null,
|
||||
blob: null
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getAllSoundSets(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundsets/',
|
||||
root: '_embedded.ngcp:soundsets',
|
||||
all: true
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getAllSoundSets (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundsets/',
|
||||
root: '_embedded.ngcp:soundsets',
|
||||
all: true
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeSoundSet(id) {
|
||||
return Vue.http.delete('api/soundsets/' + id);
|
||||
export function removeSoundSet (id) {
|
||||
return Vue.http.delete('api/soundsets/' + id)
|
||||
}
|
||||
|
||||
export function getSoundSet(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
get({
|
||||
path: 'api/soundsets/' + id
|
||||
}).then((soundSet)=>{
|
||||
resolve(soundSet);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getSoundSet (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: 'api/soundsets/' + id
|
||||
}).then((soundSet) => {
|
||||
resolve(soundSet)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function editSoundSetFields(id, fields) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return getSoundSet(id);
|
||||
}).then((result)=>{
|
||||
let prefs = Object.assign(result, fields);
|
||||
delete fields._links;
|
||||
return Vue.http.put('api/soundsets/' + id, prefs);
|
||||
}).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function editSoundSetFields (id, fields) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getSoundSet(id)
|
||||
}).then((result) => {
|
||||
const prefs = Object.assign(result, fields)
|
||||
delete fields._links
|
||||
return Vue.http.put('api/soundsets/' + id, prefs)
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createSoundSet(soundSet) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.post('api/soundsets/', soundSet).then(() => {
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createSoundSet (soundSet) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.post('api/soundsets/', soundSet).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setSoundSetName(id, value) {
|
||||
return editSoundSetFields(id, { name: value });
|
||||
export function setSoundSetName (id, value) {
|
||||
return editSoundSetFields(id, { name: value })
|
||||
}
|
||||
|
||||
export function setSoundSetDescription(id, value) {
|
||||
return editSoundSetFields(id, { description: value });
|
||||
export function setSoundSetDescription (id, value) {
|
||||
return editSoundSetFields(id, { description: value })
|
||||
}
|
||||
|
||||
export function playSoundFile(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let params = { format: options.format };
|
||||
Vue.http.get(`api/soundfilerecordings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body));
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function playSoundFile (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = { format: options.format }
|
||||
Vue.http.get(`api/soundfilerecordings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body))
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadSoundFile(options, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let formData = new FormData();
|
||||
let loopplay = options.item.loopplay ? 1 : 2;
|
||||
let fields = {
|
||||
loopplay: loopplay,
|
||||
filename: options.file.name,
|
||||
set_id: options.item.set_id,
|
||||
handle: options.item.handle,
|
||||
};
|
||||
let json = JSON.stringify(fields);
|
||||
let requestKey = `previous-${options.item.handle}-request`;
|
||||
formData.append('json', json);
|
||||
if (options.file) {
|
||||
formData.append('soundfile', options.file);
|
||||
}
|
||||
Vue.http.post('api/soundfiles/', formData, {
|
||||
before(request) {
|
||||
Vue[requestKey] = request;
|
||||
},
|
||||
progress(e) {
|
||||
if (e.lengthComputable) {
|
||||
onProgress(Math.ceil((e.loaded / e.total ) * 100));
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function uploadSoundFile (options, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const formData = new FormData()
|
||||
const loopplay = options.item.loopplay ? 1 : 2
|
||||
const fields = {
|
||||
loopplay: loopplay,
|
||||
filename: options.file.name,
|
||||
set_id: options.item.set_id,
|
||||
handle: options.item.handle
|
||||
}
|
||||
const json = JSON.stringify(fields)
|
||||
const requestKey = `previous-${options.item.handle}-request`
|
||||
formData.append('json', json)
|
||||
if (options.file) {
|
||||
formData.append('soundfile', options.file)
|
||||
}
|
||||
Vue.http.post('api/soundfiles/', formData, {
|
||||
before (request) {
|
||||
Vue[requestKey] = request
|
||||
},
|
||||
progress (e) {
|
||||
if (e.lengthComputable) {
|
||||
onProgress(Math.ceil((e.loaded / e.total) * 100))
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setSubscriberSoundSet(id, soundSet) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let promise;
|
||||
let path = 'api/subscriberpreferences/' + id;
|
||||
let fieldPath = 'contract_sound_set';
|
||||
if(soundSet === null || soundSet === void(0)) {
|
||||
promise = patchRemove({
|
||||
path: path,
|
||||
fieldPath: 'contract_sound_set'
|
||||
});
|
||||
}
|
||||
else {
|
||||
promise = patchAdd({
|
||||
path: path,
|
||||
fieldPath: fieldPath,
|
||||
value: soundSet
|
||||
});
|
||||
}
|
||||
promise.then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setSubscriberSoundSet (id, soundSet) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let promise
|
||||
const path = 'api/subscriberpreferences/' + id
|
||||
const fieldPath = 'contract_sound_set'
|
||||
if (soundSet === null || soundSet === undefined) {
|
||||
promise = patchRemove({
|
||||
path: path,
|
||||
fieldPath: 'contract_sound_set'
|
||||
})
|
||||
} else {
|
||||
promise = patchAdd({
|
||||
path: path,
|
||||
fieldPath: fieldPath,
|
||||
value: soundSet
|
||||
})
|
||||
}
|
||||
promise.then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,183 +1,179 @@
|
||||
import {
|
||||
getModel,
|
||||
getModelFrontImage,
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION
|
||||
} from "./pbx-config";
|
||||
import _ from "lodash";
|
||||
getModel,
|
||||
getModelFrontImage,
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION
|
||||
} from './pbx-config'
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
getList,
|
||||
patchReplace,
|
||||
patchReplaceFull
|
||||
} from "./common";
|
||||
import Vue from "vue";
|
||||
getList,
|
||||
patchReplace,
|
||||
patchReplaceFull
|
||||
} from './common'
|
||||
import Vue from 'vue'
|
||||
|
||||
export function getDevices(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/pbxdevices/',
|
||||
root: '_embedded.ngcp:pbxdevices'
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getDevices (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/pbxdevices/',
|
||||
root: '_embedded.ngcp:pbxdevices'
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getDeviceList(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let params = {
|
||||
page: options.page,
|
||||
profile_id: options.profile_id,
|
||||
identifier: options.identifier,
|
||||
station_name: options.station_name,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
};
|
||||
if (params.profile_id === null || params.profile_id === undefined || params.profile_id === "") {
|
||||
delete params['profile_id'];
|
||||
}
|
||||
if (params.identifier === null || params.identifier === undefined || params.identifier === "") {
|
||||
delete params['identifier'];
|
||||
}
|
||||
else {
|
||||
params.identifier = "*" + params.identifier + "*"
|
||||
}
|
||||
if (params.station_name === null || params.station_name === undefined || params.station_name === "") {
|
||||
delete params['station_name'];
|
||||
}
|
||||
else {
|
||||
params.station_name = "*" + params.station_name + "*"
|
||||
}
|
||||
getDevices({
|
||||
params: params
|
||||
}).then((devices)=>{
|
||||
resolve(devices);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getDeviceList (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = {
|
||||
page: options.page,
|
||||
profile_id: options.profile_id,
|
||||
identifier: options.identifier,
|
||||
station_name: options.station_name,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
}
|
||||
if (params.profile_id === null || params.profile_id === undefined || params.profile_id === '') {
|
||||
delete params.profile_id
|
||||
}
|
||||
if (params.identifier === null || params.identifier === undefined || params.identifier === '') {
|
||||
delete params.identifier
|
||||
} else {
|
||||
params.identifier = '*' + params.identifier + '*'
|
||||
}
|
||||
if (params.station_name === null || params.station_name === undefined || params.station_name === '') {
|
||||
delete params.station_name
|
||||
} else {
|
||||
params.station_name = '*' + params.station_name + '*'
|
||||
}
|
||||
getDevices({
|
||||
params: params
|
||||
}).then((devices) => {
|
||||
resolve(devices)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createDevice(deviceData) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.post('api/pbxdevices/', {
|
||||
station_name: deviceData.stationName,
|
||||
identifier: deviceData.identifier,
|
||||
profile_id: deviceData.profile
|
||||
}).then((res)=>{
|
||||
resolve(res);
|
||||
}).catch((err)=>{
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
export function createDevice (deviceData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.post('api/pbxdevices/', {
|
||||
station_name: deviceData.stationName,
|
||||
identifier: deviceData.identifier,
|
||||
profile_id: deviceData.profile
|
||||
}).then((res) => {
|
||||
resolve(res)
|
||||
}).catch((err) => {
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeDevice(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.delete('api/pbxdevices/' + id).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
export function removeDevice (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.delete('api/pbxdevices/' + id).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setDeviceStationName(deviceId, stationName) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'station_name',
|
||||
value: stationName
|
||||
});
|
||||
}).then((device)=>{
|
||||
resolve(device);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setDeviceStationName (deviceId, stationName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'station_name',
|
||||
value: stationName
|
||||
})
|
||||
}).then((device) => {
|
||||
resolve(device)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setDeviceIdentifier(deviceId, identifier) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'identifier',
|
||||
value: identifier
|
||||
});
|
||||
}).then((device)=>{
|
||||
resolve(device);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setDeviceIdentifier (deviceId, identifier) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'identifier',
|
||||
value: identifier
|
||||
})
|
||||
}).then((device) => {
|
||||
resolve(device)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setDeviceProfile(deviceId, profileId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return patchReplace({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'lines',
|
||||
value: []
|
||||
});
|
||||
}).then(()=>{
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'profile_id',
|
||||
value: profileId
|
||||
});
|
||||
}).then((device)=>{
|
||||
resolve(device);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setDeviceProfile (deviceId, profileId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return patchReplace({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'lines',
|
||||
value: []
|
||||
})
|
||||
}).then(() => {
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'profile_id',
|
||||
value: profileId
|
||||
})
|
||||
}).then((device) => {
|
||||
resolve(device)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setDeviceKeys(deviceId, keys) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'lines',
|
||||
value: keys
|
||||
});
|
||||
}).then((device)=>{
|
||||
resolve(device);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setDeviceKeys (deviceId, keys) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return patchReplaceFull({
|
||||
path: 'api/pbxdevices/' + deviceId,
|
||||
fieldPath: 'lines',
|
||||
value: keys
|
||||
})
|
||||
}).then((device) => {
|
||||
resolve(device)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function loadDeviceModel(modelId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.all([
|
||||
getModel(modelId),
|
||||
getModelFrontImage(modelId)
|
||||
]).then((res)=>{
|
||||
resolve({
|
||||
model: res[0],
|
||||
modelImage: res[1]
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function loadDeviceModel (modelId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.all([
|
||||
getModel(modelId),
|
||||
getModelFrontImage(modelId)
|
||||
]).then((res) => {
|
||||
resolve({
|
||||
model: res[0],
|
||||
modelImage: res[1]
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,281 +1,279 @@
|
||||
import _ from "lodash";
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
createSubscriber,
|
||||
deleteSubscriber,
|
||||
getFullSubscribers,
|
||||
getSubscriberAndPreferences,
|
||||
getSubscribers,
|
||||
setDisplayName,
|
||||
setPbxExtension, setPbxGroupMemberIds,
|
||||
setPbxHuntPolicy,
|
||||
setPbxHuntTimeout, setSubscriberNumbers
|
||||
} from "./subscriber";
|
||||
createSubscriber,
|
||||
deleteSubscriber,
|
||||
getFullSubscribers,
|
||||
getSubscriberAndPreferences,
|
||||
getSubscribers,
|
||||
setDisplayName,
|
||||
setPbxExtension, setPbxGroupMemberIds,
|
||||
setPbxHuntPolicy,
|
||||
setPbxHuntTimeout, setSubscriberNumbers
|
||||
} from './subscriber'
|
||||
import {
|
||||
getAllSoundSets,
|
||||
getPilot,
|
||||
getSoundSet,
|
||||
createId,
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION,
|
||||
setSubscriberSoundSet
|
||||
} from "./pbx-config";
|
||||
getAllSoundSets,
|
||||
getPilot,
|
||||
getSoundSet,
|
||||
createId,
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION,
|
||||
setSubscriberSoundSet
|
||||
} from './pbx-config'
|
||||
import {
|
||||
assignNumbers,
|
||||
getNumbers
|
||||
} from "./user";
|
||||
assignNumbers,
|
||||
getNumbers
|
||||
} from './user'
|
||||
import {
|
||||
getSeatsOnly
|
||||
} from "./pbx-seats";
|
||||
getSeatsOnly
|
||||
} from './pbx-seats'
|
||||
|
||||
export function getGroups(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let result = {
|
||||
subscribers: {
|
||||
items: []
|
||||
},
|
||||
preferences: {
|
||||
items: []
|
||||
},
|
||||
soundSets: {
|
||||
items: []
|
||||
}
|
||||
};
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 1,
|
||||
is_pbx_pilot: 0
|
||||
}
|
||||
});
|
||||
Promise.resolve().then(()=>{
|
||||
return Promise.all([
|
||||
getFullSubscribers(options),
|
||||
getAllSoundSets()
|
||||
]);
|
||||
}).then(($result)=> {
|
||||
result.groups = $result[0].subscribers;
|
||||
result.preferences.items = $result[0].preferences;
|
||||
result.soundSets = $result[1];
|
||||
resolve(result);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getGroups (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = {
|
||||
subscribers: {
|
||||
items: []
|
||||
},
|
||||
preferences: {
|
||||
items: []
|
||||
},
|
||||
soundSets: {
|
||||
items: []
|
||||
}
|
||||
}
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 1,
|
||||
is_pbx_pilot: 0
|
||||
}
|
||||
})
|
||||
Promise.resolve().then(() => {
|
||||
return Promise.all([
|
||||
getFullSubscribers(options),
|
||||
getAllSoundSets()
|
||||
])
|
||||
}).then(($result) => {
|
||||
result.groups = $result[0].subscribers
|
||||
result.preferences.items = $result[0].preferences
|
||||
result.soundSets = $result[1]
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getGroupsOnly(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 1,
|
||||
is_pbx_pilot: 0
|
||||
}
|
||||
});
|
||||
Promise.resolve().then(()=>{
|
||||
return getSubscribers(options);
|
||||
}).then((result)=> {
|
||||
resolve(result);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getGroupsOnly (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
params: {
|
||||
is_pbx_group: 1,
|
||||
is_pbx_pilot: 0
|
||||
}
|
||||
})
|
||||
Promise.resolve().then(() => {
|
||||
return getSubscribers(options)
|
||||
}).then((result) => {
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getGroupList(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let page = _.get(options, 'page', 1);
|
||||
Promise.all([
|
||||
getGroups({
|
||||
params: {
|
||||
page: page,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
}
|
||||
}),
|
||||
getSeatsOnly({
|
||||
all: true
|
||||
}),
|
||||
getPilot(),
|
||||
getNumbers()
|
||||
]).then((result)=>{
|
||||
resolve({
|
||||
groups: result[0].groups,
|
||||
preferences: result[0].preferences,
|
||||
soundSets: result[0].soundSets,
|
||||
seats: result[1],
|
||||
pilot: result[2],
|
||||
numbers: result[3]
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getGroupList (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const page = _.get(options, 'page', 1)
|
||||
Promise.all([
|
||||
getGroups({
|
||||
params: {
|
||||
page: page,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
}
|
||||
}),
|
||||
getSeatsOnly({
|
||||
all: true
|
||||
}),
|
||||
getPilot(),
|
||||
getNumbers()
|
||||
]).then((result) => {
|
||||
resolve({
|
||||
groups: result[0].groups,
|
||||
preferences: result[0].preferences,
|
||||
soundSets: result[0].soundSets,
|
||||
seats: result[1],
|
||||
pilot: result[2],
|
||||
numbers: result[3]
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createGroup(group) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let subscriberId;
|
||||
Promise.resolve().then(()=>{
|
||||
return createSubscriber({
|
||||
username: _.kebabCase(group.name),
|
||||
password: createId(),
|
||||
is_pbx_group: true,
|
||||
display_name: group.name,
|
||||
pbx_extension: group.extension,
|
||||
pbx_hunt_policy: group.huntPolicy,
|
||||
pbx_hunt_timeout: group.huntTimeout,
|
||||
pbx_groupmember_ids: group.seats
|
||||
});
|
||||
}).then(($subscriberId)=>{
|
||||
subscriberId = $subscriberId;
|
||||
if(group.soundSet !== null && group.soundSet !== void(0)) {
|
||||
return getSoundSet(group.soundSet);
|
||||
}
|
||||
else {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}).then((soundSet)=>{
|
||||
let promises = [
|
||||
assignNumbers(group.aliasNumbers, subscriberId)
|
||||
];
|
||||
if(soundSet !== null) {
|
||||
promises.push(setSubscriberSoundSet(subscriberId, soundSet.name));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}).then(()=>{
|
||||
resolve(subscriberId);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createGroup (group) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let subscriberId
|
||||
Promise.resolve().then(() => {
|
||||
return createSubscriber({
|
||||
username: _.kebabCase(group.name),
|
||||
password: createId(),
|
||||
is_pbx_group: true,
|
||||
display_name: group.name,
|
||||
pbx_extension: group.extension,
|
||||
pbx_hunt_policy: group.huntPolicy,
|
||||
pbx_hunt_timeout: group.huntTimeout,
|
||||
pbx_groupmember_ids: group.seats
|
||||
})
|
||||
}).then(($subscriberId) => {
|
||||
subscriberId = $subscriberId
|
||||
if (group.soundSet !== null && group.soundSet !== undefined) {
|
||||
return getSoundSet(group.soundSet)
|
||||
} else {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
}).then((soundSet) => {
|
||||
const promises = [
|
||||
assignNumbers(group.aliasNumbers, subscriberId)
|
||||
]
|
||||
if (soundSet !== null) {
|
||||
promises.push(setSubscriberSoundSet(subscriberId, soundSet.name))
|
||||
}
|
||||
return Promise.all(promises)
|
||||
}).then(() => {
|
||||
resolve(subscriberId)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeGroup(id) {
|
||||
return deleteSubscriber(id);
|
||||
export function removeGroup (id) {
|
||||
return deleteSubscriber(id)
|
||||
}
|
||||
|
||||
export function setGroupName(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return setDisplayName(options.groupId, options.groupName);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupName (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return setDisplayName(options.groupId, options.groupName)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupExtension(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return setPbxExtension(options.groupId, options.groupExtension);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupExtension (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return setPbxExtension(options.groupId, options.groupExtension)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupHuntPolicy(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return setPbxHuntPolicy(options.groupId, options.groupHuntPolicy);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupHuntPolicy (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return setPbxHuntPolicy(options.groupId, options.groupHuntPolicy)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupHuntTimeout(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return setPbxHuntTimeout(options.groupId, options.groupHuntTimeout);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupHuntTimeout (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return setPbxHuntTimeout(options.groupId, options.groupHuntTimeout)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupNumbers(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
setSubscriberNumbers({
|
||||
subscriberId: options.groupId,
|
||||
pilotId: options.pilotId,
|
||||
assignedNumbers: options.assignedNumbers,
|
||||
unassignedNumbers: options.unassignedNumbers
|
||||
}).then((result)=>{
|
||||
resolve(result);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupNumbers (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setSubscriberNumbers({
|
||||
subscriberId: options.groupId,
|
||||
pilotId: options.pilotId,
|
||||
assignedNumbers: options.assignedNumbers,
|
||||
unassignedNumbers: options.unassignedNumbers
|
||||
}).then((result) => {
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupSeats(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return setPbxGroupMemberIds(options.groupId, options.seatIds);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupSeats (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return setPbxGroupMemberIds(options.groupId, options.seatIds)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setGroupSoundSet(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
if(options.soundSetId !== null && options.soundSetId !== void(0)) {
|
||||
return getSoundSet(options.soundSetId);
|
||||
}
|
||||
else {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}).then((soundSet)=>{
|
||||
let soundSetName = _.get(soundSet, 'name', null);
|
||||
return setSubscriberSoundSet(options.groupId, soundSetName);
|
||||
}).then(()=>{
|
||||
return getSubscriberAndPreferences(options.groupId);
|
||||
}).then((result)=>{
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setGroupSoundSet (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
if (options.soundSetId !== null && options.soundSetId !== undefined) {
|
||||
return getSoundSet(options.soundSetId)
|
||||
} else {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
}).then((soundSet) => {
|
||||
const soundSetName = _.get(soundSet, 'name', null)
|
||||
return setSubscriberSoundSet(options.groupId, soundSetName)
|
||||
}).then(() => {
|
||||
return getSubscriberAndPreferences(options.groupId)
|
||||
}).then((result) => {
|
||||
resolve({
|
||||
group: result.subscriber,
|
||||
preferences: result.preferences
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,229 +1,228 @@
|
||||
import _ from "lodash";
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
getList,
|
||||
patchReplaceFull,
|
||||
getAsBlob,
|
||||
get
|
||||
} from "./common";
|
||||
getList,
|
||||
patchReplaceFull,
|
||||
getAsBlob,
|
||||
get
|
||||
} from './common'
|
||||
import {
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION
|
||||
} from "./pbx-config";
|
||||
import Vue from "vue";
|
||||
PBX_CONFIG_ORDER_BY,
|
||||
PBX_CONFIG_ORDER_DIRECTION
|
||||
} from './pbx-config'
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
Platform
|
||||
} from 'quasar-framework'
|
||||
|
||||
export function getSoundSets(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundsets/',
|
||||
root: '_embedded.ngcp:soundsets'
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getSoundSetList(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let params = {
|
||||
page: options.page,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
};
|
||||
getSoundSets({
|
||||
params: params
|
||||
}).then((soundSets)=>{
|
||||
resolve({
|
||||
soundSets: soundSets
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function createSoundSet(soundSet) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.post('api/soundsets/', soundSet).then(() => {
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function removeSoundSet(soundSetId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.delete('api/soundsets/' + soundSetId).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function setSoundSetProperty(soundSetId, property, value) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
patchReplaceFull({
|
||||
path: 'api/soundsets/' + soundSetId,
|
||||
fieldPath: property,
|
||||
value: value
|
||||
}).then((soundSet)=>{
|
||||
resolve(soundSet);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function setAsDefault(soundSetId) {
|
||||
return setSoundSetProperty(soundSetId, 'contract_default', true);
|
||||
}
|
||||
|
||||
export function unsetAsDefault(soundSetId) {
|
||||
return setSoundSetProperty(soundSetId, 'contract_default', false);
|
||||
}
|
||||
|
||||
export function setSoundSetName(soundSetId, name) {
|
||||
return setSoundSetProperty(soundSetId, 'name', name);
|
||||
}
|
||||
|
||||
export function setSoundSetDescription(soundSetId, description) {
|
||||
return setSoundSetProperty(soundSetId, 'description', description);
|
||||
}
|
||||
|
||||
export function getSoundHandles(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundhandles/',
|
||||
root: '_embedded.ngcp:soundhandles'
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getAllSoundHandles(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
all: true
|
||||
});
|
||||
getSoundHandles(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getSoundFiles(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
options = options || {};
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundfiles/',
|
||||
root: '_embedded.ngcp:soundfiles',
|
||||
});
|
||||
getList(options).then((list)=>{
|
||||
resolve(list);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getAllSoundFilesBySoundSetId(soundSetId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getSoundFiles({
|
||||
all: true,
|
||||
params: {
|
||||
set_id: soundSetId
|
||||
}
|
||||
}).then((soundFiles)=>{
|
||||
resolve(soundFiles);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getSoundFile(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getAsBlob({
|
||||
path: 'api/soundfilerecordings/' + options.id,
|
||||
params: {
|
||||
format: Platform.mozilla ? 'ogg' : 'mp3'
|
||||
}
|
||||
}).then((result)=>{
|
||||
resolve(result);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function uploadSoundFile(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let formData = new FormData();
|
||||
formData.append('json', JSON.stringify({
|
||||
loopplay: true,
|
||||
filename: options.soundFileData.name,
|
||||
set_id: options.soundSetId,
|
||||
handle: options.soundHandle,
|
||||
}));
|
||||
formData.append('soundfile', options.soundFileData);
|
||||
Vue.http.post('api/soundfiles/', formData, {
|
||||
before(request) {
|
||||
options.initialized(request);
|
||||
},
|
||||
progress(progressEvent) {
|
||||
if (progressEvent.lengthComputable) {
|
||||
options.progressed(Math.ceil((progressEvent.loaded / progressEvent.total) * 100));
|
||||
}
|
||||
}
|
||||
}).then((res) => {
|
||||
let fileId = _.last(res.headers.get('location').split(/\//));
|
||||
return Promise.all([
|
||||
get({ path: 'api/soundfiles/' + fileId }),
|
||||
getSoundFile({ id: fileId })
|
||||
]);
|
||||
}).then((res)=>{
|
||||
resolve({
|
||||
soundFile: res[0],
|
||||
soundFileUrl: res[1]
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function setLoopPlay(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
console.log(options);
|
||||
patchReplaceFull({
|
||||
path: 'api/soundfiles/' + options.soundFileId,
|
||||
fieldPath: 'loopplay',
|
||||
value: (options.loopPlay === true)? 'true' : 'false'
|
||||
}).then((soundFile)=>{
|
||||
resolve(soundFile);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
Platform
|
||||
} from 'quasar'
|
||||
|
||||
export function getSoundSets (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundsets/',
|
||||
root: '_embedded.ngcp:soundsets'
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getSoundSetList (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = {
|
||||
page: options.page,
|
||||
order_by: PBX_CONFIG_ORDER_BY,
|
||||
order_by_direction: PBX_CONFIG_ORDER_DIRECTION
|
||||
}
|
||||
getSoundSets({
|
||||
params: params
|
||||
}).then((soundSets) => {
|
||||
resolve({
|
||||
soundSets: soundSets
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createSoundSet (soundSet) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.post('api/soundsets/', soundSet).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function removeSoundSet (soundSetId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.delete('api/soundsets/' + soundSetId).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
if (err.status >= 400) {
|
||||
reject(new Error(err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setSoundSetProperty (soundSetId, property, value) {
|
||||
return new Promise((resolve, reject) => {
|
||||
patchReplaceFull({
|
||||
path: 'api/soundsets/' + soundSetId,
|
||||
fieldPath: property,
|
||||
value: value
|
||||
}).then((soundSet) => {
|
||||
resolve(soundSet)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setAsDefault (soundSetId) {
|
||||
return setSoundSetProperty(soundSetId, 'contract_default', true)
|
||||
}
|
||||
|
||||
export function unsetAsDefault (soundSetId) {
|
||||
return setSoundSetProperty(soundSetId, 'contract_default', false)
|
||||
}
|
||||
|
||||
export function setSoundSetName (soundSetId, name) {
|
||||
return setSoundSetProperty(soundSetId, 'name', name)
|
||||
}
|
||||
|
||||
export function setSoundSetDescription (soundSetId, description) {
|
||||
return setSoundSetProperty(soundSetId, 'description', description)
|
||||
}
|
||||
|
||||
export function getSoundHandles (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundhandles/',
|
||||
root: '_embedded.ngcp:soundhandles'
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getAllSoundHandles (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
all: true
|
||||
})
|
||||
getSoundHandles(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getSoundFiles (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
options = options || {}
|
||||
options = _.merge(options, {
|
||||
path: 'api/soundfiles/',
|
||||
root: '_embedded.ngcp:soundfiles'
|
||||
})
|
||||
getList(options).then((list) => {
|
||||
resolve(list)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getAllSoundFilesBySoundSetId (soundSetId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getSoundFiles({
|
||||
all: true,
|
||||
params: {
|
||||
set_id: soundSetId
|
||||
}
|
||||
}).then((soundFiles) => {
|
||||
resolve(soundFiles)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getSoundFile (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getAsBlob({
|
||||
path: 'api/soundfilerecordings/' + options.id,
|
||||
params: {
|
||||
format: Platform.mozilla ? 'ogg' : 'mp3'
|
||||
}
|
||||
}).then((result) => {
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadSoundFile (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const formData = new FormData()
|
||||
formData.append('json', JSON.stringify({
|
||||
loopplay: true,
|
||||
filename: options.soundFileData.name,
|
||||
set_id: options.soundSetId,
|
||||
handle: options.soundHandle
|
||||
}))
|
||||
formData.append('soundfile', options.soundFileData)
|
||||
Vue.http.post('api/soundfiles/', formData, {
|
||||
before (request) {
|
||||
options.initialized(request)
|
||||
},
|
||||
progress (progressEvent) {
|
||||
if (progressEvent.lengthComputable) {
|
||||
options.progressed(Math.ceil((progressEvent.loaded / progressEvent.total) * 100))
|
||||
}
|
||||
}
|
||||
}).then((res) => {
|
||||
const fileId = _.last(res.headers.get('location').split(/\//))
|
||||
return Promise.all([
|
||||
get({ path: 'api/soundfiles/' + fileId }),
|
||||
getSoundFile({ id: fileId })
|
||||
])
|
||||
}).then((res) => {
|
||||
resolve({
|
||||
soundFile: res[0],
|
||||
soundFileUrl: res[1]
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setLoopPlay (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(options)
|
||||
patchReplaceFull({
|
||||
path: 'api/soundfiles/' + options.soundFileId,
|
||||
fieldPath: 'loopplay',
|
||||
value: (options.loopPlay === true) ? 'true' : 'false'
|
||||
}).then((soundFile) => {
|
||||
resolve(soundFile)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
|
||||
import config from '../config'
|
||||
import Vue from 'vue';
|
||||
import { getJsonBody } from './utils';
|
||||
import Vue from 'vue'
|
||||
import { getJsonBody } from './utils'
|
||||
|
||||
export function create() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.post('api/rtcsessions/').then((res)=>{
|
||||
resolve(res);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function create () {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.post('api/rtcsessions/').then((res) => {
|
||||
resolve(res)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getByUrl(url) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Vue.http.get(url).then((res)=>{
|
||||
resolve(getJsonBody(res.body));
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getByUrl (url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.get(url).then((res) => {
|
||||
resolve(getJsonBody(res.body))
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createSession() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
return create();
|
||||
}).then((res)=>{
|
||||
return getByUrl(config.baseHttpUrl + res.headers.get('Location'));
|
||||
}).then((res)=>{
|
||||
resolve(res);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createSession () {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return create()
|
||||
}).then((res) => {
|
||||
return getByUrl(config.baseHttpUrl + res.headers.get('Location'))
|
||||
}).then((res) => {
|
||||
resolve(res)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createSessionToken() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
createSession().then((res)=>{
|
||||
resolve(res.rtc_browser_token);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createSessionToken () {
|
||||
return new Promise((resolve, reject) => {
|
||||
createSession().then((res) => {
|
||||
resolve(res.rtc_browser_token)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,92 +1,92 @@
|
||||
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue';
|
||||
import { i18n } from '../i18n';
|
||||
import Vue from 'vue'
|
||||
import { i18n } from 'src/boot/i18n'
|
||||
import { getFieldList } from './common'
|
||||
|
||||
export function getSpeedDialsById(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getFieldList({
|
||||
path: 'api/speeddials/' + id,
|
||||
field: 'speeddials'
|
||||
}).then((result) => {
|
||||
let sortedResult = _.sortBy(result, ['slot']);
|
||||
resolve(sortedResult);
|
||||
}).catch((err) => {
|
||||
reject(err.body.message);
|
||||
});
|
||||
});
|
||||
export function getSpeedDialsById (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getFieldList({
|
||||
path: 'api/speeddials/' + id,
|
||||
field: 'speeddials'
|
||||
}).then((result) => {
|
||||
const sortedResult = _.sortBy(result, ['slot'])
|
||||
resolve(sortedResult)
|
||||
}).catch((err) => {
|
||||
reject(err.body.message)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getUnassignedSlots(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let slots = ["*0", "*1", "*2", "*3", "*4", "*5", "*6", "*7", "*8", "*9"];
|
||||
Promise.resolve().then(() => {
|
||||
return getSpeedDialsById(id);
|
||||
}).then((assignedSlots) => {
|
||||
let unassignedSlots = _.difference(slots, assignedSlots.map((slot) => {
|
||||
return slot.slot;
|
||||
}));
|
||||
let slotOptions = [];
|
||||
unassignedSlots.forEach((slot) => {
|
||||
slotOptions.push({
|
||||
label: `${i18n.t('speedDial.slot')} ${slot}`,
|
||||
value: slot
|
||||
});
|
||||
});
|
||||
resolve(slotOptions);
|
||||
}).catch((err) => {
|
||||
reject(err.body.message);
|
||||
});
|
||||
});
|
||||
export function getUnassignedSlots (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const slots = ['*0', '*1', '*2', '*3', '*4', '*5', '*6', '*7', '*8', '*9']
|
||||
Promise.resolve().then(() => {
|
||||
return getSpeedDialsById(id)
|
||||
}).then((assignedSlots) => {
|
||||
const unassignedSlots = _.difference(slots, assignedSlots.map((slot) => {
|
||||
return slot.slot
|
||||
}))
|
||||
const slotOptions = []
|
||||
unassignedSlots.forEach((slot) => {
|
||||
slotOptions.push({
|
||||
label: `${i18n.t('speedDial.slot')} ${slot}`,
|
||||
value: slot
|
||||
})
|
||||
})
|
||||
resolve(slotOptions)
|
||||
}).catch((err) => {
|
||||
reject(err.body.message)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function unassignSpeedDialSlot(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let updatedAssignedSlots = _.without(options.slots, options.slot);
|
||||
let headers = {
|
||||
'Content-Type': 'application/json-patch+json'
|
||||
};
|
||||
Vue.http.patch('api/speeddials/' + options.id, [{
|
||||
op: 'replace',
|
||||
path: '/speeddials',
|
||||
value: updatedAssignedSlots
|
||||
}], { headers: headers }).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err.body.message);
|
||||
});
|
||||
});
|
||||
export function unassignSpeedDialSlot (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const updatedAssignedSlots = _.without(options.slots, options.slot)
|
||||
const headers = {
|
||||
'Content-Type': 'application/json-patch+json'
|
||||
}
|
||||
Vue.http.patch('api/speeddials/' + options.id, [{
|
||||
op: 'replace',
|
||||
path: '/speeddials',
|
||||
value: updatedAssignedSlots
|
||||
}], { headers: headers }).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err.body.message)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function addSlotToSpeedDials(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let headers = {
|
||||
'Content-Type': 'application/json-patch+json'
|
||||
};
|
||||
Vue.http.patch('api/speeddials/' + options.id, [{
|
||||
op: 'replace',
|
||||
path: '/speeddials',
|
||||
value: options.slots
|
||||
}], { headers: headers }).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err.body.message);
|
||||
});
|
||||
});
|
||||
export function addSlotToSpeedDials (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json-patch+json'
|
||||
}
|
||||
Vue.http.patch('api/speeddials/' + options.id, [{
|
||||
op: 'replace',
|
||||
path: '/speeddials',
|
||||
value: options.slots
|
||||
}], { headers: headers }).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err.body.message)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function assignSpeedDialSlot(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getSpeedDialsById(options.id);
|
||||
}).then((result) => {
|
||||
let concatSlots = result.concat(options.slot);
|
||||
return addSlotToSpeedDials({ id: options.id, slots: concatSlots });
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function assignSpeedDialSlot (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
return getSpeedDialsById(options.id)
|
||||
}).then((result) => {
|
||||
const concatSlots = result.concat(options.slot)
|
||||
return addSlotToSpeedDials({ id: options.id, slots: concatSlots })
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,142 +1,140 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
get,
|
||||
getList,
|
||||
patchReplace
|
||||
get,
|
||||
getList,
|
||||
patchReplace
|
||||
} from './common'
|
||||
|
||||
export function login(username, password) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let jwt = null;
|
||||
let subscriberId = null;
|
||||
Vue.http.post('login_jwt', {
|
||||
username: username,
|
||||
password: password
|
||||
}).then((result)=>{
|
||||
jwt = result.body.jwt;
|
||||
subscriberId = result.body.subscriber_id + "";
|
||||
resolve({
|
||||
jwt: jwt,
|
||||
subscriberId: subscriberId,
|
||||
});
|
||||
}).catch((err)=>{
|
||||
if(err.status && err.status >= 400) {
|
||||
reject(new Error(err.body.message));
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
export function login (username, password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let jwt = null
|
||||
let subscriberId = null
|
||||
Vue.http.post('login_jwt', {
|
||||
username: username,
|
||||
password: password
|
||||
}).then((result) => {
|
||||
jwt = result.body.jwt
|
||||
subscriberId = result.body.subscriber_id + ''
|
||||
resolve({
|
||||
jwt: jwt,
|
||||
subscriberId: subscriberId
|
||||
})
|
||||
}).catch((err) => {
|
||||
if (err.status && err.status >= 400) {
|
||||
reject(new Error(err.body.message))
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getUserData(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
return Promise.all([
|
||||
getSubscriberById(id),
|
||||
getCapabilities(id),
|
||||
getFaxServerSettingsById(id)
|
||||
]).then((results)=>{
|
||||
results[1].faxactive = results[2]
|
||||
resolve({
|
||||
subscriber: results[0],
|
||||
capabilities: results[1]
|
||||
});
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getUserData (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return Promise.all([
|
||||
getSubscriberById(id),
|
||||
getCapabilities(id),
|
||||
getFaxServerSettingsById(id)
|
||||
]).then((results) => {
|
||||
results[1].faxactive = results[2]
|
||||
resolve({
|
||||
subscriber: results[0],
|
||||
capabilities: results[1]
|
||||
})
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getSubscriberById(id) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
get({
|
||||
path: 'api/subscribers/' + id
|
||||
}).then((body)=>{
|
||||
resolve(body);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getSubscriberById (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: 'api/subscribers/' + id
|
||||
}).then((body) => {
|
||||
resolve(body)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getCapabilities() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getList({
|
||||
path: 'api/capabilities/',
|
||||
root: '_embedded.ngcp:capabilities',
|
||||
all: true
|
||||
}).then((capabilityList)=>{
|
||||
let capabilities = {};
|
||||
if(_.isArray(capabilityList.items)) {
|
||||
capabilityList.items.forEach((capability)=>{
|
||||
capabilities[capability.name] = capability.enabled;
|
||||
});
|
||||
}
|
||||
resolve(capabilities);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getCapabilities () {
|
||||
return new Promise((resolve, reject) => {
|
||||
getList({
|
||||
path: 'api/capabilities/',
|
||||
root: '_embedded.ngcp:capabilities',
|
||||
all: true
|
||||
}).then((capabilityList) => {
|
||||
const capabilities = {}
|
||||
if (_.isArray(capabilityList.items)) {
|
||||
capabilityList.items.forEach((capability) => {
|
||||
capabilities[capability.name] = capability.enabled
|
||||
})
|
||||
}
|
||||
resolve(capabilities)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function assignNumber(numberId, subscriberId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
patchReplace({
|
||||
path: 'api/numbers/' + numberId,
|
||||
fieldPath: 'subscriber_id',
|
||||
value: subscriberId
|
||||
}).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function assignNumber (numberId, subscriberId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
patchReplace({
|
||||
path: 'api/numbers/' + numberId,
|
||||
fieldPath: 'subscriber_id',
|
||||
value: subscriberId
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function assignNumbers(numberIds, subscriberId) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
if(_.isArray(numberIds) && numberIds.length > 0) {
|
||||
let assignNumberRequests = [];
|
||||
numberIds.forEach((numberId)=>{
|
||||
assignNumberRequests.push(assignNumber(numberId, subscriberId));
|
||||
});
|
||||
Promise.all(assignNumberRequests).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
export function assignNumbers (numberIds, subscriberId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (_.isArray(numberIds) && numberIds.length > 0) {
|
||||
const assignNumberRequests = []
|
||||
numberIds.forEach((numberId) => {
|
||||
assignNumberRequests.push(assignNumber(numberId, subscriberId))
|
||||
})
|
||||
Promise.all(assignNumberRequests).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function getNumbers() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
getList({
|
||||
path: 'api/numbers/',
|
||||
root: '_embedded.ngcp:numbers',
|
||||
all: true
|
||||
}).then((numberList)=>{
|
||||
resolve(numberList);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getNumbers () {
|
||||
return new Promise((resolve, reject) => {
|
||||
getList({
|
||||
path: 'api/numbers/',
|
||||
root: '_embedded.ngcp:numbers',
|
||||
all: true
|
||||
}).then((numberList) => {
|
||||
resolve(numberList)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getFaxServerSettingsById(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: 'api/faxserversettings/' + id
|
||||
}).then((body)=>{
|
||||
resolve(body.active);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getFaxServerSettingsById (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: 'api/faxserversettings/' + id
|
||||
}).then((body) => {
|
||||
resolve(body.active)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
|
||||
import _ from 'lodash'
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
export function getJsonBody(body) {
|
||||
if(_.isString(body)) {
|
||||
try {
|
||||
return JSON.parse(body);
|
||||
}
|
||||
catch(err) {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
return body;
|
||||
export function getJsonBody (body) {
|
||||
if (_.isString(body)) {
|
||||
try {
|
||||
return JSON.parse(body)
|
||||
} catch (err) {
|
||||
return body
|
||||
}
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
@ -1,161 +1,160 @@
|
||||
|
||||
import _ from 'lodash'
|
||||
import Vue from 'vue';
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
get,
|
||||
getList,
|
||||
patchReplace
|
||||
get,
|
||||
getList,
|
||||
patchReplace
|
||||
} from './common'
|
||||
|
||||
export function getVoiceboxSettings(subscriberId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: `api/voicemailsettings/${subscriberId}`
|
||||
}).then((result)=>{
|
||||
let settings = _.clone(result);
|
||||
delete settings._links;
|
||||
resolve(settings);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getVoiceboxSettings (subscriberId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get({
|
||||
path: `api/voicemailsettings/${subscriberId}`
|
||||
}).then((result) => {
|
||||
const settings = _.clone(result)
|
||||
delete settings._links
|
||||
resolve(settings)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setVoiceboxDelete(options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'delete',
|
||||
value: options.value
|
||||
});
|
||||
export function setVoiceboxDelete (options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'delete',
|
||||
value: options.value
|
||||
})
|
||||
}
|
||||
|
||||
export function setVoiceboxAttach(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
Promise.resolve().then(()=>{
|
||||
if(options.value === false) {
|
||||
return setVoiceboxDelete(options);
|
||||
}
|
||||
else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}).then(()=>{
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'attach',
|
||||
value: options.value
|
||||
});
|
||||
}).then(()=>{
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function setVoiceboxAttach (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Promise.resolve().then(() => {
|
||||
if (options.value === false) {
|
||||
return setVoiceboxDelete(options)
|
||||
} else {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}).then(() => {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'attach',
|
||||
value: options.value
|
||||
})
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function setVoiceboxPin(options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'pin',
|
||||
value: options.value
|
||||
});
|
||||
export function setVoiceboxPin (options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'pin',
|
||||
value: options.value
|
||||
})
|
||||
}
|
||||
|
||||
export function setVoiceboxEmail(options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'email',
|
||||
value: options.value
|
||||
});
|
||||
export function setVoiceboxEmail (options) {
|
||||
return patchReplace({
|
||||
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||
fieldPath: 'email',
|
||||
value: options.value
|
||||
})
|
||||
}
|
||||
|
||||
export function getVoiceboxGreetingByType(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getList({
|
||||
path: 'api/voicemailgreetings/',
|
||||
root: '_embedded.ngcp:voicemailgreetings',
|
||||
params: { subscriber_id: options.id, type: options.type }
|
||||
}).then((result) => {
|
||||
resolve(result);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function getVoiceboxGreetingByType (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getList({
|
||||
path: 'api/voicemailgreetings/',
|
||||
root: '_embedded.ngcp:voicemailgreetings',
|
||||
params: { subscriber_id: options.id, type: options.type }
|
||||
}).then((result) => {
|
||||
resolve(result)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteVoiceboxGreetingById(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.delete(`api/voicemailgreetings/${id}`).then(() => {
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function deleteVoiceboxGreetingById (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Vue.http.delete(`api/voicemailgreetings/${id}`).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function createNewGreeting(formData, onProgress, type) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let requestKey = `previous${_.capitalize(type)}Request`;
|
||||
Vue.http.post('api/voicemailgreetings/', formData, {
|
||||
before(request) {
|
||||
Vue[requestKey] = request;
|
||||
},
|
||||
progress(e) {
|
||||
if (e.lengthComputable) {
|
||||
onProgress(Math.ceil((e.loaded / e.total ) * 100));
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function createNewGreeting (formData, onProgress, type) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestKey = `previous${_.capitalize(type)}Request`
|
||||
Vue.http.post('api/voicemailgreetings/', formData, {
|
||||
before (request) {
|
||||
Vue[requestKey] = request
|
||||
},
|
||||
progress (e) {
|
||||
if (e.lengthComputable) {
|
||||
onProgress(Math.ceil((e.loaded / e.total) * 100))
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadGreeting(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let formData = new FormData();
|
||||
let fields = _.clone(options.data);
|
||||
delete fields.file;
|
||||
let json = JSON.stringify(fields);
|
||||
formData.append('json', json);
|
||||
if (options.data.file) {
|
||||
formData.append('greetingfile', options.data.file);
|
||||
}
|
||||
Promise.resolve().then(() => {
|
||||
return getVoiceboxGreetingByType({
|
||||
id: options.data.subscriber_id,
|
||||
type: options.data.dir
|
||||
});
|
||||
}).then((greetings) => {
|
||||
if (_.some(greetings.items, { dir: options.data.dir })) {
|
||||
deleteVoiceboxGreetingById(greetings.items[0].id);
|
||||
}
|
||||
return createNewGreeting(formData, options.onProgress, options.data.dir);
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function uploadGreeting (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const formData = new FormData()
|
||||
const fields = _.clone(options.data)
|
||||
delete fields.file
|
||||
const json = JSON.stringify(fields)
|
||||
formData.append('json', json)
|
||||
if (options.data.file) {
|
||||
formData.append('greetingfile', options.data.file)
|
||||
}
|
||||
Promise.resolve().then(() => {
|
||||
return getVoiceboxGreetingByType({
|
||||
id: options.data.subscriber_id,
|
||||
type: options.data.dir
|
||||
})
|
||||
}).then((greetings) => {
|
||||
if (_.some(greetings.items, { dir: options.data.dir })) {
|
||||
deleteVoiceboxGreetingById(greetings.items[0].id)
|
||||
}
|
||||
return createNewGreeting(formData, options.onProgress, options.data.dir)
|
||||
}).then(() => {
|
||||
resolve()
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function abortPreviousRequest(name) {
|
||||
return new Promise((resolve) => {
|
||||
let requestKey = `previous${_.capitalize(name)}Request`;
|
||||
Vue[requestKey].abort();
|
||||
resolve();
|
||||
});
|
||||
export function abortPreviousRequest (name) {
|
||||
return new Promise((resolve) => {
|
||||
const requestKey = `previous${_.capitalize(name)}Request`
|
||||
Vue[requestKey].abort()
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
export function playGreeting(options) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let params = { format: options.format };
|
||||
Vue.http.get(`api/voicemailgreetings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body));
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export function playGreeting (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = { format: options.format }
|
||||
Vue.http.get(`api/voicemailgreetings/${options.id}`, { params: params, responseType: 'blob' })
|
||||
.then((res) => {
|
||||
resolve(URL.createObjectURL(res.body))
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,31 @@
|
||||
|
||||
import {
|
||||
getLocal,
|
||||
setLocal,
|
||||
deleteLocal
|
||||
} from 'src/storage'
|
||||
|
||||
export function getJwt () {
|
||||
return getLocal('jwt')
|
||||
}
|
||||
|
||||
export function hasJwt () {
|
||||
return getJwt() !== null
|
||||
}
|
||||
|
||||
export function setJwt (jwt) {
|
||||
setLocal('jwt', jwt)
|
||||
}
|
||||
|
||||
export function deleteJwt () {
|
||||
deleteLocal('jwt')
|
||||
deleteLocal('subscriberId')
|
||||
}
|
||||
|
||||
export function setSubscriberId (subscriberId) {
|
||||
setLocal('subscriberId', subscriberId)
|
||||
}
|
||||
|
||||
export function getSubscriberId () {
|
||||
return getLocal('subscriberId')
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
|
||||
import axios from 'axios'
|
||||
import {
|
||||
getJwt,
|
||||
hasJwt
|
||||
} from 'src/auth'
|
||||
|
||||
export default ({ Vue, store, app }) => {
|
||||
const http = axios.create({
|
||||
baseURL: app.config.baseHttpUrl
|
||||
})
|
||||
http.interceptors.request.use(function (config) {
|
||||
if (hasJwt()) {
|
||||
config.headers.Authorization = 'Bearer ' + getJwt()
|
||||
}
|
||||
return config
|
||||
}, function (error) {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
Vue.http = http
|
||||
Vue.$http = http
|
||||
store.$http = http
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
|
||||
import QItemMain from 'src/components/quasar-legacy/QItemMain'
|
||||
import QItemSide from 'src/components/quasar-legacy/QItemSide'
|
||||
import QCollapsible from 'src/components/quasar-legacy/QCollapsible'
|
||||
import QAlert from 'src/components/quasar-legacy/QAlert'
|
||||
import QResizeObservable from 'src/components/quasar-legacy/QResizeObservable'
|
||||
import QModal from 'src/components/quasar-legacy/QModal'
|
||||
import QPopover from 'src/components/quasar-legacy/QPopover'
|
||||
|
||||
export default ({ Vue }) => {
|
||||
Vue.component('q-item-main', QItemMain)
|
||||
Vue.component('q-item-side', QItemSide)
|
||||
Vue.component('q-collapsible', QCollapsible)
|
||||
Vue.component('q-alert', QAlert)
|
||||
Vue.component('q-resize-observable', QResizeObservable)
|
||||
Vue.component('q-modal', QModal)
|
||||
Vue.component('q-popover', QPopover)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
import config from 'src/config'
|
||||
|
||||
Vue.use({
|
||||
install (Vue, options) {
|
||||
Vue.$config = config
|
||||
}
|
||||
})
|
||||
|
||||
export default ({ app }) => {
|
||||
app.config = config
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
export default ({ Vue, app }) => {
|
||||
Vue.prototype.$faxQualityOptions = [
|
||||
{ label: app.i18n.t('communication.quality.normal'), value: 'normal' },
|
||||
{ label: app.i18n.t('communication.quality.fine'), value: 'fine' },
|
||||
{ label: app.i18n.t('communication.quality.super'), value: 'super' }
|
||||
]
|
||||
Vue.prototype.$faxQualityOptionsDefault = Vue.prototype.$faxQualityOptions[0]
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
import NumberFilter from 'src/filters/number'
|
||||
import NumberFormatFilter, {
|
||||
normalizeDestination
|
||||
} from 'src/filters/number-format'
|
||||
import DateFilter, {
|
||||
smartTime,
|
||||
time
|
||||
} from 'src/filters/date'
|
||||
import {
|
||||
startCase
|
||||
} from 'src/filters/string'
|
||||
import WholeCurrency from 'src/filters/currency'
|
||||
import {
|
||||
displayName
|
||||
} from 'src/filters/subscriber'
|
||||
|
||||
export default () => {
|
||||
Vue.filter('number', NumberFilter)
|
||||
Vue.filter('readableDate', DateFilter)
|
||||
Vue.filter('numberFormat', NumberFormatFilter)
|
||||
Vue.filter('destinationFormat', normalizeDestination)
|
||||
Vue.filter('smartTime', smartTime)
|
||||
Vue.filter('startCase', startCase)
|
||||
Vue.filter('wholeCurrency', WholeCurrency)
|
||||
Vue.filter('seatName', displayName)
|
||||
Vue.filter('groupName', displayName)
|
||||
Vue.filter('displayName', displayName)
|
||||
Vue.filter('time', time)
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
import VueI18n from 'vue-i18n'
|
||||
import {
|
||||
messages
|
||||
} from 'src/i18n'
|
||||
import {
|
||||
hasSession,
|
||||
getSession,
|
||||
setSession
|
||||
} from 'src/storage'
|
||||
|
||||
Vue.use(VueI18n)
|
||||
|
||||
export const defaultLocale = 'en-US'
|
||||
|
||||
export const i18n = new VueI18n({
|
||||
locale: defaultLocale,
|
||||
fallbackLocale: defaultLocale,
|
||||
messages
|
||||
})
|
||||
|
||||
export default ({ app, store }) => {
|
||||
app.i18n = i18n
|
||||
store.$i18n = i18n
|
||||
if (!hasSession('locale')) {
|
||||
setSession('locale', navigator.language)
|
||||
}
|
||||
i18n.locale = getSession('locale') + ''
|
||||
store.commit('user/changeSessionLocaleSucceeded', i18n.locale)
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
|
||||
import routes from 'src/router/routes'
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
Dark
|
||||
} from 'quasar'
|
||||
import {
|
||||
getJwt, getSubscriberId,
|
||||
hasJwt
|
||||
} from 'src/auth'
|
||||
|
||||
export default ({ app, router, store }) => {
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (!hasJwt() && to.path !== '/login') {
|
||||
next({
|
||||
path: '/login'
|
||||
})
|
||||
} else if (hasJwt() && to.path === '/login') {
|
||||
next({
|
||||
path: '/'
|
||||
})
|
||||
} else if (hasJwt() && to.path === '/conference') {
|
||||
next({
|
||||
path: '/conference/room123'
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
router.afterEach((to, from) => {
|
||||
const mainTitle = app.i18n.t('title')
|
||||
let title = _.get(to, 'meta.title', '')
|
||||
const subTitle = _.get(to, 'meta.subtitle', '')
|
||||
if (mainTitle !== '') {
|
||||
title = mainTitle + ' - ' + title
|
||||
}
|
||||
if (subTitle !== '') {
|
||||
title = title + ' - ' + subTitle
|
||||
}
|
||||
document.title = title
|
||||
store.commit('routeChanged', to)
|
||||
})
|
||||
|
||||
if (hasJwt()) {
|
||||
store.commit('user/loginSucceeded', {
|
||||
jwt: getJwt(),
|
||||
subscriberId: getSubscriberId()
|
||||
})
|
||||
}
|
||||
|
||||
store.$router = router
|
||||
router.addRoutes(routes(app))
|
||||
Dark.set(true)
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
|
||||
import VueResource from 'vue-resource'
|
||||
import {
|
||||
getJwt,
|
||||
hasJwt
|
||||
} from 'src/auth'
|
||||
|
||||
export default ({ Vue, app }) => {
|
||||
Vue.use(VueResource)
|
||||
Vue.http.options.root = app.config.baseHttpUrl
|
||||
Vue.http.interceptors.push(function (request, next) {
|
||||
if (hasJwt()) {
|
||||
request.headers.set('Authorization', 'Bearer ' + getJwt())
|
||||
}
|
||||
if (request.method === 'POST' && (request.body === undefined || request.body === null)) {
|
||||
request.body = {}
|
||||
}
|
||||
next()
|
||||
})
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
|
||||
import VueScrollTo from 'vue-scrollto'
|
||||
|
||||
export default ({ Vue }) => {
|
||||
Vue.use(VueScrollTo)
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
|
||||
import Vuelidate from 'vuelidate'
|
||||
|
||||
export default ({ Vue, store }) => {
|
||||
Vue.use(Vuelidate)
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<q-banner
|
||||
:class="bannerClasses"
|
||||
inline-actions
|
||||
>
|
||||
<template
|
||||
v-if="icon !== null && icon !== undefined"
|
||||
v-slot:avatar
|
||||
>
|
||||
<q-icon
|
||||
:name="icon"
|
||||
color="dark"
|
||||
size="24px"
|
||||
/>
|
||||
</template>
|
||||
<slot />
|
||||
<template
|
||||
v-slot:action
|
||||
>
|
||||
<slot
|
||||
name="action"
|
||||
/>
|
||||
</template>
|
||||
</q-banner>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CscInlineAlert',
|
||||
props: {
|
||||
icon: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: 'primary'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
bannerClasses () {
|
||||
return ['text-dark', 'bg-' + this.color]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<csc-inline-alert
|
||||
icon="alert"
|
||||
color="negative"
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<slot />
|
||||
<template
|
||||
v-slot:action
|
||||
>
|
||||
<slot
|
||||
name="action"
|
||||
/>
|
||||
</template>
|
||||
</csc-inline-alert>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CscInlineAlert from 'components/CscInlineAlert'
|
||||
export default {
|
||||
name: 'CscInlineAlertAlert',
|
||||
components: {
|
||||
CscInlineAlert
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<csc-inline-alert
|
||||
icon="info"
|
||||
color="info"
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<slot />
|
||||
<template
|
||||
v-slot:action
|
||||
>
|
||||
<slot
|
||||
name="action"
|
||||
/>
|
||||
</template>
|
||||
</csc-inline-alert>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CscInlineAlert from 'components/CscInlineAlert'
|
||||
export default {
|
||||
name: 'CscInlineAlertInfo',
|
||||
components: {
|
||||
CscInlineAlert
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<csc-inline-alert
|
||||
icon="warning"
|
||||
color="warning"
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<slot />
|
||||
<template
|
||||
v-slot:action
|
||||
>
|
||||
<slot
|
||||
name="action"
|
||||
/>
|
||||
</template>
|
||||
</csc-inline-alert>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CscInlineAlert from 'components/CscInlineAlert'
|
||||
export default {
|
||||
name: 'CscInlineAlertWarning',
|
||||
components: {
|
||||
CscInlineAlert
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<q-list
|
||||
no-border
|
||||
>
|
||||
<q-expansion-item
|
||||
ref="languageCollapsible"
|
||||
v-model="expanded"
|
||||
:label="languageLabel"
|
||||
>
|
||||
<q-list
|
||||
no-border
|
||||
>
|
||||
<q-item
|
||||
v-for="(language, index) in languageLabels"
|
||||
:key="index"
|
||||
v-close-popup
|
||||
clickable
|
||||
@click="changeSessionLanguage(language[0])"
|
||||
>
|
||||
<q-item-main
|
||||
:label="language[1]"
|
||||
/>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-expansion-item>
|
||||
</q-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapActions
|
||||
} from 'vuex'
|
||||
export default {
|
||||
name: 'CscLanguageMenu',
|
||||
props: {
|
||||
languageLabel: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
languageLabels: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
expanded: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('user', [
|
||||
'changeSessionLanguage'
|
||||
])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus" rel="stylesheet/stylus">
|
||||
.csc-language-selection
|
||||
.q-item-side-right
|
||||
color white
|
||||
</style>
|
@ -1,53 +1,45 @@
|
||||
<template>
|
||||
<div
|
||||
class="csc-list-actions row justify-center"
|
||||
>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot1"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot2"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot3"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
</div>
|
||||
<div>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot1"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot2"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
<q-slide-transition
|
||||
appear
|
||||
>
|
||||
<slot
|
||||
name="slot3"
|
||||
/>
|
||||
</q-slide-transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
QSlideTransition
|
||||
} from 'quasar-framework'
|
||||
export default {
|
||||
name: 'csc-list-actions',
|
||||
data () {
|
||||
return {}
|
||||
},
|
||||
props: [
|
||||
'label'
|
||||
],
|
||||
components: {
|
||||
QSlideTransition
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
export default {
|
||||
name: 'CscListActions',
|
||||
props: {
|
||||
label: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus" rel="stylesheet/stylus">
|
||||
@import '../themes/quasar.variables.styl'
|
||||
.csc-list-actions
|
||||
margin-bottom $flex-gutter-sm
|
||||
</style>
|
||||
|
@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<q-list>
|
||||
<template
|
||||
v-for="(item, index) in items"
|
||||
>
|
||||
<q-expansion-item
|
||||
v-if="item.visible && item.children && item.children.length > 0"
|
||||
:key="index"
|
||||
:label="item.label"
|
||||
:icon="item.icon"
|
||||
:content-inset-level="1"
|
||||
group="cscMainMenu"
|
||||
class="text-weight-bold"
|
||||
>
|
||||
<q-list>
|
||||
<template
|
||||
v-for="(child, childIndex) in item.children"
|
||||
>
|
||||
<q-item
|
||||
v-if="child.visible"
|
||||
:key="childIndex"
|
||||
:to="child.to"
|
||||
>
|
||||
<q-item-section
|
||||
avatar
|
||||
>
|
||||
<q-icon
|
||||
:name="child.icon"
|
||||
/>
|
||||
</q-item-section>
|
||||
<q-item-section
|
||||
no-wrap
|
||||
>
|
||||
<q-item-label
|
||||
class="text-weight-bold"
|
||||
>
|
||||
{{ child.label }}
|
||||
</q-item-label>
|
||||
<q-item-label
|
||||
v-if="child.sublabel !== undefined"
|
||||
class="text-weight-light text-subtitle2"
|
||||
>
|
||||
{{ child.sublabel }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-list>
|
||||
</q-expansion-item>
|
||||
<q-item
|
||||
v-else-if="item.visible"
|
||||
:key="index"
|
||||
:to="item.to"
|
||||
>
|
||||
<q-item-section
|
||||
avatar
|
||||
>
|
||||
<q-icon
|
||||
:name="item.icon"
|
||||
/>
|
||||
</q-item-section>
|
||||
<q-item-section
|
||||
no-wrap
|
||||
>
|
||||
<q-item-label
|
||||
class="text-weight-bold"
|
||||
>
|
||||
{{ item.label }}
|
||||
</q-item-label>
|
||||
<q-item-label
|
||||
v-if="item.sublabel !== undefined"
|
||||
class="text-weight-light text-subtitle2"
|
||||
>
|
||||
{{ item.sublabel }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CscMainMenu',
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-if="!menuMinimized"
|
||||
class="q-pr-md q-pl-md q-pt-xs q-pb-xs text-subtitle2"
|
||||
>
|
||||
{{ $t('navigation.newFeatures.header.title') }}
|
||||
</div>
|
||||
<csc-main-menu
|
||||
:items="items"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapGetters
|
||||
} from 'vuex'
|
||||
import CscMainMenu from 'components/CscMainMenu'
|
||||
export default {
|
||||
name: 'CscMainMenuNewFeatures',
|
||||
components: {
|
||||
CscMainMenu
|
||||
},
|
||||
props: {
|
||||
callStateTitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
callStateSubtitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
isCallForward: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isCallBlocking: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isPbxAdmin: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isPbxConfiguration: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
menuMinimized: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('user', [
|
||||
'isRtcEngineUiVisible'
|
||||
]),
|
||||
items () {
|
||||
return [
|
||||
{
|
||||
to: '/user/new-call-forward',
|
||||
icon: 'phone_forwarded',
|
||||
label: this.$t('navigation.callForward.title'),
|
||||
visible: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<csc-main-menu
|
||||
:items="items"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapGetters
|
||||
} from 'vuex'
|
||||
import CscMainMenu from 'components/CscMainMenu'
|
||||
export default {
|
||||
name: 'CscMainMenuTop',
|
||||
components: {
|
||||
CscMainMenu
|
||||
},
|
||||
props: {
|
||||
callStateTitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
callStateSubtitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
isCallForward: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isCallBlocking: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isPbxAdmin: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isPbxConfiguration: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('user', [
|
||||
'isRtcEngineUiVisible'
|
||||
]),
|
||||
items () {
|
||||
return [
|
||||
{
|
||||
to: '/user/home',
|
||||
icon: 'call',
|
||||
label: this.callStateTitle,
|
||||
sublabel: this.callStateSubtitle,
|
||||
visible: this.isRtcEngineUiVisible
|
||||
},
|
||||
{
|
||||
to: '/conference',
|
||||
icon: 'videocam',
|
||||
label: this.$t('navigation.conference.title'),
|
||||
visible: this.isRtcEngineUiVisible
|
||||
},
|
||||
{
|
||||
to: '/user/conversations',
|
||||
icon: 'question_answer',
|
||||
label: this.$t('navigation.conversations.title'),
|
||||
sublabel: this.$t('navigation.conversations.subTitle'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
icon: 'phone_forwarded',
|
||||
label: this.$t('navigation.callForward.title'),
|
||||
opened: this.isCallForward,
|
||||
visible: true,
|
||||
children: [
|
||||
{
|
||||
to: '/user/call-forward/always',
|
||||
icon: 'check_circle',
|
||||
label: this.$t('navigation.callForward.always'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/call-forward/company-hours',
|
||||
icon: 'schedule',
|
||||
label: this.$t('navigation.callForward.companyHours'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/call-forward/after-hours',
|
||||
icon: 'watch_later',
|
||||
label: this.$t('navigation.callForward.afterHours'),
|
||||
visible: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 'block',
|
||||
label: this.$t('navigation.callBlocking.title'),
|
||||
opened: this.isCallBlocking,
|
||||
visible: true,
|
||||
children: [
|
||||
{
|
||||
to: '/user/call-blocking/incoming',
|
||||
icon: 'call_received',
|
||||
label: this.$t('navigation.callBlocking.incoming'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/call-blocking/outgoing',
|
||||
icon: 'call_made',
|
||||
label: this.$t('navigation.callBlocking.outgoing'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/call-blocking/privacy',
|
||||
icon: 'fas fa-user-secret',
|
||||
label: this.$t('navigation.callBlocking.privacy'),
|
||||
visible: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
to: '/user/reminder',
|
||||
icon: 'notification_important',
|
||||
label: this.$t('navigation.reminder.title'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/speeddial',
|
||||
icon: 'touch_app',
|
||||
label: this.$t('navigation.speeddial.title'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/voicebox',
|
||||
icon: 'voicemail',
|
||||
label: this.$t('navigation.voicebox.title'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
icon: 'miscellaneous_services',
|
||||
label: this.$t('navigation.pbxConfiguration.title'),
|
||||
visible: this.isPbxAdmin,
|
||||
opened: this.isPbxConfiguration,
|
||||
children: [
|
||||
{
|
||||
to: '/user/pbx-configuration/seats',
|
||||
icon: 'person',
|
||||
label: this.$t('navigation.pbxConfiguration.seats'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/pbx-configuration/groups',
|
||||
icon: 'group',
|
||||
label: this.$t('navigation.pbxConfiguration.groups'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/pbx-configuration/devices',
|
||||
icon: 'fas fa-fax',
|
||||
label: this.$t('navigation.pbxConfiguration.devices'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/pbx-configuration/call-queues',
|
||||
icon: 'filter_none',
|
||||
label: this.$t('navigation.pbxConfiguration.callQueues'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/pbx-configuration/sound-sets',
|
||||
icon: 'queue_music',
|
||||
label: this.$t('navigation.pbxConfiguration.soundSets'),
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
to: '/user/pbx-configuration/ms-configs',
|
||||
icon: 'arrow_forward',
|
||||
label: this.$t('navigation.pbxConfiguration.msConfigs'),
|
||||
visible: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<q-btn
|
||||
icon="more_vert"
|
||||
color="primary"
|
||||
flat
|
||||
dense
|
||||
@click.stop.prevent
|
||||
>
|
||||
<csc-popup-menu>
|
||||
<slot />
|
||||
</csc-popup-menu>
|
||||
</q-btn>
|
||||
</template>
|
||||
<script>
|
||||
import CscPopupMenu from 'components/CscPopupMenu'
|
||||
export default {
|
||||
name: 'CscMoreMenu',
|
||||
components: {
|
||||
CscPopupMenu
|
||||
}
|
||||
}
|
||||
</script>
|