- starting project list...
- ordering some functions
- fix error TS2339
quasar.extensions.json was the problem !
inside had:
{
"@quasar/typescript": {
"webpack": "plugin",
"rename": true
}
}
This commit is contained in:
34
.babelrc
Normal file
34
.babelrc
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
"modules": false,
|
||||||
|
"loose": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"@babel/transform-runtime",
|
||||||
|
{
|
||||||
|
"regenerator": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
|
"@babel/plugin-syntax-import-meta",
|
||||||
|
"@babel/plugin-proposal-class-properties",
|
||||||
|
"@babel/plugin-proposal-json-strings",
|
||||||
|
[
|
||||||
|
"@babel/plugin-proposal-decorators",
|
||||||
|
{
|
||||||
|
"legacy": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@babel/plugin-proposal-function-sent",
|
||||||
|
"@babel/plugin-proposal-export-namespace-from",
|
||||||
|
"@babel/plugin-proposal-numeric-separator",
|
||||||
|
"@babel/plugin-proposal-throw-expressions"
|
||||||
|
],
|
||||||
|
"comments": false
|
||||||
|
}
|
||||||
115
config/webpack.config.base.js
Normal file
115
config/webpack.config.base.js
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const helpers = require('./helpers');
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const cssNext = require('postcss-cssnext');
|
||||||
|
const postcssImport = require('postcss-import');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const baseConfig = {
|
||||||
|
entry: {
|
||||||
|
'bundle': helpers.root('/src/main.ts'),
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
publicPath: '/',
|
||||||
|
path: helpers.root('dist'),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [
|
||||||
|
'.ts', '.js', '.vue',
|
||||||
|
],
|
||||||
|
alias: {
|
||||||
|
'@components': helpers.root('src/components/components/index.ts'),
|
||||||
|
'@components': helpers.root('src/components/components'),
|
||||||
|
'@views': helpers.root('src/components/views/index.ts'),
|
||||||
|
'@views': helpers.root('src/components/views'),
|
||||||
|
'@src': helpers.root('src'),
|
||||||
|
'@icons': helpers.root('src/assets/icons'),
|
||||||
|
'@images': helpers.root('src/assets/images'),
|
||||||
|
'@classes': helpers.root('src/classes/index.ts'),
|
||||||
|
'@fonts': helpers.root('src/assets/fonts'),
|
||||||
|
'@utils': helpers.root('src/utils/index.ts'),
|
||||||
|
'@utils': helpers.root('src/utils'),
|
||||||
|
'@css': helpers.root('src/styles/variables.scss'),
|
||||||
|
'@router': helpers.root('src/router/index.ts'),
|
||||||
|
'@validators': helpers.root('src/utils/validators.ts'),
|
||||||
|
'@methods': helpers.root('src/utils/methods.ts'),
|
||||||
|
'@filters': helpers.root('src/utils/filters.ts'),
|
||||||
|
'@api': helpers.root('src/store/Api/index.ts'),
|
||||||
|
'@paths': helpers.root('src/store/Api/ApiRoutes.ts'),
|
||||||
|
'@types': helpers.root('src/typings/index.ts'),
|
||||||
|
'@store': helpers.root('src/store/index.ts'),
|
||||||
|
'@modules': helpers.root('src/store/Modules/index.ts'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [{
|
||||||
|
test: /\.vue$/,
|
||||||
|
use: {
|
||||||
|
loader: 'vue-loader',
|
||||||
|
options: {
|
||||||
|
postcss: {
|
||||||
|
plugins: [cssNext()],
|
||||||
|
options: {
|
||||||
|
sourceMap: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cssSourceMap: true,
|
||||||
|
loaders: {
|
||||||
|
scss: ['vue-style-loader', 'css-loader','sass-loader', {
|
||||||
|
loader: 'sass-resources-loader',
|
||||||
|
options: {
|
||||||
|
resources: helpers.root('src/styles/variables.scss'),
|
||||||
|
esModule: true,
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
ts: 'ts-loader',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
test: /\.ts$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
appendTsSuffixTo: [/\.vue$/]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
test: /\.(jpe?g|png|ttf|eot|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
||||||
|
use: 'base64-inline-loader?limit=1000&name=[name].[ext]'
|
||||||
|
},{
|
||||||
|
test: /\.(svg)(\?[a-z0-9=&.]+)?$/,
|
||||||
|
use: 'base64-inline-loader?limit=4000&name=[name].[ext]'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new FaviconsWebpackPlugin({
|
||||||
|
logo: helpers.root('src/assets/images/logo_M.png'),
|
||||||
|
persistentCache: true,
|
||||||
|
inject: true,
|
||||||
|
background: '#fff',
|
||||||
|
icons: {
|
||||||
|
android: false,
|
||||||
|
appleIcon: false,
|
||||||
|
appleStartup: false,
|
||||||
|
coast: false,
|
||||||
|
favicons: true,
|
||||||
|
firefox: false,
|
||||||
|
opengraph: false,
|
||||||
|
twitter: false,
|
||||||
|
yandex: false,
|
||||||
|
windows: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new CopyWebpackPlugin([{
|
||||||
|
from: helpers.root('src/assets')
|
||||||
|
}])
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = baseConfig;
|
||||||
90
config/webpack.config.dev.js
Normal file
90
config/webpack.config.dev.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
const webpackBaseConfig = require('./webpack.config.base');
|
||||||
|
const env = require('../environment/dev.env');
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const path = require('path');
|
||||||
|
const helpers = require('./helpers');
|
||||||
|
const merge = require('webpack-merge')
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
||||||
|
const webpackDashboard = require('webpack-dashboard/plugin');
|
||||||
|
const DefinePlugin = require('webpack/lib/DefinePlugin');
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
|
||||||
|
const webpackDevConfig = {
|
||||||
|
module: {
|
||||||
|
rules: [{
|
||||||
|
test: /\.s?css$/,
|
||||||
|
use: [{
|
||||||
|
loader: 'style-loader'
|
||||||
|
}, {
|
||||||
|
loader: 'css-loader',
|
||||||
|
options: {
|
||||||
|
minimize: false,
|
||||||
|
sourceMap: true,
|
||||||
|
importLoaders: 2
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
loader: 'postcss-loader',
|
||||||
|
options: {
|
||||||
|
plugins: () => [autoprefixer],
|
||||||
|
sourceMap: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
loader: 'sass-loader',
|
||||||
|
options: {
|
||||||
|
outputStyle: 'expanded',
|
||||||
|
sourceMap: true,
|
||||||
|
sourceMapContents: true
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: true,
|
||||||
|
template: helpers.root('/src/index.html'),
|
||||||
|
filename: 'index.html',
|
||||||
|
favicon: helpers.root('/src/assets/images/logo_M.png')
|
||||||
|
}),
|
||||||
|
new DefinePlugin({
|
||||||
|
'process.env': env
|
||||||
|
}),
|
||||||
|
new webpackDashboard(),
|
||||||
|
new FriendlyErrorsPlugin(),
|
||||||
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
new webpack.NamedModulesPlugin(),
|
||||||
|
],
|
||||||
|
devServer: {
|
||||||
|
contentBase: path.join(__dirname, "dist"),
|
||||||
|
port: 5000,
|
||||||
|
historyApiFallback: true,
|
||||||
|
disableHostCheck: true,
|
||||||
|
host: "0.0.0.0",
|
||||||
|
hot: true,
|
||||||
|
open: true,
|
||||||
|
quiet: true,
|
||||||
|
inline: true,
|
||||||
|
noInfo: true,
|
||||||
|
stats: {
|
||||||
|
colors: true,
|
||||||
|
hash: false,
|
||||||
|
version: false,
|
||||||
|
timings: false,
|
||||||
|
assets: false,
|
||||||
|
chunks: false,
|
||||||
|
modules: false,
|
||||||
|
reasons: false,
|
||||||
|
children: false,
|
||||||
|
source: false,
|
||||||
|
errors: true,
|
||||||
|
errorDetails: true,
|
||||||
|
warnings: false,
|
||||||
|
publicPath: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
devtool: 'cheap-module-eval-source-map'
|
||||||
|
}
|
||||||
|
|
||||||
|
const devExport = merge(webpackBaseConfig, webpackDevConfig);
|
||||||
|
|
||||||
|
module.exports = devExport;
|
||||||
26180
npm-shrinkwrap.json
generated
Normal file
26180
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
63
package.json
Normal file → Executable file
63
package.json
Normal file → Executable file
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "freeplanet",
|
"name": "freeplanet",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"freeplanet",
|
"freeplanet",
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"lint": "tslint --project tsconfig.json",
|
"lint": "tslint --project tsconfig.json",
|
||||||
"lint:fix": "tslint --project tsconfig.json --fix",
|
"lint:fix": "tslint --project tsconfig.json --fix",
|
||||||
"dev": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
"dev": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
||||||
|
"dev2": "webpack-dev-server --inline --progress",
|
||||||
"dev:ssr": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m ssr",
|
"dev:ssr": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m ssr",
|
||||||
"pwa": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
"pwa": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
||||||
"test:unit": "jest",
|
"test:unit": "jest",
|
||||||
@@ -25,15 +26,20 @@
|
|||||||
"generate-sw": "workbox generateSW workbox-config.js"
|
"generate-sw": "workbox generateSW workbox-config.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@babel/plugin-transform-runtime": "^7.4.0",
|
||||||
|
"@babel/runtime": "^7.0.0",
|
||||||
"@quasar/extras": "^1.1.0",
|
"@quasar/extras": "^1.1.0",
|
||||||
"@types/vuelidate": "^0.7.0",
|
"@types/vuelidate": "^0.7.0",
|
||||||
|
"@vue/eslint-config-standard": "^4.0.0",
|
||||||
"acorn": "^6.0.0",
|
"acorn": "^6.0.0",
|
||||||
|
"autoprefixer": "^9.5.0",
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"babel-runtime": "^6.26.0",
|
"babel-eslint": "^10.0.1",
|
||||||
"bcrypt-nodejs": "0.0.3",
|
"bcrypt-nodejs": "0.0.3",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"dotenv": "^6.1.0",
|
"dotenv": "^6.1.0",
|
||||||
"element-ui": "^2.3.6",
|
"element-ui": "^2.3.6",
|
||||||
|
"eslint-plugin-vue": "^5.2.2",
|
||||||
"google-translate-api": "^2.3.0",
|
"google-translate-api": "^2.3.0",
|
||||||
"graphql": "^0.13.2",
|
"graphql": "^0.13.2",
|
||||||
"graphql-tag": "^2.8.0",
|
"graphql-tag": "^2.8.0",
|
||||||
@@ -42,13 +48,13 @@
|
|||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"localforage": "^1.7.3",
|
"localforage": "^1.7.3",
|
||||||
"normalize.css": "^8.0.0",
|
"normalize.css": "^8.0.0",
|
||||||
"npm": "^6.4.1",
|
"npm": "^6.9.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"quasar": "^1.0.0-beta.10",
|
"quasar": "^1.0.0-beta.10",
|
||||||
"quasar-extras": "^2.0.8",
|
"quasar-extras": "^2.0.8",
|
||||||
"register-service-worker": "^1.0.0",
|
"register-service-worker": "^1.0.0",
|
||||||
"vee-validate": "^2.1.2",
|
"vee-validate": "^2.1.2",
|
||||||
"vue": "^2.5.17",
|
"vue": "^2.6.10",
|
||||||
"vue-class-component": "^6.3.2",
|
"vue-class-component": "^6.3.2",
|
||||||
"vue-i18n": "^8.1.0",
|
"vue-i18n": "^8.1.0",
|
||||||
"vue-idb": "^0.2.0",
|
"vue-idb": "^0.2.0",
|
||||||
@@ -62,26 +68,29 @@
|
|||||||
"vuex-class": "^0.3.1",
|
"vuex-class": "^0.3.1",
|
||||||
"vuex-module-decorators": "^0.4.3",
|
"vuex-module-decorators": "^0.4.3",
|
||||||
"vuex-router-sync": "^5.0.0",
|
"vuex-router-sync": "^5.0.0",
|
||||||
"vuex-typex": "^3.0.1"
|
"vuex-typex": "^3.0.1",
|
||||||
|
"webpack-cli": "^3.3.0",
|
||||||
|
"workbox": "0.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/code-frame": "7.0.0-beta.54",
|
"@babel/cli": "^7.2.3",
|
||||||
"@babel/core": "7.0.0-beta.50",
|
"@babel/core": "^7.4.0",
|
||||||
"@babel/generator": "7.0.0-beta.54",
|
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
||||||
"@babel/helpers": "7.0.0-beta.54",
|
"@babel/plugin-proposal-decorators": "^7.0.0",
|
||||||
"@babel/parser": "7.0.0-beta.54",
|
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
||||||
"@babel/preset-env": "7.0.0-beta.54",
|
"@babel/plugin-proposal-function-sent": "^7.0.0",
|
||||||
"@babel/preset-react": "7.0.0",
|
"@babel/plugin-proposal-json-strings": "^7.0.0",
|
||||||
"@babel/runtime": "7.0.0-beta.54",
|
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
||||||
"@babel/template": "7.0.0-beta.54",
|
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
|
||||||
"@babel/traverse": "7.0.0-beta.54",
|
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||||
"@babel/types": "7.0.0-beta.54",
|
"@babel/plugin-syntax-import-meta": "^7.2.0",
|
||||||
|
"@babel/preset-env": "^7.4.2",
|
||||||
"@quasar/app": "^1.0.0-beta.11",
|
"@quasar/app": "^1.0.0-beta.11",
|
||||||
"@quasar/quasar-app-extension-typescript": "^1.0.0-alpha.11",
|
"@quasar/quasar-app-extension-typescript": "^1.0.0-alpha.11",
|
||||||
"@types/dotenv": "^4.0.3",
|
"@types/dotenv": "^4.0.3",
|
||||||
"@types/jest": "^23.1.4",
|
"@types/jest": "^23.1.4",
|
||||||
"@types/js-cookie": "^2.1.0",
|
"@types/js-cookie": "^2.1.0",
|
||||||
"@types/node": "11.9.5",
|
"@types/node": "^11.9.5",
|
||||||
"@types/nprogress": "^0.0.29",
|
"@types/nprogress": "^0.0.29",
|
||||||
"@types/webpack-env": "^1.13.6",
|
"@types/webpack-env": "^1.13.6",
|
||||||
"@vue/babel-preset-app": "3.1.1",
|
"@vue/babel-preset-app": "3.1.1",
|
||||||
@@ -92,12 +101,15 @@
|
|||||||
"@vue/cli-plugin-unit-jest": "^3.0.1",
|
"@vue/cli-plugin-unit-jest": "^3.0.1",
|
||||||
"@vue/cli-service": "^3.0.1",
|
"@vue/cli-service": "^3.0.1",
|
||||||
"@vue/test-utils": "^1.0.0-beta.20",
|
"@vue/test-utils": "^1.0.0-beta.20",
|
||||||
"babel-loader": "^8.0.0-beta.2",
|
"babel-core": "^7.0.0-bridge.0",
|
||||||
|
"babel-jest": "^23.4.2",
|
||||||
|
"babel-loader": "8.0.0-beta.2",
|
||||||
"babel-plugin-transform-imports": "1.5.1",
|
"babel-plugin-transform-imports": "1.5.1",
|
||||||
"eslint": "^5.5.0",
|
"eslint": "^5.5.0",
|
||||||
|
"file-loader": "^3.0.1",
|
||||||
"html-webpack-plugin": "^2.8.1",
|
"html-webpack-plugin": "^2.8.1",
|
||||||
"http-proxy-middleware": "^0.17.0",
|
"http-proxy-middleware": "^0.19.1",
|
||||||
"jest": "^23.6.0",
|
"jest": "^24.5.0",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"node-sass": "^4.11.0",
|
"node-sass": "^4.11.0",
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
||||||
@@ -105,13 +117,13 @@
|
|||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"strip-ansi": "=3.0.1",
|
"strip-ansi": "=3.0.1",
|
||||||
"ts-jest": "^23.0.0",
|
"ts-jest": "^23.0.0",
|
||||||
"ts-loader": "^5.3.0",
|
"ts-loader": "^5.3.3",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-standard": "^8.0.1",
|
"tslint-config-standard": "^8.0.1",
|
||||||
"tslint-loader": "^3.4.3",
|
"tslint-loader": "^3.4.3",
|
||||||
"typescript": "^3.1.6",
|
"typescript": "^3.3.3333",
|
||||||
"vue-cli-plugin-element-ui": "^1.1.2",
|
"vue-cli-plugin-element-ui": "^1.1.2",
|
||||||
"vue-template-compiler": "^2.5.17",
|
"vue-template-compiler": "^2.6.10",
|
||||||
"vueify": "^9.4.1",
|
"vueify": "^9.4.1",
|
||||||
"webpack": "^4.29.6",
|
"webpack": "^4.29.6",
|
||||||
"webpack-dev-middleware": "^3.2.0",
|
"webpack-dev-middleware": "^3.2.0",
|
||||||
@@ -128,5 +140,8 @@
|
|||||||
"> 1%",
|
"> 1%",
|
||||||
"last 2 versions",
|
"last 2 versions",
|
||||||
"not ie <= 10"
|
"not ie <= 10"
|
||||||
]
|
],
|
||||||
|
"resolutions": {
|
||||||
|
"ajv": "6.8.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const extendTypescriptToWebpack = (config) => {
|
|||||||
.set('@views', helpers.root('src/components/views/index.ts'))
|
.set('@views', helpers.root('src/components/views/index.ts'))
|
||||||
// .set('@views', helpers.root('src/components/views'))
|
// .set('@views', helpers.root('src/components/views'))
|
||||||
.set('@src', helpers.root('src'))
|
.set('@src', helpers.root('src'))
|
||||||
.set('@css', helpers.root('src/statics/css/*'))
|
.set('@css', helpers.root('src/statics/css/variables.scss'))
|
||||||
.set('@icons', helpers.root('src/statics/icons/*'))
|
.set('@icons', helpers.root('src/statics/icons/*'))
|
||||||
.set('@images', helpers.root('src/statics/images/*'))
|
.set('@images', helpers.root('src/statics/images/*'))
|
||||||
.set('@classes', helpers.root('src/classes/index.ts'))
|
.set('@classes', helpers.root('src/classes/index.ts'))
|
||||||
@@ -25,6 +25,7 @@ const extendTypescriptToWebpack = (config) => {
|
|||||||
.set('@utils', helpers.root('src/utils/*'))
|
.set('@utils', helpers.root('src/utils/*'))
|
||||||
.set('@router', helpers.root('src/router/index.ts'))
|
.set('@router', helpers.root('src/router/index.ts'))
|
||||||
.set('@validators', helpers.root('src/utils/validators.ts'))
|
.set('@validators', helpers.root('src/utils/validators.ts'))
|
||||||
|
.set('@methods', helpers.root('src/utils/methods.ts'))
|
||||||
.set('@api', helpers.root('src/store/Api/index.ts'))
|
.set('@api', helpers.root('src/store/Api/index.ts'))
|
||||||
.set('@paths', helpers.root('src/store/Api/ApiRoutes.ts'))
|
.set('@paths', helpers.root('src/store/Api/ApiRoutes.ts'))
|
||||||
.set('@types', helpers.root('src/typings/index.ts'))
|
.set('@types', helpers.root('src/typings/index.ts'))
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"@quasar/typescript": {
|
|
||||||
"webpack": "plugin",
|
|
||||||
"rename": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -153,7 +153,7 @@ if (workbox) {
|
|||||||
})
|
})
|
||||||
.then((clonedRes) => {
|
.then((clonedRes) => {
|
||||||
// console.log(' 3) ')
|
// console.log(' 3) ')
|
||||||
if (clonedRes !== undefined)
|
if (!!clonedRes)
|
||||||
return clonedRes.json();
|
return clonedRes.json();
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@@ -514,7 +514,7 @@ self.addEventListener('notificationclick', function (event) {
|
|||||||
return c.visibilityState === 'visible';
|
return c.visibilityState === 'visible';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (client !== undefined) {
|
if (!!client) {
|
||||||
client.navigate(notification.data.url);
|
client.navigate(notification.data.url);
|
||||||
client.focus();
|
client.focus();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
// import something here
|
// import something here
|
||||||
|
|
||||||
|
import { IMyRoute } from '@src/router/route-config'
|
||||||
|
|
||||||
|
// import { isEqual } from 'lodash'
|
||||||
|
import { ProgressBar } from '@src/store/Modules/Interface'
|
||||||
|
import { UserStore } from "@store"
|
||||||
|
|
||||||
export default ({ app, router, store, Vue }) => {
|
export default ({ app, router, store, Vue }) => {
|
||||||
// ******************************************
|
// ******************************************
|
||||||
// *** Per non permettere di accedere alle pagine in cui è necessario essere Loggati ! ***
|
// *** Per non permettere di accedere alle pagine in cui è necessario essere Loggati ! ***
|
||||||
@@ -8,42 +14,6 @@ export default ({ app, router, store, Vue }) => {
|
|||||||
// Creates a `nextMiddleware()` function which not only
|
// Creates a `nextMiddleware()` function which not only
|
||||||
// runs the default `next()` callback but also triggers
|
// runs the default `next()` callback but also triggers
|
||||||
// the subsequent Middleware function.
|
// the subsequent Middleware function.
|
||||||
function nextFactory(context, middleware, index) {
|
|
||||||
const subsequentMiddleware = middleware[index]
|
|
||||||
// If no subsequent Middleware exists,
|
|
||||||
// the default `next()` callback is returned.
|
|
||||||
if (!subsequentMiddleware) { return context.next }
|
|
||||||
|
|
||||||
return (...parameters) => {
|
|
||||||
// Run the default Vue Router `next()` callback first.
|
|
||||||
context.next(...parameters)
|
|
||||||
// Then run the subsequent Middleware with a new
|
|
||||||
// `nextMiddleware()` callback.
|
|
||||||
const nextMiddleware = nextFactory(context, middleware, index + 1)
|
|
||||||
subsequentMiddleware({ ...context, next: nextMiddleware })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
|
||||||
if (to.meta.middleware) {
|
|
||||||
const middleware = Array.isArray(to.meta.middleware)
|
|
||||||
? to.meta.middleware
|
|
||||||
: [to.meta.middleware];
|
|
||||||
|
|
||||||
const context = {
|
|
||||||
from,
|
|
||||||
next,
|
|
||||||
router,
|
|
||||||
to,
|
|
||||||
};
|
|
||||||
const nextMiddleware = nextFactory(context, middleware, 1)
|
|
||||||
|
|
||||||
return middleware[0]({ ...context, next: nextMiddleware })
|
|
||||||
}
|
|
||||||
|
|
||||||
return next()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
/*router.beforeEach((to, from, next) => {
|
/*router.beforeEach((to, from, next) => {
|
||||||
var accessToken = store.state.session.userSession.accessToken
|
var accessToken = store.state.session.userSession.accessToken
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export function debounce<F extends Procedure>(
|
|||||||
|
|
||||||
const shouldCallNow = options.isImmediate && timeoutId === undefined
|
const shouldCallNow = options.isImmediate && timeoutId === undefined
|
||||||
|
|
||||||
if (timeoutId !== undefined) {
|
if (!!timeoutId) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export default class Header extends Vue {
|
|||||||
|
|
||||||
const color = (value === 'online') ? 'positive' : 'warning'
|
const color = (value === 'online') ? 'positive' : 'warning'
|
||||||
|
|
||||||
if (oldValue !== undefined) {
|
if (!!oldValue) {
|
||||||
tools.showNotif(this.$q, this.$t('connection') + ` ${value}`, {
|
tools.showNotif(this.$q, this.$t('connection') + ` ${value}`, {
|
||||||
color,
|
color,
|
||||||
icon: 'wifi'
|
icon: 'wifi'
|
||||||
|
|||||||
49
src/components/Widgets/ProgressBar.vue
Normal file
49
src/components/Widgets/ProgressBar.vue
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<template>
|
||||||
|
<transition name='fade'>
|
||||||
|
<div class="progress" v-if="progressState.show"
|
||||||
|
:style="{
|
||||||
|
width: progressState.percent+'%',
|
||||||
|
height: progressState.height,
|
||||||
|
backgroundColor: progressState.canSuccess? progressState.color : progressState.failedColor,
|
||||||
|
}"
|
||||||
|
></div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang='ts'>
|
||||||
|
import Vue from 'vue'
|
||||||
|
import { Component } from 'vue-property-decorator'
|
||||||
|
import { ProgressBar } from '../../store/Modules/Interface'
|
||||||
|
|
||||||
|
@Component({})
|
||||||
|
export default class ProgressBarComponent extends Vue {
|
||||||
|
|
||||||
|
get progressState() {
|
||||||
|
return ProgressBar.state
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.progress {
|
||||||
|
position: fixed;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
height: 2px;
|
||||||
|
width: 0%;
|
||||||
|
transition: width 0.2s linear;
|
||||||
|
z-index: 999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter-active, .fade-leave-active {
|
||||||
|
transition: opacity 0.4s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter, .fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
1
src/components/Widgets/index.ts
Normal file
1
src/components/Widgets/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {default as ProgressBarComponent} from './ProgressBar.vue'
|
||||||
@@ -120,7 +120,7 @@ export default class Tabledata extends Vue {
|
|||||||
|
|
||||||
for (const myobj of myarrobj) {
|
for (const myobj of myarrobj) {
|
||||||
|
|
||||||
if (myobj.id !== undefined) {
|
if (!!myobj.id) {
|
||||||
console.log('KEY = ', myobj.id)
|
console.log('KEY = ', myobj.id)
|
||||||
|
|
||||||
// Delete item
|
// Delete item
|
||||||
|
|||||||
@@ -1,52 +1,11 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component } from 'vue-property-decorator'
|
import { Component } from 'vue-property-decorator'
|
||||||
|
import { tools } from '@src/store/Modules/tools'
|
||||||
import { TimelineLite, Back } from 'gsap'
|
|
||||||
|
|
||||||
import $ from 'jquery'
|
|
||||||
import Timeout = NodeJS.Timeout
|
|
||||||
import { tools } from "@src/store/Modules/tools"
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
||||||
})
|
})
|
||||||
export default class Logo extends Vue {
|
export default class Logo extends Vue {
|
||||||
public logoimg: string = ''
|
get logoimg() {
|
||||||
|
return '../../' + tools.getimglogo()
|
||||||
public created() {
|
|
||||||
this.logoimg = '../../' + tools.getimglogo()
|
|
||||||
this.animate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public animate() {
|
|
||||||
const timeline = new TimelineLite()
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
let mysmile = $('#smile')
|
|
||||||
|
|
||||||
mysmile.attr('class', 'smile_hide')
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
mysmile.removeClass('smilevisible')
|
|
||||||
mysmile.addClass('smile_hide')
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
mysmile.addClass('smilevisible')
|
|
||||||
mysmile.removeClass('smile_hide')
|
|
||||||
}, 10000)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
timeline.to('#smile', 5, {
|
|
||||||
cy: 20,
|
|
||||||
cx: 60,
|
|
||||||
ease: Back.easeInOut // Specify an ease
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,10 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component } from 'vue-property-decorator'
|
import { Component } from 'vue-property-decorator'
|
||||||
|
|
||||||
import { TimelineLite, Back } from 'gsap'
|
|
||||||
|
|
||||||
import $ from 'jquery'
|
|
||||||
import Timeout = NodeJS.Timeout
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
||||||
})
|
})
|
||||||
export default class Offline extends Vue {
|
export default class Offline extends Vue {
|
||||||
logoimg: string = ''
|
get logoimg() {
|
||||||
|
return '/statics/images/' + process.env.LOGO_REG
|
||||||
created() {
|
|
||||||
this.logoimg = '/statics/images/' + process.env.LOGO_REG
|
|
||||||
this.animate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
animate () {
|
|
||||||
const timeline = new TimelineLite()
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
let mysmile = $('#smile')
|
|
||||||
|
|
||||||
mysmile.attr('class', 'smile_hide')
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
mysmile.removeClass('smilevisible')
|
|
||||||
mysmile.addClass('smile_hide')
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
mysmile.addClass('smilevisible')
|
|
||||||
mysmile.removeClass('smile_hide')
|
|
||||||
}, 10000)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
timeline.to('#smile', 5, {
|
|
||||||
cy: 20,
|
|
||||||
cx: 60,
|
|
||||||
ease: Back.easeInOut // Specify an ease
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
110
src/components/projects/proj-list/proj-list.scss
Normal file
110
src/components/projects/proj-list/proj-list.scss
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
.flex-container{
|
||||||
|
background-color: rgb(250, 250, 250);
|
||||||
|
padding: 2px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.mycard {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myitemdrag {
|
||||||
|
padding: 2px;
|
||||||
|
//margin-top: 4px;
|
||||||
|
border-width: 1px 0px 0px 0px;
|
||||||
|
//border: solid 1px #ccc;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #ccc;
|
||||||
|
transition: all .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titlePriority, .titleCompleted{
|
||||||
|
border-width: 0px 0px 1px 0px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #ccc;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleCompleted {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.high_priority {
|
||||||
|
background-color: #4caf50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.medium_priority {
|
||||||
|
background-color: #3846af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.low_priority {
|
||||||
|
background-color: #af2218;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.myitemdrag-enter, .myitemdrag-leave-active {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drag {
|
||||||
|
//background-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dragArea {
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.divtitlecat {
|
||||||
|
margin: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.categorytitle{
|
||||||
|
color:blue;
|
||||||
|
background-color: lightblue;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleSubMenu {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 350;
|
||||||
|
}
|
||||||
|
|
||||||
|
.draggatodraggato2 {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.non-draggato {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.divdrag{
|
||||||
|
animation: fadeIn 0.2s ease-in 1 forwards;
|
||||||
|
min-height: 50px;
|
||||||
|
background-color: #9f9f9f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuInputCompleted > div:nth-child(2) > div > input {
|
||||||
|
min-width: 30px;
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
267
src/components/projects/proj-list/proj-list.ts
Normal file
267
src/components/projects/proj-list/proj-list.ts
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { Component, Watch } from 'vue-property-decorator'
|
||||||
|
|
||||||
|
import { IDrag, ITodo, ITodosState } from '@src/model'
|
||||||
|
import { SingleTodo } from '../../todos/SingleTodo'
|
||||||
|
|
||||||
|
import { tools } from '../../../store/Modules/tools'
|
||||||
|
|
||||||
|
import { GlobalStore, Todos } from '@store'
|
||||||
|
import { UserStore } from '@store'
|
||||||
|
|
||||||
|
import { Getter, Mutation, State } from 'vuex-class'
|
||||||
|
const namespace: string = 'Todos'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
|
||||||
|
components: { SingleTodo },
|
||||||
|
filters: {
|
||||||
|
capitalize(value) {
|
||||||
|
if (!value) { return '' }
|
||||||
|
value = value.toString()
|
||||||
|
return value.charAt(0).toUpperCase() + value.slice(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
export default class ProjList extends Vue {
|
||||||
|
|
||||||
|
get showtype() {
|
||||||
|
return Todos.state.showtype
|
||||||
|
}
|
||||||
|
|
||||||
|
set showtype(value) {
|
||||||
|
console.log('showtype', value)
|
||||||
|
GlobalStore.mutations.setShowType(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
get doneTodosCount() {
|
||||||
|
return Todos.getters.doneTodosCount(this.categoryAtt)
|
||||||
|
}
|
||||||
|
|
||||||
|
get menuPopupConfigTodo() {
|
||||||
|
return tools.menuPopupConfigTodo[UserStore.state.lang]
|
||||||
|
}
|
||||||
|
|
||||||
|
get listOptionShowTask() {
|
||||||
|
return tools.listOptionShowTask[UserStore.state.lang]
|
||||||
|
}
|
||||||
|
|
||||||
|
get TodosCount() {
|
||||||
|
return Todos.getters.TodosCount(this.categoryAtt)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Computed:
|
||||||
|
get reload_fromServer() {
|
||||||
|
return Todos.state.reload_fromServer
|
||||||
|
}
|
||||||
|
|
||||||
|
set reload_fromServer(value: number) {
|
||||||
|
Todos.state.reload_fromServer = value
|
||||||
|
}
|
||||||
|
public $q: any
|
||||||
|
public filter: boolean = false
|
||||||
|
public title: string = ''
|
||||||
|
public todotop: string = ''
|
||||||
|
public todobottom: string = ''
|
||||||
|
public drag: boolean = true
|
||||||
|
public startpos: number = 0
|
||||||
|
public listPriorityLabel: number[] = []
|
||||||
|
public arrPrior: number[] = []
|
||||||
|
public itemDragStart: any = null
|
||||||
|
public polling = null
|
||||||
|
public loadDone: boolean = false
|
||||||
|
public inddragging: number = -1
|
||||||
|
public service: any
|
||||||
|
public actualMaxPosition: number = 15
|
||||||
|
public scrollable = true
|
||||||
|
public tmpstrTodos: string = ''
|
||||||
|
public categoryAtt: string = ''
|
||||||
|
// public showtype: number = Todos.state.showtype
|
||||||
|
|
||||||
|
public $refs: {
|
||||||
|
single: SingleTodo[]
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter('projList', { namespace })
|
||||||
|
public projList: (state: ITodosState, category: string) => ITodo[]
|
||||||
|
|
||||||
|
public async onEnd(itemdragend) {
|
||||||
|
console.log('************ END DRAG: ', itemdragend)
|
||||||
|
this.inddragging = -1
|
||||||
|
|
||||||
|
await Todos.actions.swapElems(itemdragend)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public created() {
|
||||||
|
const $service = this.$dragula.$service
|
||||||
|
$service.options('first',
|
||||||
|
{
|
||||||
|
// isContainer: function (el) {
|
||||||
|
// return el.classList.contains('dragula-container')
|
||||||
|
// },
|
||||||
|
moves(el, source, handle, sibling) {
|
||||||
|
// console.log('moves')
|
||||||
|
return !el.classList.contains('donotdrag') // elements are always draggable by default
|
||||||
|
},
|
||||||
|
accepts(el, target, source, sibling) {
|
||||||
|
// console.log('accepts dragging '+ el.id + ' from ' + source.id + ' to ' + target.id)
|
||||||
|
return true // elements can be dropped in any of the `containers` by default
|
||||||
|
},
|
||||||
|
invalid(el, handle) {
|
||||||
|
// console.log('invalid')
|
||||||
|
return el.classList.contains('donotdrag') // don't prevent any drags from initiating by default
|
||||||
|
},
|
||||||
|
direction: 'vertical'
|
||||||
|
})
|
||||||
|
$service.eventBus.$on('dragend', (args) => {
|
||||||
|
|
||||||
|
const itemdragend: IDrag = {
|
||||||
|
category: this.categoryAtt,
|
||||||
|
newIndex: this.getElementIndex(args.el),
|
||||||
|
oldIndex: this.getElementOldIndex(args.el)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onEnd(itemdragend)
|
||||||
|
})
|
||||||
|
|
||||||
|
$service.eventBus.$on('drag', (el, source) => {
|
||||||
|
// mythis.inddragging = mythis.getElementIndex(el)
|
||||||
|
console.log('+++ DRAG ind=', this.inddragging)
|
||||||
|
this.scrollable = false
|
||||||
|
})
|
||||||
|
$service.eventBus.$on('drop', (el, source) => {
|
||||||
|
console.log('+++ DROP')
|
||||||
|
this.scrollable = true
|
||||||
|
})
|
||||||
|
|
||||||
|
this.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
public mounted() {
|
||||||
|
// console.log('*** MOUNTED ***')
|
||||||
|
|
||||||
|
this.categoryAtt = this.$route.params.category
|
||||||
|
|
||||||
|
if (window) {
|
||||||
|
window.addEventListener('touchmove', (e) => {
|
||||||
|
// console.log('touchmove')
|
||||||
|
if (!this.scrollable) {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}, { passive: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setarrPriority() {
|
||||||
|
this.arrPrior = []
|
||||||
|
const arr = tools.selectPriority[UserStore.state.lang]
|
||||||
|
if (arr) {
|
||||||
|
arr.forEach((rec) => {
|
||||||
|
this.arrPrior.push(rec.value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// console.log('Array PRIOR:', this.arrPrior)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async load() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public beforeDestroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public insertTodo(atfirst: boolean = false) {
|
||||||
|
let descr = this.todobottom.trim()
|
||||||
|
if (atfirst) {
|
||||||
|
descr = this.todotop.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descr === '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UserStore.state.userId === undefined) {
|
||||||
|
tools.showNotif(this.$q, this.$t('todo.usernotdefined'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (!this.isRegistered()) {
|
||||||
|
// // Not logged
|
||||||
|
// tools.showNotif(this.$q, this.$t('user.notregistered'))
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
const myobj: ITodo = {
|
||||||
|
descr,
|
||||||
|
category: this.categoryAtt
|
||||||
|
}
|
||||||
|
|
||||||
|
return Todos.actions.insertTodo({ myobj, atfirst })
|
||||||
|
.then((data) => {
|
||||||
|
|
||||||
|
console.log('data', data)
|
||||||
|
// if (data !== null) {
|
||||||
|
// tools.showNotif(this.$q, data)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// empty the field
|
||||||
|
if (atfirst) {
|
||||||
|
this.todotop = ''
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.todobottom = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updateitem({ myitem, field }) {
|
||||||
|
console.log('calling MODIFY updateitem', myitem, field)
|
||||||
|
// Update the others components...
|
||||||
|
|
||||||
|
const itemdragend: IDrag = {
|
||||||
|
category: this.categoryAtt,
|
||||||
|
field,
|
||||||
|
idelemtochange: myitem._id,
|
||||||
|
prioritychosen: myitem.priority,
|
||||||
|
atfirst: false
|
||||||
|
}
|
||||||
|
|
||||||
|
await Todos.actions.swapElems(itemdragend)
|
||||||
|
|
||||||
|
await Todos.actions.modify({ myitem, field })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public deselectAllRows(item: ITodo, check, onlythis: boolean = false) {
|
||||||
|
// console.log('deselectAllRows : ', item)
|
||||||
|
|
||||||
|
for (let i = 0; i < this.$refs.single.length; i++) {
|
||||||
|
|
||||||
|
const contr = this.$refs.single[i] as SingleTodo
|
||||||
|
// @ts-ignore
|
||||||
|
const id = contr.itemtodo._id
|
||||||
|
// Don't deselect the actual clicked!
|
||||||
|
let des = false
|
||||||
|
if (onlythis) {
|
||||||
|
des = item._id === id
|
||||||
|
} else {
|
||||||
|
des = ((check && (item._id !== id)) || (!check))
|
||||||
|
}
|
||||||
|
if (des) {
|
||||||
|
// @ts-ignore
|
||||||
|
contr.deselectAndExitEdit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getElementIndex(el: any) {
|
||||||
|
return [].slice.call(el.parentElement.children).indexOf(el)
|
||||||
|
}
|
||||||
|
|
||||||
|
private getElementOldIndex(el: any) {
|
||||||
|
return parseInt(el.attributes.index.value, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
100
src/components/projects/proj-list/proj-list.vue
Normal file
100
src/components/projects/proj-list/proj-list.vue
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<template>
|
||||||
|
<q-page>
|
||||||
|
<div class="panel">
|
||||||
|
<div class="divtitlecat">
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex-item categorytitle">{{categoryAtt | capitalize}}</div>
|
||||||
|
<div class="flex-item">
|
||||||
|
<q-btn push
|
||||||
|
icon="settings">
|
||||||
|
<q-menu id="popconfig" self="top right">
|
||||||
|
<q-list link separator no-border class="todo-menu">
|
||||||
|
<q-item clickable v-for="field in menuPopupConfigTodo" :key="field.value">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-icon :name="field.icon"/>
|
||||||
|
</q-item-section>
|
||||||
|
|
||||||
|
<q-item-section>{{field.label}}</q-item-section>
|
||||||
|
|
||||||
|
<q-item-section side v-if="showTask(field.value)">
|
||||||
|
<q-item-section side>
|
||||||
|
<q-icon name="keyboard_arrow_right"/>
|
||||||
|
</q-item-section>
|
||||||
|
|
||||||
|
<q-menu auto-close anchor="bottom middle" self="top middle">
|
||||||
|
<q-list dense>
|
||||||
|
<q-item side :icon="field.icon">
|
||||||
|
|
||||||
|
<q-item-section>
|
||||||
|
<q-list dense>
|
||||||
|
<q-item clickable v-ripple
|
||||||
|
v-for="opt in listOptionShowTask"
|
||||||
|
:key="opt.value"
|
||||||
|
@click="showtype = opt.value">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-icon :name="opt.icon" inverted
|
||||||
|
color="primary"/>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
{{opt.label}}
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
|
||||||
|
<div>
|
||||||
|
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
|
||||||
|
<div class="container" v-dragula="todos_dacompletare(categoryAtt)" drake="first">
|
||||||
|
<div :id="getmyid(mytodo._id)" :index="index"
|
||||||
|
v-for="(mytodo, index) in todos_dacompletare(categoryAtt)"
|
||||||
|
:key="mytodo._id" class="myitemdrag">
|
||||||
|
|
||||||
|
<div v-if="(prior !== mytodo.priority) && !mytodo.completed"
|
||||||
|
:class="getTitlePriority(mytodo.priority)">
|
||||||
|
<label>{{getPriorityByInd(mytodo.priority)}}</label>
|
||||||
|
</div>
|
||||||
|
<SingleTodo ref="single" @deleteItem="mydeleteItem(mytodo._id)" @eventupdate="updateitem"
|
||||||
|
@deselectAllRows="deselectAllRows" @onEnd="onEnd"
|
||||||
|
:itemtodo='mytodo'/>
|
||||||
|
|
||||||
|
<!--<div :name="`REF${index}`" class="divdrag non-draggato"></div>-->
|
||||||
|
|
||||||
|
<div style="display: none">{{ prior = mytodo.priority, priorcomplet = mytodo.completed }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--</q-infinite-scroll>-->
|
||||||
|
|
||||||
|
|
||||||
|
<q-input v-if="TodosCount > 0" ref="insertTaskBottom" v-model="todobottom"
|
||||||
|
style="margin-left: 6px;"
|
||||||
|
color="blue-12"
|
||||||
|
:label="$t('todo.insertbottom')"
|
||||||
|
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
|
||||||
|
v-on:keyup.enter="insertTodo(false)"/>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-page>
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script lang="ts" src="./proj-list.ts">
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './proj-list.scss';
|
||||||
|
</style>
|
||||||
@@ -271,7 +271,7 @@ export default class SingleTodo extends Vue {
|
|||||||
theField = this.$refs[elem] as HTMLInputElement
|
theField = this.$refs[elem] as HTMLInputElement
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theField !== undefined) {
|
if (!!theField) {
|
||||||
theField.focus()
|
theField.focus()
|
||||||
}
|
}
|
||||||
// console.log('focus()')
|
// console.log('focus()')
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
<q-btn push
|
<q-btn push
|
||||||
:class="clButtPopover"
|
:class="clButtPopover"
|
||||||
icon="menu">
|
icon="menu">
|
||||||
<q-menu id="popmenu" v-if="true" self="top right">
|
<q-menu ref="popmenu" self="top right">
|
||||||
<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu"
|
<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu"
|
||||||
@setPriority="setPriority"></SubMenus>
|
@setPriority="setPriority"></SubMenus>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
|
||||||
<q-list separator no-border class="todo-menu">
|
<q-list separator no-border class="todo-menu">
|
||||||
<div v-for="field in menuPopupTodo" :key="field.value">
|
<div v-for="field in menuPopupTodo" :key="field.value">
|
||||||
<q-item clickable v-if="(field.value !== 130) && (field.value !== 100)" :icon="field.icon"
|
<q-item clickable v-if="(field.value !== 130) && (field.value !== 100)" :icon="field.icon"
|
||||||
@@ -36,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item v-if="(field.value === 100)" :icon="field.icon"
|
<q-item clickable v-if="(field.value === 100)" :icon="field.icon"
|
||||||
@click.native="clickMenu(field.value)">
|
@click.native="clickMenu(field.value)">
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-icon :name="field.icon" inverted color="primary"/>
|
<q-icon :name="field.icon" inverted color="primary"/>
|
||||||
@@ -80,7 +79,6 @@
|
|||||||
</q-item>
|
</q-item>
|
||||||
</div>
|
</div>
|
||||||
</q-list>
|
</q-list>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" src="./SubMenus.ts">
|
<script lang="ts" src="./SubMenus.ts">
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ export default class Todo extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public checkUpdate() {
|
public checkUpdate() {
|
||||||
Todos.actions.waitAndcheckPendingMsg()
|
tools.waitAndcheckPendingMsg()
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadMoreTodo(index, done) {
|
public loadMoreTodo(index, done) {
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import { Todos, UserStore } from '@store'
|
import { Todos, UserStore } from '@store'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import store, { GlobalStore } from '../store'
|
import { GlobalStore } from '../store/Modules'
|
||||||
|
|
||||||
import { idbKeyval as storage } from '../js/storage.js'
|
import { idbKeyval as storage } from '../js/storage.js'
|
||||||
import { costanti } from '../store/Modules/costanti'
|
import { costanti } from '../store/Modules/costanti'
|
||||||
import { ICfgData } from '@src/model'
|
import { ICfgData, IGlobalState } from '@src/model'
|
||||||
|
|
||||||
function saveConfigIndexDb(context) {
|
function saveConfigIndexDb(context) {
|
||||||
|
|
||||||
const data: ICfgData = {}
|
const data: ICfgData = {
|
||||||
data._id = costanti.CONFIG_ID_CFG
|
_id: costanti.CONFIG_ID_CFG,
|
||||||
data.lang = UserStore.state.lang
|
lang: UserStore.state.lang,
|
||||||
data.token = UserStore.state.x_auth_token
|
token: UserStore.state.x_auth_token,
|
||||||
data.userId = UserStore.state.userId
|
userId: UserStore.state.userId
|
||||||
|
}
|
||||||
|
|
||||||
writeConfigIndexDb('config', data)
|
writeConfigIndexDb('config', data)
|
||||||
}
|
}
|
||||||
@@ -21,10 +22,6 @@ function writeConfigIndexDb(context, data) {
|
|||||||
// console.log('writeConfigIndexDb', data)
|
// console.log('writeConfigIndexDb', data)
|
||||||
|
|
||||||
storage.setdata('config', data)
|
storage.setdata('config', data)
|
||||||
.then((ris) => {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readfromIndexDbToStateTodos(context, table) {
|
async function readfromIndexDbToStateTodos(context, table) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function translate(params) {
|
|||||||
const stringa = messages[lang]
|
const stringa = messages[lang]
|
||||||
|
|
||||||
let ris = stringa
|
let ris = stringa
|
||||||
if (ris !== undefined) {
|
if (!!ris) {
|
||||||
msg.forEach((param) => {
|
msg.forEach((param) => {
|
||||||
ris = ris[param]
|
ris = ris[param]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
export let idbKeyval = (() => {
|
export let idbKeyval = (() => {
|
||||||
let db;
|
let db;
|
||||||
const fieldsData = ['completed_at', 'created_at', 'expiring_at', 'modify_at']
|
|
||||||
|
|
||||||
function getDB() {
|
function getDB() {
|
||||||
if (!db) {
|
if (!db) {
|
||||||
@@ -14,13 +13,9 @@ export let idbKeyval = (() => {
|
|||||||
|
|
||||||
openreq.onupgradeneeded = () => {
|
openreq.onupgradeneeded = () => {
|
||||||
// First time setup: create an empty object store
|
// First time setup: create an empty object store
|
||||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
for (mytab of tools.allTables) {
|
||||||
openreq.result.createObjectStore('categories', { keyPath: '_id' });
|
openreq.result.createObjectStore(mytab, { keyPath: '_id' });
|
||||||
openreq.result.createObjectStore('sync_todos', { keyPath: '_id' });
|
}
|
||||||
openreq.result.createObjectStore('sync_todos_patch', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('delete_todos', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('config', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('swmsg', { keyPath: '_id' });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
openreq.onsuccess = () => {
|
openreq.onsuccess = () => {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { tools } from "../store/Modules/tools";
|
import { tools } from '../store/Modules/tools'
|
||||||
|
|
||||||
import { RouteNames } from '../router/route-names'
|
import { RouteNames } from '../router/route-names'
|
||||||
|
|
||||||
export default function auth({ next, router }) {
|
export default function auth({ next, router }) {
|
||||||
const tok = tools.getItemLS(tools.localStorage.token)
|
const tok = tools.getItemLS(tools.localStorage.token)
|
||||||
if (!tok) {
|
if (!tok) {
|
||||||
return router.push({ name: RouteNames.login });
|
return router.push({ name: RouteNames.login })
|
||||||
}
|
}
|
||||||
|
|
||||||
return next();
|
return next()
|
||||||
}
|
}
|
||||||
|
|||||||
49
src/model/Projects.ts
Normal file
49
src/model/Projects.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
export interface IProject {
|
||||||
|
_id?: any,
|
||||||
|
userId?: string
|
||||||
|
category?: string
|
||||||
|
descr?: string,
|
||||||
|
priority?: number,
|
||||||
|
completed?: boolean,
|
||||||
|
created_at?: Date,
|
||||||
|
modify_at?: Date,
|
||||||
|
completed_at?: Date,
|
||||||
|
expiring_at?: Date,
|
||||||
|
enableExpiring?: boolean,
|
||||||
|
id_prev?: string,
|
||||||
|
modified?: boolean,
|
||||||
|
pos?: number,
|
||||||
|
order?: number,
|
||||||
|
progress?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IParamProject {
|
||||||
|
categorySel?: string
|
||||||
|
checkPending?: boolean
|
||||||
|
id?: string
|
||||||
|
objtodo?: IProject
|
||||||
|
atfirst?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
export interface IDrag {
|
||||||
|
field?: string
|
||||||
|
idelemtochange?: string
|
||||||
|
prioritychosen?: number
|
||||||
|
oldIndex?: number
|
||||||
|
newIndex?: number
|
||||||
|
category: string
|
||||||
|
atfirst?: boolean
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface IProjectState {
|
||||||
|
showtype: number
|
||||||
|
todos: {}
|
||||||
|
categories: string[]
|
||||||
|
// todos_changed: number
|
||||||
|
reload_fromServer: number
|
||||||
|
testpao: string
|
||||||
|
insidePending: boolean
|
||||||
|
visuLastCompleted: number
|
||||||
|
}
|
||||||
@@ -41,7 +41,7 @@ export interface ITodosState {
|
|||||||
categories: string[]
|
categories: string[]
|
||||||
// todos_changed: number
|
// todos_changed: number
|
||||||
reload_fromServer: number
|
reload_fromServer: number
|
||||||
testpao: String
|
testpao: string
|
||||||
insidePending: boolean
|
insidePending: boolean
|
||||||
visuLastCompleted: number
|
visuLastCompleted: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { IToken } from 'model/other'
|
|||||||
export const DefaultUser = <IUserState>{
|
export const DefaultUser = <IUserState>{
|
||||||
email: '',
|
email: '',
|
||||||
username: '',
|
username: '',
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
password: '',
|
password: '',
|
||||||
lang: 'it'
|
lang: 'it'
|
||||||
}
|
}
|
||||||
@@ -12,7 +11,6 @@ export interface IUserState {
|
|||||||
userId?: string
|
userId?: string
|
||||||
email?: string
|
email?: string
|
||||||
username?: string
|
username?: string
|
||||||
idapp?: any
|
|
||||||
password?: string
|
password?: string
|
||||||
lang?: string
|
lang?: string
|
||||||
repeatPassword?: string
|
repeatPassword?: string
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export default class Home extends Vue {
|
|||||||
public visibile: boolean = false
|
public visibile: boolean = false
|
||||||
public cardvisible: string = 'hidden'
|
public cardvisible: string = 'hidden'
|
||||||
public displaycard: string = 'block'
|
public displaycard: string = 'block'
|
||||||
public svgclass: string = 'svgclass'
|
|
||||||
public $t: any
|
public $t: any
|
||||||
// public firstClassSection: string = 'landing_background fade homep-cover-img animate-fade homep-cover-img-1'
|
// public firstClassSection: string = 'landing_background fade homep-cover-img animate-fade homep-cover-img-1'
|
||||||
public firstClassSection: string = 'fade homep-cover-img animate-fade homep-cover-img-1'
|
public firstClassSection: string = 'fade homep-cover-img animate-fade homep-cover-img-1'
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ import Vue from 'vue'
|
|||||||
import VueRouter, { RouterMode } from 'vue-router'
|
import VueRouter, { RouterMode } from 'vue-router'
|
||||||
import { PositionResult } from 'vue-router/types/router'
|
import { PositionResult } from 'vue-router/types/router'
|
||||||
|
|
||||||
import { RouteConfig } from './route-config'
|
import { IMyRoute, IMyRouteRecord, routesList } from './route-config'
|
||||||
|
import { ProgressBar } from '@src/store/Modules/Interface'
|
||||||
|
import { isEqual } from 'lodash'
|
||||||
|
import { UserStore } from '@store'
|
||||||
|
import { RouteNames } from '@src/router/route-names'
|
||||||
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
/*
|
/*
|
||||||
@@ -11,8 +16,8 @@ Vue.use(VueRouter)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const Router = new VueRouter({
|
const Router = new VueRouter({
|
||||||
scrollBehavior: () => ({ y: 0 } as PositionResult),
|
scrollBehavior: () => ({ x: 0, y: 0 } as PositionResult),
|
||||||
routes: RouteConfig,
|
routes: routesList,
|
||||||
|
|
||||||
// Leave these as is and change from quasar.conf.js instead!
|
// Leave these as is and change from quasar.conf.js instead!
|
||||||
// quasar.conf.js -> build -> vueRouterMode
|
// quasar.conf.js -> build -> vueRouterMode
|
||||||
@@ -20,4 +25,159 @@ const Router = new VueRouter({
|
|||||||
base: process.env.VUE_ROUTER_BASE
|
base: process.env.VUE_ROUTER_BASE
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function nextFactory(context, middleware, index) {
|
||||||
|
const subsequentMiddleware = middleware[index]
|
||||||
|
// If no subsequent Middleware exists,
|
||||||
|
// the default `next()` callback is returned.
|
||||||
|
if (!subsequentMiddleware) {
|
||||||
|
return context.next
|
||||||
|
}
|
||||||
|
|
||||||
|
return (...parameters) => {
|
||||||
|
// Run the default Vue Router `next()` callback first.
|
||||||
|
context.next(...parameters)
|
||||||
|
// Then run the subsequent Middleware with a new
|
||||||
|
// `nextMiddleware()` callback.
|
||||||
|
const nextMiddleware = nextFactory(context, middleware, index + 1)
|
||||||
|
subsequentMiddleware({ ...context, next: nextMiddleware })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Router.beforeEach(async (to: IMyRoute, from: IMyRoute, next) => {
|
||||||
|
try {
|
||||||
|
// Check session
|
||||||
|
// if (!LoginStore.state.sessionChecked) {
|
||||||
|
// await LoginStore.actions.checkUserSession();
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log(to, from)
|
||||||
|
|
||||||
|
if (from.name && from.matched[0].name === to.name && from.meta.isModal) {
|
||||||
|
next()
|
||||||
|
console.log('Route interceptor log: <1>')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else if (from.name === to.name && isEqual(from.params, to.params)) {
|
||||||
|
console.log('Route interceptor log: <2>')
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
if (!to.meta.transparent && !to.meta.isModal) {
|
||||||
|
console.log('Route interceptor log: <4>')
|
||||||
|
ProgressBar.mutations.start()
|
||||||
|
}
|
||||||
|
else if (to.meta.transparent && !from.name) {
|
||||||
|
console.log('Route interceptor log: <5>')
|
||||||
|
ProgressBar.mutations.start()
|
||||||
|
}
|
||||||
|
else if (to.meta.transparent && !to.matched.some((m) => m.name === from.name)) {
|
||||||
|
console.log('Route interceptor log: <6>')
|
||||||
|
ProgressBar.mutations.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// If page is initialazed on child
|
||||||
|
/*
|
||||||
|
if (to.matched[0] && to.meta.isModal) {
|
||||||
|
console.log('Route interceptor log: <7>')
|
||||||
|
if (!from.name) {
|
||||||
|
getRouteData(to.matched[0])
|
||||||
|
GlobalStore.mutations.setPreviousModalRoute(to.matched[0].path)
|
||||||
|
} else {
|
||||||
|
GlobalStore.mutations.setPreviousModalRoute(from.fullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// Check requires auth
|
||||||
|
if (to.matched.some((m) => m.meta.requiresAuth)) {
|
||||||
|
// await LoginStore.actions.refreshUserInfos()
|
||||||
|
if (tools.isLoggedToSystem()) {
|
||||||
|
if (!!to.meta.asyncData) {
|
||||||
|
await getRouteData(to)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (to.matched.some((m) => !!m.meta.isAuthorized)) {
|
||||||
|
const results = await Promise.all([
|
||||||
|
...to.matched.filter((m) => !!m.meta.isAuthorized)
|
||||||
|
.map((m) => m.meta.isAuthorized(to))
|
||||||
|
])
|
||||||
|
|
||||||
|
if (!results.every((m) => m)) {
|
||||||
|
NotificationsStore.actions.addNotification({
|
||||||
|
type: 'warning',
|
||||||
|
message: `Vous n'avez pas accès à cette page`
|
||||||
|
})
|
||||||
|
ProgressBar.mutations.fail()
|
||||||
|
if (from.name) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
next('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
// LoginStore.mutations.showLoginRoute(to.fullPath)
|
||||||
|
if (from.name) {
|
||||||
|
ProgressBar.mutations.hide()
|
||||||
|
} else {
|
||||||
|
// next('/')
|
||||||
|
}
|
||||||
|
|
||||||
|
return Router.push({ name: RouteNames.login })
|
||||||
|
}
|
||||||
|
} else if (to.matched.some((m) => m.meta.noAuth) && UserStore.state.isLogged) {
|
||||||
|
next('/')
|
||||||
|
} else {
|
||||||
|
if (to.meta.asyncData) {
|
||||||
|
await getRouteData(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if (to.meta.middleware) {
|
||||||
|
// const middleware = Array.isArray(to.meta.middleware)
|
||||||
|
// ? to.meta.middleware
|
||||||
|
// : [to.meta.middleware]
|
||||||
|
//
|
||||||
|
// const context = {
|
||||||
|
// from,
|
||||||
|
// next,
|
||||||
|
// Router,
|
||||||
|
// to
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// const nextMiddleware = nextFactory(context, middleware, 1)
|
||||||
|
//
|
||||||
|
// return middleware[0]({ ...context, next: nextMiddleware })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
return next()
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
(err) {
|
||||||
|
console.log('Route error:', err)
|
||||||
|
ProgressBar.mutations.fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const getRouteData = async (to: IMyRoute | IMyRouteRecord) => {
|
||||||
|
if (!to.meta.transparent) {
|
||||||
|
ProgressBar.mutations.start()
|
||||||
|
}
|
||||||
|
const titleToDisplay: any = await to.meta.asyncData(to)
|
||||||
|
// if (to.meta.contentProp) {
|
||||||
|
// document.title = `${titleToDisplay.title || to.meta.title} - MovingMate`
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
Router.afterEach(async (from: IMyRoute, next) => {
|
||||||
|
ProgressBar.mutations.finish()
|
||||||
|
// AlertsStore.mutations.hideAlert()
|
||||||
|
// EventBus.$emit('closePopups')
|
||||||
|
})
|
||||||
|
|
||||||
export default Router
|
export default Router
|
||||||
|
|||||||
@@ -1,12 +1,40 @@
|
|||||||
import { RouteConfig as VueRouteConfig } from 'vue-router'
|
import { RouteConfig, Route, RouteRecord } from 'vue-router/types'
|
||||||
|
|
||||||
import { RouteNames } from './route-names'
|
import { RouteNames } from './route-names'
|
||||||
import { tools } from '@src/store/Modules/tools'
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
|
||||||
import auth from '../middleware/auth'
|
import auth from '../middleware/auth'
|
||||||
|
import { Todos } from "@store"
|
||||||
|
|
||||||
|
interface IMyMeta {
|
||||||
|
title?: string,
|
||||||
|
headerShadow?: boolean,
|
||||||
|
contentProp?: boolean,
|
||||||
|
transparent?: boolean,
|
||||||
|
isModal?: boolean,
|
||||||
|
requiresAuth?: boolean,
|
||||||
|
isTab?: boolean,
|
||||||
|
noAuth?: boolean,
|
||||||
|
asyncData?: (to?: IMyRoute | IMyRouteRecord) => Promise<{title?: string} | void>,
|
||||||
|
isAuthorized?: (to?: any) => boolean
|
||||||
|
middleware?: any[]
|
||||||
|
}
|
||||||
|
|
||||||
export const RouteConfig: VueRouteConfig[] = [
|
export interface IMyRoute extends Route {
|
||||||
|
meta: IMyMeta,
|
||||||
|
matched: IMyRouteRecord[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMyRouteRecord extends RouteRecord {
|
||||||
|
meta: IMyMeta,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMyRouteConfig extends RouteConfig {
|
||||||
|
children?: IMyRouteConfig[],
|
||||||
|
meta?: IMyMeta
|
||||||
|
}
|
||||||
|
|
||||||
|
export const routesList: IMyRouteConfig[] = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: RouteNames.home,
|
name: RouteNames.home,
|
||||||
@@ -32,7 +60,11 @@ export const RouteConfig: VueRouteConfig[] = [
|
|||||||
name: 'Todos',
|
name: 'Todos',
|
||||||
component: () => import('@/components/todos/todo/todo.vue'),
|
component: () => import('@/components/todos/todo/todo.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
middleware: [auth]
|
requiresAuth: true,
|
||||||
|
async asyncData() {
|
||||||
|
await Todos.actions.dbLoadTodo({ checkPending: false })
|
||||||
|
}
|
||||||
|
// middleware: [auth]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,7 +77,8 @@ export const RouteConfig: VueRouteConfig[] = [
|
|||||||
name: 'cfgserv',
|
name: 'cfgserv',
|
||||||
component: () => import('@/components/admin/cfgServer/cfgServer.vue'),
|
component: () => import('@/components/admin/cfgServer/cfgServer.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
middleware: [auth]
|
requiresAuth: true
|
||||||
|
// middleware: [auth]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -57,8 +90,19 @@ export const RouteConfig: VueRouteConfig[] = [
|
|||||||
path: '/offline',
|
path: '/offline',
|
||||||
name: 'Offline',
|
name: 'Offline',
|
||||||
component: () => import('@/components/offline/offline.vue')
|
component: () => import('@/components/offline/offline.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/projects',
|
||||||
|
name: 'progetti',
|
||||||
|
component: () => import('@/components/projects/proj-list/proj-list.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true
|
||||||
|
// middleware: [auth]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/requestresetpwd',
|
path: '/requestresetpwd',
|
||||||
component: () => import('@/views/login/requestresetpwd.vue'),
|
component: () => import('@/views/login/requestresetpwd.vue'),
|
||||||
|
|||||||
184
src/statics/css/variables.scss
Normal file
184
src/statics/css/variables.scss
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
// Couleurs
|
||||||
|
$mainStyle: #4975BA;
|
||||||
|
$mainColor: #3c4858;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$yellow1: #f8ab1c;
|
||||||
|
$yellow2: rgb(221, 144, 35);
|
||||||
|
$yellow3: #f8d71c;
|
||||||
|
|
||||||
|
$blue1: #4286f4;
|
||||||
|
$blue2: #a9dff5;
|
||||||
|
|
||||||
|
$red1: #c84242;
|
||||||
|
$orange1: #cf7219;
|
||||||
|
$rose1: #dd4587;
|
||||||
|
|
||||||
|
$green1: #5cb85c;
|
||||||
|
$green2: #CEE8DF;
|
||||||
|
$green3: #70BEB1;
|
||||||
|
$green4: #4c964c;
|
||||||
|
|
||||||
|
$brown1: #D99E7E;
|
||||||
|
|
||||||
|
:export {
|
||||||
|
mainStyle: $mainStyle;
|
||||||
|
red1: $red1;
|
||||||
|
blue2: $blue2;
|
||||||
|
yellow1: $yellow1;
|
||||||
|
yellow2: $yellow2;
|
||||||
|
yellow3: $yellow3;
|
||||||
|
mainColor: $mainColor;
|
||||||
|
green1: $green1;
|
||||||
|
green2: $green2;
|
||||||
|
green3: $green3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$w255: rgb(255, 255, 255);
|
||||||
|
$w250: rgb(250, 250, 250);
|
||||||
|
$w245: rgb(245, 245, 245);
|
||||||
|
$w240: rgb(240, 240, 240);
|
||||||
|
$w235: rgb(235, 235, 235);
|
||||||
|
$w230: rgb(230, 230, 230);
|
||||||
|
$w225: rgb(225, 225, 225);
|
||||||
|
$w220: rgb(220, 220, 220);
|
||||||
|
$w210: rgb(210, 210, 210);
|
||||||
|
$w200: rgb(200, 200, 200);
|
||||||
|
$w190: rgb(190, 190, 190);
|
||||||
|
$w180: rgb(180, 180, 180);
|
||||||
|
$w170: rgb(170, 170, 170);
|
||||||
|
$w160: rgb(160, 160, 160);
|
||||||
|
$w150: rgb(150, 150, 150);
|
||||||
|
$w140: rgb(140, 140, 140);
|
||||||
|
$w130: rgb(130, 130, 130);
|
||||||
|
$w120: rgb(120, 120, 120);
|
||||||
|
$w110: rgb(110, 110, 110);
|
||||||
|
$w100: rgb(100, 100, 100);
|
||||||
|
|
||||||
|
$g90: rgb(90, 90, 90);
|
||||||
|
$g80: rgb(80, 80, 80);
|
||||||
|
$g70: rgb(70, 70, 70);
|
||||||
|
$g60: rgb(60, 60, 60);
|
||||||
|
$g50: rgb(50, 50, 50);
|
||||||
|
$g40: rgb(40, 40, 40);
|
||||||
|
$g30: rgb(30, 30, 30);
|
||||||
|
$g20: rgb(20, 20, 20);
|
||||||
|
$g10: rgb(10, 10, 10);
|
||||||
|
$g0: rgb(0, 0, 0);
|
||||||
|
|
||||||
|
$ombre: rgba(10,10,10,0.2);
|
||||||
|
|
||||||
|
|
||||||
|
$mainFont: 'Arial, sans-serif';
|
||||||
|
|
||||||
|
$mini: "(max-width: 1000px)";
|
||||||
|
$desktop: "(min-width: 1001px)";
|
||||||
|
|
||||||
|
|
||||||
|
$Loadersize: 20px;
|
||||||
|
|
||||||
|
//tailles
|
||||||
|
|
||||||
|
$headerHeight: 60px;
|
||||||
|
$headerColor: #373F46;
|
||||||
|
|
||||||
|
|
||||||
|
$boutonfont: 14px;
|
||||||
|
$boutonH: 20px;
|
||||||
|
|
||||||
|
$aside-w: 180px;
|
||||||
|
|
||||||
|
$contentSize: 170px;
|
||||||
|
|
||||||
|
// fonts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@mixin transition($args...) {
|
||||||
|
-webkit-transition: $args;
|
||||||
|
-moz-transition: $args;
|
||||||
|
-o-transition: $args;
|
||||||
|
-ms-transition: $args;
|
||||||
|
transition: $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin scale($scale) {
|
||||||
|
-webkit-transform: scale($scale);
|
||||||
|
-moz-transform: scale($scale);
|
||||||
|
-o-transform: scale($scale);
|
||||||
|
-ms-transform: scale($scale);
|
||||||
|
transform: scale($scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin rotate($angle) {
|
||||||
|
-webkit-transform: rotate($angle);
|
||||||
|
-moz-transform: rotate($angle);
|
||||||
|
-o-transform: rotate($angle);
|
||||||
|
-ms-transform: rotate($angle);
|
||||||
|
transform: rotate($angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin translateX($value) {
|
||||||
|
-webkit-transform: translateX($value);
|
||||||
|
-moz-transform: translateX($value);
|
||||||
|
-o-transform: translateX($value);
|
||||||
|
-ms-transform: translateX($value);
|
||||||
|
transform: translateX($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin translateY($value) {
|
||||||
|
-webkit-transform: translateY($value);
|
||||||
|
-moz-transform: translateY($value);
|
||||||
|
-o-transform: translateY($value);
|
||||||
|
-ms-transform: translateY($value);
|
||||||
|
transform: translateY($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin translate($x, $y) {
|
||||||
|
-webkit-transform: translate($x, $y);
|
||||||
|
-moz-transform: translate($x, $y);
|
||||||
|
-o-transform: translate($x, $y);
|
||||||
|
-ms-transform: translate($x, $y);
|
||||||
|
transform: translate($x, $y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin userselect {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-o-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin ellipsis {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin inputbase {
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin bg-center {
|
||||||
|
background: {
|
||||||
|
size: cover;
|
||||||
|
position: center center;
|
||||||
|
repeat: no-repeat;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin filter($property) {
|
||||||
|
-webkit-filter: $property;
|
||||||
|
-o-filter: $property;
|
||||||
|
-moz-filter: $property;
|
||||||
|
-ms-filter: $property;
|
||||||
|
filter: $property;
|
||||||
|
}
|
||||||
@@ -126,6 +126,7 @@ const messages = {
|
|||||||
Admin: 'Admin',
|
Admin: 'Admin',
|
||||||
Test1: 'Test1',
|
Test1: 'Test1',
|
||||||
Test2: 'Test2',
|
Test2: 'Test2',
|
||||||
|
Projects: 'Progetti'
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
authentication: {
|
authentication: {
|
||||||
@@ -361,6 +362,7 @@ const messages = {
|
|||||||
Admin: 'Administración',
|
Admin: 'Administración',
|
||||||
Test1: 'Test1',
|
Test1: 'Test1',
|
||||||
Test2: 'Test2',
|
Test2: 'Test2',
|
||||||
|
Projects: 'Projectos',
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
authentication: {
|
authentication: {
|
||||||
@@ -589,6 +591,7 @@ const messages = {
|
|||||||
Admin: 'Admin',
|
Admin: 'Admin',
|
||||||
Test1: 'Test1',
|
Test1: 'Test1',
|
||||||
Test2: 'Test2',
|
Test2: 'Test2',
|
||||||
|
Projects: 'Projects',
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
authentication: {
|
authentication: {
|
||||||
|
|||||||
@@ -271,7 +271,7 @@
|
|||||||
}
|
}
|
||||||
items.push(cursor.value);
|
items.push(cursor.value);
|
||||||
|
|
||||||
if (count !== undefined && items.length == count) {
|
if (!!count && items.length == count) {
|
||||||
resolve(items);
|
resolve(items);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
const allTables = ['todos', 'categories', 'sync_post_todos', 'sync_patch_todos', 'delete_todos', 'config', 'swmsg']
|
||||||
|
|
||||||
let idbKeyval = (() => {
|
let idbKeyval = (() => {
|
||||||
let db;
|
let db;
|
||||||
// console.log('idbKeyval...')
|
// console.log('idbKeyval...')
|
||||||
@@ -14,13 +16,9 @@ let idbKeyval = (() => {
|
|||||||
|
|
||||||
openreq.onupgradeneeded = () => {
|
openreq.onupgradeneeded = () => {
|
||||||
// First time setup: create an empty object store
|
// First time setup: create an empty object store
|
||||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
for (mytab of allTables) {
|
||||||
openreq.result.createObjectStore('categories', { keyPath: '_id' });
|
openreq.result.createObjectStore(mytab, { keyPath: '_id' });
|
||||||
openreq.result.createObjectStore('sync_todos', { keyPath: '_id' });
|
}
|
||||||
openreq.result.createObjectStore('sync_todos_patch', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('delete_todos', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('config', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('swmsg', { keyPath: '_id' });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
openreq.onsuccess = () => {
|
openreq.onsuccess = () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// import { NotificationsStore, LoginStore } from '@store'
|
// import { NotificationsStore, LoginStore } from '@store'
|
||||||
|
|
||||||
export class AxiosSuccess {
|
export class AxiosSuccess {
|
||||||
public success: boolean = true
|
public success: any = true
|
||||||
public status: number
|
public status: number
|
||||||
public data: any
|
public data: any
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ export class AxiosSuccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class AxiosError {
|
export class AxiosError {
|
||||||
public success: boolean = false
|
public success: boolean = false
|
||||||
public status: number = 0
|
public status: number = 0
|
||||||
@@ -18,7 +19,7 @@ export class AxiosError {
|
|||||||
public code: any = 0
|
public code: any = 0
|
||||||
public msgerr: string = ''
|
public msgerr: string = ''
|
||||||
|
|
||||||
constructor(status: number, data?: any, code?: any, msgerr?: string) {
|
constructor(status: number, data?: any, code?: any, msgerr: string = '') {
|
||||||
this.status = status
|
this.status = status
|
||||||
this.data = data
|
this.data = data
|
||||||
this.code = code
|
this.code = code
|
||||||
@@ -89,10 +90,6 @@ export class ApiResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class ApiSuccess extends ApiResponse {
|
export class ApiSuccess extends ApiResponse {
|
||||||
constructor(fields: {message?: string, data?: any} = {}) {
|
constructor(fields: {message?: string, data?: any} = {}) {
|
||||||
super({
|
super({
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export const removeAuthHeaders = () => {
|
|||||||
async function Request(type: string, path: string, payload: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
async function Request(type: string, path: string, payload: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||||
let ricevuto = false
|
let ricevuto = false
|
||||||
try {
|
try {
|
||||||
console.log(`Axios Request [${type}]:`, axiosInstance.defaults, 'path:', path)
|
console.log('Axios Request', path, type, axiosInstance.defaults)
|
||||||
let response: AxiosResponse
|
let response: AxiosResponse
|
||||||
if (type === 'post' || type === 'put' || type === 'patch') {
|
if (type === 'post' || type === 'put' || type === 'patch') {
|
||||||
response = await axiosInstance[type](path, payload, {
|
response = await axiosInstance[type](path, payload, {
|
||||||
@@ -63,6 +63,8 @@ async function Request(type: string, path: string, payload: any): Promise<Types.
|
|||||||
|
|
||||||
const setAuthToken = (path === '/updatepwd')
|
const setAuthToken = (path === '/updatepwd')
|
||||||
|
|
||||||
|
// console.log('--------- 0 ')
|
||||||
|
|
||||||
if (response && (response.status === 200)) {
|
if (response && (response.status === 200)) {
|
||||||
let x_auth_token = ''
|
let x_auth_token = ''
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -62,6 +62,15 @@ export namespace ApiTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function SendReq(url: string, method: string, mydata: any, setAuthToken: boolean = false): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
export async function SendReq(url: string, method: string, mydata: any, setAuthToken: boolean = false): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||||
|
|
||||||
|
mydata = {
|
||||||
|
...mydata,
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
idapp: process.env.APP_ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('mydata', mydata)
|
||||||
|
|
||||||
UserStore.mutations.setServerCode(tools.EMPTY)
|
UserStore.mutations.setServerCode(tools.EMPTY)
|
||||||
UserStore.mutations.setResStatus(0)
|
UserStore.mutations.setResStatus(0)
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
@@ -122,7 +131,7 @@ export namespace ApiTool {
|
|||||||
const token = multiparams[3]
|
const token = multiparams[3]
|
||||||
// let lang = multiparams[3]
|
// let lang = multiparams[3]
|
||||||
|
|
||||||
if (cmd === 'sync-todos') {
|
if (cmd === tools.DB.CMD_SYNC) {
|
||||||
// console.log('[Alternative] Syncing', cmd, table, method)
|
// console.log('[Alternative] Syncing', cmd, table, method)
|
||||||
|
|
||||||
// const headers = new Headers()
|
// const headers = new Headers()
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import { GlobalStore, Todos, UserStore } from '@store'
|
|||||||
import messages from '../../statics/i18n'
|
import messages from '../../statics/i18n'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
|
|
||||||
const allTables = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
|
||||||
const allTablesAfterLogin = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
|
||||||
|
|
||||||
let stateConnDefault = 'online'
|
let stateConnDefault = 'online'
|
||||||
|
|
||||||
getstateConnSaved()
|
getstateConnSaved()
|
||||||
@@ -134,6 +131,8 @@ namespace Getters {
|
|||||||
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
|
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
|
||||||
routes2: listatodo
|
routes2: listatodo
|
||||||
},
|
},
|
||||||
|
{ route: '/projects', faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects' },
|
||||||
|
|
||||||
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' },
|
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' },
|
||||||
{ route: '/admin/cfgserv', faIcon: 'fa fa-database', materialIcon: 'event_seat', name: 'pages.Admin' },
|
{ route: '/admin/cfgserv', faIcon: 'fa fa-database', materialIcon: 'event_seat', name: 'pages.Admin' },
|
||||||
{ route: '/admin/testp1/par1', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test1' },
|
{ route: '/admin/testp1/par1', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test1' },
|
||||||
@@ -444,22 +443,22 @@ namespace Actions {
|
|||||||
console.log('clearDataAfterLogout')
|
console.log('clearDataAfterLogout')
|
||||||
|
|
||||||
// Clear all data from the IndexedDB
|
// Clear all data from the IndexedDB
|
||||||
for (const table of allTables) {
|
for (const table of tools.allTables) {
|
||||||
await globalroutines(null, 'clearalldata', table, null)
|
await globalroutines(null, 'clearalldata', table, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
// REMOVE ALL SUBSCRIPTION
|
// REMOVE ALL SUBSCRIPTION
|
||||||
console.log('REMOVE ALL SUBSCRIPTION...')
|
console.log('REMOVE ALL SUBSCRIPTION...')
|
||||||
await navigator.serviceWorker.ready.then(function (reg) {
|
await navigator.serviceWorker.ready.then((reg) => {
|
||||||
console.log('... Ready')
|
console.log('... Ready')
|
||||||
reg.pushManager.getSubscription().then((subscription) => {
|
reg.pushManager.getSubscription().then((subscription) => {
|
||||||
console.log(' Found Subscription...')
|
console.log(' Found Subscription...')
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
subscription.unsubscribe().then(function (successful) {
|
subscription.unsubscribe().then((successful) => {
|
||||||
// You've successfully unsubscribed
|
// You've successfully unsubscribed
|
||||||
console.log('You\'ve successfully unsubscribed')
|
console.log('You\'ve successfully unsubscribed')
|
||||||
}).catch(function (e) {
|
}).catch( (e) => {
|
||||||
// Unsubscription failed
|
// Unsubscription failed
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
111
src/store/Modules/Interface/ProgressBar.ts
Normal file
111
src/store/Modules/Interface/ProgressBar.ts
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { IProgressState } from '@types'
|
||||||
|
import { storeBuilder } from '../Store/Store'
|
||||||
|
const css = require('@css')
|
||||||
|
|
||||||
|
let TIMER = null
|
||||||
|
let TIMEOUT = null
|
||||||
|
let CUT = null
|
||||||
|
|
||||||
|
// State
|
||||||
|
const state: IProgressState = {
|
||||||
|
percent: 0,
|
||||||
|
show: false,
|
||||||
|
canSuccess: true,
|
||||||
|
duration: 3000,
|
||||||
|
height: '2px',
|
||||||
|
color: css.mainStyle,
|
||||||
|
failedColor: css.red1
|
||||||
|
}
|
||||||
|
|
||||||
|
const b = storeBuilder.module<IProgressState>('ProgressModule', state)
|
||||||
|
const stateGetter = b.state()
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
namespace Getters {
|
||||||
|
export const getters = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutations
|
||||||
|
namespace Mutations {
|
||||||
|
function start(state: IProgressState) {
|
||||||
|
if (!state.show) {
|
||||||
|
clearTimeout(TIMEOUT)
|
||||||
|
state.show = true
|
||||||
|
state.canSuccess = true
|
||||||
|
if (TIMER) {
|
||||||
|
clearInterval(TIMER)
|
||||||
|
state.percent = 0
|
||||||
|
}
|
||||||
|
CUT = 20000 / Math.floor(state.duration)
|
||||||
|
TIMER = setInterval(() => {
|
||||||
|
Mutations.mutations.increase(CUT * Math.random())
|
||||||
|
if (state.percent > 80) {
|
||||||
|
Mutations.mutations.pause()
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function set(state: IProgressState, num: number) {
|
||||||
|
state.show = true
|
||||||
|
state.canSuccess = true
|
||||||
|
state.percent = Math.floor(num)
|
||||||
|
}
|
||||||
|
function increase(state: IProgressState, num: number) {
|
||||||
|
state.percent = state.percent + Math.floor(num)
|
||||||
|
}
|
||||||
|
function decrease(state: IProgressState, num: number) {
|
||||||
|
state.percent = state.percent - Math.floor(num)
|
||||||
|
}
|
||||||
|
function finish(state: IProgressState) {
|
||||||
|
state.percent = 100
|
||||||
|
Mutations.mutations.hide()
|
||||||
|
}
|
||||||
|
function pause(state: IProgressState) {
|
||||||
|
clearInterval(TIMER)
|
||||||
|
}
|
||||||
|
function hide(state: IProgressState) {
|
||||||
|
clearInterval(TIMER)
|
||||||
|
TIMER = null
|
||||||
|
TIMEOUT = setTimeout(() => {
|
||||||
|
state.show = false
|
||||||
|
state.percent = 0
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
state.percent = 0
|
||||||
|
}, 200)
|
||||||
|
})
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
function fail(state: IProgressState) {
|
||||||
|
state.canSuccess = false
|
||||||
|
mutations.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mutations = {
|
||||||
|
start: b.commit(start),
|
||||||
|
set: b.commit(set),
|
||||||
|
finish: b.commit(finish),
|
||||||
|
increase: b.commit(increase),
|
||||||
|
decrease: b.commit(decrease),
|
||||||
|
pause: b.commit(pause),
|
||||||
|
hide: b.commit(hide),
|
||||||
|
fail: b.commit(fail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
namespace Actions {
|
||||||
|
export const actions = {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module
|
||||||
|
const ProgressModule = {
|
||||||
|
get state() { return stateGetter()},
|
||||||
|
getters: Getters.getters,
|
||||||
|
mutations: Mutations.mutations,
|
||||||
|
actions: Actions.actions
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProgressModule
|
||||||
4
src/store/Modules/Interface/index.ts
Normal file
4
src/store/Modules/Interface/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// export {default as NotificationsStore} from './NotificationsStore';
|
||||||
|
export {default as ProgressBar} from './ProgressBar'
|
||||||
|
// export {default as AlertsStore} from './AlertsStore';
|
||||||
|
// export {default as GoogleMaps, getMapInstance, geoLocate} from './GoogleMaps/GoogleMaps';
|
||||||
@@ -11,6 +11,8 @@ import { GetterTree } from 'vuex'
|
|||||||
import objectId from '@src/js/objectId'
|
import objectId from '@src/js/objectId'
|
||||||
import { costanti } from '@src/store/Modules/costanti'
|
import { costanti } from '@src/store/Modules/costanti'
|
||||||
|
|
||||||
|
const nametable = 'todos'
|
||||||
|
|
||||||
// import _ from 'lodash'
|
// import _ from 'lodash'
|
||||||
|
|
||||||
const state: ITodosState = {
|
const state: ITodosState = {
|
||||||
@@ -24,7 +26,7 @@ const state: ITodosState = {
|
|||||||
visuLastCompleted: 10
|
visuLastCompleted: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldtochange: String [] = ['descr', 'completed', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress']
|
const fieldtochange: string [] = ['descr', 'completed', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress']
|
||||||
|
|
||||||
const b = storeBuilder.module<ITodosState>('Todos', state)
|
const b = storeBuilder.module<ITodosState>('Todos', state)
|
||||||
const stateGetter = b.state()
|
const stateGetter = b.state()
|
||||||
@@ -35,8 +37,9 @@ function getindexbycategory(category: string) {
|
|||||||
|
|
||||||
function gettodosByCategory(category: string) {
|
function gettodosByCategory(category: string) {
|
||||||
const indcat = state.categories.indexOf(category)
|
const indcat = state.categories.indexOf(category)
|
||||||
if (!state.todos[indcat])
|
if (!state.todos[indcat]) {
|
||||||
return []
|
return []
|
||||||
|
}
|
||||||
return state.todos[indcat]
|
return state.todos[indcat]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,49 +51,34 @@ function isValidIndex(cat, index) {
|
|||||||
function getElemByIndex(cat, index) {
|
function getElemByIndex(cat, index) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
|
|
||||||
if (index >= 0 && index < myarr.length)
|
if (index >= 0 && index < myarr.length) {
|
||||||
return myarr[index]
|
return myarr[index]
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getElemById(cat, id) {
|
function getElemById(cat, id) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
return myarr.find((elem) => elem._id === id)
|
||||||
if (myarr[indrec]._id === id) {
|
|
||||||
return myarr[indrec]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIndexById(cat, id) {
|
function getIndexById(cat, id) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
return myarr.findIndex((elem) => elem._id === id)
|
||||||
if (myarr[indrec]._id === id) {
|
|
||||||
return indrec
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getElemPrevById(cat, id_prev) {
|
function getElemPrevById(cat, id_prev) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
return myarr.find((elem) => elem._id === id_prev)
|
||||||
if (myarr[indrec].id_prev === id_prev) {
|
|
||||||
return myarr[indrec]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolean, escludiId: string) {
|
function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolean, escludiId: string) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
if (myarr === null)
|
if (myarr === null) {
|
||||||
return -1
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
let trovato: boolean = false
|
let trovato: boolean = false
|
||||||
|
|
||||||
@@ -114,31 +102,30 @@ function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolea
|
|||||||
if (trovato) {
|
if (trovato) {
|
||||||
return myarr.length - 1
|
return myarr.length - 1
|
||||||
} else {
|
} else {
|
||||||
if (priority === tools.Todos.PRIORITY_LOW)
|
if (priority === tools.Todos.PRIORITY_LOW) {
|
||||||
return myarr.length - 1
|
return myarr.length - 1
|
||||||
else if (priority === tools.Todos.PRIORITY_HIGH)
|
}
|
||||||
|
else if (priority === tools.Todos.PRIORITY_HIGH) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFirstList(cat) {
|
function getFirstList(cat) {
|
||||||
const myarr = gettodosByCategory(cat)
|
const myarr = gettodosByCategory(cat)
|
||||||
for (let indrec in myarr) {
|
return myarr.find((elem) => elem.id_prev === tools.LIST_START)
|
||||||
if (myarr[indrec].id_prev === tools.LIST_START) {
|
|
||||||
return myarr[indrec]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastListNotCompleted(cat) {
|
function getLastListNotCompleted(cat) {
|
||||||
const arr = Todos.getters.todos_dacompletare(cat)
|
const arr = Todos.getters.todos_dacompletare(cat)
|
||||||
// console.log('cat', cat, 'arr', arr)
|
// console.log('cat', cat, 'arr', arr)
|
||||||
if (arr.length > 0)
|
if (arr.length > 0) {
|
||||||
return arr[arr.length - 1]
|
return arr[arr.length - 1]
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getstrelem(elem) {
|
function getstrelem(elem) {
|
||||||
return 'ID [' + elem._id + '] ' + elem.descr + ' [ID_PREV=' + elem.id_prev + '] modif=' + elem.modified
|
return 'ID [' + elem._id + '] ' + elem.descr + ' [ID_PREV=' + elem.id_prev + '] modif=' + elem.modified
|
||||||
@@ -158,10 +145,9 @@ function update_idprev(indcat, indelemchange, indelemId) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initcat() {
|
function initcat() {
|
||||||
|
|
||||||
let tomorrow = new Date()
|
const tomorrow = new Date()
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1)
|
tomorrow.setDate(tomorrow.getDate() + 1)
|
||||||
|
|
||||||
const objtodo: ITodo = {
|
const objtodo: ITodo = {
|
||||||
@@ -187,55 +173,31 @@ function initcat() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteItemToSyncAndDb(table: String, item: ITodo, id) {
|
|
||||||
cmdToSyncAndDbTodo(tools.DB.CMD_DELETE_TODOS, table, 'DELETE', item, id, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveItemToSyncAndDb(table: String, method, item: ITodo) {
|
|
||||||
return await cmdToSyncAndDbTodo(tools.DB.CMD_SYNC_NEW_TODOS, table, method, item, 0, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cmdToSyncAndDbTodo(cmd, table, method, item: ITodo, id, msg: String) {
|
|
||||||
// Send to Server to Sync
|
|
||||||
|
|
||||||
console.log('cmdToSyncAndDbTodo', cmd, table, method, item.descr, id, msg)
|
|
||||||
|
|
||||||
const risdata = await tools.cmdToSyncAndDb(cmd, table, method, item, id, msg)
|
|
||||||
|
|
||||||
if (cmd === tools.DB.CMD_SYNC_NEW_TODOS) {
|
|
||||||
if (method === 'POST')
|
|
||||||
await Todos.actions.dbInsertTodo(item)
|
|
||||||
else if (method === 'PATCH')
|
|
||||||
await Todos.actions.dbSaveTodo(item)
|
|
||||||
} else if (cmd === tools.DB.CMD_DELETE_TODOS) {
|
|
||||||
await Todos.actions.dbdeleteItem(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
return risdata
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Getters {
|
namespace Getters {
|
||||||
// const fullName = b.read(function fullName(state): string {
|
|
||||||
// return state.userInfos.firstname?capitalize(state.userInfos.firstname) + " " + capitalize(state.userInfos.lastname):null;
|
|
||||||
// })
|
|
||||||
const todos_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
const todos_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||||
const indcat = getindexbycategory(cat)
|
const indcat = getindexbycategory(cat)
|
||||||
if (state.todos[indcat]) {
|
if (state.todos[indcat]) {
|
||||||
return state.todos[indcat].filter(todo => !todo.completed)
|
return state.todos[indcat].filter((todo) => !todo.completed)
|
||||||
} else return []
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}, 'todos_dacompletare')
|
}, 'todos_dacompletare')
|
||||||
|
|
||||||
const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||||
const indcat = getindexbycategory(cat)
|
const indcat = getindexbycategory(cat)
|
||||||
if (state.todos[indcat]) {
|
if (state.todos[indcat]) {
|
||||||
if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED)
|
if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) {
|
||||||
return state.todos[indcat].filter(todo => todo.completed).slice(0, state.visuLastCompleted) // Show only the first N completed
|
return state.todos[indcat].filter((todo) => todo.completed).slice(0, state.visuLastCompleted)
|
||||||
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL)
|
} // Show only the first N completed
|
||||||
return state.todos[indcat].filter(todo => todo.completed)
|
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) {
|
||||||
else
|
return state.todos[indcat].filter((todo) => todo.completed)
|
||||||
|
}
|
||||||
|
else {
|
||||||
return []
|
return []
|
||||||
} else return []
|
}
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}, 'todos_completati')
|
}, 'todos_completati')
|
||||||
|
|
||||||
const doneTodosCount = b.read((state: ITodosState) => (cat: string): number => {
|
const doneTodosCount = b.read((state: ITodosState) => (cat: string): number => {
|
||||||
@@ -250,9 +212,7 @@ namespace Getters {
|
|||||||
}
|
}
|
||||||
}, 'TodosCount')
|
}, 'TodosCount')
|
||||||
|
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
// get fullName() { return fullName();},
|
|
||||||
get todos_dacompletare() {
|
get todos_dacompletare() {
|
||||||
return todos_dacompletare()
|
return todos_dacompletare()
|
||||||
},
|
},
|
||||||
@@ -268,28 +228,17 @@ namespace Getters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Mutations {
|
namespace Mutations {
|
||||||
|
|
||||||
function setTestpao(state: ITodosState, testpao: String) {
|
|
||||||
state.testpao = testpao
|
|
||||||
}
|
|
||||||
|
|
||||||
function findTodoById(state: ITodosState, data: IParamTodo) {
|
function findTodoById(state: ITodosState, data: IParamTodo) {
|
||||||
const indcat = state.categories.indexOf(data.categorySel)
|
const indcat = state.categories.indexOf(data.categorySel)
|
||||||
if (indcat >= 0) {
|
if (indcat >= 0) {
|
||||||
if (state.todos[indcat]) {
|
return state.todos[indcat].find((elem) => elem._id === data.id)
|
||||||
for (let i = 0; i < state.todos[indcat].length; i++) {
|
|
||||||
if (state.todos[indcat][i]._id === data.id)
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createNewItem(state: ITodosState, { objtodo, atfirst, categorySel }) {
|
function createNewItem(state: ITodosState, { objtodo, atfirst, categorySel }) {
|
||||||
let indcat = state.categories.indexOf(categorySel)
|
let indcat = state.categories.indexOf(categorySel)
|
||||||
if (indcat == -1) {
|
if (indcat == -1) {
|
||||||
@@ -303,10 +252,12 @@ namespace Mutations {
|
|||||||
console.log('push state.todos[indcat]', state.todos)
|
console.log('push state.todos[indcat]', state.todos)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (atfirst)
|
if (atfirst) {
|
||||||
state.todos[indcat].unshift(objtodo)
|
state.todos[indcat].unshift(objtodo)
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
state.todos[indcat].push(objtodo)
|
state.todos[indcat].push(objtodo)
|
||||||
|
}
|
||||||
|
|
||||||
console.log('state.todos[indcat]', state.todos[indcat])
|
console.log('state.todos[indcat]', state.todos[indcat])
|
||||||
|
|
||||||
@@ -319,162 +270,35 @@ namespace Mutations {
|
|||||||
|
|
||||||
console.log('PRIMA state.todos', state.todos)
|
console.log('PRIMA state.todos', state.todos)
|
||||||
// Delete Item in to Array
|
// Delete Item in to Array
|
||||||
if (ind >= 0)
|
if (ind >= 0) {
|
||||||
state.todos[indcat].splice(ind, 1)
|
state.todos[indcat].splice(ind, 1)
|
||||||
|
}
|
||||||
|
|
||||||
console.log('DOPO state.todos', state.todos, 'ind', ind)
|
console.log('DOPO state.todos', state.todos, 'ind', ind)
|
||||||
|
|
||||||
// tools.notifyarraychanged(state.todos[indcat])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
setTestpao: b.commit(setTestpao),
|
// setTestpao: b.commit(setTestpao),
|
||||||
deletemyitem: b.commit(deletemyitem),
|
deletemyitem: b.commit(deletemyitem),
|
||||||
createNewItem: b.commit(createNewItem)
|
createNewItem: b.commit(createNewItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function consolelogpao(strlog, strlog2 = '', strlog3 = '') {
|
|
||||||
globalroutines(null, 'log', strlog + ' ' + strlog2 + ' ' + strlog3, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Actions {
|
namespace Actions {
|
||||||
|
|
||||||
// If something in the call of Service Worker went wrong (Network or Server Down), then retry !
|
|
||||||
async function sendSwMsgIfAvailable() {
|
|
||||||
let something = false
|
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
console.log(' -------- sendSwMsgIfAvailable')
|
|
||||||
|
|
||||||
let count = await checkPendingMsg(null)
|
|
||||||
if (count > 0) {
|
|
||||||
return await navigator.serviceWorker.ready
|
|
||||||
.then(function (sw) {
|
|
||||||
|
|
||||||
return globalroutines(null, 'readall', 'swmsg')
|
|
||||||
.then(function (arr_recmsg) {
|
|
||||||
// let recclone = [...arr_recmsg]
|
|
||||||
if (arr_recmsg.length > 0) {
|
|
||||||
|
|
||||||
// console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
|
||||||
let promiseChain = Promise.resolve()
|
|
||||||
|
|
||||||
for (let indrec in arr_recmsg) {
|
|
||||||
// console.log(' .... sw.sync.register ( ', rec._id)
|
|
||||||
// if ('SyncManager' in window) {
|
|
||||||
// sw.sync.register(rec._id)
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// #Alternative to SyncManager
|
|
||||||
promiseChain = promiseChain.then(() => {
|
|
||||||
return Api.syncAlternative(arr_recmsg[indrec]._id)
|
|
||||||
.then(() => {
|
|
||||||
something = true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
return promiseChain
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
resolve(something)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function waitAndcheckPendingMsg(context) {
|
|
||||||
|
|
||||||
// await aspettansec(1000)
|
|
||||||
|
|
||||||
return await checkPendingMsg(context)
|
|
||||||
.then(ris => {
|
|
||||||
if (ris) {
|
|
||||||
// console.log('risPending = ', ris)
|
|
||||||
return sendSwMsgIfAvailable()
|
|
||||||
.then(something => {
|
|
||||||
if (something) {
|
|
||||||
if (process.env.DEBUG === '1')
|
|
||||||
console.log('something')
|
|
||||||
// Refresh data
|
|
||||||
return waitAndRefreshData(context)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function waitAndRefreshData(context) {
|
|
||||||
// await aspettansec(3000)
|
|
||||||
|
|
||||||
return await dbLoadTodo(context, { checkPending: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function readConfig(id) {
|
|
||||||
return await globalroutines(null, 'read', 'config', null, String(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
async function checkPendingMsg(context) {
|
|
||||||
// console.log('checkPendingMsg')
|
|
||||||
|
|
||||||
const config = await globalroutines(null, 'read', 'config', null, '1')
|
|
||||||
// console.log('config', config)
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (config) {
|
|
||||||
if (config[1].stateconn !== undefined) {
|
|
||||||
// console.log('config.stateconn', config[1].stateconn)
|
|
||||||
|
|
||||||
if (config[1].stateconn !== GlobalStore.state.stateConnection) {
|
|
||||||
GlobalStore.mutations.setStateConnection(config[1].stateconn)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
// Check if there is something
|
|
||||||
return globalroutines(null, 'count', 'swmsg')
|
|
||||||
.then(function (count) {
|
|
||||||
if (count > 0) {
|
|
||||||
// console.log('count = ', count)
|
|
||||||
return resolve(true)
|
|
||||||
} else {
|
|
||||||
return resolve(false)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
return reject()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dbLoadTodo(context, { checkPending }) {
|
async function dbLoadTodo(context, { checkPending }) {
|
||||||
console.log('dbLoadTodo', checkPending, 'userid=', UserStore.state.userId)
|
console.log('dbLoadTodo', checkPending, 'userid=', UserStore.state.userId)
|
||||||
|
|
||||||
if (UserStore.state.userId === '')
|
if (UserStore.state.userId === '') {
|
||||||
return false // Login not made
|
return false
|
||||||
|
} // Login not made
|
||||||
|
|
||||||
let ris = await Api.SendReq('/todos/' + UserStore.state.userId, 'GET', null)
|
const ris = await Api.SendReq('/todos/' + UserStore.state.userId, 'GET', null)
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
if (res.data.todos) {
|
if (res.data.todos) {
|
||||||
// console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
// console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||||
// console.log('RISULTANTE TODOS DAL SERVER = ', res.data.todos)
|
|
||||||
|
|
||||||
state.todos = res.data.todos
|
state.todos = res.data.todos
|
||||||
state.categories = res.data.categories
|
state.categories = res.data.categories
|
||||||
} else {
|
} else {
|
||||||
@@ -483,53 +307,47 @@ namespace Actions {
|
|||||||
|
|
||||||
// console.log('PRIMA showtype = ', state.showtype)
|
// console.log('PRIMA showtype = ', state.showtype)
|
||||||
|
|
||||||
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({id: costanti.CONFIG_ID_SHOW_TYPE_TODOS, default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED }))
|
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
||||||
|
id: costanti.CONFIG_ID_SHOW_TYPE_TODOS,
|
||||||
// console.log('showtype = ', state.showtype)
|
default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED
|
||||||
|
}), 10)
|
||||||
|
|
||||||
// console.log('ARRAY TODOS = ', state.todos)
|
// console.log('ARRAY TODOS = ', state.todos)
|
||||||
if (process.env.DEBUG === '1')
|
if (process.env.DEBUG === '1') {
|
||||||
console.log('dbLoadTodo', 'state.todos', state.todos, 'state.categories', state.categories)
|
console.log('dbLoadTodo', 'state.todos', state.todos, 'state.categories', state.categories)
|
||||||
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
console.log('error dbLoadTodo', error)
|
console.log('error dbLoadTodo', error)
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return error
|
return error
|
||||||
})
|
})
|
||||||
|
|
||||||
if (ris.status !== 200) {
|
if (ris.status !== 200) {
|
||||||
if (process.env.DEBUG === '1')
|
if (process.env.DEBUG === '1') {
|
||||||
console.log('ris.status', ris.status)
|
console.log('ris.status', ris.status)
|
||||||
|
}
|
||||||
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
tools.consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||||
} else {
|
} else {
|
||||||
consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.status)
|
tools.consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.status)
|
||||||
}
|
}
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
// Read all data from IndexedDB Store into Memory
|
// Read all data from IndexedDB Store into Memory
|
||||||
await updatefromIndexedDbToStateTodo(context)
|
await tools.updatefromIndexedDbToStateTodo('categories')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ris.status === tools.OK && checkPending) {
|
if (ris.status === tools.OK && checkPending) {
|
||||||
waitAndcheckPendingMsg(context)
|
tools.waitAndcheckPendingMsg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updatefromIndexedDbToStateTodo(context) {
|
|
||||||
// console.log('Update the array in memory, from todos table from IndexedDb')
|
|
||||||
await globalroutines(null, 'updatefromIndexedDbToStateTodo', 'categories', null)
|
|
||||||
.then(() => {
|
|
||||||
console.log('updatefromIndexedDbToStateTodo! ')
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function aspettansec(numsec) {
|
function aspettansec(numsec) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
resolve('anything')
|
resolve('anything')
|
||||||
}, numsec)
|
}, numsec)
|
||||||
})
|
})
|
||||||
@@ -537,71 +355,12 @@ namespace Actions {
|
|||||||
|
|
||||||
async function testfunc() {
|
async function testfunc() {
|
||||||
while (true) {
|
while (true) {
|
||||||
consolelogpao('testfunc')
|
tools.consolelogpao('testfunc')
|
||||||
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
||||||
await aspettansec(5000)
|
await aspettansec(5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dbSaveTodo(context, itemtodo: ITodo) {
|
|
||||||
return await dbInsertSaveTodo(context, itemtodo, 'PATCH')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dbInsertTodo(context, itemtodo: ITodo) {
|
|
||||||
return await dbInsertSaveTodo(context, itemtodo, 'POST')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
|
|
||||||
|
|
||||||
if (!('serviceWorker' in navigator)) {
|
|
||||||
|
|
||||||
console.log('dbInsertSaveTodo', itemtodo, method)
|
|
||||||
let call = '/todos'
|
|
||||||
|
|
||||||
if (UserStore.state.userId === '')
|
|
||||||
return false // Login not made
|
|
||||||
|
|
||||||
if (method !== 'POST')
|
|
||||||
call += '/' + itemtodo._id
|
|
||||||
|
|
||||||
console.log('TODO TO SAVE: ', itemtodo)
|
|
||||||
|
|
||||||
let res = await Api.SendReq(call, method, itemtodo)
|
|
||||||
.then(res => {
|
|
||||||
console.log('dbInsertSaveTodo to the Server', res.data)
|
|
||||||
|
|
||||||
return (res.status === 200)
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
UserStore.mutations.setErrorCatch(error)
|
|
||||||
// return UserStore.getters.getServerCode
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dbdeleteItem(context, item: ITodo) {
|
|
||||||
|
|
||||||
if (!('serviceWorker' in navigator)) {
|
|
||||||
// console.log('dbdeleteItem', item)
|
|
||||||
if (UserStore.state.userId === '')
|
|
||||||
return false // Login not made
|
|
||||||
|
|
||||||
let res = await Api.SendReq('/todos/' + item._id, 'DELETE', item)
|
|
||||||
.then(res => {
|
|
||||||
console.log('dbdeleteItem to the Server')
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
UserStore.mutations.setErrorCatch(error)
|
|
||||||
return UserStore.getters.getServerCode
|
|
||||||
})
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setmodifiedIfchanged(recOut, recIn, field) {
|
function setmodifiedIfchanged(recOut, recIn, field) {
|
||||||
if (String(recOut[field]) !== String(recIn[field])) {
|
if (String(recOut[field]) !== String(recIn[field])) {
|
||||||
// console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
// console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
||||||
@@ -615,12 +374,12 @@ namespace Actions {
|
|||||||
async function deleteItem(context, { cat, idobj }) {
|
async function deleteItem(context, { cat, idobj }) {
|
||||||
console.log('deleteItem: KEY = ', idobj)
|
console.log('deleteItem: KEY = ', idobj)
|
||||||
|
|
||||||
let myobjtrov = getElemById(cat, idobj)
|
const myobjtrov = getElemById(cat, idobj)
|
||||||
|
|
||||||
if (myobjtrov !== null) {
|
if (!!myobjtrov) {
|
||||||
let myobjnext = getElemPrevById(cat, myobjtrov._id)
|
const myobjnext = getElemPrevById(cat, myobjtrov._id)
|
||||||
|
|
||||||
if (myobjnext !== null) {
|
if (!!myobjnext) {
|
||||||
myobjnext.id_prev = myobjtrov.id_prev
|
myobjnext.id_prev = myobjtrov.id_prev
|
||||||
myobjnext.modified = true
|
myobjnext.modified = true
|
||||||
console.log('calling MODIFY 1')
|
console.log('calling MODIFY 1')
|
||||||
@@ -631,15 +390,13 @@ namespace Actions {
|
|||||||
Todos.mutations.deletemyitem(myobjtrov)
|
Todos.mutations.deletemyitem(myobjtrov)
|
||||||
|
|
||||||
// 2) Delete from the IndexedDb
|
// 2) Delete from the IndexedDb
|
||||||
globalroutines(context, 'delete', 'todos', null, idobj)
|
globalroutines(context, 'delete', nametable, null, idobj)
|
||||||
.then((ris) => {
|
.catch((error) => {
|
||||||
|
|
||||||
}).catch((error) => {
|
|
||||||
console.log('err: ', error)
|
console.log('err: ', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 3) Delete from the Server (call)
|
// 3) Delete from the Server (call)
|
||||||
deleteItemToSyncAndDb(tools.DB.TABLE_DELETE_TODOS, myobjtrov, idobj)
|
tools.deleteItemToSyncAndDb(nametable, myobjtrov, idobj)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,7 +436,7 @@ namespace Actions {
|
|||||||
Todos.mutations.createNewItem({ objtodo, atfirst, categorySel: objtodo.category })
|
Todos.mutations.createNewItem({ objtodo, atfirst, categorySel: objtodo.category })
|
||||||
|
|
||||||
// 2) Insert into the IndexedDb
|
// 2) Insert into the IndexedDb
|
||||||
const id = await globalroutines(context, 'write', 'todos', objtodo)
|
const id = await globalroutines(context, 'write', nametable, objtodo)
|
||||||
|
|
||||||
let field = ''
|
let field = ''
|
||||||
// update also the last elem
|
// update also the last elem
|
||||||
@@ -695,11 +452,11 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3) send to the Server
|
// 3) send to the Server
|
||||||
return await saveItemToSyncAndDb(tools.DB.TABLE_SYNC_TODOS, 'POST', objtodo)
|
return await tools.saveItemToSyncAndDb(nametable, 'POST', objtodo)
|
||||||
.then((ris) => {
|
.then((ris) => {
|
||||||
// Check if need to be moved...
|
// Check if need to be moved...
|
||||||
const indelem = getIndexById(objtodo.category, objtodo._id)
|
const indelem = getIndexById(objtodo.category, objtodo._id)
|
||||||
let itemdragend = undefined
|
let itemdragend
|
||||||
if (atfirst) {
|
if (atfirst) {
|
||||||
// Check the second item, if it's different priority, then move to the first position of the priority
|
// Check the second item, if it's different priority, then move to the first position of the priority
|
||||||
const secondindelem = indelem + 1
|
const secondindelem = indelem + 1
|
||||||
@@ -733,8 +490,9 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemdragend)
|
if (itemdragend) {
|
||||||
swapElems(context, itemdragend)
|
swapElems(context, itemdragend)
|
||||||
|
}
|
||||||
|
|
||||||
return ris
|
return ris
|
||||||
|
|
||||||
@@ -742,24 +500,25 @@ namespace Actions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function modify(context, { myitem, field }) {
|
async function modify(context, { myitem, field }) {
|
||||||
if (myitem === null)
|
if (myitem === null) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
}
|
||||||
const myobjsaved = tools.jsonCopy(myitem)
|
const myobjsaved = tools.jsonCopy(myitem)
|
||||||
// get record from IndexedDb
|
// get record from IndexedDb
|
||||||
const miorec = await globalroutines(context, 'read', 'todos', null, myobjsaved._id)
|
const miorec = await globalroutines(context, 'read', nametable, null, myobjsaved._id)
|
||||||
if (miorec === undefined) {
|
if (miorec === undefined) {
|
||||||
console.log('~~~~~~~~~~~~~~~~~~~~ !!!!!!!!!!!!!!!!!! Record not Found !!!!!! id=', myobjsaved._id)
|
console.log('~~~~~~~~~~~~~~~~~~~~ !!!!!!!!!!!!!!!!!! Record not Found !!!!!! id=', myobjsaved._id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setmodifiedIfchanged(miorec, myobjsaved, 'completed'))
|
if (setmodifiedIfchanged(miorec, myobjsaved, 'completed')) {
|
||||||
miorec.completed_at = new Date().getDate()
|
miorec.completed_at = new Date().getDate()
|
||||||
|
}
|
||||||
|
|
||||||
fieldtochange.forEach(field => {
|
fieldtochange.forEach((field) => {
|
||||||
setmodifiedIfchanged(miorec, myobjsaved, field)
|
setmodifiedIfchanged(miorec, myobjsaved, field)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -775,32 +534,16 @@ namespace Actions {
|
|||||||
|
|
||||||
// this.logelem('modify', miorec)
|
// this.logelem('modify', miorec)
|
||||||
// 2) Modify on IndexedDb
|
// 2) Modify on IndexedDb
|
||||||
return globalroutines(context, 'write', 'todos', miorec)
|
return globalroutines(context, 'write', nametable, miorec)
|
||||||
.then(ris => {
|
.then((ris) => {
|
||||||
|
|
||||||
// 3) Modify on the Server (call)
|
// 3) Modify on the Server (call)
|
||||||
saveItemToSyncAndDb(tools.DB.TABLE_SYNC_TODOS_PATCH, 'PATCH', miorec)
|
tools.saveItemToSyncAndDb(nametable, 'PATCH', miorec)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// async function updateModifyRecords(context, cat: string) {
|
|
||||||
//
|
|
||||||
// const indcat = getindexbycategory(cat)
|
|
||||||
// for (const elem of state.todos[indcat]) {
|
|
||||||
// if (elem.modified) {
|
|
||||||
// console.log('calling MODIFY 3')
|
|
||||||
// await modify(context, { myitem: elem, field })
|
|
||||||
// .then(() => {
|
|
||||||
// elem.modified = false
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
async function swapElems(context, itemdragend: IDrag) {
|
async function swapElems(context, itemdragend: IDrag) {
|
||||||
console.log('swapElems', itemdragend)
|
console.log('swapElems', itemdragend)
|
||||||
console.log('state.todos', state.todos)
|
console.log('state.todos', state.todos)
|
||||||
@@ -826,8 +569,8 @@ namespace Actions {
|
|||||||
tools.notifyarraychanged(state.todos[indcat][itemdragend.oldIndex])
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.oldIndex])
|
||||||
|
|
||||||
if (itemdragend.field !== 'priority') {
|
if (itemdragend.field !== 'priority') {
|
||||||
let precind = itemdragend.newIndex - 1
|
const precind = itemdragend.newIndex - 1
|
||||||
let nextind = itemdragend.newIndex + 1
|
const nextind = itemdragend.newIndex + 1
|
||||||
|
|
||||||
if (isValidIndex(cat, precind) && isValidIndex(cat, nextind)) {
|
if (isValidIndex(cat, precind) && isValidIndex(cat, nextind)) {
|
||||||
if ((state.todos[indcat][precind].priority === state.todos[indcat][nextind].priority) && (state.todos[indcat][precind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
|
if ((state.todos[indcat][precind].priority === state.todos[indcat][nextind].priority) && (state.todos[indcat][precind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
|
||||||
@@ -854,7 +597,6 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update the id_prev property
|
// Update the id_prev property
|
||||||
const elem1 = update_idprev(indcat, itemdragend.newIndex, itemdragend.newIndex - 1)
|
const elem1 = update_idprev(indcat, itemdragend.newIndex, itemdragend.newIndex - 1)
|
||||||
const elem2 = update_idprev(indcat, itemdragend.newIndex + 1, itemdragend.newIndex)
|
const elem2 = update_idprev(indcat, itemdragend.newIndex + 1, itemdragend.newIndex)
|
||||||
@@ -871,15 +613,8 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
dbInsertTodo: b.dispatch(dbInsertTodo),
|
|
||||||
dbSaveTodo: b.dispatch(dbSaveTodo),
|
|
||||||
dbLoadTodo: b.dispatch(dbLoadTodo),
|
dbLoadTodo: b.dispatch(dbLoadTodo),
|
||||||
dbdeleteItem: b.dispatch(dbdeleteItem),
|
|
||||||
updatefromIndexedDbToStateTodo: b.dispatch(updatefromIndexedDbToStateTodo),
|
|
||||||
checkPendingMsg: b.dispatch(checkPendingMsg),
|
|
||||||
waitAndcheckPendingMsg: b.dispatch(waitAndcheckPendingMsg),
|
|
||||||
swapElems: b.dispatch(swapElems),
|
swapElems: b.dispatch(swapElems),
|
||||||
// updateModifyRecords: b.dispatch(updateModifyRecords),
|
|
||||||
deleteItem: b.dispatch(deleteItem),
|
deleteItem: b.dispatch(deleteItem),
|
||||||
insertTodo: b.dispatch(insertTodo),
|
insertTodo: b.dispatch(insertTodo),
|
||||||
modify: b.dispatch(modify)
|
modify: b.dispatch(modify)
|
||||||
@@ -887,7 +622,6 @@ namespace Actions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module
|
// Module
|
||||||
const TodosModule = {
|
const TodosModule = {
|
||||||
get state() {
|
get state() {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ const state: IUserState = {
|
|||||||
userId: '',
|
userId: '',
|
||||||
email: '',
|
email: '',
|
||||||
username: '',
|
username: '',
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
password: '',
|
password: '',
|
||||||
lang: '',
|
lang: '',
|
||||||
repeatPassword: '',
|
repeatPassword: '',
|
||||||
@@ -28,6 +27,7 @@ const state: IUserState = {
|
|||||||
categorySel: 'personal',
|
categorySel: 'personal',
|
||||||
servercode: 0,
|
servercode: 0,
|
||||||
x_auth_token: '',
|
x_auth_token: '',
|
||||||
|
isLogged: false,
|
||||||
isAdmin: false
|
isAdmin: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ namespace Getters {
|
|||||||
},
|
},
|
||||||
get getServerCode() {
|
get getServerCode() {
|
||||||
return getServerCode()
|
return getServerCode()
|
||||||
}
|
},
|
||||||
// get fullName() { return fullName();},
|
// get fullName() { return fullName();},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,8 +221,6 @@ namespace Actions {
|
|||||||
async function resetpwd(context, paramquery: IUserState) {
|
async function resetpwd(context, paramquery: IUserState) {
|
||||||
|
|
||||||
const usertosend = {
|
const usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
email: paramquery.email,
|
email: paramquery.email,
|
||||||
password: paramquery.password,
|
password: paramquery.password,
|
||||||
tokenforgot: paramquery.tokenforgot
|
tokenforgot: paramquery.tokenforgot
|
||||||
@@ -245,8 +243,6 @@ namespace Actions {
|
|||||||
async function requestpwd(context, paramquery: IUserState) {
|
async function requestpwd(context, paramquery: IUserState) {
|
||||||
|
|
||||||
const usertosend = {
|
const usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
email: paramquery.email
|
email: paramquery.email
|
||||||
}
|
}
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
@@ -265,8 +261,6 @@ namespace Actions {
|
|||||||
|
|
||||||
async function vreg(context, paramquery: ILinkReg) {
|
async function vreg(context, paramquery: ILinkReg) {
|
||||||
const usertosend = {
|
const usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
idlink: paramquery.idlink
|
idlink: paramquery.idlink
|
||||||
}
|
}
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
@@ -301,12 +295,10 @@ namespace Actions {
|
|||||||
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
||||||
.then((hashedPassword: string) => {
|
.then((hashedPassword: string) => {
|
||||||
const usertosend = {
|
const usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
lang: mylang,
|
lang: mylang,
|
||||||
email: authData.email,
|
email: authData.email,
|
||||||
password: String(hashedPassword),
|
password: String(hashedPassword),
|
||||||
username: authData.username,
|
username: authData.username,
|
||||||
idapp: process.env.APP_ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
@@ -393,8 +385,6 @@ namespace Actions {
|
|||||||
const usertosend = {
|
const usertosend = {
|
||||||
username: authData.username,
|
username: authData.username,
|
||||||
password: authData.password,
|
password: authData.password,
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
lang: state.lang,
|
lang: state.lang,
|
||||||
subs: sub,
|
subs: sub,
|
||||||
options
|
options
|
||||||
@@ -487,13 +477,7 @@ namespace Actions {
|
|||||||
|
|
||||||
await GlobalStore.actions.clearDataAfterLogout()
|
await GlobalStore.actions.clearDataAfterLogout()
|
||||||
|
|
||||||
const usertosend = {
|
const riscall = await Api.SendReq('/users/me/token', 'DELETE', null)
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(usertosend)
|
|
||||||
const riscall = await Api.SendReq('/users/me/token', 'DELETE', usertosend)
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@@ -510,6 +494,7 @@ namespace Actions {
|
|||||||
|
|
||||||
async function setGlobal(loggedWithNetwork: boolean) {
|
async function setGlobal(loggedWithNetwork: boolean) {
|
||||||
state.isLogged = true
|
state.isLogged = true
|
||||||
|
console.log('state.isLogged')
|
||||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||||
|
|
||||||
@@ -523,7 +508,7 @@ namespace Actions {
|
|||||||
|
|
||||||
async function autologin_FromLocalStorage(context) {
|
async function autologin_FromLocalStorage(context) {
|
||||||
try {
|
try {
|
||||||
// console.log('*** autologin_FromLocalStorage ***')
|
console.log('*** autologin_FromLocalStorage ***')
|
||||||
// INIT
|
// INIT
|
||||||
|
|
||||||
UserStore.state.lang = tools.getItemLS(tools.localStorage.lang)
|
UserStore.state.lang = tools.getItemLS(tools.localStorage.lang)
|
||||||
@@ -566,6 +551,22 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
async function refreshUserInfos(){
|
||||||
|
let {token, refresh_token} = JWT.fetch();
|
||||||
|
if (!!token) {
|
||||||
|
try {
|
||||||
|
let { data } = await Api.checkSession({token, refresh_token});
|
||||||
|
JWT.set(data);
|
||||||
|
let userData = await jwtDecode(data.token);
|
||||||
|
LoginModule.mutations.updateUserInfos({userData, token: data.token});
|
||||||
|
} catch(e) {
|
||||||
|
Mutations.mutations.disconnectUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
autologin_FromLocalStorage: b.dispatch(autologin_FromLocalStorage),
|
autologin_FromLocalStorage: b.dispatch(autologin_FromLocalStorage),
|
||||||
logout: b.dispatch(logout),
|
logout: b.dispatch(logout),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Api from '@api'
|
import Api from '@api'
|
||||||
import { ITodo } from '@src/model'
|
import { ITodo } from '@src/model'
|
||||||
import { Todos, UserStore } from '@store'
|
import { GlobalStore, Todos, UserStore } from '@store'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
import { costanti } from './costanti'
|
import { costanti } from './costanti'
|
||||||
import Quasar from 'quasar'
|
import Quasar from 'quasar'
|
||||||
@@ -12,6 +12,7 @@ export interface INotify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const tools = {
|
export const tools = {
|
||||||
|
allTables: ['todos', 'categories', 'sync_post_todos', 'sync_patch_todos', 'delete_todos', 'config', 'swmsg'],
|
||||||
EMPTY: 0,
|
EMPTY: 0,
|
||||||
CALLING: 10,
|
CALLING: 10,
|
||||||
OK: 20,
|
OK: 20,
|
||||||
@@ -48,12 +49,12 @@ export const tools = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
DB: {
|
DB: {
|
||||||
CMD_SYNC_TODOS: 'sync-todos',
|
CMD_SYNC: 'sync-',
|
||||||
CMD_SYNC_NEW_TODOS: 'sync-new-todos',
|
CMD_SYNC_NEW: 'sync-new-',
|
||||||
CMD_DELETE_TODOS: 'sync-delete-todos',
|
CMD_DELETE: 'sync-delete-',
|
||||||
TABLE_SYNC_TODOS: 'sync_todos',
|
TABLE_SYNC_POST: 'sync_post_',
|
||||||
TABLE_SYNC_TODOS_PATCH: 'sync_todos_patch',
|
TABLE_SYNC_PATCH: 'sync_patch_',
|
||||||
TABLE_DELETE_TODOS: 'delete_todos'
|
TABLE_DELETE: 'delete_'
|
||||||
},
|
},
|
||||||
|
|
||||||
MenuAction: {
|
MenuAction: {
|
||||||
@@ -386,7 +387,7 @@ export const tools = {
|
|||||||
json2array(json) {
|
json2array(json) {
|
||||||
const result = []
|
const result = []
|
||||||
const keys = Object.keys(json)
|
const keys = Object.keys(json)
|
||||||
keys.forEach(function (key) {
|
keys.forEach((key) => {
|
||||||
result.push(json[key])
|
result.push(json[key])
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
@@ -395,20 +396,20 @@ export const tools = {
|
|||||||
async cmdToSyncAndDb(cmd, table, method, item: ITodo, id, msg: String) {
|
async cmdToSyncAndDb(cmd, table, method, item: ITodo, id, msg: String) {
|
||||||
// Send to Server to Sync
|
// Send to Server to Sync
|
||||||
|
|
||||||
console.log('cmdToSyncAndDb', cmd, table, method, item.descr, id, msg)
|
// console.log('cmdToSyncAndDb', cmd, table, method, item.descr, id, msg)
|
||||||
|
|
||||||
let cmdSw = cmd
|
let cmdSw = cmd
|
||||||
if ((cmd === tools.DB.CMD_SYNC_NEW_TODOS) || (cmd === tools.DB.CMD_DELETE_TODOS)) {
|
if ((cmd === tools.DB.CMD_SYNC_NEW) || (cmd === tools.DB.CMD_DELETE)) {
|
||||||
cmdSw = tools.DB.CMD_SYNC_TODOS
|
cmdSw = tools.DB.CMD_SYNC
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
return await navigator.serviceWorker.ready
|
return await navigator.serviceWorker.ready
|
||||||
.then(function (sw) {
|
.then((sw) => {
|
||||||
// console.log('---------------------- navigator.serviceWorker.ready')
|
// console.log('---------------------- navigator.serviceWorker.ready')
|
||||||
|
|
||||||
return globalroutines(null, 'write', table, item, id)
|
return globalroutines(null, 'write', table, item, id)
|
||||||
.then(function (id) {
|
.then((id) => {
|
||||||
// console.log('id', id)
|
// console.log('id', id)
|
||||||
const sep = '|'
|
const sep = '|'
|
||||||
|
|
||||||
@@ -427,14 +428,14 @@ export const tools = {
|
|||||||
return Api.syncAlternative(multiparams)
|
return Api.syncAlternative(multiparams)
|
||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
.then(function () {
|
.then(() => {
|
||||||
let data = null
|
let data = null
|
||||||
if (msg !== '') {
|
if (msg !== '') {
|
||||||
data = { message: msg, position: 'bottom', timeout: 3000 }
|
data = { message: msg, position: 'bottom', timeout: 3000 }
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch((err) => {
|
||||||
console.error('Errore in globalroutines', table, err)
|
console.error('Errore in globalroutines', table, err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -442,13 +443,104 @@ export const tools = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async dbInsertSave(call, item, method) {
|
||||||
|
|
||||||
|
let ret = true
|
||||||
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
|
||||||
|
console.log('dbInsertSave', item, method)
|
||||||
|
|
||||||
|
if (UserStore.state.userId === '') {
|
||||||
|
return false
|
||||||
|
} // Login not made
|
||||||
|
|
||||||
|
call = '/' + call
|
||||||
|
if (method !== 'POST') {
|
||||||
|
call += '/' + item._id
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('SAVE: ', item)
|
||||||
|
|
||||||
|
ret = await Api.SendReq(call, method, item)
|
||||||
|
.then((res) => {
|
||||||
|
console.log('dbInsertSave ', call, 'to the Server', res.data)
|
||||||
|
|
||||||
|
return (res.status === 200)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
UserStore.mutations.setErrorCatch(error)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
},
|
||||||
|
|
||||||
|
async dbdeleteItem(call, item) {
|
||||||
|
|
||||||
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
// console.log('dbdeleteItem', item)
|
||||||
|
if (UserStore.state.userId === '') {
|
||||||
|
return false
|
||||||
|
} // Login not made
|
||||||
|
|
||||||
|
call = '/' + call
|
||||||
|
|
||||||
|
const res = await Api.SendReq(call + item._id, 'DELETE', item)
|
||||||
|
.then((res) => {
|
||||||
|
console.log('dbdeleteItem to the Server')
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
UserStore.mutations.setErrorCatch(error)
|
||||||
|
return UserStore.getters.getServerCode
|
||||||
|
})
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async cmdToSyncAndDbTable(cmd, nametab: string, table, method, item: ITodo, id, msg: String) {
|
||||||
|
// Send to Server to Sync
|
||||||
|
|
||||||
|
console.log('cmdToSyncAndDb', cmd, table, method, item.descr, id, msg)
|
||||||
|
|
||||||
|
const risdata = await tools.cmdToSyncAndDb(cmd, table, method, item, id, msg)
|
||||||
|
|
||||||
|
if (cmd === tools.DB.CMD_SYNC_NEW) {
|
||||||
|
if ((method === 'POST') || (method === 'PATCH')) {
|
||||||
|
await tools.dbInsertSave(nametab, item, method)
|
||||||
|
}
|
||||||
|
} else if (cmd === tools.DB.CMD_DELETE) {
|
||||||
|
await tools.dbdeleteItem(nametab, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
return risdata
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteItemToSyncAndDb(nametab: string, item, id) {
|
||||||
|
tools.cmdToSyncAndDbTable(tools.DB.CMD_DELETE, nametab, tools.DB.TABLE_DELETE + nametab, 'DELETE', item, id, '')
|
||||||
|
},
|
||||||
|
|
||||||
|
async saveItemToSyncAndDb(nametab: string, method, item) {
|
||||||
|
let table = ''
|
||||||
|
if (method === 'POST')
|
||||||
|
table = tools.DB.TABLE_SYNC_POST
|
||||||
|
else if (method === 'PATCH')
|
||||||
|
table = tools.DB.TABLE_SYNC_PATCH
|
||||||
|
|
||||||
|
return await tools.cmdToSyncAndDbTable(tools.DB.CMD_SYNC_NEW, nametab, table + nametab, method, item, 0, '')
|
||||||
|
},
|
||||||
|
|
||||||
showNotif(q: any, msg, data?: INotify | null) {
|
showNotif(q: any, msg, data?: INotify | null) {
|
||||||
let myicon = data ? data.icon : 'ion-add'
|
let myicon = data ? data.icon : 'ion-add'
|
||||||
if (!myicon)
|
if (!myicon) {
|
||||||
myicon = 'ion-add'
|
myicon = 'ion-add'
|
||||||
|
}
|
||||||
let mycolor = data ? data.color : 'primary'
|
let mycolor = data ? data.color : 'primary'
|
||||||
if (!mycolor)
|
if (!mycolor) {
|
||||||
mycolor = 'primary'
|
mycolor = 'primary'
|
||||||
|
}
|
||||||
q.notify({
|
q.notify({
|
||||||
message: msg,
|
message: msg,
|
||||||
icon: myicon,
|
icon: myicon,
|
||||||
@@ -489,6 +581,136 @@ export const tools = {
|
|||||||
|
|
||||||
getimglogo() {
|
getimglogo() {
|
||||||
return 'statics/images/' + process.env.LOGO_REG
|
return 'statics/images/' + process.env.LOGO_REG
|
||||||
|
},
|
||||||
|
|
||||||
|
consolelogpao(strlog, strlog2 = '', strlog3 = '') {
|
||||||
|
globalroutines(null, 'log', strlog + ' ' + strlog2 + ' ' + strlog3, null)
|
||||||
|
},
|
||||||
|
|
||||||
|
async checkPendingMsg() {
|
||||||
|
// console.log('checkPendingMsg')
|
||||||
|
|
||||||
|
const config = await globalroutines(null, 'read', 'config', null, '1')
|
||||||
|
// console.log('config', config)
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (config) {
|
||||||
|
if (!!config[1].stateconn) {
|
||||||
|
// console.log('config.stateconn', config[1].stateconn)
|
||||||
|
|
||||||
|
if (config[1].stateconn !== GlobalStore.state.stateConnection) {
|
||||||
|
GlobalStore.mutations.setStateConnection(config[1].stateconn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// Check if there is something
|
||||||
|
return globalroutines(null, 'count', 'swmsg')
|
||||||
|
.then((count) => {
|
||||||
|
if (count > 0) {
|
||||||
|
// console.log('count = ', count)
|
||||||
|
return resolve(true)
|
||||||
|
} else {
|
||||||
|
return resolve(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
return reject()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
// If something in the call of Service Worker went wrong (Network or Server Down), then retry !
|
||||||
|
async sendSwMsgIfAvailable() {
|
||||||
|
let something = false
|
||||||
|
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
console.log(' -------- sendSwMsgIfAvailable')
|
||||||
|
|
||||||
|
const count = await tools.checkPendingMsg()
|
||||||
|
if (count > 0) {
|
||||||
|
return await navigator.serviceWorker.ready
|
||||||
|
.then((sw) => {
|
||||||
|
|
||||||
|
return globalroutines(null, 'readall', 'swmsg')
|
||||||
|
.then((arr_recmsg) => {
|
||||||
|
if (arr_recmsg.length > 0) {
|
||||||
|
|
||||||
|
// console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
||||||
|
let promiseChain = Promise.resolve()
|
||||||
|
|
||||||
|
for (const rec of arr_recmsg) {
|
||||||
|
// console.log(' .... sw.sync.register ( ', rec._id)
|
||||||
|
// if ('SyncManager' in window) {
|
||||||
|
// sw.sync.register(rec._id)
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// #Alternative to SyncManager
|
||||||
|
promiseChain = promiseChain.then(() => {
|
||||||
|
return Api.syncAlternative(rec._id)
|
||||||
|
.then(() => {
|
||||||
|
something = true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return promiseChain
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
resolve(something)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async waitAndRefreshData() {
|
||||||
|
return await Todos.actions.dbLoadTodo({ checkPending: false })
|
||||||
|
},
|
||||||
|
|
||||||
|
async waitAndcheckPendingMsg() {
|
||||||
|
|
||||||
|
// await aspettansec(1000)
|
||||||
|
|
||||||
|
return await tools.checkPendingMsg()
|
||||||
|
.then((ris) => {
|
||||||
|
if (ris) {
|
||||||
|
// console.log('risPending = ', ris)
|
||||||
|
return tools.sendSwMsgIfAvailable()
|
||||||
|
.then((something) => {
|
||||||
|
if (something) {
|
||||||
|
if (process.env.DEBUG === '1') {
|
||||||
|
console.log('something')
|
||||||
|
}
|
||||||
|
// Refresh data
|
||||||
|
return tools.waitAndRefreshData()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async updatefromIndexedDbToStateTodo(nametab) {
|
||||||
|
await globalroutines(null, 'updatefromIndexedDbToStateTodo', nametab, null)
|
||||||
|
.then(() => {
|
||||||
|
console.log('updatefromIndexedDbToStateTodo! ')
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
isLoggedToSystem() {
|
||||||
|
const tok = tools.getItemLS(tools.localStorage.token)
|
||||||
|
return !!tok
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { IGlobalState } from 'model'
|
|||||||
import { Route } from 'vue-router'
|
import { Route } from 'vue-router'
|
||||||
import { getStoreBuilder } from 'vuex-typex'
|
import { getStoreBuilder } from 'vuex-typex'
|
||||||
|
|
||||||
|
import { IProgressState } from '@types'
|
||||||
|
|
||||||
export interface RootState {
|
export interface RootState {
|
||||||
GlobalModule: IGlobalState
|
GlobalModule: IGlobalState
|
||||||
|
|||||||
9
src/typings/ProgressBar.d.ts
vendored
Normal file
9
src/typings/ProgressBar.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export interface IProgressState {
|
||||||
|
percent: number,
|
||||||
|
show: boolean,
|
||||||
|
canSuccess: boolean,
|
||||||
|
duration: number,
|
||||||
|
height: string,
|
||||||
|
color: string,
|
||||||
|
failedColor: string,
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// export * from './GlobalState.d'
|
// export * from './GlobalState.d'
|
||||||
|
|
||||||
|
export * from './ProgressBar.d'
|
||||||
|
|
||||||
export interface IResponse<T> {
|
export interface IResponse<T> {
|
||||||
success?: boolean,
|
success?: boolean,
|
||||||
|
|||||||
10
src/utils/methods.ts
Normal file
10
src/utils/methods.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
export function timeout(duration: number): Promise<{}> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {resolve()}, duration);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function randomNumber(min: number, max: number) : number {
|
||||||
|
return Math.floor((Math.random() * max) + min);
|
||||||
|
}
|
||||||
1
src/webpack.config.js
Normal file
1
src/webpack.config.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("./config/webpack.config.dev");
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"target": "es2016",
|
"target": "es2015",
|
||||||
|
"importHelpers": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
// "noUnusedParameters": true,
|
// "noUnusedParameters": true,
|
||||||
"pretty": true,
|
"pretty": true,
|
||||||
"noImplicitThis": true,
|
"strict": false,
|
||||||
|
"noImplicitThis": false,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"dom",
|
"dom",
|
||||||
"es5",
|
"es5",
|
||||||
@@ -25,13 +29,14 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@src/*": ["./*"],
|
"@src/*": ["./*"],
|
||||||
"@components": ["./components/index.ts"],
|
"@components": ["./components/index.ts"],
|
||||||
"@css/*": ["./statics/css/*"],
|
"@css/*": ["./statics/css/variables.scss"],
|
||||||
"@icons/*": ["./statics/icons/*"],
|
"@icons/*": ["./statics/icons/*"],
|
||||||
"@images/*": ["./statics/images/*"],
|
"@images/*": ["./statics/images/*"],
|
||||||
"@js/*": ["./statics/js/*"],
|
"@js/*": ["./statics/js/*"],
|
||||||
"@classes": ["./classes/index.ts"],
|
"@classes": ["./classes/index.ts"],
|
||||||
"@utils/*": ["./utils/*"],
|
"@utils/*": ["./utils/*"],
|
||||||
"@validators": ["./utils/validators.ts"],
|
"@validators": ["./utils/validators.ts"],
|
||||||
|
"@methods": ["./utils/methods.ts"],
|
||||||
"@router": ["./router/index.ts"],
|
"@router": ["./router/index.ts"],
|
||||||
"@paths": ["./store/Api/ApiRoutes.ts"],
|
"@paths": ["./store/Api/ApiRoutes.ts"],
|
||||||
"@types": ["./typings/index.ts"],
|
"@types": ["./typings/index.ts"],
|
||||||
@@ -42,6 +47,9 @@
|
|||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
// "usePostCSS": true,
|
// "usePostCSS": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
// "checkJs": true,
|
||||||
|
// "noEmit": true,
|
||||||
|
// "strict": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
@@ -59,5 +67,5 @@
|
|||||||
"dist",
|
"dist",
|
||||||
"node_modules"
|
"node_modules"
|
||||||
],
|
],
|
||||||
"compileOnSave": true
|
"compileOnSave": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"defaultSeverity": "warning",
|
|
||||||
"extends": [
|
|
||||||
"tslint:recommended"
|
|
||||||
],
|
|
||||||
"linterOptions": {
|
|
||||||
"exclude": [
|
|
||||||
"node_modules/**"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "never"],
|
|
||||||
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
|
|
||||||
"quotemark": [true, "single"],
|
|
||||||
"indent": [true, "spaces", 2],
|
|
||||||
"interface-name": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"max-line-length": false,
|
|
||||||
"member-access": false,
|
|
||||||
"no-console": [true, "warning"],
|
|
||||||
"no-consecutive-blank-lines": false,
|
|
||||||
"no-empty": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user