- 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",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
"freeplanet",
|
||||
@@ -12,6 +12,7 @@
|
||||
"lint": "tslint --project tsconfig.json",
|
||||
"lint:fix": "tslint --project tsconfig.json --fix",
|
||||
"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",
|
||||
"pwa": "NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
||||
"test:unit": "jest",
|
||||
@@ -25,15 +26,20 @@
|
||||
"generate-sw": "workbox generateSW workbox-config.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-runtime": "^7.4.0",
|
||||
"@babel/runtime": "^7.0.0",
|
||||
"@quasar/extras": "^1.1.0",
|
||||
"@types/vuelidate": "^0.7.0",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"acorn": "^6.0.0",
|
||||
"autoprefixer": "^9.5.0",
|
||||
"axios": "^0.18.0",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"bcrypt-nodejs": "0.0.3",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"dotenv": "^6.1.0",
|
||||
"element-ui": "^2.3.6",
|
||||
"eslint-plugin-vue": "^5.2.2",
|
||||
"google-translate-api": "^2.3.0",
|
||||
"graphql": "^0.13.2",
|
||||
"graphql-tag": "^2.8.0",
|
||||
@@ -42,13 +48,13 @@
|
||||
"js-cookie": "^2.2.0",
|
||||
"localforage": "^1.7.3",
|
||||
"normalize.css": "^8.0.0",
|
||||
"npm": "^6.4.1",
|
||||
"npm": "^6.9.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"quasar": "^1.0.0-beta.10",
|
||||
"quasar-extras": "^2.0.8",
|
||||
"register-service-worker": "^1.0.0",
|
||||
"vee-validate": "^2.1.2",
|
||||
"vue": "^2.5.17",
|
||||
"vue": "^2.6.10",
|
||||
"vue-class-component": "^6.3.2",
|
||||
"vue-i18n": "^8.1.0",
|
||||
"vue-idb": "^0.2.0",
|
||||
@@ -62,26 +68,29 @@
|
||||
"vuex-class": "^0.3.1",
|
||||
"vuex-module-decorators": "^0.4.3",
|
||||
"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": {
|
||||
"@babel/code-frame": "7.0.0-beta.54",
|
||||
"@babel/core": "7.0.0-beta.50",
|
||||
"@babel/generator": "7.0.0-beta.54",
|
||||
"@babel/helpers": "7.0.0-beta.54",
|
||||
"@babel/parser": "7.0.0-beta.54",
|
||||
"@babel/preset-env": "7.0.0-beta.54",
|
||||
"@babel/preset-react": "7.0.0",
|
||||
"@babel/runtime": "7.0.0-beta.54",
|
||||
"@babel/template": "7.0.0-beta.54",
|
||||
"@babel/traverse": "7.0.0-beta.54",
|
||||
"@babel/types": "7.0.0-beta.54",
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.4.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
||||
"@babel/plugin-proposal-decorators": "^7.0.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
||||
"@babel/plugin-proposal-function-sent": "^7.0.0",
|
||||
"@babel/plugin-proposal-json-strings": "^7.0.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/plugin-syntax-import-meta": "^7.2.0",
|
||||
"@babel/preset-env": "^7.4.2",
|
||||
"@quasar/app": "^1.0.0-beta.11",
|
||||
"@quasar/quasar-app-extension-typescript": "^1.0.0-alpha.11",
|
||||
"@types/dotenv": "^4.0.3",
|
||||
"@types/jest": "^23.1.4",
|
||||
"@types/js-cookie": "^2.1.0",
|
||||
"@types/node": "11.9.5",
|
||||
"@types/node": "^11.9.5",
|
||||
"@types/nprogress": "^0.0.29",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@vue/babel-preset-app": "3.1.1",
|
||||
@@ -92,12 +101,15 @@
|
||||
"@vue/cli-plugin-unit-jest": "^3.0.1",
|
||||
"@vue/cli-service": "^3.0.1",
|
||||
"@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",
|
||||
"eslint": "^5.5.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"html-webpack-plugin": "^2.8.1",
|
||||
"http-proxy-middleware": "^0.17.0",
|
||||
"jest": "^23.6.0",
|
||||
"http-proxy-middleware": "^0.19.1",
|
||||
"jest": "^24.5.0",
|
||||
"json-loader": "^0.5.4",
|
||||
"node-sass": "^4.11.0",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
||||
@@ -105,13 +117,13 @@
|
||||
"sass-loader": "^7.1.0",
|
||||
"strip-ansi": "=3.0.1",
|
||||
"ts-jest": "^23.0.0",
|
||||
"ts-loader": "^5.3.0",
|
||||
"ts-loader": "^5.3.3",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-standard": "^8.0.1",
|
||||
"tslint-loader": "^3.4.3",
|
||||
"typescript": "^3.1.6",
|
||||
"typescript": "^3.3.3333",
|
||||
"vue-cli-plugin-element-ui": "^1.1.2",
|
||||
"vue-template-compiler": "^2.5.17",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"vueify": "^9.4.1",
|
||||
"webpack": "^4.29.6",
|
||||
"webpack-dev-middleware": "^3.2.0",
|
||||
@@ -128,5 +140,8 @@
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"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'))
|
||||
.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('@images', helpers.root('src/statics/images/*'))
|
||||
.set('@classes', helpers.root('src/classes/index.ts'))
|
||||
@@ -25,6 +25,7 @@ const extendTypescriptToWebpack = (config) => {
|
||||
.set('@utils', helpers.root('src/utils/*'))
|
||||
.set('@router', helpers.root('src/router/index.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('@paths', helpers.root('src/store/Api/ApiRoutes.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) => {
|
||||
// console.log(' 3) ')
|
||||
if (clonedRes !== undefined)
|
||||
if (!!clonedRes)
|
||||
return clonedRes.json();
|
||||
return null
|
||||
})
|
||||
@@ -514,7 +514,7 @@ self.addEventListener('notificationclick', function (event) {
|
||||
return c.visibilityState === 'visible';
|
||||
});
|
||||
|
||||
if (client !== undefined) {
|
||||
if (!!client) {
|
||||
client.navigate(notification.data.url);
|
||||
client.focus();
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// 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 }) => {
|
||||
// ******************************************
|
||||
// *** 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
|
||||
// runs the default `next()` callback but also triggers
|
||||
// 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) => {
|
||||
var accessToken = store.state.session.userSession.accessToken
|
||||
|
||||
@@ -29,7 +29,7 @@ export function debounce<F extends Procedure>(
|
||||
|
||||
const shouldCallNow = options.isImmediate && timeoutId === undefined
|
||||
|
||||
if (timeoutId !== undefined) {
|
||||
if (!!timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ export default class Header extends Vue {
|
||||
|
||||
const color = (value === 'online') ? 'positive' : 'warning'
|
||||
|
||||
if (oldValue !== undefined) {
|
||||
if (!!oldValue) {
|
||||
tools.showNotif(this.$q, this.$t('connection') + ` ${value}`, {
|
||||
color,
|
||||
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) {
|
||||
|
||||
if (myobj.id !== undefined) {
|
||||
if (!!myobj.id) {
|
||||
console.log('KEY = ', myobj.id)
|
||||
|
||||
// Delete item
|
||||
|
||||
@@ -1,52 +1,11 @@
|
||||
import Vue from 'vue'
|
||||
import { Component } from 'vue-property-decorator'
|
||||
|
||||
import { TimelineLite, Back } from 'gsap'
|
||||
|
||||
import $ from 'jquery'
|
||||
import Timeout = NodeJS.Timeout
|
||||
import { tools } from "@src/store/Modules/tools"
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
|
||||
@Component({
|
||||
|
||||
})
|
||||
export default class Logo extends Vue {
|
||||
public logoimg: string = ''
|
||||
|
||||
public created() {
|
||||
this.logoimg = '../../' + tools.getimglogo()
|
||||
this.animate()
|
||||
get logoimg() {
|
||||
return '../../' + tools.getimglogo()
|
||||
}
|
||||
|
||||
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 { Component } from 'vue-property-decorator'
|
||||
|
||||
import { TimelineLite, Back } from 'gsap'
|
||||
|
||||
import $ from 'jquery'
|
||||
import Timeout = NodeJS.Timeout
|
||||
|
||||
@Component({
|
||||
|
||||
})
|
||||
export default class Offline extends Vue {
|
||||
logoimg: string = ''
|
||||
|
||||
created() {
|
||||
this.logoimg = '/statics/images/' + process.env.LOGO_REG
|
||||
this.animate()
|
||||
get logoimg() {
|
||||
return '/statics/images/' + process.env.LOGO_REG
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if (theField !== undefined) {
|
||||
if (!!theField) {
|
||||
theField.focus()
|
||||
}
|
||||
// console.log('focus()')
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<q-btn push
|
||||
:class="clButtPopover"
|
||||
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"
|
||||
@setPriority="setPriority"></SubMenus>
|
||||
</q-menu>
|
||||
|
||||
@@ -1,86 +1,84 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-list separator no-border class="todo-menu">
|
||||
<div v-for="field in menuPopupTodo" :key="field.value">
|
||||
<q-item clickable v-if="(field.value !== 130) && (field.value !== 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon"/>
|
||||
</q-item-section>
|
||||
<q-list separator no-border class="todo-menu">
|
||||
<div v-for="field in menuPopupTodo" :key="field.value">
|
||||
<q-item clickable v-if="(field.value !== 130) && (field.value !== 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon"/>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section v-if="field.value !== 120" label class="item-menu">
|
||||
<q-item-label>{{field.label}}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section v-if="field.value !== 120" label class="item-menu">
|
||||
<q-item-label>{{field.label}}</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section side top v-if="field.value === 101">
|
||||
<q-checkbox v-model="itemtodo.enableExpiring"/>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="field.value === 110">
|
||||
<q-checkbox v-model="itemtodo.completed"/>
|
||||
</q-item-section>
|
||||
<q-item-section side top v-if="field.value === 101">
|
||||
<q-checkbox v-model="itemtodo.enableExpiring"/>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="field.value === 110">
|
||||
<q-checkbox v-model="itemtodo.completed"/>
|
||||
</q-item-section>
|
||||
|
||||
|
||||
<q-item-section v-if="field.value === 120">
|
||||
<q-slider label
|
||||
:class="$parent.menuProgress"
|
||||
v-model="itemtodo.progress"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="5" @change="val => { lazy = val }"
|
||||
/>
|
||||
<q-item-section v-if="field.value === 120">
|
||||
<q-slider label
|
||||
:class="$parent.menuProgress"
|
||||
v-model="itemtodo.progress"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="5" @change="val => { lazy = val }"
|
||||
/>
|
||||
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="field.value === 120">
|
||||
<div>
|
||||
<q-item-label style="color: blue">{{itemtodo.progress}} %</q-item-label>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item v-if="(field.value === 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
<q-item-section class="item-menu">
|
||||
{{field.label}}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 130)">
|
||||
<q-item-section avatar>
|
||||
<q-icon name="priority_high" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="field.value === 120">
|
||||
<div>
|
||||
<q-item-label style="color: blue">{{itemtodo.progress}} %</q-item-label>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
<q-item-section class="item-menu">
|
||||
{{field.label}}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 130)">
|
||||
<q-item-section avatar>
|
||||
<q-icon name="priority_high" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>{{field.label}}</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-icon name="keyboard_arrow_right"/>
|
||||
</q-item-section>
|
||||
<q-item-section>{{field.label}}</q-item-section>
|
||||
<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 clickable :icon="field.icon"
|
||||
@click="clickMenu(field.value)">
|
||||
<q-menu auto-close anchor="bottom middle" self="top middle">
|
||||
<q-list dense>
|
||||
<q-item side clickable :icon="field.icon"
|
||||
@click="clickMenu(field.value)">
|
||||
|
||||
<q-item-section>
|
||||
<q-list dense>
|
||||
<q-item clickable v-ripple v-for="fieldprior in selectPriority"
|
||||
:key="fieldprior.value"
|
||||
@click="setPriority(fieldprior.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="fieldprior.icon" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
{{fieldprior.label}}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-item>
|
||||
</div>
|
||||
</q-list>
|
||||
</div>
|
||||
<q-item-section>
|
||||
<q-list dense>
|
||||
<q-item clickable v-ripple v-for="fieldprior in selectPriority"
|
||||
:key="fieldprior.value"
|
||||
@click="setPriority(fieldprior.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="fieldprior.icon" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
{{fieldprior.label}}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-item>
|
||||
</div>
|
||||
</q-list>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./SubMenus.ts">
|
||||
|
||||
@@ -409,7 +409,7 @@ export default class Todo extends Vue {
|
||||
}
|
||||
|
||||
public checkUpdate() {
|
||||
Todos.actions.waitAndcheckPendingMsg()
|
||||
tools.waitAndcheckPendingMsg()
|
||||
}
|
||||
|
||||
public loadMoreTodo(index, done) {
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { Todos, UserStore } from '@store'
|
||||
import _ from 'lodash'
|
||||
import store, { GlobalStore } from '../store'
|
||||
import { GlobalStore } from '../store/Modules'
|
||||
|
||||
import { idbKeyval as storage } from '../js/storage.js'
|
||||
import { costanti } from '../store/Modules/costanti'
|
||||
import { ICfgData } from '@src/model'
|
||||
import { ICfgData, IGlobalState } from '@src/model'
|
||||
|
||||
function saveConfigIndexDb(context) {
|
||||
|
||||
const data: ICfgData = {}
|
||||
data._id = costanti.CONFIG_ID_CFG
|
||||
data.lang = UserStore.state.lang
|
||||
data.token = UserStore.state.x_auth_token
|
||||
data.userId = UserStore.state.userId
|
||||
const data: ICfgData = {
|
||||
_id: costanti.CONFIG_ID_CFG,
|
||||
lang: UserStore.state.lang,
|
||||
token: UserStore.state.x_auth_token,
|
||||
userId: UserStore.state.userId
|
||||
}
|
||||
|
||||
writeConfigIndexDb('config', data)
|
||||
}
|
||||
@@ -21,10 +22,6 @@ function writeConfigIndexDb(context, data) {
|
||||
// console.log('writeConfigIndexDb', data)
|
||||
|
||||
storage.setdata('config', data)
|
||||
.then((ris) => {
|
||||
return true
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async function readfromIndexDbToStateTodos(context, table) {
|
||||
|
||||
@@ -8,7 +8,7 @@ function translate(params) {
|
||||
const stringa = messages[lang]
|
||||
|
||||
let ris = stringa
|
||||
if (ris !== undefined) {
|
||||
if (!!ris) {
|
||||
msg.forEach((param) => {
|
||||
ris = ris[param]
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export let idbKeyval = (() => {
|
||||
let db;
|
||||
const fieldsData = ['completed_at', 'created_at', 'expiring_at', 'modify_at']
|
||||
|
||||
function getDB() {
|
||||
if (!db) {
|
||||
@@ -14,13 +13,9 @@ export let idbKeyval = (() => {
|
||||
|
||||
openreq.onupgradeneeded = () => {
|
||||
// First time setup: create an empty object store
|
||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
||||
openreq.result.createObjectStore('categories', { 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' });
|
||||
for (mytab of tools.allTables) {
|
||||
openreq.result.createObjectStore(mytab, { keyPath: '_id' });
|
||||
}
|
||||
};
|
||||
|
||||
openreq.onsuccess = () => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { tools } from "../store/Modules/tools";
|
||||
import { tools } from '../store/Modules/tools'
|
||||
|
||||
import { RouteNames } from '../router/route-names'
|
||||
|
||||
export default function auth({ next, router }) {
|
||||
const tok = tools.getItemLS(tools.localStorage.token)
|
||||
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[]
|
||||
// todos_changed: number
|
||||
reload_fromServer: number
|
||||
testpao: String
|
||||
testpao: string
|
||||
insidePending: boolean
|
||||
visuLastCompleted: number
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { IToken } from 'model/other'
|
||||
export const DefaultUser = <IUserState>{
|
||||
email: '',
|
||||
username: '',
|
||||
idapp: process.env.APP_ID,
|
||||
password: '',
|
||||
lang: 'it'
|
||||
}
|
||||
@@ -12,7 +11,6 @@ export interface IUserState {
|
||||
userId?: string
|
||||
email?: string
|
||||
username?: string
|
||||
idapp?: any
|
||||
password?: string
|
||||
lang?: string
|
||||
repeatPassword?: string
|
||||
|
||||
@@ -28,7 +28,6 @@ export default class Home extends Vue {
|
||||
public visibile: boolean = false
|
||||
public cardvisible: string = 'hidden'
|
||||
public displaycard: string = 'block'
|
||||
public svgclass: string = 'svgclass'
|
||||
public $t: any
|
||||
// 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'
|
||||
|
||||
@@ -2,7 +2,12 @@ import Vue from 'vue'
|
||||
import VueRouter, { RouterMode } from 'vue-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)
|
||||
/*
|
||||
@@ -11,8 +16,8 @@ Vue.use(VueRouter)
|
||||
*/
|
||||
|
||||
const Router = new VueRouter({
|
||||
scrollBehavior: () => ({ y: 0 } as PositionResult),
|
||||
routes: RouteConfig,
|
||||
scrollBehavior: () => ({ x: 0, y: 0 } as PositionResult),
|
||||
routes: routesList,
|
||||
|
||||
// Leave these as is and change from quasar.conf.js instead!
|
||||
// quasar.conf.js -> build -> vueRouterMode
|
||||
@@ -20,4 +25,159 @@ const Router = new VueRouter({
|
||||
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
|
||||
|
||||
@@ -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 { tools } from '@src/store/Modules/tools'
|
||||
|
||||
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: '/',
|
||||
name: RouteNames.home,
|
||||
@@ -32,7 +60,11 @@ export const RouteConfig: VueRouteConfig[] = [
|
||||
name: 'Todos',
|
||||
component: () => import('@/components/todos/todo/todo.vue'),
|
||||
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',
|
||||
component: () => import('@/components/admin/cfgServer/cfgServer.vue'),
|
||||
meta: {
|
||||
middleware: [auth]
|
||||
requiresAuth: true
|
||||
// middleware: [auth]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -57,8 +90,19 @@ export const RouteConfig: VueRouteConfig[] = [
|
||||
path: '/offline',
|
||||
name: 'Offline',
|
||||
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',
|
||||
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',
|
||||
Test1: 'Test1',
|
||||
Test2: 'Test2',
|
||||
Projects: 'Progetti'
|
||||
},
|
||||
components: {
|
||||
authentication: {
|
||||
@@ -361,6 +362,7 @@ const messages = {
|
||||
Admin: 'Administración',
|
||||
Test1: 'Test1',
|
||||
Test2: 'Test2',
|
||||
Projects: 'Projectos',
|
||||
},
|
||||
components: {
|
||||
authentication: {
|
||||
@@ -589,6 +591,7 @@ const messages = {
|
||||
Admin: 'Admin',
|
||||
Test1: 'Test1',
|
||||
Test2: 'Test2',
|
||||
Projects: 'Projects',
|
||||
},
|
||||
components: {
|
||||
authentication: {
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
}
|
||||
items.push(cursor.value);
|
||||
|
||||
if (count !== undefined && items.length == count) {
|
||||
if (!!count && items.length == count) {
|
||||
resolve(items);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const allTables = ['todos', 'categories', 'sync_post_todos', 'sync_patch_todos', 'delete_todos', 'config', 'swmsg']
|
||||
|
||||
let idbKeyval = (() => {
|
||||
let db;
|
||||
// console.log('idbKeyval...')
|
||||
@@ -14,13 +16,9 @@ let idbKeyval = (() => {
|
||||
|
||||
openreq.onupgradeneeded = () => {
|
||||
// First time setup: create an empty object store
|
||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
||||
openreq.result.createObjectStore('categories', { 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' });
|
||||
for (mytab of allTables) {
|
||||
openreq.result.createObjectStore(mytab, { keyPath: '_id' });
|
||||
}
|
||||
};
|
||||
|
||||
openreq.onsuccess = () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// import { NotificationsStore, LoginStore } from '@store'
|
||||
|
||||
export class AxiosSuccess {
|
||||
public success: boolean = true
|
||||
public success: any = true
|
||||
public status: number
|
||||
public data: any
|
||||
|
||||
@@ -11,6 +11,7 @@ export class AxiosSuccess {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class AxiosError {
|
||||
public success: boolean = false
|
||||
public status: number = 0
|
||||
@@ -18,7 +19,7 @@ export class AxiosError {
|
||||
public code: any = 0
|
||||
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.data = data
|
||||
this.code = code
|
||||
@@ -89,10 +90,6 @@ export class ApiResponse {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class ApiSuccess extends ApiResponse {
|
||||
constructor(fields: {message?: string, data?: any} = {}) {
|
||||
super({
|
||||
|
||||
@@ -48,7 +48,7 @@ export const removeAuthHeaders = () => {
|
||||
async function Request(type: string, path: string, payload: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
let ricevuto = false
|
||||
try {
|
||||
console.log(`Axios Request [${type}]:`, axiosInstance.defaults, 'path:', path)
|
||||
console.log('Axios Request', path, type, axiosInstance.defaults)
|
||||
let response: AxiosResponse
|
||||
if (type === 'post' || type === 'put' || type === 'patch') {
|
||||
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')
|
||||
|
||||
// console.log('--------- 0 ')
|
||||
|
||||
if (response && (response.status === 200)) {
|
||||
let x_auth_token = ''
|
||||
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> {
|
||||
|
||||
mydata = {
|
||||
...mydata,
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID
|
||||
}
|
||||
|
||||
// console.log('mydata', mydata)
|
||||
|
||||
UserStore.mutations.setServerCode(tools.EMPTY)
|
||||
UserStore.mutations.setResStatus(0)
|
||||
return await new Promise((resolve, reject) => {
|
||||
@@ -122,7 +131,7 @@ export namespace ApiTool {
|
||||
const token = multiparams[3]
|
||||
// let lang = multiparams[3]
|
||||
|
||||
if (cmd === 'sync-todos') {
|
||||
if (cmd === tools.DB.CMD_SYNC) {
|
||||
// console.log('[Alternative] Syncing', cmd, table, method)
|
||||
|
||||
// const headers = new Headers()
|
||||
|
||||
@@ -15,9 +15,6 @@ import { GlobalStore, Todos, UserStore } from '@store'
|
||||
import messages from '../../statics/i18n'
|
||||
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'
|
||||
|
||||
getstateConnSaved()
|
||||
@@ -134,6 +131,8 @@ namespace Getters {
|
||||
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
|
||||
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: '/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' },
|
||||
@@ -444,22 +443,22 @@ namespace Actions {
|
||||
console.log('clearDataAfterLogout')
|
||||
|
||||
// Clear all data from the IndexedDB
|
||||
for (const table of allTables) {
|
||||
for (const table of tools.allTables) {
|
||||
await globalroutines(null, 'clearalldata', table, null)
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
// REMOVE ALL SUBSCRIPTION
|
||||
console.log('REMOVE ALL SUBSCRIPTION...')
|
||||
await navigator.serviceWorker.ready.then(function (reg) {
|
||||
await navigator.serviceWorker.ready.then((reg) => {
|
||||
console.log('... Ready')
|
||||
reg.pushManager.getSubscription().then((subscription) => {
|
||||
console.log(' Found Subscription...')
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then(function (successful) {
|
||||
subscription.unsubscribe().then((successful) => {
|
||||
// You've successfully unsubscribed
|
||||
console.log('You\'ve successfully unsubscribed')
|
||||
}).catch(function (e) {
|
||||
}).catch( (e) => {
|
||||
// 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 { costanti } from '@src/store/Modules/costanti'
|
||||
|
||||
const nametable = 'todos'
|
||||
|
||||
// import _ from 'lodash'
|
||||
|
||||
const state: ITodosState = {
|
||||
@@ -24,7 +26,7 @@ const state: ITodosState = {
|
||||
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 stateGetter = b.state()
|
||||
@@ -35,8 +37,9 @@ function getindexbycategory(category: string) {
|
||||
|
||||
function gettodosByCategory(category: string) {
|
||||
const indcat = state.categories.indexOf(category)
|
||||
if (!state.todos[indcat])
|
||||
if (!state.todos[indcat]) {
|
||||
return []
|
||||
}
|
||||
return state.todos[indcat]
|
||||
}
|
||||
|
||||
@@ -48,49 +51,34 @@ function isValidIndex(cat, index) {
|
||||
function getElemByIndex(cat, index) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
|
||||
if (index >= 0 && index < myarr.length)
|
||||
if (index >= 0 && index < myarr.length) {
|
||||
return myarr[index]
|
||||
else
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function getElemById(cat, id) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
||||
if (myarr[indrec]._id === id) {
|
||||
return myarr[indrec]
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
return myarr.find((elem) => elem._id === id)
|
||||
}
|
||||
|
||||
function getIndexById(cat, id) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
||||
if (myarr[indrec]._id === id) {
|
||||
return indrec
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
return myarr.findIndex((elem) => elem._id === id)
|
||||
}
|
||||
|
||||
function getElemPrevById(cat, id_prev) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
||||
if (myarr[indrec].id_prev === id_prev) {
|
||||
return myarr[indrec]
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
return myarr.find((elem) => elem._id === id_prev)
|
||||
}
|
||||
|
||||
function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolean, escludiId: string) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
if (myarr === null)
|
||||
if (myarr === null) {
|
||||
return -1
|
||||
}
|
||||
|
||||
let trovato: boolean = false
|
||||
|
||||
@@ -114,30 +102,29 @@ function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolea
|
||||
if (trovato) {
|
||||
return myarr.length - 1
|
||||
} else {
|
||||
if (priority === tools.Todos.PRIORITY_LOW)
|
||||
if (priority === tools.Todos.PRIORITY_LOW) {
|
||||
return myarr.length - 1
|
||||
else if (priority === tools.Todos.PRIORITY_HIGH)
|
||||
}
|
||||
else if (priority === tools.Todos.PRIORITY_HIGH) {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFirstList(cat) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
for (let indrec in myarr) {
|
||||
if (myarr[indrec].id_prev === tools.LIST_START) {
|
||||
return myarr[indrec]
|
||||
}
|
||||
}
|
||||
return null
|
||||
return myarr.find((elem) => elem.id_prev === tools.LIST_START)
|
||||
}
|
||||
|
||||
function getLastListNotCompleted(cat) {
|
||||
const arr = Todos.getters.todos_dacompletare(cat)
|
||||
// console.log('cat', cat, 'arr', arr)
|
||||
if (arr.length > 0)
|
||||
if (arr.length > 0) {
|
||||
return arr[arr.length - 1]
|
||||
else
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function getstrelem(elem) {
|
||||
@@ -158,10 +145,9 @@ function update_idprev(indcat, indelemchange, indelemId) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
function initcat() {
|
||||
|
||||
let tomorrow = new Date()
|
||||
const tomorrow = new Date()
|
||||
tomorrow.setDate(tomorrow.getDate() + 1)
|
||||
|
||||
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 {
|
||||
// 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 indcat = getindexbycategory(cat)
|
||||
if (state.todos[indcat]) {
|
||||
return state.todos[indcat].filter(todo => !todo.completed)
|
||||
} else return []
|
||||
return state.todos[indcat].filter((todo) => !todo.completed)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'todos_dacompletare')
|
||||
|
||||
const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
if (state.todos[indcat]) {
|
||||
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
|
||||
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL)
|
||||
return state.todos[indcat].filter(todo => todo.completed)
|
||||
else
|
||||
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
|
||||
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) {
|
||||
return state.todos[indcat].filter((todo) => todo.completed)
|
||||
}
|
||||
else {
|
||||
return []
|
||||
} else return []
|
||||
}
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'todos_completati')
|
||||
|
||||
const doneTodosCount = b.read((state: ITodosState) => (cat: string): number => {
|
||||
@@ -250,9 +212,7 @@ namespace Getters {
|
||||
}
|
||||
}, 'TodosCount')
|
||||
|
||||
|
||||
export const getters = {
|
||||
// get fullName() { return fullName();},
|
||||
get todos_dacompletare() {
|
||||
return todos_dacompletare()
|
||||
},
|
||||
@@ -268,28 +228,17 @@ namespace Getters {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Mutations {
|
||||
|
||||
function setTestpao(state: ITodosState, testpao: String) {
|
||||
state.testpao = testpao
|
||||
}
|
||||
|
||||
function findTodoById(state: ITodosState, data: IParamTodo) {
|
||||
const indcat = state.categories.indexOf(data.categorySel)
|
||||
if (indcat >= 0) {
|
||||
if (state.todos[indcat]) {
|
||||
for (let i = 0; i < state.todos[indcat].length; i++) {
|
||||
if (state.todos[indcat][i]._id === data.id)
|
||||
return i
|
||||
}
|
||||
}
|
||||
return state.todos[indcat].find((elem) => elem._id === data.id)
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
|
||||
|
||||
function createNewItem(state: ITodosState, { objtodo, atfirst, categorySel }) {
|
||||
let indcat = state.categories.indexOf(categorySel)
|
||||
if (indcat == -1) {
|
||||
@@ -303,10 +252,12 @@ namespace Mutations {
|
||||
console.log('push state.todos[indcat]', state.todos)
|
||||
return
|
||||
}
|
||||
if (atfirst)
|
||||
if (atfirst) {
|
||||
state.todos[indcat].unshift(objtodo)
|
||||
else
|
||||
}
|
||||
else {
|
||||
state.todos[indcat].push(objtodo)
|
||||
}
|
||||
|
||||
console.log('state.todos[indcat]', state.todos[indcat])
|
||||
|
||||
@@ -319,162 +270,35 @@ namespace Mutations {
|
||||
|
||||
console.log('PRIMA state.todos', state.todos)
|
||||
// Delete Item in to Array
|
||||
if (ind >= 0)
|
||||
if (ind >= 0) {
|
||||
state.todos[indcat].splice(ind, 1)
|
||||
}
|
||||
|
||||
console.log('DOPO state.todos', state.todos, 'ind', ind)
|
||||
|
||||
// tools.notifyarraychanged(state.todos[indcat])
|
||||
}
|
||||
|
||||
|
||||
export const mutations = {
|
||||
setTestpao: b.commit(setTestpao),
|
||||
// setTestpao: b.commit(setTestpao),
|
||||
deletemyitem: b.commit(deletemyitem),
|
||||
createNewItem: b.commit(createNewItem)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function consolelogpao(strlog, strlog2 = '', strlog3 = '') {
|
||||
globalroutines(null, 'log', strlog + ' ' + strlog2 + ' ' + strlog3, null)
|
||||
}
|
||||
|
||||
|
||||
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 }) {
|
||||
console.log('dbLoadTodo', checkPending, 'userid=', UserStore.state.userId)
|
||||
|
||||
if (UserStore.state.userId === '')
|
||||
return false // Login not made
|
||||
if (UserStore.state.userId === '') {
|
||||
return false
|
||||
} // Login not made
|
||||
|
||||
let ris = await Api.SendReq('/todos/' + UserStore.state.userId, 'GET', null)
|
||||
.then(res => {
|
||||
const ris = await Api.SendReq('/todos/' + UserStore.state.userId, 'GET', null)
|
||||
.then((res) => {
|
||||
if (res.data.todos) {
|
||||
// console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
// console.log('RISULTANTE TODOS DAL SERVER = ', res.data.todos)
|
||||
|
||||
state.todos = res.data.todos
|
||||
state.categories = res.data.categories
|
||||
} else {
|
||||
@@ -483,53 +307,47 @@ namespace Actions {
|
||||
|
||||
// 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 }))
|
||||
|
||||
// console.log('showtype = ', state.showtype)
|
||||
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
||||
id: costanti.CONFIG_ID_SHOW_TYPE_TODOS,
|
||||
default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED
|
||||
}), 10)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
return res
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.log('error dbLoadTodo', error)
|
||||
UserStore.mutations.setErrorCatch(error)
|
||||
return error
|
||||
})
|
||||
|
||||
if (ris.status !== 200) {
|
||||
if (process.env.DEBUG === '1')
|
||||
if (process.env.DEBUG === '1') {
|
||||
console.log('ris.status', ris.status)
|
||||
}
|
||||
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||
tools.consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||
} 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) {
|
||||
// Read all data from IndexedDB Store into Memory
|
||||
await updatefromIndexedDbToStateTodo(context)
|
||||
await tools.updatefromIndexedDbToStateTodo('categories')
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
setTimeout(function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('anything')
|
||||
}, numsec)
|
||||
})
|
||||
@@ -537,71 +355,12 @@ namespace Actions {
|
||||
|
||||
async function testfunc() {
|
||||
while (true) {
|
||||
consolelogpao('testfunc')
|
||||
tools.consolelogpao('testfunc')
|
||||
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
||||
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) {
|
||||
if (String(recOut[field]) !== String(recIn[field])) {
|
||||
// console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
||||
@@ -615,12 +374,12 @@ namespace Actions {
|
||||
async function deleteItem(context, { cat, idobj }) {
|
||||
console.log('deleteItem: KEY = ', idobj)
|
||||
|
||||
let myobjtrov = getElemById(cat, idobj)
|
||||
const myobjtrov = getElemById(cat, idobj)
|
||||
|
||||
if (myobjtrov !== null) {
|
||||
let myobjnext = getElemPrevById(cat, myobjtrov._id)
|
||||
if (!!myobjtrov) {
|
||||
const myobjnext = getElemPrevById(cat, myobjtrov._id)
|
||||
|
||||
if (myobjnext !== null) {
|
||||
if (!!myobjnext) {
|
||||
myobjnext.id_prev = myobjtrov.id_prev
|
||||
myobjnext.modified = true
|
||||
console.log('calling MODIFY 1')
|
||||
@@ -631,15 +390,13 @@ namespace Actions {
|
||||
Todos.mutations.deletemyitem(myobjtrov)
|
||||
|
||||
// 2) Delete from the IndexedDb
|
||||
globalroutines(context, 'delete', 'todos', null, idobj)
|
||||
.then((ris) => {
|
||||
|
||||
}).catch((error) => {
|
||||
console.log('err: ', error)
|
||||
})
|
||||
globalroutines(context, 'delete', nametable, null, idobj)
|
||||
.catch((error) => {
|
||||
console.log('err: ', error)
|
||||
})
|
||||
|
||||
// 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 })
|
||||
|
||||
// 2) Insert into the IndexedDb
|
||||
const id = await globalroutines(context, 'write', 'todos', objtodo)
|
||||
const id = await globalroutines(context, 'write', nametable, objtodo)
|
||||
|
||||
let field = ''
|
||||
// update also the last elem
|
||||
@@ -695,11 +452,11 @@ namespace Actions {
|
||||
}
|
||||
|
||||
// 3) send to the Server
|
||||
return await saveItemToSyncAndDb(tools.DB.TABLE_SYNC_TODOS, 'POST', objtodo)
|
||||
return await tools.saveItemToSyncAndDb(nametable, 'POST', objtodo)
|
||||
.then((ris) => {
|
||||
// Check if need to be moved...
|
||||
const indelem = getIndexById(objtodo.category, objtodo._id)
|
||||
let itemdragend = undefined
|
||||
let itemdragend
|
||||
if (atfirst) {
|
||||
// Check the second item, if it's different priority, then move to the first position of the priority
|
||||
const secondindelem = indelem + 1
|
||||
@@ -733,8 +490,9 @@ namespace Actions {
|
||||
}
|
||||
}
|
||||
|
||||
if (itemdragend)
|
||||
if (itemdragend) {
|
||||
swapElems(context, itemdragend)
|
||||
}
|
||||
|
||||
return ris
|
||||
|
||||
@@ -742,24 +500,25 @@ namespace Actions {
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function modify(context, { myitem, field }) {
|
||||
if (myitem === null)
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (myitem === null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
const myobjsaved = tools.jsonCopy(myitem)
|
||||
// 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) {
|
||||
console.log('~~~~~~~~~~~~~~~~~~~~ !!!!!!!!!!!!!!!!!! Record not Found !!!!!! id=', myobjsaved._id)
|
||||
return
|
||||
}
|
||||
|
||||
if (setmodifiedIfchanged(miorec, myobjsaved, 'completed'))
|
||||
if (setmodifiedIfchanged(miorec, myobjsaved, 'completed')) {
|
||||
miorec.completed_at = new Date().getDate()
|
||||
}
|
||||
|
||||
fieldtochange.forEach(field => {
|
||||
fieldtochange.forEach((field) => {
|
||||
setmodifiedIfchanged(miorec, myobjsaved, field)
|
||||
})
|
||||
|
||||
@@ -775,32 +534,16 @@ namespace Actions {
|
||||
|
||||
// this.logelem('modify', miorec)
|
||||
// 2) Modify on IndexedDb
|
||||
return globalroutines(context, 'write', 'todos', miorec)
|
||||
.then(ris => {
|
||||
return globalroutines(context, 'write', nametable, miorec)
|
||||
.then((ris) => {
|
||||
|
||||
// 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) {
|
||||
console.log('swapElems', itemdragend)
|
||||
console.log('state.todos', state.todos)
|
||||
@@ -826,8 +569,8 @@ namespace Actions {
|
||||
tools.notifyarraychanged(state.todos[indcat][itemdragend.oldIndex])
|
||||
|
||||
if (itemdragend.field !== 'priority') {
|
||||
let precind = itemdragend.newIndex - 1
|
||||
let nextind = itemdragend.newIndex + 1
|
||||
const precind = itemdragend.newIndex - 1
|
||||
const nextind = itemdragend.newIndex + 1
|
||||
|
||||
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)) {
|
||||
@@ -854,7 +597,6 @@ namespace Actions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the id_prev property
|
||||
const elem1 = update_idprev(indcat, itemdragend.newIndex, itemdragend.newIndex - 1)
|
||||
const elem2 = update_idprev(indcat, itemdragend.newIndex + 1, itemdragend.newIndex)
|
||||
@@ -871,15 +613,8 @@ namespace Actions {
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
dbInsertTodo: b.dispatch(dbInsertTodo),
|
||||
dbSaveTodo: b.dispatch(dbSaveTodo),
|
||||
dbLoadTodo: b.dispatch(dbLoadTodo),
|
||||
dbdeleteItem: b.dispatch(dbdeleteItem),
|
||||
updatefromIndexedDbToStateTodo: b.dispatch(updatefromIndexedDbToStateTodo),
|
||||
checkPendingMsg: b.dispatch(checkPendingMsg),
|
||||
waitAndcheckPendingMsg: b.dispatch(waitAndcheckPendingMsg),
|
||||
swapElems: b.dispatch(swapElems),
|
||||
// updateModifyRecords: b.dispatch(updateModifyRecords),
|
||||
deleteItem: b.dispatch(deleteItem),
|
||||
insertTodo: b.dispatch(insertTodo),
|
||||
modify: b.dispatch(modify)
|
||||
@@ -887,7 +622,6 @@ namespace Actions {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Module
|
||||
const TodosModule = {
|
||||
get state() {
|
||||
|
||||
@@ -19,7 +19,6 @@ const state: IUserState = {
|
||||
userId: '',
|
||||
email: '',
|
||||
username: '',
|
||||
idapp: process.env.APP_ID,
|
||||
password: '',
|
||||
lang: '',
|
||||
repeatPassword: '',
|
||||
@@ -28,6 +27,7 @@ const state: IUserState = {
|
||||
categorySel: 'personal',
|
||||
servercode: 0,
|
||||
x_auth_token: '',
|
||||
isLogged: false,
|
||||
isAdmin: false
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ namespace Getters {
|
||||
},
|
||||
get getServerCode() {
|
||||
return getServerCode()
|
||||
}
|
||||
},
|
||||
// get fullName() { return fullName();},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Mutations {
|
||||
function authUser(state: IUserState, data: IUserState ) {
|
||||
function authUser(state: IUserState, data: IUserState) {
|
||||
state.userId = data.userId
|
||||
state.username = data.username
|
||||
if (data.verified_email) {
|
||||
@@ -221,8 +221,6 @@ namespace Actions {
|
||||
async function resetpwd(context, paramquery: IUserState) {
|
||||
|
||||
const usertosend = {
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID,
|
||||
email: paramquery.email,
|
||||
password: paramquery.password,
|
||||
tokenforgot: paramquery.tokenforgot
|
||||
@@ -245,8 +243,6 @@ namespace Actions {
|
||||
async function requestpwd(context, paramquery: IUserState) {
|
||||
|
||||
const usertosend = {
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID,
|
||||
email: paramquery.email
|
||||
}
|
||||
console.log(usertosend)
|
||||
@@ -265,8 +261,6 @@ namespace Actions {
|
||||
|
||||
async function vreg(context, paramquery: ILinkReg) {
|
||||
const usertosend = {
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID,
|
||||
idlink: paramquery.idlink
|
||||
}
|
||||
console.log(usertosend)
|
||||
@@ -301,12 +295,10 @@ namespace Actions {
|
||||
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
||||
.then((hashedPassword: string) => {
|
||||
const usertosend = {
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
lang: mylang,
|
||||
email: authData.email,
|
||||
password: String(hashedPassword),
|
||||
username: authData.username,
|
||||
idapp: process.env.APP_ID
|
||||
}
|
||||
|
||||
console.log(usertosend)
|
||||
@@ -371,7 +363,7 @@ namespace Actions {
|
||||
try {
|
||||
if ('serviceWorker' in navigator) {
|
||||
sub = await navigator.serviceWorker.ready
|
||||
.then(function(swreg) {
|
||||
.then(function (swreg) {
|
||||
console.log('swreg')
|
||||
const sub = swreg.pushManager.getSubscription()
|
||||
return sub
|
||||
@@ -393,8 +385,6 @@ namespace Actions {
|
||||
const usertosend = {
|
||||
username: authData.username,
|
||||
password: authData.password,
|
||||
idapp: process.env.APP_ID,
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
lang: state.lang,
|
||||
subs: sub,
|
||||
options
|
||||
@@ -487,13 +477,7 @@ namespace Actions {
|
||||
|
||||
await GlobalStore.actions.clearDataAfterLogout()
|
||||
|
||||
const usertosend = {
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
idapp: process.env.APP_ID
|
||||
}
|
||||
|
||||
console.log(usertosend)
|
||||
const riscall = await Api.SendReq('/users/me/token', 'DELETE', usertosend)
|
||||
const riscall = await Api.SendReq('/users/me/token', 'DELETE', null)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
}).then(() => {
|
||||
@@ -510,6 +494,7 @@ namespace Actions {
|
||||
|
||||
async function setGlobal(loggedWithNetwork: boolean) {
|
||||
state.isLogged = true
|
||||
console.log('state.isLogged')
|
||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||
|
||||
@@ -523,7 +508,7 @@ namespace Actions {
|
||||
|
||||
async function autologin_FromLocalStorage(context) {
|
||||
try {
|
||||
// console.log('*** autologin_FromLocalStorage ***')
|
||||
console.log('*** autologin_FromLocalStorage ***')
|
||||
// INIT
|
||||
|
||||
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 = {
|
||||
autologin_FromLocalStorage: b.dispatch(autologin_FromLocalStorage),
|
||||
logout: b.dispatch(logout),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Api from '@api'
|
||||
import { ITodo } from '@src/model'
|
||||
import { Todos, UserStore } from '@store'
|
||||
import { GlobalStore, Todos, UserStore } from '@store'
|
||||
import globalroutines from './../../globalroutines/index'
|
||||
import { costanti } from './costanti'
|
||||
import Quasar from 'quasar'
|
||||
@@ -12,6 +12,7 @@ export interface INotify {
|
||||
}
|
||||
|
||||
export const tools = {
|
||||
allTables: ['todos', 'categories', 'sync_post_todos', 'sync_patch_todos', 'delete_todos', 'config', 'swmsg'],
|
||||
EMPTY: 0,
|
||||
CALLING: 10,
|
||||
OK: 20,
|
||||
@@ -48,12 +49,12 @@ export const tools = {
|
||||
},
|
||||
|
||||
DB: {
|
||||
CMD_SYNC_TODOS: 'sync-todos',
|
||||
CMD_SYNC_NEW_TODOS: 'sync-new-todos',
|
||||
CMD_DELETE_TODOS: 'sync-delete-todos',
|
||||
TABLE_SYNC_TODOS: 'sync_todos',
|
||||
TABLE_SYNC_TODOS_PATCH: 'sync_todos_patch',
|
||||
TABLE_DELETE_TODOS: 'delete_todos'
|
||||
CMD_SYNC: 'sync-',
|
||||
CMD_SYNC_NEW: 'sync-new-',
|
||||
CMD_DELETE: 'sync-delete-',
|
||||
TABLE_SYNC_POST: 'sync_post_',
|
||||
TABLE_SYNC_PATCH: 'sync_patch_',
|
||||
TABLE_DELETE: 'delete_'
|
||||
},
|
||||
|
||||
MenuAction: {
|
||||
@@ -386,7 +387,7 @@ export const tools = {
|
||||
json2array(json) {
|
||||
const result = []
|
||||
const keys = Object.keys(json)
|
||||
keys.forEach(function (key) {
|
||||
keys.forEach((key) => {
|
||||
result.push(json[key])
|
||||
})
|
||||
return result
|
||||
@@ -395,20 +396,20 @@ export const tools = {
|
||||
async cmdToSyncAndDb(cmd, table, method, item: ITodo, id, msg: String) {
|
||||
// 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
|
||||
if ((cmd === tools.DB.CMD_SYNC_NEW_TODOS) || (cmd === tools.DB.CMD_DELETE_TODOS)) {
|
||||
cmdSw = tools.DB.CMD_SYNC_TODOS
|
||||
if ((cmd === tools.DB.CMD_SYNC_NEW) || (cmd === tools.DB.CMD_DELETE)) {
|
||||
cmdSw = tools.DB.CMD_SYNC
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
return await navigator.serviceWorker.ready
|
||||
.then(function (sw) {
|
||||
.then((sw) => {
|
||||
// console.log('---------------------- navigator.serviceWorker.ready')
|
||||
|
||||
return globalroutines(null, 'write', table, item, id)
|
||||
.then(function (id) {
|
||||
.then((id) => {
|
||||
// console.log('id', id)
|
||||
const sep = '|'
|
||||
|
||||
@@ -427,14 +428,14 @@ export const tools = {
|
||||
return Api.syncAlternative(multiparams)
|
||||
// }
|
||||
})
|
||||
.then(function () {
|
||||
.then(() => {
|
||||
let data = null
|
||||
if (msg !== '') {
|
||||
data = { message: msg, position: 'bottom', timeout: 3000 }
|
||||
}
|
||||
return data
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch((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) {
|
||||
let myicon = data ? data.icon : 'ion-add'
|
||||
if (!myicon)
|
||||
if (!myicon) {
|
||||
myicon = 'ion-add'
|
||||
}
|
||||
let mycolor = data ? data.color : 'primary'
|
||||
if (!mycolor)
|
||||
if (!mycolor) {
|
||||
mycolor = 'primary'
|
||||
}
|
||||
q.notify({
|
||||
message: msg,
|
||||
icon: myicon,
|
||||
@@ -489,6 +581,136 @@ export const tools = {
|
||||
|
||||
getimglogo() {
|
||||
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 { getStoreBuilder } from 'vuex-typex'
|
||||
|
||||
import { IProgressState } from '@types'
|
||||
|
||||
export interface RootState {
|
||||
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 './ProgressBar.d'
|
||||
|
||||
export interface IResponse<T> {
|
||||
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": {
|
||||
"module": "esnext",
|
||||
"target": "es2016",
|
||||
"target": "es2015",
|
||||
"importHelpers": true,
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": true,
|
||||
"noImplicitAny": false,
|
||||
"noUnusedLocals": false,
|
||||
// "noUnusedParameters": true,
|
||||
"pretty": true,
|
||||
"noImplicitThis": true,
|
||||
"strict": false,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"lib": [
|
||||
"dom",
|
||||
"es5",
|
||||
@@ -25,13 +29,14 @@
|
||||
"paths": {
|
||||
"@src/*": ["./*"],
|
||||
"@components": ["./components/index.ts"],
|
||||
"@css/*": ["./statics/css/*"],
|
||||
"@css/*": ["./statics/css/variables.scss"],
|
||||
"@icons/*": ["./statics/icons/*"],
|
||||
"@images/*": ["./statics/images/*"],
|
||||
"@js/*": ["./statics/js/*"],
|
||||
"@classes": ["./classes/index.ts"],
|
||||
"@utils/*": ["./utils/*"],
|
||||
"@validators": ["./utils/validators.ts"],
|
||||
"@methods": ["./utils/methods.ts"],
|
||||
"@router": ["./router/index.ts"],
|
||||
"@paths": ["./store/Api/ApiRoutes.ts"],
|
||||
"@types": ["./typings/index.ts"],
|
||||
@@ -42,6 +47,9 @@
|
||||
"sourceMap": true,
|
||||
// "usePostCSS": true,
|
||||
"allowJs": true,
|
||||
// "checkJs": true,
|
||||
// "noEmit": true,
|
||||
// "strict": true,
|
||||
"skipLibCheck": true,
|
||||
"types": [
|
||||
"node",
|
||||
@@ -59,5 +67,5 @@
|
||||
"dist",
|
||||
"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