9
.babelrc
9
.babelrc
@@ -22,15 +22,6 @@
|
|||||||
"loose": false,
|
"loose": false,
|
||||||
"useBuiltIns": "usage"
|
"useBuiltIns": "usage"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
[
|
|
||||||
"@babel/preset-stage-2",
|
|
||||||
{
|
|
||||||
"modules": false,
|
|
||||||
"loose": false,
|
|
||||||
"useBuiltIns": true,
|
|
||||||
"decoratorsLegacy": true
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
APP_VERSION="DEV 0.0.27"
|
APP_VERSION="0.0.47"
|
||||||
SERVICE_WORKER_FILE='service-worker.js'
|
SERVICE_WORKER_FILE='service-worker.js'
|
||||||
APP_ID='1'
|
APP_ID='1'
|
||||||
APP_URL='https://freeplanet.app'
|
APP_URL='https://freeplanet.app'
|
||||||
@@ -7,8 +7,10 @@ LANG_DEFAULT='it'
|
|||||||
PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF'
|
PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF'
|
||||||
MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
|
MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
|
||||||
MONGODB_HOST='http://localhost:3000'
|
MONGODB_HOST='http://localhost:3000'
|
||||||
LOGO_REG='freeplanet-logo-full.svg'
|
LOGO_REG="freeplanet-logo-full.svg"
|
||||||
TEST_EMAIL='paolo.arena77@gmail.com'
|
TEST_EMAIL='paolo.arena77@gmail.com'
|
||||||
TEST_USERNAME='paoloar77'
|
TEST_USERNAME='paoloar77'
|
||||||
TEST_PASSWORD='mypassword@1A'
|
TEST_PASSWORD='mypassword@1A'
|
||||||
PUBLICKEY_PUSH='BGxRrFWnPoa_ImUaWXmeEOFVI9VNKVKaAPsvsM1XY6wn24yxp9MyOQ4crNYCJKxSXV65Y1GblW5_VLoamedcZ1I'
|
PUBLICKEY_PUSH='BGxRrFWnPoa_ImUaWXmeEOFVI9VNKVKaAPsvsM1XY6wn24yxp9MyOQ4crNYCJKxSXV65Y1GblW5_VLoamedcZ1I'
|
||||||
|
IN_CONSTRUCTION='0'
|
||||||
|
DEBUG='1'
|
||||||
|
|||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -2,6 +2,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.thumbs.db
|
.thumbs.db
|
||||||
.env
|
.env
|
||||||
|
.env.development
|
||||||
.env.production
|
.env.production
|
||||||
.env.production.bak
|
.env.production.bak
|
||||||
.env.prod.bak
|
.env.prod.bak
|
||||||
@@ -12,7 +13,6 @@ node_modules
|
|||||||
/src-cordova/platforms
|
/src-cordova/platforms
|
||||||
/src-cordova/plugins
|
/src-cordova/plugins
|
||||||
/src-cordova/www
|
/src-cordova/www
|
||||||
/src-pwa
|
|
||||||
/src-ssr
|
/src-ssr
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
@@ -34,3 +34,8 @@ deploy.sh
|
|||||||
deploy_on_production.sh
|
deploy_on_production.sh
|
||||||
deploy_on_test_server.sh
|
deploy_on_test_server.sh
|
||||||
send_to_production.sh
|
send_to_production.sh
|
||||||
|
compileandserve.sh
|
||||||
|
deploy_all.sh
|
||||||
|
deploy_frontend.sh
|
||||||
|
mongodb_delete_pc_locale_paolo.sh
|
||||||
|
serve_on_localhost.sh
|
||||||
|
|||||||
@@ -4,3 +4,31 @@ md 992px Medium-sized window
|
|||||||
lg 1200px Large sized window
|
lg 1200px Large sized window
|
||||||
xl Infinite Extra large sized window
|
xl Infinite Extra large sized window
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------
|
||||||
|
https://alligator.io/vuejs/progressive-image-rendering/
|
||||||
|
--- lOADING LAZY IMAGES:
|
||||||
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<v-lazy-image src="http://lorempixel.com/400/200/" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import VLazyImage from "v-lazy-image";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
VLazyImage
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
.v-lazy-image {
|
||||||
|
filter: blur(10px);
|
||||||
|
transition: filter 0.7s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-lazy-image-loaded {
|
||||||
|
filter: blur(0);
|
||||||
|
}
|
||||||
|
--------------------------------------------------------
|
||||||
|
|||||||
10
helpers.js
Normal file
10
helpers.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const ROOT = path.resolve(__dirname, '.');
|
||||||
|
|
||||||
|
function root(args) {
|
||||||
|
args = Array.prototype.slice.call(arguments, 0);
|
||||||
|
return path.join.apply(path, [ROOT].concat(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.root = root;
|
||||||
1835
package-lock.json
generated
1835
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
|||||||
"acorn": "^6.0.0",
|
"acorn": "^6.0.0",
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"babel-runtime": "^6.26.0",
|
"babel-runtime": "^6.26.0",
|
||||||
"bcrypt": "^3.0.2",
|
"bcrypt-nodejs": "0.0.3",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"dotenv": "^6.1.0",
|
"dotenv": "^6.1.0",
|
||||||
"element-ui": "^2.3.6",
|
"element-ui": "^2.3.6",
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
"graphql": "^0.13.2",
|
"graphql": "^0.13.2",
|
||||||
"graphql-tag": "^2.8.0",
|
"graphql-tag": "^2.8.0",
|
||||||
"gsap": "^2.0.2",
|
"gsap": "^2.0.2",
|
||||||
"immortal-db": "^1.0.2",
|
|
||||||
"jquery": "^3.3.1",
|
"jquery": "^3.3.1",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"localforage": "^1.7.3",
|
"localforage": "^1.7.3",
|
||||||
@@ -55,7 +54,7 @@
|
|||||||
"vue-property-decorator": "^7.2.0",
|
"vue-property-decorator": "^7.2.0",
|
||||||
"vue-router": "^3.0.1",
|
"vue-router": "^3.0.1",
|
||||||
"vue-svgicon": "^3.1.0",
|
"vue-svgicon": "^3.1.0",
|
||||||
"vuedraggable": "^2.17.0",
|
"vue2-dragula": "^2.5.4",
|
||||||
"vuelidate": "^0.7.4",
|
"vuelidate": "^0.7.4",
|
||||||
"vuex": "^3.0.1",
|
"vuex": "^3.0.1",
|
||||||
"vuex-class": "^0.3.1",
|
"vuex-class": "^0.3.1",
|
||||||
@@ -98,7 +97,7 @@
|
|||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"node-sass": "^4.11.0",
|
"node-sass": "^4.11.0",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"quasar-cli": "^0.17.20",
|
"quasar-cli": "^0.17.23",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"strip-ansi": "=3.0.1",
|
"strip-ansi": "=3.0.1",
|
||||||
"ts-jest": "^23.0.0",
|
"ts-jest": "^23.0.0",
|
||||||
@@ -110,7 +109,7 @@
|
|||||||
"vue-cli-plugin-element-ui": "^1.1.2",
|
"vue-cli-plugin-element-ui": "^1.1.2",
|
||||||
"vue-template-compiler": "^2.5.17",
|
"vue-template-compiler": "^2.5.17",
|
||||||
"vueify": "^9.4.1",
|
"vueify": "^9.4.1",
|
||||||
"webpack": "^4.0.0",
|
"webpack": "^4.29.6",
|
||||||
"webpack-dev-middleware": "^3.2.0",
|
"webpack-dev-middleware": "^3.2.0",
|
||||||
"webpack-hot-middleware": "^2.24.3",
|
"webpack-hot-middleware": "^2.24.3",
|
||||||
"webpack-merge": "^4.0.0",
|
"webpack-merge": "^4.0.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Configuration for your app
|
// Configuration for your app
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const helpers = require('./helpers');
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const envparser = require('./config/envparser')
|
const envparser = require('./config/envparser')
|
||||||
|
|
||||||
@@ -12,24 +12,24 @@ const extendTypescriptToWebpack = (config) => {
|
|||||||
.add('.ts', '.js', '.vue')
|
.add('.ts', '.js', '.vue')
|
||||||
config.resolve
|
config.resolve
|
||||||
.alias
|
.alias
|
||||||
.set('@components', path.resolve(__dirname, 'src/components/index.ts'))
|
.set('@components', helpers.root('src/components/index.ts'))
|
||||||
// .set('@components', path.resolve(__dirname, 'src/components'))
|
// .set('@components', helpers.root('src/components'))
|
||||||
.set('@views', path.resolve(__dirname, 'src/components/views/index.ts'))
|
.set('@views', helpers.root('src/components/views/index.ts'))
|
||||||
// .set('@views', path.resolve(__dirname, 'src/components/views'))
|
// .set('@views', helpers.root('src/components/views'))
|
||||||
.set('@src', path.resolve(__dirname, 'src'))
|
.set('@src', helpers.root('src'))
|
||||||
.set('@icons', path.resolve(__dirname, 'src/assets/icons'))
|
.set('@css', helpers.root('src/statics/css/*'))
|
||||||
.set('@images', path.resolve(__dirname, 'src/assets/images'))
|
.set('@icons', helpers.root('src/statics/icons/*'))
|
||||||
.set('@classes', path.resolve(__dirname, 'src/classes/index.ts'))
|
.set('@images', helpers.root('src/statics/images/*'))
|
||||||
.set('@utils', path.resolve(__dirname, 'src/utils/index.ts'))
|
.set('@classes', helpers.root('src/classes/index.ts'))
|
||||||
.set('@utils', path.resolve(__dirname, 'src/utils/*'))
|
.set('@utils', helpers.root('src/utils/index.ts'))
|
||||||
.set('@css', path.resolve(__dirname, 'src/styles/variables.scss'))
|
.set('@utils', helpers.root('src/utils/*'))
|
||||||
.set('@router', path.resolve(__dirname, 'src/router/index.ts'))
|
.set('@router', helpers.root('src/router/index.ts'))
|
||||||
.set('@validators', path.resolve(__dirname, 'src/utils/validators.ts'))
|
.set('@validators', helpers.root('src/utils/validators.ts'))
|
||||||
.set('@api', path.resolve(__dirname, 'src/store/Api/index.ts'))
|
.set('@api', helpers.root('src/store/Api/index.ts'))
|
||||||
.set('@paths', path.resolve(__dirname, 'src/store/Api/ApiRoutes.ts'))
|
.set('@paths', helpers.root('src/store/Api/ApiRoutes.ts'))
|
||||||
.set('@types', path.resolve(__dirname, 'src/typings/index.ts'))
|
.set('@types', helpers.root('src/typings/index.ts'))
|
||||||
.set('@store', path.resolve(__dirname, 'src/store/index.ts'))
|
.set('@store', helpers.root('src/store/index.ts'))
|
||||||
.set('@modules', path.resolve(__dirname, 'src/store/Modules/index.ts'))
|
.set('@modules', helpers.root('src/store/Modules/index.ts'))
|
||||||
config.module
|
config.module
|
||||||
.rule('typescript')
|
.rule('typescript')
|
||||||
.test(/\.tsx?$/)
|
.test(/\.tsx?$/)
|
||||||
@@ -59,7 +59,7 @@ module.exports = function (ctx) {
|
|||||||
store: 'src/store/index.ts'
|
store: 'src/store/index.ts'
|
||||||
},
|
},
|
||||||
// app plugins (/src/plugins)
|
// app plugins (/src/plugins)
|
||||||
plugins: ['i18n', 'axios', 'vee-validate', 'myconfig', 'local-storage', 'error-handler', 'globalroutines', 'vue-idb'],
|
plugins: ['i18n', 'axios', 'vee-validate', 'myconfig', 'local-storage', 'error-handler', 'globalroutines', 'vue-idb', 'dragula', 'guard'],
|
||||||
css: [
|
css: [
|
||||||
'app.styl'
|
'app.styl'
|
||||||
],
|
],
|
||||||
@@ -72,6 +72,12 @@ module.exports = function (ctx) {
|
|||||||
'fontawesome'
|
'fontawesome'
|
||||||
],
|
],
|
||||||
supportIE: false,
|
supportIE: false,
|
||||||
|
aliases: {
|
||||||
|
quasar: path.resolve(__dirname, '../node_modules/quasar-framework/'),
|
||||||
|
src: path.resolve(__dirname, '../src'),
|
||||||
|
statics: path.resolve(__dirname, '../src/statics'),
|
||||||
|
components: path.resolve(__dirname, '../src/components')
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
showProgress: true,
|
showProgress: true,
|
||||||
env: envparser(),
|
env: envparser(),
|
||||||
@@ -87,8 +93,8 @@ module.exports = function (ctx) {
|
|||||||
config.resolve
|
config.resolve
|
||||||
.alias
|
.alias
|
||||||
.set('~', __dirname)
|
.set('~', __dirname)
|
||||||
.set('@', path.resolve(__dirname, 'src'))
|
.set('@', helpers.root('src'))
|
||||||
// .set('env', path.resolve(__dirname, 'config/helpers/env.js'))
|
// .set('env', helpers.root('config/helpers/env.js'))
|
||||||
config.module
|
config.module
|
||||||
.rule('template-engine')
|
.rule('template-engine')
|
||||||
.test(/\.pug$/)
|
.test(/\.pug$/)
|
||||||
@@ -150,9 +156,15 @@ module.exports = function (ctx) {
|
|||||||
'QDatetime',
|
'QDatetime',
|
||||||
'QSlideTransition',
|
'QSlideTransition',
|
||||||
'QTable',
|
'QTable',
|
||||||
|
'QTableColumns',
|
||||||
|
'QTh',
|
||||||
|
'QTr',
|
||||||
|
'QSearch',
|
||||||
|
'QTd',
|
||||||
'QContextMenu',
|
'QContextMenu',
|
||||||
'QProgress',
|
'QProgress',
|
||||||
'QSlider',
|
'QSlider',
|
||||||
|
'QPopupEdit',
|
||||||
],
|
],
|
||||||
directives: [
|
directives: [
|
||||||
'Ripple',
|
'Ripple',
|
||||||
@@ -160,9 +172,9 @@ module.exports = function (ctx) {
|
|||||||
],
|
],
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: [
|
plugins: [
|
||||||
|
'Meta',
|
||||||
'Dialog',
|
'Dialog',
|
||||||
'Notify',
|
'Notify',
|
||||||
'Meta',
|
|
||||||
'Cookies',
|
'Cookies',
|
||||||
'ActionSheet', 'Loading'
|
'ActionSheet', 'Loading'
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -122,24 +122,50 @@ if (workbox) {
|
|||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const clonedRes = res.clone();
|
const clonedRes = res.clone();
|
||||||
|
|
||||||
|
// console.log('1) clearAllData(categories)')
|
||||||
|
return clearAllData('categories')
|
||||||
|
.then(() => {
|
||||||
|
// console.log('2) clearAllData(todos)')
|
||||||
return clearAllData('todos')
|
return clearAllData('todos')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
// console.log('3) ....return clonedRes')
|
||||||
return clonedRes
|
return clonedRes
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((clonedRes) => {
|
.then((clonedRes) => {
|
||||||
|
// console.log(' 3) ')
|
||||||
if (clonedRes !== undefined)
|
if (clonedRes !== undefined)
|
||||||
return clonedRes.json();
|
return clonedRes.json();
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
.then(async data => {
|
.then(data => {
|
||||||
|
// console.log(' 4) data = ', data)
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.todos) {
|
if (data.todos) {
|
||||||
console.log('***********************+++++++++++++++++++++++++++++++++++++++++++++++++++********** Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
|
|
||||||
for (const key in data.todos) {
|
let promiseChain = Promise.resolve();
|
||||||
await writeData('todos', data.todos[key])
|
|
||||||
|
console.log('*********+++++++++++++++++********** Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
|
||||||
|
|
||||||
|
for (let cat in data.categories) {
|
||||||
|
promiseChain = promiseChain.then(() => {
|
||||||
|
return writeData('categories', { _id: cat, valore: data.categories[cat] } )
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let indrecCat in data.todos) {
|
||||||
|
for (let indrec in data.todos[indrecCat]) {
|
||||||
|
promiseChain = promiseChain.then(() => {
|
||||||
|
return writeData('todos', data.todos[indrecCat][indrec])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('promiseChain', promiseChain)
|
||||||
|
|
||||||
|
return promiseChain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -506,7 +532,9 @@ self.addEventListener('push', function (event) {
|
|||||||
badge: '/statics/icons/android-chrome-192x192.png',
|
badge: '/statics/icons/android-chrome-192x192.png',
|
||||||
data: {
|
data: {
|
||||||
url: data.url
|
url: data.url
|
||||||
}
|
},
|
||||||
|
tag: 'received',
|
||||||
|
renitify: true, // vibrate also with others messages.
|
||||||
};
|
};
|
||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ register(process.env.SERVICE_WORKER_FILE, {
|
|||||||
},
|
},
|
||||||
updatefound(registration) {
|
updatefound(registration) {
|
||||||
console.log('UPDATEFOUND::: New content is downloading.')
|
console.log('UPDATEFOUND::: New content is downloading.')
|
||||||
|
// $('#newvers').addClass('btnNewVersShow').removeClass("btnNewVersHide")
|
||||||
},
|
},
|
||||||
updated(registration) {
|
updated(registration) {
|
||||||
console.log('New content is available; please refresh.')
|
console.log('New content is available; please refresh.')
|
||||||
@@ -33,7 +34,7 @@ register(process.env.SERVICE_WORKER_FILE, {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// ServiceWorkerRegistration: https://developer.mozilla.org/en-uk/docs/Web/API/ServiceWorkerRegistration
|
// ServiceWorkerRegistration: https://developer.mozilla.org/enUs/docs/Web/API/ServiceWorkerRegistration
|
||||||
|
|
||||||
|
|
||||||
// "build": "quasar build -m pwa && workbox generateSW workbox-config.js",
|
// "build": "quasar build -m pwa && workbox generateSW workbox-config.js",
|
||||||
|
|||||||
22
src/App.ts
22
src/App.ts
@@ -26,6 +26,17 @@ export default class App extends Vue {
|
|||||||
|
|
||||||
public listaRoutingNoLogin = ['/vreg?', '/offline']
|
public listaRoutingNoLogin = ['/vreg?', '/offline']
|
||||||
|
|
||||||
|
meta () {
|
||||||
|
return {
|
||||||
|
keywords: { name: 'keywords', content: 'WebSite' },
|
||||||
|
// meta tags
|
||||||
|
meta: {
|
||||||
|
mykey: { name: 'mykey', content: 'Key 1' },
|
||||||
|
keywords: { name: 'keywords', content: 'MyKeywords' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
if (process.env.DEV) {
|
if (process.env.DEV) {
|
||||||
console.info('SESSIONE IN SVILUPPO ! (DEV)')
|
console.info('SESSIONE IN SVILUPPO ! (DEV)')
|
||||||
@@ -48,10 +59,19 @@ export default class App extends Vue {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (chiamaautologin) {
|
if (chiamaautologin) {
|
||||||
console.log('CHIAMA autologin_FromLocalStorage')
|
// console.log('CHIAMA autologin_FromLocalStorage')
|
||||||
UserStore.actions.autologin_FromLocalStorage()
|
UserStore.actions.autologin_FromLocalStorage()
|
||||||
.then((loadstorage) => {
|
.then((loadstorage) => {
|
||||||
if (loadstorage) {
|
if (loadstorage) {
|
||||||
|
|
||||||
|
if (UserStore.state.lang !== '') {
|
||||||
|
// console.log('SETLOCALE :', this.$i18n.locale)
|
||||||
|
this.$i18n.locale = UserStore.state.lang // Set Lang
|
||||||
|
} else {
|
||||||
|
UserStore.mutations.setlang(this.$i18n.locale)
|
||||||
|
}
|
||||||
|
// console.log('lang CARICATO:', this.$i18n.locale)
|
||||||
|
|
||||||
globalroutines(this, 'loadapp', '')
|
globalroutines(this, 'loadapp', '')
|
||||||
// this.$router.replace('/')
|
// this.$router.replace('/')
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="q-app">
|
<div id="q-app">
|
||||||
<q-layout :style="{ backgroundColor: backgroundColor}">
|
<q-layout :style="">
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
<div class="layout-view">
|
<div class="layout-view">
|
||||||
<q-ajax-bar></q-ajax-bar>
|
<q-ajax-bar></q-ajax-bar>
|
||||||
|
|||||||
26
src/classes/DateController.ts
Normal file
26
src/classes/DateController.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
import 'moment/locale/fr';
|
||||||
|
moment.locale('fr')
|
||||||
|
|
||||||
|
const monthsStrings = ['Janvier','Fevrier','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'];
|
||||||
|
|
||||||
|
|
||||||
|
export class DateMoving {
|
||||||
|
public date: moment.Moment;
|
||||||
|
public hour: string;
|
||||||
|
public number: number;
|
||||||
|
public month: string;
|
||||||
|
public year: number;
|
||||||
|
|
||||||
|
constructor(time: number) {
|
||||||
|
this.date = moment(time * 1000);
|
||||||
|
this.hour = `${this.date.format('HH:mm')}`;
|
||||||
|
this.number = this.date.date();
|
||||||
|
this.year = this.date.year();
|
||||||
|
this.month = monthsStrings[this.date.month()];
|
||||||
|
}
|
||||||
|
|
||||||
|
fullString() {
|
||||||
|
return this.date.format('Do MMMM YYYY, HH:mm');
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/classes/index.ts
Normal file
1
src/classes/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './DateController';
|
||||||
@@ -27,11 +27,38 @@
|
|||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
||||||
|
|
||||||
|
<div v-if="$q.platform.is.desktop">
|
||||||
|
<!--I'm only rendered on desktop!-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="$q.platform.is.mobile">
|
||||||
|
<!--I'm only rendered on mobile!-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="$q.platform.is.electron">
|
||||||
|
<!--I'm only rendered on Electron!-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<q-btn id="newvers" v-if="isNewVersionAvailable" color="secondary" rounded icon="refresh"
|
||||||
|
class="btnNewVersShow" @click="RefreshApp" :label="$t('notification.newVersionAvailable')"/>
|
||||||
|
|
||||||
|
|
||||||
<q-toolbar-title>
|
<q-toolbar-title>
|
||||||
{{$t('msg.myAppName')}}
|
{{$t('msg.myAppName')}}
|
||||||
<div slot="subtitle">{{$t('msg.myDescriz')}} {{ getAppVersion() }}</div>
|
<div slot="subtitle">{{$t('msg.myDescriz')}} {{ getAppVersion() }}</div>
|
||||||
</q-toolbar-title>
|
</q-toolbar-title>
|
||||||
|
|
||||||
|
<div v-if="isAdmin">
|
||||||
|
<q-btn flat dense round aria-label="">
|
||||||
|
<q-icon :class="clCloudUpload" name="cloud_upload"></q-icon>
|
||||||
|
</q-btn>
|
||||||
|
|
||||||
|
<q-btn flat dense round aria-label="">
|
||||||
|
<q-icon :class="clCloudUp_Indexeddb" name="arrow_upward"></q-icon>
|
||||||
|
</q-btn>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
@@ -43,7 +70,23 @@
|
|||||||
<q-icon v-if="isUserNotAuth" name="device_unknown"></q-icon>
|
<q-icon v-if="isUserNotAuth" name="device_unknown"></q-icon>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
||||||
<q-select class="sel_lang" v-model="lang" stack-label="" :options="selectOpLang"/>
|
|
||||||
|
<q-btn-dropdown
|
||||||
|
:label="langshort"
|
||||||
|
>
|
||||||
|
<q-list link>
|
||||||
|
<q-item v-for="langrec in selectOpLang" :key="langrec.value" v-close-overlay
|
||||||
|
@click.native="lang = langrec.value">
|
||||||
|
<q-item-side>
|
||||||
|
<img :src="langrec.image" class="flagimg">
|
||||||
|
</q-item-side>
|
||||||
|
<q-item-main>
|
||||||
|
<q-item-tile sublabel>{{langrec.label}}</q-item-tile>
|
||||||
|
</q-item-main>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-btn-dropdown>
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<message-popover></message-popover>
|
<message-popover></message-popover>
|
||||||
@@ -77,12 +120,12 @@
|
|||||||
import drawer from '../layouts/drawer/drawer.vue'
|
import drawer from '../layouts/drawer/drawer.vue'
|
||||||
import messagePopover from '../layouts/toolbar/messagePopover/messagePopover.vue'
|
import messagePopover from '../layouts/toolbar/messagePopover/messagePopover.vue'
|
||||||
|
|
||||||
import { GlobalStore } from '@modules'
|
import { GlobalStore, UserStore } from '@modules'
|
||||||
import { rescodes } from '../store/Modules/rescodes'
|
import { tools } from '../store/Modules/tools'
|
||||||
import QIcon from "quasar-framework/src/components/icon/QIcon";
|
import QIcon from "quasar-framework/src/components/icon/QIcon"
|
||||||
import { StateConnection } from "../model";
|
import { StateConnection } from "../model"
|
||||||
import { Watch } from "vue-property-decorator";
|
import { Watch } from "vue-property-decorator"
|
||||||
import QField from "quasar-framework/src/components/field/QField";
|
import QField from "quasar-framework/src/components/field/QField"
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
@@ -101,11 +144,24 @@
|
|||||||
public iconConn: string = 'wifi'
|
public iconConn: string = 'wifi'
|
||||||
public clIconConn: string = 'clIconOnline'
|
public clIconConn: string = 'clIconOnline'
|
||||||
public strConn: string = ''
|
public strConn: string = ''
|
||||||
|
public langshort: string = ''
|
||||||
|
public clCloudUpload: string = ''
|
||||||
|
public clCloudDownload: string = ''
|
||||||
|
public clCloudUp_Indexeddb: string = ''
|
||||||
|
public clCloudDown_Indexeddb: string = 'clIndexeddbsend'
|
||||||
|
|
||||||
get conn_changed() {
|
get conn_changed() {
|
||||||
return GlobalStore.state.stateConnection
|
return GlobalStore.state.stateConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isAdmin() {
|
||||||
|
return UserStore.state.isAdmin
|
||||||
|
}
|
||||||
|
|
||||||
|
get conndata_changed() {
|
||||||
|
return GlobalStore.state.connData
|
||||||
|
}
|
||||||
|
|
||||||
@Watch('GlobalStore.state.stateConnection', { immediate: true, deep: true })
|
@Watch('GlobalStore.state.stateConnection', { immediate: true, deep: true })
|
||||||
changeconn(value: string, oldValue: string) {
|
changeconn(value: string, oldValue: string) {
|
||||||
|
|
||||||
@@ -119,6 +175,27 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Watch('conndata_changed', { immediate: true, deep: true })
|
||||||
|
changeconnData(value: any, oldValue: any) {
|
||||||
|
// console.log('CHANGED GlobalStore.state.connData', value)
|
||||||
|
|
||||||
|
this.clCloudUpload = (value.uploading_server === 1) ? "clCloudUpload send" : "clCloudUpload"
|
||||||
|
this.clCloudUpload = (value.downloading_server === 1) ? "clCloudUpload receive" : "clCloudUpload"
|
||||||
|
this.clCloudUp_Indexeddb = (value.uploading_indexeddb === 1) ? "clIndexeddb send" : "clIndexeddb"
|
||||||
|
this.clCloudUp_Indexeddb = (value.downloading_indexeddb === 1) ? "clIndexeddb receive" : "clIndexeddb"
|
||||||
|
|
||||||
|
this.clCloudUpload = (value.uploading_server === -1) ? "clCloudUpload error" : this.clCloudUpload
|
||||||
|
this.clCloudUpload = (value.downloading_server === -1) ? "clCloudUpload error" : this.clCloudDownload
|
||||||
|
this.clCloudUp_Indexeddb = (value.uploading_indexeddb === -1) ? "clIndexeddb error" : this.clCloudUp_Indexeddb
|
||||||
|
this.clCloudUp_Indexeddb = (value.downloading_indexeddb === -1) ? "clIndexeddb error" : this.clCloudDown_Indexeddb
|
||||||
|
|
||||||
|
// console.log('clCloudUpload', this.clCloudUpload)
|
||||||
|
// console.log('clCloudDownload', this.clCloudDownload)
|
||||||
|
// console.log('clCloudUp_Indexeddb', this.clCloudUp_Indexeddb)
|
||||||
|
// console.log('value.downloading_indexeddb', value.downloading_indexeddb)
|
||||||
|
// console.log('value.uploading_server', value.uploading_server)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Watch('conn_changed', { immediate: true, deep: true })
|
@Watch('conn_changed', { immediate: true, deep: true })
|
||||||
changeconn_changed(value: string, oldValue: string) {
|
changeconn_changed(value: string, oldValue: string) {
|
||||||
@@ -136,56 +213,177 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('Todos.state.todos_changed CHANGED!', value, oldValue)
|
|
||||||
this.changeIconConn()
|
this.changeIconConn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isNewVersionAvailable() {
|
||||||
|
console.log('______________ isNewVersionAvailable')
|
||||||
|
return GlobalStore.getters.isNewVersionAvailable
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshApp() {
|
||||||
|
// Unregister Service Worker
|
||||||
|
navigator.serviceWorker.getRegistrations().then(function(registrations) {
|
||||||
|
for(let registration of registrations) {
|
||||||
|
registration.unregister()
|
||||||
|
} })
|
||||||
|
window.location.reload(true)
|
||||||
|
}
|
||||||
|
|
||||||
changeIconConn() {
|
changeIconConn() {
|
||||||
this.iconConn = GlobalStore.state.stateConnection === 'online' ? "wifi" : "wifi_off"
|
this.iconConn = GlobalStore.state.stateConnection === 'online' ? "wifi" : "wifi_off"
|
||||||
this.clIconConn = GlobalStore.state.stateConnection === 'online' ? 'clIconOnline' : 'clIconOffline'
|
this.clIconConn = GlobalStore.state.stateConnection === 'online' ? 'clIconOnline' : 'clIconOffline'
|
||||||
}
|
}
|
||||||
|
|
||||||
public selectOpLang = [
|
public selectOpLang = [
|
||||||
{ label: 'English (UK)', icon: 'fa-flag-us', value: 'en-uk' },
|
{ label: 'English', icon: 'fa-flag-us', value: 'enUs', image: '../statics/images/gb.png', short: 'EN' },
|
||||||
{ label: 'German', icon: 'fa-flag-de', value: 'de' },
|
// { label: 'German', icon: 'fa-flag-de', value: 'de', image: '../statics/images/de.png', short: 'DE' },
|
||||||
{ label: 'Spanish', icon: 'fa-flag-es', value: 'es' },
|
{ label: 'Italiano', icon: 'fa-facebook', value: 'it', image: '../statics/images/it.png', short: 'IT' },
|
||||||
{ label: 'Italian', icon: 'fa-facebook', value: 'it' }
|
{ label: 'Español', icon: 'fa-flag-es', value: 'esEs', image: '../statics/images/es.png', short: 'ES' }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// QUASAR Example using event to open drawer from another component or page
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// (1) This code is inside layout file that have a drawer
|
||||||
|
// if this.leftDrawerOpen is true, drawer is displayed
|
||||||
|
|
||||||
|
// (2) Listen for an event in created
|
||||||
|
/* created(){
|
||||||
|
this.$root.$on("openLeftDrawer", this.openLeftDrawercb);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openURL,
|
||||||
|
// (3) Define the callback in methods
|
||||||
|
openLeftDrawercb() {
|
||||||
|
this.leftDrawerOpen = !this.leftDrawerOpen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// (4) In another component or page, emit the event!
|
||||||
|
// Call the method when clicking button etc.
|
||||||
|
methods: {
|
||||||
|
openLeftDrawer() {
|
||||||
|
this.$root.$emit("openLeftDrawer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
get leftDrawerOpen() {
|
get leftDrawerOpen() {
|
||||||
return GlobalStore.state.leftDrawerOpen
|
return GlobalStore.state.leftDrawerOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
set leftDrawerOpen(value) {
|
set leftDrawerOpen(value) {
|
||||||
GlobalStore.state.leftDrawerOpen = value
|
GlobalStore.state.leftDrawerOpen = value
|
||||||
localStorage.setItem(rescodes.localStorage.leftDrawerOpen, value.toString())
|
localStorage.setItem(tools.localStorage.leftDrawerOpen, value.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppVersion() {
|
getAppVersion() {
|
||||||
// return "AA"
|
// return "AA"
|
||||||
return "[" + process.env.APP_VERSION + "]"
|
let strv = ''
|
||||||
|
if (process.env.DEV) {
|
||||||
|
strv = 'DEV '
|
||||||
|
} else if (process.env.TEST) {
|
||||||
|
strv = 'TEST '
|
||||||
}
|
}
|
||||||
|
return "[" + strv + process.env.APP_VERSION + "]"
|
||||||
|
}
|
||||||
|
|
||||||
get lang() {
|
get lang() {
|
||||||
return this.$q.i18n.lang
|
return this.$q.i18n.lang
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setshortlang(lang) {
|
||||||
|
for (let indrec in this.selectOpLang) {
|
||||||
|
if (this.selectOpLang[indrec].value === lang) {
|
||||||
|
// console.log('this.selectOpLang[indrec].short', this.selectOpLang[indrec].short, this.selectOpLang[indrec].value)
|
||||||
|
this.langshort = this.selectOpLang[indrec].short
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
set lang(lang) {
|
set lang(lang) {
|
||||||
|
console.log('set lang(' + this.$i18n.locale)
|
||||||
this.$i18n.locale = this.snakeToCamel(lang)
|
this.$i18n.locale = this.snakeToCamel(lang)
|
||||||
|
// this.$q.notify('IMPOSTA LANG= ' + this.$i18n.locale)
|
||||||
|
// console.log('IMPOSTA LANG= ' + this.$i18n.locale)
|
||||||
|
|
||||||
|
UserStore.mutations.setlang(this.$i18n.locale)
|
||||||
|
|
||||||
|
let mylangtopass = lang
|
||||||
|
|
||||||
|
this.setshortlang(mylangtopass)
|
||||||
|
|
||||||
|
if (mylangtopass === 'enUs')
|
||||||
|
mylangtopass = 'en-us'
|
||||||
|
|
||||||
|
if (mylangtopass === 'esEs')
|
||||||
|
mylangtopass = 'es'
|
||||||
|
|
||||||
// dynamic import, so loading on demand only
|
// dynamic import, so loading on demand only
|
||||||
import(`quasar-framework/i18n/${lang}`).then(lang => {
|
import(`quasar-framework/i18n/${mylangtopass}`).then(lang => {
|
||||||
this.$q.i18n.set(lang.default)
|
this.$q.i18n.set(lang.default)
|
||||||
import(`src/statics/i18n`).then(function () {
|
import(`src/statics/i18n`).then(function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLangAtt() {
|
||||||
|
return this.$q.i18n.lang
|
||||||
|
}
|
||||||
|
|
||||||
|
setLangAtt(mylang) {
|
||||||
|
console.log('MYLL=', mylang)
|
||||||
|
this.$q.i18n.lang = mylang
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeMount() {
|
||||||
|
// Estrai la Lang dal Localstorage
|
||||||
|
|
||||||
|
let my = this.getLangAtt()
|
||||||
|
// this.$q.notify('prima: ' + String(my))
|
||||||
|
|
||||||
|
let mylang = tools.getItemLS(tools.localStorage.lang)
|
||||||
|
if (mylang === '') {
|
||||||
|
if (navigator) {
|
||||||
|
mylang = navigator.language
|
||||||
|
console.log(`LANG2 NAVIGATOR ${mylang}`)
|
||||||
|
} else {
|
||||||
|
mylang = this.$q.i18n.lang
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('IMPOSTA LANGMY', mylang)
|
||||||
|
}
|
||||||
|
if (mylang !== '') {
|
||||||
|
if (mylang.toLowerCase() === 'enus')
|
||||||
|
mylang = 'enUs'
|
||||||
|
if ((mylang.toLowerCase() === 'eses') || (mylang.toLowerCase() === 'es-es'))
|
||||||
|
mylang = 'esEs'
|
||||||
|
if ((mylang.toLowerCase() === 'enus') || (mylang.toLowerCase() === 'en-us'))
|
||||||
|
mylang = 'enUs'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mylang)
|
||||||
|
mylang = process.env.LANG_DEFAULT
|
||||||
|
|
||||||
|
|
||||||
|
this.setLangAtt(mylang)
|
||||||
|
this.setshortlang(mylang)
|
||||||
|
// this.$q.notify('Dopo: ' + String(this.getLangAtt()))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
|
|
||||||
// Test this by running the code snippet below and then
|
// Test this by running the code snippet below and then
|
||||||
// use the "Offline" checkbox in DevTools Network panel
|
// use the "TableOnlyView" checkbox in DevTools Network panel
|
||||||
|
|
||||||
let mythis = this
|
let mythis = this
|
||||||
// console.log('Event LOAD')
|
// console.log('Event LOAD')
|
||||||
@@ -207,9 +405,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('online', updateOnlineStatus);
|
window.addEventListener('online', updateOnlineStatus)
|
||||||
window.addEventListener('offline', updateOnlineStatus);
|
window.addEventListener('offline', updateOnlineStatus)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,5 +663,52 @@
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flagimg {
|
||||||
|
width: 30px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clCloudUpload {
|
||||||
|
transition: all 1s ease-out;
|
||||||
|
color: initial;
|
||||||
|
&.send {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: lightgreen;
|
||||||
|
}
|
||||||
|
&.receive {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
&.error {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.clIndexeddb {
|
||||||
|
transition: all 1s ease-out;
|
||||||
|
color: initial;
|
||||||
|
&.receive {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
&.send {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: lightgreen;
|
||||||
|
}
|
||||||
|
&.error {
|
||||||
|
transition: all 1s ease-in;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnNewVersHide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnNewVersShow {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
1
src/components/admin/TableOnlyView/index.ts
Normal file
1
src/components/admin/TableOnlyView/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {default as tableOnlyView} from './tableOnlyView.vue'
|
||||||
63
src/components/admin/TableOnlyView/tableOnlyView.ts
Normal file
63
src/components/admin/TableOnlyView/tableOnlyView.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { Component } from 'vue-property-decorator'
|
||||||
|
|
||||||
|
import { GlobalStore, UserStore } from '@store'
|
||||||
|
|
||||||
|
|
||||||
|
@Component({})
|
||||||
|
export default class TableOnlyView extends Vue {
|
||||||
|
public loading: boolean = false
|
||||||
|
public serverPagination: {
|
||||||
|
page: number ,
|
||||||
|
rowsNumber: number // specifying this determines pagination is server-side
|
||||||
|
} = {page: 1, rowsNumber: 10}
|
||||||
|
|
||||||
|
public serverData: any [] = []
|
||||||
|
public columns: any[] = [
|
||||||
|
{
|
||||||
|
name: 'chiave',
|
||||||
|
required: true,
|
||||||
|
label: 'Chiave',
|
||||||
|
align: 'left',
|
||||||
|
field: 'chiave',
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
{ name: 'valore', label: 'Valore', field: 'valore', sortable: false }
|
||||||
|
]
|
||||||
|
|
||||||
|
public filter: string = ''
|
||||||
|
public selected: any[] = []
|
||||||
|
|
||||||
|
|
||||||
|
request(props) {
|
||||||
|
this.loading = true
|
||||||
|
setTimeout(() => {
|
||||||
|
this.serverPagination = props.pagination
|
||||||
|
let
|
||||||
|
table = this.$refs.table,
|
||||||
|
rows = GlobalStore.state.cfgServer.slice(),
|
||||||
|
{ page, rowsPerPage, sortBy, descending } = props.pagination
|
||||||
|
|
||||||
|
// if (props.filter) {
|
||||||
|
// rows = table.filterMethod(rows, props.filter)
|
||||||
|
// }
|
||||||
|
// if (sortBy) {
|
||||||
|
// rows = table.sortMethod(rows, sortBy, descending)
|
||||||
|
// }
|
||||||
|
|
||||||
|
this.serverPagination.rowsNumber = rows.length
|
||||||
|
if (rowsPerPage) {
|
||||||
|
rows = rows.slice((page - 1) * rowsPerPage, page * rowsPerPage)
|
||||||
|
}
|
||||||
|
this.serverData = rows
|
||||||
|
this.loading = false
|
||||||
|
}, 1500)
|
||||||
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.request({
|
||||||
|
pagination: this.serverPagination,
|
||||||
|
filter: this.filter
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/components/admin/TableOnlyView/tableOnlyView.vue
Normal file
29
src/components/admin/TableOnlyView/tableOnlyView.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<q-page padding class="docs-table">
|
||||||
|
<p class="caption">TableOnlyView</p>
|
||||||
|
<q-table
|
||||||
|
ref="table"
|
||||||
|
color="primary"
|
||||||
|
title="Parametri di Configurazione Server"
|
||||||
|
:data="serverData"
|
||||||
|
:columns="columns"
|
||||||
|
:filter="filter"
|
||||||
|
selection="multiple"
|
||||||
|
:selected.sync="selected"
|
||||||
|
row-key="chiave"
|
||||||
|
:pagination.sync="serverPagination"
|
||||||
|
@request="request"
|
||||||
|
:loading="loading"
|
||||||
|
>
|
||||||
|
<template slot="top-right" slot-scope="props">
|
||||||
|
<q-search hide-underline v-model="filter" />
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</q-page>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" src="./tableOnlyView.ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './tableOnlyView.scss';
|
||||||
|
</style>
|
||||||
0
src/components/admin/cfgServer/cfgServer.scss
Normal file
0
src/components/admin/cfgServer/cfgServer.scss
Normal file
73
src/components/admin/cfgServer/cfgServer.ts
Normal file
73
src/components/admin/cfgServer/cfgServer.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { Component } from 'vue-property-decorator'
|
||||||
|
|
||||||
|
import { GlobalStore } from '@store'
|
||||||
|
|
||||||
|
|
||||||
|
@Component({})
|
||||||
|
export default class CfgServer extends Vue {
|
||||||
|
public loading: boolean = false
|
||||||
|
public paginationControl: {
|
||||||
|
page: number,
|
||||||
|
rowsPerPage: number // specifying this determines pagination is server-side
|
||||||
|
} = { page: 1, rowsPerPage: 20 }
|
||||||
|
|
||||||
|
public pagination: {
|
||||||
|
page: number
|
||||||
|
} = {page: 1 }
|
||||||
|
|
||||||
|
public serverData: any [] = GlobalStore.state.cfgServer.slice() // [{ chiave: 'chiave1', valore: 'valore 1' }]
|
||||||
|
public columns: any[] = [
|
||||||
|
{
|
||||||
|
name: 'chiave',
|
||||||
|
required: true,
|
||||||
|
label: 'Chiave',
|
||||||
|
align: 'left',
|
||||||
|
field: 'chiave',
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
{ name: 'userid', label: 'UserId', field: 'userid', sortable: false },
|
||||||
|
{ name: 'valore', label: 'Valore', field: 'valore', sortable: false }
|
||||||
|
]
|
||||||
|
|
||||||
|
public visibleColumns: ['chiave', 'userid', 'valore']
|
||||||
|
public separator: 'horizontal'
|
||||||
|
public filter: string = ''
|
||||||
|
public selected: any[] = []
|
||||||
|
public dark: boolean = true
|
||||||
|
|
||||||
|
public keysel: string = ''
|
||||||
|
public userIdsel: string = ''
|
||||||
|
|
||||||
|
|
||||||
|
get tableClass () {
|
||||||
|
if (this.dark) {
|
||||||
|
return 'bg-black'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selItem(item) {
|
||||||
|
console.log('item', item)
|
||||||
|
this.keysel = item.chiave
|
||||||
|
this.userIdsel = item.userid
|
||||||
|
console.log('this.keysel', this.keysel)
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveValue(newVal, valinitial) {
|
||||||
|
console.log('SaveValue', newVal, 'selected', this.selected)
|
||||||
|
|
||||||
|
const mydata = {
|
||||||
|
chiave: this.keysel,
|
||||||
|
userId: this.userIdsel,
|
||||||
|
valore: newVal
|
||||||
|
}
|
||||||
|
// Save on Server
|
||||||
|
GlobalStore.actions.saveCfgServerKey(mydata)
|
||||||
|
}
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.serverData = GlobalStore.state.cfgServer.slice() // [{ chiave: 'chiave1', valore: 'valore 1' }]
|
||||||
|
// this.serverData = GlobalStore.state.cfgServer.slice()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
src/components/admin/cfgServer/cfgServer.vue
Normal file
40
src/components/admin/cfgServer/cfgServer.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<q-table
|
||||||
|
:data="serverData"
|
||||||
|
:columns="columns"
|
||||||
|
:filter="filter"
|
||||||
|
title="Configurazione Server"
|
||||||
|
row-key="chiave"
|
||||||
|
>
|
||||||
|
<q-tr slot="body" slot-scope="props" :props="props">
|
||||||
|
<q-td key="chiave" :props="props">
|
||||||
|
{{ props.row.chiave }}
|
||||||
|
<q-popup-edit v-model="props.row.chiave" disable>
|
||||||
|
<q-field count>
|
||||||
|
<q-input v-model="props.row.chiave" />
|
||||||
|
</q-field>
|
||||||
|
</q-popup-edit>
|
||||||
|
</q-td>
|
||||||
|
<q-td key="userid" :props="props">
|
||||||
|
{{ props.row.userId }}
|
||||||
|
<q-popup-edit v-model="props.row.userId" disable>
|
||||||
|
<q-field count>
|
||||||
|
<q-input v-model="props.row.userId" />
|
||||||
|
</q-field>
|
||||||
|
</q-popup-edit>
|
||||||
|
</q-td>
|
||||||
|
<q-td key="valore" :props="props">
|
||||||
|
{{ props.row.valore }}
|
||||||
|
<q-popup-edit v-model="props.row.valore" title="Aggiorna Valore" buttons @save="SaveValue" @show="selItem(props.row)">
|
||||||
|
<q-input v-model="props.row.valore"/>
|
||||||
|
</q-popup-edit>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</q-table>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" src="./cfgServer.ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './cfgServer.scss';
|
||||||
|
</style>
|
||||||
1
src/components/admin/cfgServer/index.ts
Normal file
1
src/components/admin/cfgServer/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {default as cfgServer} from './cfgServer.vue'
|
||||||
1
src/components/admin/testp1/index.ts
Normal file
1
src/components/admin/testp1/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {default as testp1} from './testp1.vue'
|
||||||
0
src/components/admin/testp1/testp1.scss
Normal file
0
src/components/admin/testp1/testp1.scss
Normal file
95
src/components/admin/testp1/testp1.ts
Normal file
95
src/components/admin/testp1/testp1.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { Component, Watch } from 'vue-property-decorator'
|
||||||
|
|
||||||
|
import { GlobalStore, UserStore } from '@store'
|
||||||
|
import { Getter } from "vuex-class"
|
||||||
|
import { ICfgServer, IGlobalState, ITodo, ITodosState } from '@src/model'
|
||||||
|
|
||||||
|
const namespace: string = 'GlobalModule'
|
||||||
|
|
||||||
|
@Component({})
|
||||||
|
export default class Testp1 extends Vue {
|
||||||
|
public myvar:number = 5
|
||||||
|
public paramcategory: string = ''
|
||||||
|
public mioobj: any
|
||||||
|
|
||||||
|
// @Getter('todos_dacompletare', { namespace })
|
||||||
|
// public todos_dacompletare: (state: ITodosState, category: string) => ITodo[]
|
||||||
|
|
||||||
|
@Getter('testpao1_getter_contatore', { namespace })
|
||||||
|
public testpao1: (state: IGlobalState, param1: number) => number
|
||||||
|
|
||||||
|
@Getter('testpao1_getter_array', { namespace })
|
||||||
|
public testpao1_array: (state: IGlobalState, miorec: ICfgServer) => ICfgServer[]
|
||||||
|
|
||||||
|
@Watch('GlobalStore.state.testp1.mioarray', { immediate: true, deep: true })
|
||||||
|
array_changed() {
|
||||||
|
console.log('*** array_changed *** ', GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Watch('$route.params.category') changecat() {
|
||||||
|
// this.mytypetransgroup = ''
|
||||||
|
console.log('PRIMA this.paramcategory', this.paramcategory)
|
||||||
|
this.paramcategory = this.$route.params.category
|
||||||
|
console.log('DOPO this.paramcategory', this.paramcategory)
|
||||||
|
}
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.mioobj = {
|
||||||
|
arr1: [{chiave: 'key1', userId: 'ALL', valore: 'val1'}],
|
||||||
|
arr2: [{chiave: 'key2', userId: 'ALL', valore: 'val2'}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get getarr1 () {
|
||||||
|
// return this.mioobj.arr1
|
||||||
|
return this.mioobj['arr1']
|
||||||
|
}
|
||||||
|
|
||||||
|
get prova2() {
|
||||||
|
return GlobalStore.state.testp1.contatore
|
||||||
|
}
|
||||||
|
|
||||||
|
get provagetter() {
|
||||||
|
return GlobalStore.getters.testpao1_getter_contatore(130)
|
||||||
|
}
|
||||||
|
|
||||||
|
get provagetterarray() {
|
||||||
|
return GlobalStore.getters.testpao1_getter_array(GlobalStore.state.testp1.contatore)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TestBtnCambioaParamPassing () {
|
||||||
|
this.paramcategory += 's'
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtn() {
|
||||||
|
GlobalStore.state.testp1.contatore++
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtn2() {
|
||||||
|
GlobalStore.state.testp1.mioarray.push({chiave: 'pippo2', userId: UserStore.state.userId, valore: GlobalStore.state.testp1.contatore.toString() })
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtnModify() {
|
||||||
|
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||||
|
GlobalStore.mutations.setPaoArray({chiave: 'pippo', userId: UserStore.state.userId, valore: '20' } )
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtnCambiaTutto() {
|
||||||
|
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||||
|
GlobalStore.mutations.NewArray([{chiave: 'nuovorec1', userId: UserStore.state.userId, valore: '1' }, {chiave: 'nuovorec2', userId: UserStore.state.userId, valore: '2' }] )
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtnAction() {
|
||||||
|
GlobalStore.actions.prova()
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBtnDelete() {
|
||||||
|
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||||
|
GlobalStore.mutations.setPaoArray_Delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/components/admin/testp1/testp1.vue
Normal file
43
src/components/admin/testp1/testp1.vue
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
CATEGORY: <strong>{{ paramcategory }}</strong> <br>
|
||||||
|
|
||||||
|
<label>TEST Prova Paolo</label><br>
|
||||||
|
|
||||||
|
|
||||||
|
GETTER CONTATORE:
|
||||||
|
{{ testpao1(300) }} <br>
|
||||||
|
ARRAY:
|
||||||
|
{{ testpao1_array(300) }} <br>
|
||||||
|
|
||||||
|
TEST OBJECT {{ mioobj }} <br>
|
||||||
|
ARR1 {{ getarr1 }} <br>
|
||||||
|
<!--ARR2 {{ mioobj.arr2 }} <br>-->
|
||||||
|
|
||||||
|
<!--<q-input v-model="testpao1(myvar)"></q-input>-->
|
||||||
|
|
||||||
|
<q-input v-model="prova2" float-label="PROVA2:"></q-input>
|
||||||
|
|
||||||
|
<q-input v-model="provagetter" float-label="PROVA GETTER:"></q-input>
|
||||||
|
<q-input v-model="provagetterarray" float-label="GETTER ARRAY:"></q-input>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<q-btn color="secondary" rounded icon="refresh"
|
||||||
|
@click="TestBtn" label="Test 1"/>
|
||||||
|
|
||||||
|
<q-btn color="secondary" rounded icon="refresh" @click="TestBtn2" label="ADD TO ARRAY"/>
|
||||||
|
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnModify" label="MODIFY"/>
|
||||||
|
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnAction" label="MODIF_BYACTION"/>
|
||||||
|
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnDelete" label="DEL LAST"/>
|
||||||
|
<!--<q-btn color="secondary" rounded icon="refresh" @click="TestBtnCambiaTutto" label="NEW ARR"/>-->
|
||||||
|
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnCambioaParamPassing" label="CAMBIA PARAM"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" src="./testp1.ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './testp1.scss';
|
||||||
|
</style>
|
||||||
@@ -121,7 +121,7 @@ export default class Category extends Vue {
|
|||||||
|
|
||||||
async deleteCategory(myarrobj) {
|
async deleteCategory(myarrobj) {
|
||||||
|
|
||||||
await myarrobj.forEach(myobj => {
|
for (const myobj of myarrobj) {
|
||||||
|
|
||||||
if (myobj.id !== undefined) {
|
if (myobj.id !== undefined) {
|
||||||
console.log('KEY = ', myobj.id)
|
console.log('KEY = ', myobj.id)
|
||||||
@@ -141,7 +141,7 @@ export default class Category extends Vue {
|
|||||||
return deleteCount
|
return deleteCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Vue from 'vue'
|
|||||||
import { Component, Watch } from 'vue-property-decorator'
|
import { Component, Watch } from 'vue-property-decorator'
|
||||||
|
|
||||||
import { ICategory } from '@src/model'
|
import { ICategory } from '@src/model'
|
||||||
|
import globalroutines from "@src/globalroutines"
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
})
|
})
|
||||||
@@ -116,7 +117,7 @@ export default class Tabledata extends Vue {
|
|||||||
|
|
||||||
async deleteCategory(myarrobj) {
|
async deleteCategory(myarrobj) {
|
||||||
|
|
||||||
await myarrobj.forEach(myobj => {
|
for (const myobj of myarrobj) {
|
||||||
|
|
||||||
if (myobj.id !== undefined) {
|
if (myobj.id !== undefined) {
|
||||||
console.log('KEY = ', myobj.id)
|
console.log('KEY = ', myobj.id)
|
||||||
@@ -136,7 +137,7 @@ export default class Tabledata extends Vue {
|
|||||||
return deleteCount
|
return deleteCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
.svgclass {
|
.svgclass {
|
||||||
color: white;
|
color: white;
|
||||||
transform: translateY(0px);
|
transform: translateY(0px);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.svgclass_animate {
|
.svgclass_animate {
|
||||||
transform: translateY(-70px);
|
transform: translateY(-70px);
|
||||||
color: red;
|
color: red;
|
||||||
@@ -14,6 +16,13 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#logoimg {
|
||||||
|
height: 150px;
|
||||||
|
width: auto;
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes gravity {
|
@keyframes gravity {
|
||||||
0% {
|
0% {
|
||||||
transform: rotateY(0deg);
|
transform: rotateY(0deg);
|
||||||
@@ -27,3 +36,4 @@
|
|||||||
opacity: 0.1 !important;
|
opacity: 0.1 !important;
|
||||||
fill: red;
|
fill: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default class Offline extends Vue {
|
|||||||
logoimg: string = ''
|
logoimg: string = ''
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.logoimg = 'statics/images/' + process.env.LOGO_REG
|
this.logoimg = '/statics/images/' + process.env.LOGO_REG
|
||||||
this.animate()
|
this.animate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="offline">
|
<div id="offline">
|
||||||
Offline Page !
|
TableOnlyView Page !
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" src="./offline.ts">
|
<script lang="ts" src="./offline.ts">
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
$colcompleted: #a2a2a2;
|
$colcompleted: #a2a2a2;
|
||||||
$heightitem: 19px;
|
$heightitem: 32px;
|
||||||
|
$heightothers: 32px;
|
||||||
|
$heightBtn: 100%;
|
||||||
|
$heightcounter: 26px;
|
||||||
|
$heightdescr: 20px;
|
||||||
|
|
||||||
.flex-item{
|
.flex-item{
|
||||||
// background-color: #d5e2eb;
|
// background-color: #d5e2eb;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin: 0px;
|
margin: 1px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
|
height: $heightBtn;
|
||||||
|
line-height: $heightBtn;
|
||||||
|
vertical-align: middle;
|
||||||
//flex: 0 0 100%;
|
//flex: 0 0 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,7 +25,7 @@ $heightitem: 19px;
|
|||||||
.flex-container2 {
|
.flex-container2 {
|
||||||
flex-flow: row wrap;
|
flex-flow: row wrap;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 2px 5px 2px 5px; // top right bottom left
|
margin: 0px 5px 0px 5px; // top right bottom left
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set visibility: visible to the icon menu of pos-item-popover
|
// Set visibility: visible to the icon menu of pos-item-popover
|
||||||
@@ -24,6 +33,11 @@ $heightitem: 19px;
|
|||||||
//.flex-container2:hover .pos-item-popover {
|
//.flex-container2:hover .pos-item-popover {
|
||||||
background-color: rgba(230, 230, 230, 0.8);
|
background-color: rgba(230, 230, 230, 0.8);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
transition: all ease-in-out .3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comp_selected {
|
||||||
|
display: inline-block !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex-container2:hover{
|
.flex-container2:hover{
|
||||||
@@ -34,7 +48,7 @@ $heightitem: 19px;
|
|||||||
border-width: 1px 0px 1px 0px;
|
border-width: 1px 0px 1px 0px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: rgba(49, 68, 240, 0.6);
|
border-color: rgba(49, 68, 240, 0.6);
|
||||||
//background-color: rgba(166, 153, 240, 0.7) !important;
|
background-color: rgba(83, 132, 250, 0.44) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +56,18 @@ $heightitem: 19px;
|
|||||||
max-width: 24px;
|
max-width: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.counter-item {
|
||||||
|
margin: auto auto auto 2px;
|
||||||
|
padding: 2px;
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 1.10rem;
|
||||||
|
//color: blue !important;
|
||||||
|
|
||||||
|
//order: 2;
|
||||||
|
//height: 24px;
|
||||||
|
//line-height: 24px; /* same as height! */
|
||||||
|
}
|
||||||
|
|
||||||
.pos-item {
|
.pos-item {
|
||||||
max-width: 24px;
|
max-width: 24px;
|
||||||
@@ -50,11 +76,18 @@ $heightitem: 19px;
|
|||||||
margin-right: 1px;
|
margin-right: 1px;
|
||||||
padding-left: 1px;
|
padding-left: 1px;
|
||||||
padding-right: 1px;
|
padding-right: 1px;
|
||||||
height: $heightitem;
|
margin: 0px;
|
||||||
|
padding-top: 0px;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
//height: $heightitem;
|
||||||
line-height: $heightitem;
|
line-height: $heightitem;
|
||||||
|
min-height: $heightitem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
// background-color: #ff4081;
|
// background-color: #ff4081;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
|
order: 2;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,12 +116,16 @@ $heightitem: 19px;
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
color: #777;
|
color: #777;
|
||||||
height: 100%;
|
height: $heightitem;
|
||||||
|
line-height: $heightitem;
|
||||||
//visibility: hidden;
|
//visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//.q-popover.animate-scale {
|
||||||
|
// animation: none;
|
||||||
|
//}
|
||||||
|
|
||||||
.pos-item:hover, .pos-item-popover:hover {
|
.pos-item:hover, .pos-item-popover_cursor:hover {
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +147,8 @@ $heightitem: 19px;
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 100%;
|
height: $heightitem;
|
||||||
|
line-height: $heightitem;
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,23 +160,38 @@ $heightitem: 19px;
|
|||||||
.completed-item {
|
.completed-item {
|
||||||
max-width: 24px;
|
max-width: 24px;
|
||||||
min-width: 24px;
|
min-width: 24px;
|
||||||
|
height: $heightitem;
|
||||||
|
line-height: $heightitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-item {
|
.progress-item {
|
||||||
max-width: 32px;
|
margin: 1px;
|
||||||
min-width: 24px;
|
padding: 2px;
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
max-width: 36px;
|
||||||
|
min-width: 32px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
order: 2;
|
order: 1;
|
||||||
text-align: right;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progrbar-item {
|
||||||
|
//height: 10px
|
||||||
|
padding-top: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
.percProgress {
|
.percProgress {
|
||||||
height: $heightitem;
|
padding-top: 3px;
|
||||||
line-height: $heightitem;
|
|
||||||
color: #888;
|
color: #888;
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
//line-height: $heightitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editProgress{
|
||||||
|
//height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.colProgress {
|
.colProgress {
|
||||||
}
|
}
|
||||||
@@ -158,13 +211,14 @@ $heightitem: 19px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.myexpired {
|
.myexpired {
|
||||||
padding-top: 0px;
|
padding-top: 5px;
|
||||||
padding-bottom: 0px;
|
padding-bottom: 3px;
|
||||||
font-size: 12px;
|
font-size: 0.85rem;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-item {
|
.data-item {
|
||||||
max-width: 100px;
|
max-width: 84px;
|
||||||
//min-width: 100px;
|
//min-width: 100px;
|
||||||
//display: flex;
|
//display: flex;
|
||||||
//visibility: initial;
|
//visibility: initial;
|
||||||
@@ -172,6 +226,8 @@ $heightitem: 19px;
|
|||||||
color: #ccc;
|
color: #ccc;
|
||||||
order: 1;
|
order: 1;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
height: $heightBtn;
|
||||||
|
line-height: $heightBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -190,17 +246,28 @@ $heightitem: 19px;
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.div_descr, .div_descr_edit {
|
.divdescrTot {
|
||||||
margin: 2px;
|
display: table;
|
||||||
padding: 2px;
|
|
||||||
min-width: 200px;
|
|
||||||
vertical-align: middle;
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
height: $heightitem;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.div_descr, .div_descr_edit {
|
||||||
|
margin: auto auto auto 0px;
|
||||||
|
//padding: 2px;
|
||||||
|
min-width: 100px;
|
||||||
|
text-align: left;
|
||||||
|
color: blue !important;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
vertical-align: middle;
|
||||||
|
line-height: 120%;
|
||||||
|
max-height: 40px;
|
||||||
|
|
||||||
|
//background-color: #d50000;
|
||||||
|
|
||||||
//order: 2;
|
//order: 2;
|
||||||
//height: 24px;
|
|
||||||
//line-height: 24px; /* same as height! */
|
|
||||||
|
|
||||||
&.hide {
|
&.hide {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
@@ -211,12 +278,22 @@ $heightitem: 19px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.div_descr {
|
||||||
|
display: table-cell;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.div_descr_edit {
|
||||||
|
max-height: 90px;
|
||||||
|
//line-height: 120%;
|
||||||
|
line-height: $heightitem;
|
||||||
|
}
|
||||||
|
|
||||||
.div_descr:hover {
|
.div_descr:hover {
|
||||||
border-width: 1px 0px 1px 0px;
|
//border-width: 1px 0px 1px 0px;
|
||||||
border-color: rgba(125, 255, 125, 0.5);
|
border-color: rgba(125, 255, 125, 0.5);
|
||||||
padding: 1px;
|
//padding: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -265,7 +342,7 @@ $heightitem: 19px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.status_completed {
|
.status_completed {
|
||||||
color: $colcompleted
|
color: $colcompleted !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuTitlePriority {
|
.menuTitlePriority {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component, Prop, Watch } from 'vue-property-decorator'
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
||||||
|
|
||||||
import { rescodes } from '../../../store/Modules/rescodes'
|
import { tools } from '../../../store/Modules/tools'
|
||||||
import { UserStore } from '@modules'
|
import { UserStore } from '@modules'
|
||||||
|
|
||||||
import { ITodo } from '../../../model/index'
|
import { ITodo } from '../../../model/index'
|
||||||
@@ -40,26 +40,29 @@ export default class SingleTodo extends Vue {
|
|||||||
public togglemenu: boolean = false
|
public togglemenu: boolean = false
|
||||||
public percentageProgress: number = 0
|
public percentageProgress: number = 0
|
||||||
public itemtodoPrec: ITodo
|
public itemtodoPrec: ITodo
|
||||||
|
public clButtPopover: string = 'pos-item-popover'
|
||||||
|
public numpos: number = 0
|
||||||
|
|
||||||
$q: any
|
$q: any
|
||||||
|
|
||||||
@Prop({ required: true }) itemtodo: ITodo
|
@Prop({ required: true }) itemtodo: ITodo
|
||||||
|
|
||||||
|
|
||||||
@Watch('itemtodo.completed') valueChanged() {
|
// @Watch('itemtodo.completed') valueChanged() {
|
||||||
this.watchupdate()
|
// this.watchupdate('completed')
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Watch('itemtodo.enableExpiring') valueChanged4() {
|
@Watch('itemtodo.enableExpiring') valueChanged4() {
|
||||||
this.watchupdate()
|
this.watchupdate('enableExpiring')
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('itemtodo.expiring_at') valueChanged2() {
|
@Watch('itemtodo.expiring_at') valueChanged2() {
|
||||||
this.watchupdate()
|
this.watchupdate('expiring_at')
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('itemtodo.priority') valueChanged3() {
|
// @Watch('itemtodo.priority') valueChanged3() {
|
||||||
this.watchupdate()
|
// this.watchupdate('priority')
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Watch('itemtodo.descr') valueChanged5() {
|
@Watch('itemtodo.descr') valueChanged5() {
|
||||||
@@ -75,6 +78,11 @@ export default class SingleTodo extends Vue {
|
|||||||
return date && date.toISOString().split('T')[0]
|
return date && date.toISOString().split('T')[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Computed:
|
||||||
|
get isSel() {
|
||||||
|
return this.sel
|
||||||
|
}
|
||||||
|
|
||||||
isTodo() {
|
isTodo() {
|
||||||
return this.isTodoByElem(this.itemtodo)
|
return this.isTodoByElem(this.itemtodo)
|
||||||
}
|
}
|
||||||
@@ -83,25 +91,28 @@ export default class SingleTodo extends Vue {
|
|||||||
return elem.descr.slice(-1) !== ':'
|
return elem.descr.slice(-1) !== ':'
|
||||||
}
|
}
|
||||||
|
|
||||||
watchupdate() {
|
watchupdate(field = '') {
|
||||||
this.$emit('eventupdate', this.itemtodo)
|
this.$emit('eventupdate', {myitem: this.itemtodo, field } )
|
||||||
this.updateicon()
|
this.updateicon()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateClasses() {
|
updateClasses() {
|
||||||
// this.classCompleted = 'completed-item'
|
// this.classCompleted = 'completed-item'
|
||||||
this.classCompleted = 'completed-item-popover'
|
this.classCompleted = 'completed-item-popover'
|
||||||
this.classDescr = 'flex-item div_descr show'
|
this.classDescr = 'flex-item div_descr show donotdrag'
|
||||||
this.classDescrEdit = 'flex-item div_descr_edit'
|
this.classDescrEdit = 'flex-item div_descr_edit donotdrag'
|
||||||
if (!this.isTodo())
|
if (!this.isTodo()) {
|
||||||
this.classDescr += ' titleLista-item'
|
this.classDescr += ' titleLista-item'
|
||||||
|
this.classDescrEdit += ' titleLista-item'
|
||||||
|
}
|
||||||
|
|
||||||
this.classExpiring = 'flex-item data-item'
|
this.classExpiring = 'flex-item data-item shadow-1'
|
||||||
this.classExpiringEx = ''
|
this.classExpiringEx = ''
|
||||||
if (this.itemtodo.completed) {
|
if (this.itemtodo.completed) {
|
||||||
this.percentageProgress = 100
|
this.percentageProgress = 100
|
||||||
this.classCompleted += ' icon_completed'
|
this.classCompleted += ' icon_completed'
|
||||||
this.classDescr += ' status_completed'
|
this.classDescr += ' status_completed'
|
||||||
|
this.classDescrEdit += ' status_completed'
|
||||||
this.classExpiring += ' status_completed'
|
this.classExpiring += ' status_completed'
|
||||||
this.classExpiringEx += ' status_completed'
|
this.classExpiringEx += ' status_completed'
|
||||||
} else {
|
} else {
|
||||||
@@ -120,14 +131,23 @@ export default class SingleTodo extends Vue {
|
|||||||
mycolcl = ' highperc'
|
mycolcl = ' highperc'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.itemtodo.completed)
|
if (this.itemtodo.completed) {
|
||||||
mycolcl = ' percompleted'
|
mycolcl = ' percompleted'
|
||||||
|
}
|
||||||
|
|
||||||
this.colProgress = mycolcl
|
this.colProgress = mycolcl
|
||||||
|
|
||||||
this.menuProgress += mycolcl
|
this.menuProgress += mycolcl
|
||||||
this.percProgress += mycolcl
|
this.percProgress += mycolcl
|
||||||
|
|
||||||
|
this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover'
|
||||||
|
|
||||||
|
if (!this.itemtodo.completed) {
|
||||||
|
this.clButtPopover += ' pos-item-popover_cursor'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (this.inEdit) {
|
// if (this.inEdit) {
|
||||||
// this.classDescr += ' hide'
|
// this.classDescr += ' hide'
|
||||||
// this.classDescrEdit += ' show'
|
// this.classDescrEdit += ' show'
|
||||||
@@ -141,11 +161,12 @@ export default class SingleTodo extends Vue {
|
|||||||
// console.log('classDescrEdit = ', this.classDescrEdit)
|
// console.log('classDescrEdit = ', this.classDescrEdit)
|
||||||
// console.log('classDescr', this.classDescr)
|
// console.log('classDescr', this.classDescr)
|
||||||
|
|
||||||
|
// console.log('UserStore.state.lang', UserStore.state.lang)
|
||||||
if (this.isTodo())
|
if (this.isTodo())
|
||||||
this.menuPopupTodo = rescodes.menuPopupTodo[UserStore.state.lang]
|
this.menuPopupTodo = tools.menuPopupTodo[UserStore.state.lang]
|
||||||
else {
|
else {
|
||||||
this.menuPopupTodo = []
|
this.menuPopupTodo = []
|
||||||
this.menuPopupTodo.push(rescodes.menuPopupTodo[UserStore.state.lang][rescodes.INDEX_MENU_DELETE])
|
this.menuPopupTodo.push(tools.menuPopupTodo[UserStore.state.lang][tools.INDEX_MENU_DELETE])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -156,7 +177,7 @@ export default class SingleTodo extends Vue {
|
|||||||
|
|
||||||
this.updateClasses()
|
this.updateClasses()
|
||||||
|
|
||||||
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
|
this.selectPriority = tools.selectPriority[UserStore.state.lang]
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -165,8 +186,10 @@ export default class SingleTodo extends Vue {
|
|||||||
return 'row flex-container2 ' + this.classRow
|
return 'row flex-container2 ' + this.classRow
|
||||||
}
|
}
|
||||||
|
|
||||||
clickRiga() {
|
clickRiga(clickmenu: boolean = false) {
|
||||||
// console.log('CLICK RIGA ************')
|
// console.log('CLICK RIGA ************')
|
||||||
|
|
||||||
|
if (!this.sel) {
|
||||||
if (!this.inEdit) {
|
if (!this.inEdit) {
|
||||||
this.$emit('deselectAllRows', this.itemtodo, true)
|
this.$emit('deselectAllRows', this.itemtodo, true)
|
||||||
|
|
||||||
@@ -177,6 +200,7 @@ export default class SingleTodo extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
selectRiga() {
|
selectRiga() {
|
||||||
// console.log('selectRiga', this.itemtodo.descr)
|
// console.log('selectRiga', this.itemtodo.descr)
|
||||||
@@ -209,7 +233,12 @@ export default class SingleTodo extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clickRow() {
|
||||||
|
this.clickRiga()
|
||||||
|
}
|
||||||
|
|
||||||
editTodo() {
|
editTodo() {
|
||||||
|
if (!this.itemtodo.completed) {
|
||||||
// console.log('INIZIO - editTodo')
|
// console.log('INIZIO - editTodo')
|
||||||
this.$emit('click')
|
this.$emit('click')
|
||||||
this.precDescr = this.itemtodo.descr
|
this.precDescr = this.itemtodo.descr
|
||||||
@@ -220,8 +249,7 @@ export default class SingleTodo extends Vue {
|
|||||||
this.updateClasses()
|
this.updateClasses()
|
||||||
|
|
||||||
this.faiFocus('inputdescr')
|
this.faiFocus('inputdescr')
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('FINE - editTodo')
|
// console.log('FINE - editTodo')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +261,8 @@ export default class SingleTodo extends Vue {
|
|||||||
theField = <HTMLInputElement>mythis.$parent.$parent.$parent.$parent.$refs[elem]
|
theField = <HTMLInputElement>mythis.$parent.$parent.$parent.$parent.$refs[elem]
|
||||||
else
|
else
|
||||||
theField = <HTMLInputElement>mythis.$refs[elem]
|
theField = <HTMLInputElement>mythis.$refs[elem]
|
||||||
|
|
||||||
|
if (theField !== undefined)
|
||||||
theField.focus()
|
theField.focus()
|
||||||
// console.log('focus()')
|
// console.log('focus()')
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -250,7 +280,23 @@ export default class SingleTodo extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
keyDownRow(e) {
|
||||||
|
console.log('keyDownRow')
|
||||||
|
// Delete Key or Backspage
|
||||||
|
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
this.deselectRiga()
|
||||||
|
this.clickMenu(tools.MenuAction.DELETE)
|
||||||
|
.then(() => {
|
||||||
|
this.faiFocus('insertTask', true)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
keyDownArea(e) {
|
keyDownArea(e) {
|
||||||
|
console.log('keyDownArea')
|
||||||
/*
|
/*
|
||||||
if ((e.key === 'ArrowUp') && !e.shiftKey) {
|
if ((e.key === 'ArrowUp') && !e.shiftKey) {
|
||||||
e.key = 'Tab'
|
e.key = 'Tab'
|
||||||
@@ -264,10 +310,11 @@ export default class SingleTodo extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
// Delete Key or Backspage
|
||||||
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
|
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.deselectRiga()
|
this.deselectRiga()
|
||||||
this.clickMenu(rescodes.MenuAction.DELETE)
|
this.clickMenu(tools.MenuAction.DELETE)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.faiFocus('insertTask', true)
|
this.faiFocus('insertTask', true)
|
||||||
return
|
return
|
||||||
@@ -282,14 +329,14 @@ export default class SingleTodo extends Vue {
|
|||||||
} else {
|
} else {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.deselectRiga()
|
this.deselectRiga()
|
||||||
this.faiFocus('insertTask', true)
|
this.faiFocus('insertTask', false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('keyDownArea', e)
|
// console.log('keyDownArea', e)
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
this.deselectRiga()
|
this.deselectRiga()
|
||||||
this.faiFocus('insertTask', true)
|
// this.faiFocus('insertTask', true)
|
||||||
console.log('LOAD this.precDescr', this.precDescr)
|
console.log('LOAD this.precDescr', this.precDescr)
|
||||||
this.precDescr = this.itemtodo.descr
|
this.precDescr = this.itemtodo.descr
|
||||||
}
|
}
|
||||||
@@ -305,7 +352,7 @@ export default class SingleTodo extends Vue {
|
|||||||
console.log('itemtodo', this.itemtodo)
|
console.log('itemtodo', this.itemtodo)
|
||||||
console.log('Prec:', this.itemtodoPrec)
|
console.log('Prec:', this.itemtodoPrec)
|
||||||
|
|
||||||
this.watchupdate()
|
this.watchupdate('descr')
|
||||||
this.inEdit = false
|
this.inEdit = false
|
||||||
// this.precDescr = this.itemtodo.descr
|
// this.precDescr = this.itemtodo.descr
|
||||||
this.updateClasses()
|
this.updateClasses()
|
||||||
@@ -317,12 +364,15 @@ export default class SingleTodo extends Vue {
|
|||||||
|
|
||||||
this.updateicon()
|
this.updateicon()
|
||||||
|
|
||||||
this.updatedata()
|
this.updatedata('completed')
|
||||||
|
|
||||||
|
this.deselectAndExitEdit()
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedata() {
|
updatedata(field: string) {
|
||||||
console.log('calling this.$emit(eventupdate)')
|
// const myitem = tools.jsonCopy(this.itemtodo)
|
||||||
this.$emit('eventupdate', this.itemtodo)
|
console.log('calling this.$emit(eventupdate)', this.itemtodo)
|
||||||
|
this.$emit('eventupdate', { myitem: this.itemtodo, field } )
|
||||||
}
|
}
|
||||||
|
|
||||||
updateicon() {
|
updateicon() {
|
||||||
@@ -333,11 +383,11 @@ export default class SingleTodo extends Vue {
|
|||||||
this.iconCompleted = 'check_circle_outline'
|
this.iconCompleted = 'check_circle_outline'
|
||||||
|
|
||||||
|
|
||||||
if (this.itemtodo.priority === rescodes.Todos.PRIORITY_HIGH)
|
if (this.itemtodo.priority === tools.Todos.PRIORITY_HIGH)
|
||||||
this.iconPriority = 'expand_less' // expand_less
|
this.iconPriority = 'expand_less' // expand_less
|
||||||
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_NORMAL)
|
else if (this.itemtodo.priority === tools.Todos.PRIORITY_NORMAL)
|
||||||
this.iconPriority = 'remove'
|
this.iconPriority = 'remove'
|
||||||
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_LOW)
|
else if (this.itemtodo.priority === tools.Todos.PRIORITY_LOW)
|
||||||
this.iconPriority = 'expand_more' // expand_more
|
this.iconPriority = 'expand_more' // expand_more
|
||||||
|
|
||||||
this.updateClasses()
|
this.updateClasses()
|
||||||
@@ -345,7 +395,7 @@ export default class SingleTodo extends Vue {
|
|||||||
|
|
||||||
|
|
||||||
removeitem(id) {
|
removeitem(id) {
|
||||||
this.$emit('deleteitem', id)
|
this.$emit('deleteItem', id)
|
||||||
}
|
}
|
||||||
|
|
||||||
enableExpiring() {
|
enableExpiring() {
|
||||||
@@ -355,25 +405,29 @@ export default class SingleTodo extends Vue {
|
|||||||
|
|
||||||
async clickMenu(action) {
|
async clickMenu(action) {
|
||||||
console.log('click menu: ', action)
|
console.log('click menu: ', action)
|
||||||
if (action === rescodes.MenuAction.DELETE) {
|
if (action === tools.MenuAction.DELETE) {
|
||||||
return await this.askConfirmDelete()
|
return await this.askConfirmDelete()
|
||||||
} else if (action === rescodes.MenuAction.TOGGLE_EXPIRING) {
|
} else if (action === tools.MenuAction.TOGGLE_EXPIRING) {
|
||||||
return await this.enableExpiring()
|
return await this.enableExpiring()
|
||||||
} else if (action === rescodes.MenuAction.COMPLETED) {
|
} else if (action === tools.MenuAction.COMPLETED) {
|
||||||
return await this.setCompleted()
|
return await this.setCompleted()
|
||||||
} else if (action === rescodes.MenuAction.PROGRESS_BAR) {
|
} else if (action === tools.MenuAction.PROGRESS_BAR) {
|
||||||
return await this.updatedata()
|
return await this.updatedata('progress')
|
||||||
|
} else if (action === 0) {
|
||||||
|
this.deselectAndExitEdit()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setPriority(newpriority) {
|
setPriority(newpriority) {
|
||||||
|
|
||||||
|
if (this.itemtodo.priority !== newpriority) {
|
||||||
this.itemtodo.priority = newpriority
|
this.itemtodo.priority = newpriority
|
||||||
|
|
||||||
this.updatedata()
|
this.updatedata('priority')
|
||||||
|
|
||||||
this.updateicon()
|
this.updateicon()
|
||||||
|
}
|
||||||
|
|
||||||
// this.$q.notify('setPriority: ' + elem)
|
// this.$q.notify('setPriority: ' + elem)
|
||||||
}
|
}
|
||||||
@@ -382,14 +436,17 @@ export default class SingleTodo extends Vue {
|
|||||||
const deletestr = this.$t('dialog.delete')
|
const deletestr = this.$t('dialog.delete')
|
||||||
const cancelstr = this.$t('dialog.cancel')
|
const cancelstr = this.$t('dialog.cancel')
|
||||||
|
|
||||||
await askConfirm(this.$q, this.$t('dialog.msg.titledeleteTask'), this.$t('dialog.msg.deleteTask').toString(), deletestr, cancelstr)
|
let msg = this.$t('dialog.msg.deleteTask', {'mytodo' : this.itemtodo.descr })
|
||||||
|
await askConfirm(this.$q, this.$t('dialog.msg.titledeleteTask'), msg, deletestr, cancelstr)
|
||||||
.then(ris => {
|
.then(ris => {
|
||||||
console.log('ris', ris)
|
console.log('ris', ris)
|
||||||
if (ris)
|
if (ris) {
|
||||||
this.removeitem(this.itemtodo._id)
|
this.removeitem(this.itemtodo._id)
|
||||||
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="getClassRow()">
|
<div :class="getClassRow()" @click="clickRow">
|
||||||
<q-context-menu ref="contextMenu">
|
<!--<div v-if="isTodo()" class="flex-item counter-item dragula-container">{{itemtodo.pos}}</div>-->
|
||||||
<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu" @setPriority="setPriority"></SubMenus>
|
<!--<div v-if="isFirst">-->
|
||||||
</q-context-menu>
|
<!--<q-context-menu ref="contextMenu">-->
|
||||||
|
<!--<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu" @setPriority="setPriority"></SubMenus>-->
|
||||||
|
<!--</q-context-menu>-->
|
||||||
|
<!--</div>-->
|
||||||
|
|
||||||
|
<div v-if="isTodo()" class="flex-item completed-item donotdrag">
|
||||||
<div v-if="isTodo()" class="flex-item completed-item">
|
|
||||||
<q-btn push flat
|
<q-btn push flat
|
||||||
:class="classCompleted"
|
:class="classCompleted"
|
||||||
:icon="iconCompleted"
|
:icon="iconCompleted"
|
||||||
@@ -13,34 +15,48 @@
|
|||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-input type="textarea" ref="inputdescr" v-model.trim="precDescr"
|
<div class="flex-item donotdrag divdescrTot">
|
||||||
:class="classDescr" :max-height="50"
|
<q-input v-if="sel && !itemtodo.completed" hide-underline type="textarea" ref="inputdescr"
|
||||||
|
v-model.trim="precDescr"
|
||||||
|
:class="classDescrEdit" :max-height="100"
|
||||||
@keydown="keyDownArea" v-on:keydown.esc="exitEdit" @blur="exitEdit(true)" @click="editTodo()"/>
|
@keydown="keyDownArea" v-on:keydown.esc="exitEdit" @blur="exitEdit(true)" @click="editTodo()"/>
|
||||||
|
|
||||||
|
<div v-else :class="classDescr"
|
||||||
|
@keydown="keyDownRow">{{itemtodo.descr}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<q-field dark v-else :label="itemtodo.descr"-->
|
||||||
|
<!--:class="classDescr"-->
|
||||||
|
<!--@keydown="keyDownRow"></q-field>-->
|
||||||
|
|
||||||
<!--:after="[{icon: 'arrow_forward', content: true, handler () {}}]"-->
|
<!--:after="[{icon: 'arrow_forward', content: true, handler () {}}]"-->
|
||||||
|
|
||||||
<!--<div :class="classDescr" @mousedown.left="editTodo()">-->
|
<!--<div :class="classDescr" @mousedown.left="editTodo()">-->
|
||||||
<!--<q-field>{{ itemtodo.descr }}</q-field>-->
|
<!--<q-field>{{ itemtodo.descr }}</q-field>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
|
|
||||||
<div v-if="isTodo() && (percentageProgress > 0) " class="flex-item progress-item">
|
<div v-if="isTodo() && (percentageProgress > 0) " class="flex-item progress-item shadow-1">
|
||||||
<q-progress
|
<q-progress
|
||||||
:percentage="percentageProgress"
|
:percentage="percentageProgress"
|
||||||
class="progress-item"
|
class="progrbar-item"
|
||||||
:color="colProgress"
|
:color="colProgress"
|
||||||
>
|
>
|
||||||
</q-progress>
|
</q-progress>
|
||||||
<div :class="percProgress">
|
<div :class="percProgress">
|
||||||
{{percentageProgress}}%
|
{{percentageProgress}}%
|
||||||
|
<q-popup-edit v-model="itemtodo.progress" title="Progress" buttons class="editProgress">
|
||||||
|
<q-input type="number" v-model="itemtodo.progress" :max="100" :min="0"/>
|
||||||
|
</q-popup-edit>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div v-if="itemtodo.enableExpiring">
|
<div v-if="itemtodo.enableExpiring" :class="classExpiring">
|
||||||
<div :class="classExpiring">
|
|
||||||
<q-datetime
|
<q-datetime
|
||||||
type="date"
|
type="date"
|
||||||
:class="classExpiringEx"
|
|
||||||
v-model="itemtodo.expiring_at"
|
v-model="itemtodo.expiring_at"
|
||||||
class="myexpired"
|
class="myexpired"
|
||||||
format="DD/MM/YY"
|
format="DD/MM/YY"
|
||||||
@@ -48,26 +64,25 @@
|
|||||||
|
|
||||||
</q-datetime>
|
</q-datetime>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div v-if="isTodo()" class="flex-item pos-item " @mousedown="clickRiga">
|
||||||
<div v-if="isTodo()" class="flex-item pos-item" @mouseup.left="mouseUp" @mousedown="clickRiga">
|
<q-btn push
|
||||||
<q-btn flat
|
:class="clButtPopover"
|
||||||
class="pos-item-popover"
|
|
||||||
icon="menu">
|
icon="menu">
|
||||||
<q-popover self="top right">
|
<q-popover id="popmenu" v-if="true" self="top right">
|
||||||
<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu" @setPriority="setPriority"></SubMenus>
|
<SubMenus :menuPopupTodo="menuPopupTodo" :itemtodo="itemtodo" @clickMenu="clickMenu"
|
||||||
|
@setPriority="setPriority"></SubMenus>
|
||||||
</q-popover>
|
</q-popover>
|
||||||
|
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
<!--clButtPopover: {{ clButtPopover }}-->
|
||||||
|
<!--Sel: {{ sel }}-->
|
||||||
<!--<div class="flex-item btn-item">-->
|
<!--<div class="flex-item btn-item">-->
|
||||||
<!--{{itemtodo.expiring_at}}-->
|
<!--{{itemtodo.expiring_at}}-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
<!--<div class="flex-item btn-item">-->
|
<!--<div class="flex-item btn-item">-->
|
||||||
<!--<q-btn class="mybtn" round color="" icon="delete" @click.native="removeitem(itemtodo._id)"></q-btn>-->
|
<!--<q-btn class="mybtn" round color="" icon="delete" @click.native="removeitem(itemtodo._id)"></q-btn>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
<!--<div class="flex-item">-->
|
|
||||||
<!--[{{ itemtodo.id_prev}} - {{ itemtodo.id_next}}]-->
|
|
||||||
<!--</div>-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,16 +2,21 @@ import Vue from 'vue'
|
|||||||
import { Component, Prop } from 'vue-property-decorator'
|
import { Component, Prop } from 'vue-property-decorator'
|
||||||
|
|
||||||
import { ITodo } from '../../../model/index'
|
import { ITodo } from '../../../model/index'
|
||||||
import { rescodes } from '@src/store/Modules/rescodes'
|
import { tools } from '@src/store/Modules/tools'
|
||||||
import { UserStore } from '@store'
|
import { UserStore } from '@store'
|
||||||
|
|
||||||
|
// Doesn't exist in quasar this ? error TS2305
|
||||||
|
// import { format } from 'quasar'
|
||||||
|
// const { between } = format
|
||||||
|
|
||||||
|
// import { filter } from 'quasar'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'SubMenus'
|
name: 'SubMenus'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default class SubMenus extends Vue {
|
export default class SubMenus extends Vue {
|
||||||
public selectPriority: [] = rescodes.selectPriority[UserStore.state.lang]
|
public selectPriority: [] = tools.selectPriority[UserStore.state.lang]
|
||||||
|
|
||||||
@Prop({ required: false }) menuPopupTodo: any[]
|
@Prop({ required: false }) menuPopupTodo: any[]
|
||||||
@Prop({ required: false }) itemtodo: ITodo
|
@Prop({ required: false }) itemtodo: ITodo
|
||||||
@@ -26,16 +31,23 @@ export default class SubMenus extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeychangeProgress (e) {
|
KeychangeProgress (e) {
|
||||||
|
// between(50, 10, 20)
|
||||||
|
|
||||||
if (this.itemtodo.progress > 100) {
|
if (this.itemtodo.progress > 100) {
|
||||||
this.itemtodo.progress = 100
|
this.itemtodo.progress = 100
|
||||||
}
|
}
|
||||||
if (this.itemtodo.progress < 0) {
|
if (this.itemtodo.progress < 0) {
|
||||||
this.itemtodo.progress = 0
|
this.itemtodo.progress = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
// chiudi il meno
|
||||||
|
this.$emit('clickMenu', 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create () {
|
create () {
|
||||||
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
|
this.selectPriority = tools.selectPriority[UserStore.state.lang]
|
||||||
|
|
||||||
console.log('CREAZIONE')
|
console.log('CREAZIONE')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
.flex-container{
|
.flex-container{
|
||||||
background-color: rgb(250, 250, 250);
|
background-color: rgb(250, 250, 250);
|
||||||
padding: 5px;
|
padding: 2px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
|
|
||||||
.myitemdrag {
|
.myitemdrag {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
margin-top: 4px;
|
//margin-top: 4px;
|
||||||
border-width: 1px 0px 0px 0px;
|
border-width: 1px 0px 0px 0px;
|
||||||
//border: solid 1px #ccc;
|
//border: solid 1px #ccc;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
@@ -70,9 +71,40 @@
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.titleSubMenu {
|
.titleSubMenu {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
font-weight: 350;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,59 +1,124 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-page>
|
<q-page>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<p class="caption"></p>
|
|
||||||
|
|
||||||
<div class="divtitlecat">
|
<div class="divtitlecat">
|
||||||
<div class="categorytitle">{{ getCategory() }}</div>
|
<div class="flex-container">
|
||||||
|
<div class="flex-item categorytitle">{{categoryAtt | capitalize}}</div>
|
||||||
|
<div class="flex-item">
|
||||||
|
<q-btn push
|
||||||
|
icon="settings">
|
||||||
|
<q-popover id="popconfig" self="top right">
|
||||||
|
<q-list link separator no-border class="todo-menu">
|
||||||
|
<div v-for="field in menuPopupConfigTodo" :key="field.value">
|
||||||
|
<q-item :icon="field.icon"
|
||||||
|
@click.native="">
|
||||||
|
<q-item-side :icon="field.icon"/>
|
||||||
|
|
||||||
|
<q-item-main v-if="showTask(field.value)">
|
||||||
|
|
||||||
|
<q-select
|
||||||
|
radio
|
||||||
|
color="secondary"
|
||||||
|
:float-label="field.label"
|
||||||
|
v-model="showtype"
|
||||||
|
:options="listOptionShowTask"/>
|
||||||
|
</q-item-main>
|
||||||
|
<q-item-main v-else>
|
||||||
|
<q-item-tile label class="item-menu">{{field.label}}</q-item-tile>
|
||||||
|
</q-item-main>
|
||||||
|
</q-item>
|
||||||
|
</div>
|
||||||
|
</q-list>
|
||||||
|
</q-popover>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<q-input ref="insertTask" v-model="todotop" inverted :float-label="$t('todo.inserttop')"
|
||||||
|
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
|
||||||
|
v-on:keyup.enter="insertTodo(true)"/>
|
||||||
|
|
||||||
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
|
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
|
||||||
<div class="drag">
|
<div>
|
||||||
<draggable v-model="todos_arr" :options="{draggable:'.myitemdrag'}"
|
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
|
||||||
@start="onStart" @end="onEnd" class="dragArea">
|
<div class="container" v-dragula="todos_dacompletare(categoryAtt)" drake="first">
|
||||||
<transition-group :name="mytypetransgroup">
|
<div :id="getmyid(mytodo._id)" :index="index"
|
||||||
<div :id="getmyid(mytodo._id)" :key="mytodo._id" v-for="mytodo in todos_arr" class="myitemdrag">
|
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)">
|
<div v-if="(prior !== mytodo.priority) && !mytodo.completed"
|
||||||
|
:class="getTitlePriority(mytodo.priority)">
|
||||||
<label>{{getPriorityByInd(mytodo.priority)}}</label>
|
<label>{{getPriorityByInd(mytodo.priority)}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="(!priorcomplet && mytodo.completed)" class="titleCompleted">
|
<SingleTodo ref="single" @deleteItem="mydeleteItem(mytodo._id)" @eventupdate="updateitem"
|
||||||
<label>{{$t('todo.completed')}}</label>
|
@deselectAllRows="deselectAllRows" @onEnd="onEnd"
|
||||||
<div style="display: none">{{ priorcomplet = true }}</div>
|
|
||||||
</div>
|
|
||||||
<SingleTodo ref="single" @deleteitem="deleteitem" @eventupdate="updateitem"
|
|
||||||
@deselectAllRows="deselectAllRows"
|
|
||||||
:itemtodo='mytodo'/>
|
:itemtodo='mytodo'/>
|
||||||
|
|
||||||
<div style="display: none">{{ prior = mytodo.priority, priorcomplet = mytodo.completed }}</div>
|
<!--<div :name="`REF${index}`" class="divdrag non-draggato"></div>-->
|
||||||
|
|
||||||
|
<div style="display: none">{{ prior = mytodo.priority, priorcomplet = mytodo.completed }}
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
|
||||||
</draggable>
|
|
||||||
</div>
|
</div>
|
||||||
<q-input ref="insertTask" v-model="todo" inverted :float-label="$t('todo.insert')"
|
</div>
|
||||||
|
<!--</q-infinite-scroll>-->
|
||||||
|
|
||||||
|
<div v-if="doneTodosCount > 0" class="titleCompleted">
|
||||||
|
<label>{{$t('todo.completed')}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
|
||||||
|
<div class="container">
|
||||||
|
<div :id="getmyid(mytodo._id)" :index="index"
|
||||||
|
v-for="(mytodo, index) in todos_completati(categoryAtt)"
|
||||||
|
:key="mytodo._id" class="myitemdrag">
|
||||||
|
|
||||||
|
<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>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<q-input v-if="TodosCount > 0" ref="insertTaskBottom" v-model="todobottom" inverted
|
||||||
|
:float-label="$t('todo.insertbottom')"
|
||||||
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
|
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
|
||||||
v-on:keyup.enter="insertTodo"/>
|
v-on:keyup.enter="insertTodo(false)"/>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
<!--{{ tmpstrTodos }}-->
|
<!--{{ tmpstrTodos }}-->
|
||||||
|
|
||||||
<!--<div class="flex-item btn-item">-->
|
<!--<div class="flex-item btn-item">-->
|
||||||
<!--<q-btn class="mybtn" round color="" icon="lock" @click="getArrTodos">Get Todo</q-btn>-->
|
<!--<q-btn class="mybtn" round color="" icon="lock" @click="getArrTodos">Get Todo</q-btn>-->
|
||||||
<!--<q-btn class="mybtn" round color="" icon="person" @click="setArrTodos">Set Todo</q-btn>-->
|
<!--<!–<q-btn class="mybtn" round color="" icon="person" @click="setArrTodos">Set Todo</q-btn>–>-->
|
||||||
<!--<q-btn class="mybtn" round color="" icon="list" @click="reload_fromServer++">Reload</q-btn>-->
|
<!--<!–<q-btn class="mybtn" round color="" icon="list" @click="reload_fromServer++">Reload</q-btn>–>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
|
|
||||||
<!--<q-input v-model="testPao" float-label="testPao"/>-->
|
<!--
|
||||||
|
<!--<!–<q-input v-model="testPao" float-label="testPao"/>–>-->
|
||||||
<!--<q-input v-model="todos_changed" float-label="todos_changed"/>-->
|
<!--<q-input v-model="todos_changed" float-label="todos_changed"/>-->
|
||||||
|
|
||||||
<!--<q-input v-model="reload_fromServer" float-label="reload_fromServer"/>-->
|
<!--<q-input v-model="reload_fromServer" float-label="reload_fromServer"/>-->
|
||||||
|
|
||||||
<!--<div class="flex-item btn-item">-->
|
<!--<div class="flex-item btn-item">-->
|
||||||
<!--<!–<q-btn class="mybtn" round color="" icon="lock" @click="clicktest()"></q-btn>–>-->
|
<!--<q-btn class="mybtn" round color="" icon="lock" @click="clicktest()"></q-btn>-->
|
||||||
<!--<!–<q-btn class="mybtn" round color="" icon="person" @click="clicktest2()"></q-btn>–>-->
|
<!--<q-btn class="mybtn" round color="" icon="person" @click="clicktest2()"></q-btn>-->
|
||||||
<!--<q-btn class="mybtn" round color="" icon="list" @click="checkUpdate()"></q-btn>-->
|
<!--<q-btn class="mybtn" round color="" icon="list" @click="checkUpdate()"></q-btn>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
|
<!--–>-->
|
||||||
|
|
||||||
|
<!--<q-btn class="mybtn" round color="" icon="lock" @click="clickaggshowtype()"></q-btn>-->
|
||||||
|
|
||||||
|
|
||||||
|
<!--<span style="white-space: pre;">{{ todos_vista }}</span>-->
|
||||||
</div>
|
</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,24 @@
|
|||||||
import indexdb from './indexdb'
|
import indexdb from './indexdb'
|
||||||
|
import { GlobalStore } from "../store/Modules";
|
||||||
|
|
||||||
export default async (context, cmd, table, data = null, id = '') => {
|
export default async (context, cmd, table, data = null, id = '') => {
|
||||||
const descr = data !== null ? data.descr : ''
|
const descr = data !== null ? data.descr : ''
|
||||||
// console.log('globalroutines', cmd, table, descr, id)
|
// console.log('globalroutines', cmd, table, descr, id)
|
||||||
return await indexdb(context, cmd, table, data, id)
|
return await indexdb(context, cmd, table, data, id)
|
||||||
|
.then(ris => {
|
||||||
|
setTimeout(function () {
|
||||||
|
GlobalStore.state.connData.uploading_indexeddb = 0
|
||||||
|
GlobalStore.state.connData.downloading_indexeddb = 0
|
||||||
|
}, 1000)
|
||||||
|
return ris
|
||||||
|
}
|
||||||
|
|
||||||
|
).catch(err => {
|
||||||
|
setTimeout(function () {
|
||||||
|
GlobalStore.state.connData.uploading_indexeddb = (GlobalStore.state.connData.uploading_indexeddb === 1) ? -1 : GlobalStore.state.connData.uploading_indexeddb
|
||||||
|
GlobalStore.state.connData.downloading_indexeddb = (GlobalStore.state.connData.downloading_indexeddb === 1) ? -1 : GlobalStore.state.connData.downloading_indexeddb
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
console.log('ERROR INDEXEDDB: ', err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import { UserStore, Todos } from '@store'
|
|||||||
import { i18n } from '../plugins/i18n'
|
import { i18n } from '../plugins/i18n'
|
||||||
|
|
||||||
import { idbKeyval as storage } from '../js/storage.js';
|
import { idbKeyval as storage } from '../js/storage.js';
|
||||||
|
import { costanti } from '../store/Modules/costanti';
|
||||||
|
|
||||||
function saveConfigIndexDb(context) {
|
function saveConfigIndexDb(context) {
|
||||||
|
|
||||||
let data = []
|
let data = []
|
||||||
data['_id'] = 1
|
data['_id'] = costanti.CONFIG_ID_CFG
|
||||||
data['lang'] = UserStore.state.lang
|
data['lang'] = UserStore.state.lang
|
||||||
data['token'] = UserStore.state.x_auth_token
|
data['token'] = UserStore.state.x_auth_token
|
||||||
data['userId'] = UserStore.state.userId
|
data['userId'] = UserStore.state.userId
|
||||||
@@ -27,17 +28,40 @@ function writeConfigIndexDb(context, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function readfromIndexDbToStateTodos(context, table) {
|
async function readfromIndexDbToStateTodos(context, table) {
|
||||||
// console.log('*** read from IndexDb to state.todos')
|
console.log('*** readfromIndexDbToStateTodos ***')
|
||||||
|
|
||||||
return await storage.getalldata(table)
|
return await storage.getalldata(table)
|
||||||
.then(records => {
|
.then(reccat => {
|
||||||
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
|
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
|
||||||
if (table === 'todos') {
|
if (table === 'categories') {
|
||||||
Todos.state.todos = [...records]
|
console.log('reccat', reccat)
|
||||||
Todos.mutations.setTodos_changed()
|
Todos.state.categories = []
|
||||||
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
for (let indcat in reccat) {
|
||||||
// setTimeout(testfunc2, 3000)
|
Todos.state.categories.push(reccat[indcat].valore)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('ARRAY Categories', Todos.state.categories)
|
||||||
|
|
||||||
|
return storage.getalldata('todos')
|
||||||
|
.then(records => {
|
||||||
|
console.log('todos records', records)
|
||||||
|
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
|
||||||
|
|
||||||
|
for (let myrec in records) {
|
||||||
|
const cat = myrec.category
|
||||||
|
let indcat = state.categories.indexOf(cat)
|
||||||
|
if (Todos.state.todos[indcat] === undefined)
|
||||||
|
Todos.state.todos[indcat] = {}
|
||||||
|
|
||||||
|
// add to the right array
|
||||||
|
Todos.state.todos[indcat].push(myrec)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('************ ARRAYS SALVATI IN MEMORIA Todos.state.todos ', Todos.state.todos)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log('err: ', error)
|
console.log('err: ', error)
|
||||||
})
|
})
|
||||||
@@ -51,29 +75,39 @@ function consolelogpao(str, str2 = '', str3 = '') {
|
|||||||
|
|
||||||
function testfunc2() {
|
function testfunc2() {
|
||||||
consolelogpao('testfunc2')
|
consolelogpao('testfunc2')
|
||||||
Todos.mutations.setTodos_changed()
|
|
||||||
|
|
||||||
consolelogpao('testfunc2: Todos.state.todos_changed:', Todos.state.todos_changed)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (context, cmd, table, datakey = null, id = '') => {
|
export default async (context, cmd, table, datakey = null, id = '') => {
|
||||||
|
|
||||||
|
// console.log('TABLE', table, 'cmd', cmd)
|
||||||
if (cmd === 'loadapp') {
|
if (cmd === 'loadapp') {
|
||||||
// ****** LOAD APP AL CARICAMENTO ! *******
|
// ****** LOAD APP AL CARICAMENTO ! *******
|
||||||
return saveConfigIndexDb(context, datakey)
|
return saveConfigIndexDb(context, datakey)
|
||||||
|
|
||||||
} else if (cmd === 'write') {
|
} else if (cmd === 'write') {
|
||||||
|
if (GlobalStore)
|
||||||
|
GlobalStore.state.connData.uploading_indexeddb = 1
|
||||||
return await storage.setdata(table, datakey)
|
return await storage.setdata(table, datakey)
|
||||||
} else if (cmd === 'updateinMemory') {
|
} else if (cmd === 'updatefromIndexedDbToStateTodo') {
|
||||||
return await readfromIndexDbToStateTodos(context, table)
|
return await readfromIndexDbToStateTodos(context, table)
|
||||||
} else if (cmd === 'readall') {
|
} else if (cmd === 'readall') {
|
||||||
|
if (GlobalStore)
|
||||||
|
GlobalStore.state.connData.downloading_indexeddb = 1
|
||||||
return await storage.getalldata(table)
|
return await storage.getalldata(table)
|
||||||
} else if (cmd === 'count') {
|
} else if (cmd === 'count') {
|
||||||
return await storage.count(table)
|
return await storage.count(table)
|
||||||
} else if (cmd === 'read') {
|
} else if (cmd === 'read') {
|
||||||
|
if (GlobalStore)
|
||||||
|
GlobalStore.state.connData.downloading_indexeddb = 1
|
||||||
return await storage.getdata(table, id)
|
return await storage.getdata(table, id)
|
||||||
} else if (cmd === 'delete') {
|
} else if (cmd === 'delete') {
|
||||||
|
if (GlobalStore)
|
||||||
|
GlobalStore.state.connData.uploading_indexeddb = 1
|
||||||
return await storage.deletedata(table, id)
|
return await storage.deletedata(table, id)
|
||||||
} else if (cmd === 'clearalldata') {
|
} else if (cmd === 'clearalldata') {
|
||||||
|
if (GlobalStore)
|
||||||
|
GlobalStore.state.connData.uploading_indexeddb = 1
|
||||||
return await storage.clearalldata(table)
|
return await storage.clearalldata(table)
|
||||||
} else if (cmd === 'log') {
|
} else if (cmd === 'log') {
|
||||||
consolelogpao(table)
|
consolelogpao(table)
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ function translate(params) {
|
|||||||
let stringa = messages[lang]
|
let stringa = messages[lang]
|
||||||
|
|
||||||
let ris = stringa
|
let ris = stringa
|
||||||
|
if (ris !== undefined) {
|
||||||
msg.forEach(param => {
|
msg.forEach(param => {
|
||||||
ris = ris[param]
|
ris = ris[param]
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
console.log('ERRORE IN TRANSLATE! ', params, ' NON ESISTE!')
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
return ris
|
return ris
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,30 +10,20 @@
|
|||||||
<meta name="viewport"
|
<meta name="viewport"
|
||||||
content="user-scalable=no, initial-scale=1, minimum-scale=1, width=device-width<% if (htmlWebpackPlugin.options.ctx.mode.cordova) { %>, viewport-fit=cover<% } %>">
|
content="user-scalable=no, initial-scale=1, minimum-scale=1, width=device-width<% if (htmlWebpackPlugin.options.ctx.mode.cordova) { %>, viewport-fit=cover<% } %>">
|
||||||
|
|
||||||
<link rel="icon" href="/statics/icons/favicon.ico" type="image/x-icon">
|
<link rel="icon" href="<%= htmlWebpackPlugin.files.publicPath %>statics/icons/favicon.ico" type="image/x-icon">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/statics/icons/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="<%= htmlWebpackPlugin.files.publicPath %>statics/icons/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/statics/icons/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="<%= htmlWebpackPlugin.files.publicPath %>statics/icons/favicon-16x16.png">
|
||||||
<script defer src="/statics/js/material.min.js"></script>
|
<link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.files.publicPath %>statics/css/dragula.css">
|
||||||
<script src="/statics/js/promise.js"></script>
|
<script defer src="<%= htmlWebpackPlugin.files.publicPath %>statics/js/material.min.js"></script>
|
||||||
<script src="/statics/js/fetch.js"></script>
|
<!--<script src="<%= htmlWebpackPlugin.files.publicPath %>statics/js/promise.js"></script>-->
|
||||||
<script src="/statics/js/idb.js"></script>
|
<!--<script src="<%= htmlWebpackPlugin.files.publicPath %>statics/js/fetch.js"></script>-->
|
||||||
<script src="/statics/js/storage.js"></script>
|
<!--<script src="<%= htmlWebpackPlugin.files.publicPath %>statics/js/idb.js"></script>-->
|
||||||
<!--
|
<!--<script src="<%= htmlWebpackPlugin.files.publicPath %>statics/js/storage.js"></script>-->
|
||||||
<script src="/statics/js/immortal-db.min.js"></script>
|
|
||||||
<script>
|
|
||||||
;(async () => {
|
|
||||||
const db = ImmortalDB.ImmortalDB
|
|
||||||
await db.set('hi', 'lolsup')
|
|
||||||
})()
|
|
||||||
</script>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!--<link type="text/css" rel="stylesheet" href="statics/firebaseui.css" />-->
|
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- DO NOT touch the following DIV -->
|
|
||||||
<div id="q-app"></div>
|
<div id="q-app"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export let idbKeyval = (() => {
|
|||||||
openreq.onupgradeneeded = () => {
|
openreq.onupgradeneeded = () => {
|
||||||
// First time setup: create an empty object store
|
// First time setup: create an empty object store
|
||||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
||||||
|
openreq.result.createObjectStore('categories', { keyPath: '_id' });
|
||||||
openreq.result.createObjectStore('sync_todos', { keyPath: '_id' });
|
openreq.result.createObjectStore('sync_todos', { keyPath: '_id' });
|
||||||
openreq.result.createObjectStore('sync_todos_patch', { keyPath: '_id' });
|
openreq.result.createObjectStore('sync_todos_patch', { keyPath: '_id' });
|
||||||
openreq.result.createObjectStore('delete_todos', { keyPath: '_id' });
|
openreq.result.createObjectStore('delete_todos', { keyPath: '_id' });
|
||||||
@@ -56,7 +57,7 @@ export let idbKeyval = (() => {
|
|||||||
let req;
|
let req;
|
||||||
|
|
||||||
await withStore('readonly', table, store => {
|
await withStore('readonly', table, store => {
|
||||||
console.log('getdata', table, key)
|
// console.log('getdata', table, key)
|
||||||
req = store.get(key);
|
req = store.get(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
50
src/layouts/drawer/drawer.scss
Normal file
50
src/layouts/drawer/drawer.scss
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
.background-red {
|
||||||
|
background-color: red;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-bottom {
|
||||||
|
margin-bottom: 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-bottom a img {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#avatar {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#profile {
|
||||||
|
height: 130px;
|
||||||
|
background-color: #009688;
|
||||||
|
}
|
||||||
|
|
||||||
|
#user-name {
|
||||||
|
left: 90px;
|
||||||
|
bottom: 77px;
|
||||||
|
position: relative;
|
||||||
|
width: 159px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#user-actions {
|
||||||
|
left: 90px;
|
||||||
|
bottom: 71px;
|
||||||
|
position: relative;
|
||||||
|
width: 171px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu-collapse {
|
||||||
|
margin-top: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-left:hover {
|
||||||
|
cursor: ew-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
small {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
127
src/layouts/drawer/drawer.ts
Normal file
127
src/layouts/drawer/drawer.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
import menuOne from './menuOne.vue'
|
||||||
|
|
||||||
|
import Vue from 'vue'
|
||||||
|
import { Component, Watch, Prop } from 'vue-property-decorator'
|
||||||
|
import { Store } from 'vuex'
|
||||||
|
import { UserStore } from '@modules'
|
||||||
|
import { GlobalStore } from '@modules'
|
||||||
|
import { ITodoList } from '../../model'
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
components: {
|
||||||
|
menuOne
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default class Drawer extends Vue {
|
||||||
|
public $q
|
||||||
|
$t: any
|
||||||
|
public arrlista = GlobalStore.state.listatodo
|
||||||
|
photo = ''
|
||||||
|
user = null
|
||||||
|
links
|
||||||
|
|
||||||
|
created() {
|
||||||
|
let listatodo = []
|
||||||
|
|
||||||
|
this.arrlista.forEach((elem: ITodoList) => {
|
||||||
|
let item = {
|
||||||
|
route: '/todo/' + elem.namecat,
|
||||||
|
faIcon: 'fa fa-list-alt',
|
||||||
|
materialIcon: 'todo',
|
||||||
|
name: 'pages.' + elem.description
|
||||||
|
}
|
||||||
|
listatodo.push(item)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
if (UserStore.state.isAdmin) {
|
||||||
|
this.links = {
|
||||||
|
Dashboard: {
|
||||||
|
routes: [
|
||||||
|
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
|
||||||
|
{
|
||||||
|
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'todo', name: 'pages.Todo',
|
||||||
|
routes2: listatodo
|
||||||
|
},
|
||||||
|
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' },
|
||||||
|
// { route: '/signup', faIcon: 'fa fa-registered', materialIcon: 'home', name: 'pages.SignUp' },
|
||||||
|
{ route: '/admin/cfgserv', faIcon: 'fa fa-database', materialIcon: 'admin', name: 'pages.Admin' },
|
||||||
|
{ route: '/admin/testp1/par1', faIcon: 'fa fa-database', materialIcon: 'admin', name: 'pages.Test1' },
|
||||||
|
{ route: '/admin/testp1/par2', faIcon: 'fa fa-database', materialIcon: 'admin', name: 'pages.Test2' },
|
||||||
|
// { route: '/signin', faIcon: 'fa fa-anchor', materialIcon: 'home', name: 'pages.SignIn' },
|
||||||
|
/* {route: '/vreg?idlink=aaa', faIcon: 'fa fa-login', materialIcon: 'login', name: 'pages.vreg'},*/
|
||||||
|
],
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// PRODUCTION USER:
|
||||||
|
if (process.env.PROD) {
|
||||||
|
this.links = {
|
||||||
|
Dashboard: {
|
||||||
|
routes: [
|
||||||
|
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
|
||||||
|
],
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// SERVER TEST
|
||||||
|
this.links = {
|
||||||
|
Dashboard: {
|
||||||
|
routes: [
|
||||||
|
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
|
||||||
|
{
|
||||||
|
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'todo', name: 'pages.Todo',
|
||||||
|
routes2: listatodo
|
||||||
|
},
|
||||||
|
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' }
|
||||||
|
// { route: '/signup', faIcon: 'fa fa-registered', materialIcon: 'home', name: 'pages.SignUp' },
|
||||||
|
// { route: '/signin', faIcon: 'fa fa-anchor', materialIcon: 'home', name: 'pages.SignIn' },
|
||||||
|
/* {route: '/vreg?idlink=aaa', faIcon: 'fa fa-login', materialIcon: 'login', name: 'pages.vreg'},*/
|
||||||
|
],
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get MenuCollapse() {
|
||||||
|
return GlobalStore.state.menuCollapse
|
||||||
|
// return true
|
||||||
|
}
|
||||||
|
|
||||||
|
get Username() {
|
||||||
|
return UserStore.state.username
|
||||||
|
}
|
||||||
|
|
||||||
|
get Verificato() {
|
||||||
|
return UserStore.state.verified_email
|
||||||
|
}
|
||||||
|
|
||||||
|
get Email() {
|
||||||
|
return UserStore.state.email
|
||||||
|
}
|
||||||
|
|
||||||
|
logoutHandler() {
|
||||||
|
UserStore.actions.logout()
|
||||||
|
.then(() => {
|
||||||
|
this.$router.replace('/logout')
|
||||||
|
|
||||||
|
const mythis = this
|
||||||
|
setTimeout(function () {
|
||||||
|
mythis.$router.replace('/')
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
this.$q.notify(this.$t('logout.uscito'))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -17,154 +17,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<menu-one :links="links"></menu-one>
|
<menu-one :links="links"></menu-one>
|
||||||
|
|
||||||
<!--<footer>
|
<!--<footer>
|
||||||
<small>- Small</small>
|
<small>- Small</small>
|
||||||
</footer>-->
|
</footer>-->
|
||||||
|
|
||||||
<div class="fixed-bottom text-center light text-italic">
|
<!--<div class="fixed-bottom text-center light text-italic">-->
|
||||||
Powered by Perseo
|
<!--Powered by Perseo-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" src="./drawer.ts">
|
||||||
import menuOne from './menuOne.vue'
|
|
||||||
|
|
||||||
import Vue from 'vue'
|
|
||||||
import { Component, Watch, Prop } from 'vue-property-decorator'
|
|
||||||
import { Store } from 'vuex'
|
|
||||||
import { UserStore } from '@modules'
|
|
||||||
import { GlobalStore } from '@modules'
|
|
||||||
import { ITodoList } from "../../model";
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
components: {
|
|
||||||
menuOne,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
export default class Drawer extends Vue {
|
|
||||||
public $q
|
|
||||||
$t: any
|
|
||||||
public arrlista = GlobalStore.state.listatodo
|
|
||||||
photo = ''
|
|
||||||
user = null
|
|
||||||
links
|
|
||||||
|
|
||||||
created() {
|
|
||||||
// console.log('Drawer created...')
|
|
||||||
|
|
||||||
let listatodo = []
|
|
||||||
|
|
||||||
this.arrlista.forEach((elem: ITodoList) => {
|
|
||||||
let item = { route: '/todo/' + elem.namecat, faIcon: 'fa fa-list-alt', materialIcon: 'todo', name: 'pages.' + elem.description }
|
|
||||||
listatodo.push(item)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
this.links = {
|
|
||||||
Dashboard: {
|
|
||||||
routes: [
|
|
||||||
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
|
|
||||||
{
|
|
||||||
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'todo', name: 'pages.Todo',
|
|
||||||
routes2: listatodo
|
|
||||||
},
|
|
||||||
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' },
|
|
||||||
{ route: '/signup', faIcon: 'fa fa-registered', materialIcon: 'home', name: 'pages.SignUp' },
|
|
||||||
{ route: '/signin', faIcon: 'fa fa-anchor', materialIcon: 'home', name: 'pages.SignIn' },
|
|
||||||
/* {route: '/vreg?idlink=aaa', faIcon: 'fa fa-login', materialIcon: 'login', name: 'pages.vreg'},*/
|
|
||||||
],
|
|
||||||
show: true,
|
|
||||||
},
|
|
||||||
Forms: {
|
|
||||||
routes: [
|
|
||||||
{ route: '/prec', faIcon: 'fa fa-search', materialIcon: 'search', name: 'pages.Test' },
|
|
||||||
],
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
get MenuCollapse() {
|
|
||||||
return GlobalStore.state.menuCollapse
|
|
||||||
// return true
|
|
||||||
}
|
|
||||||
|
|
||||||
get Username() {
|
|
||||||
return UserStore.state.username
|
|
||||||
}
|
|
||||||
|
|
||||||
get Verificato() {
|
|
||||||
return UserStore.state.verified_email
|
|
||||||
}
|
|
||||||
|
|
||||||
get Email() {
|
|
||||||
return UserStore.state.email
|
|
||||||
}
|
|
||||||
|
|
||||||
logoutHandler() {
|
|
||||||
UserStore.actions.logout()
|
|
||||||
this.$router.push('/signin')
|
|
||||||
this.$q.notify(this.$t('logout.uscito'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style lang="scss" scoped>
|
||||||
.background-red {
|
@import './drawer.scss';
|
||||||
background-color: red;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed-bottom {
|
|
||||||
margin-bottom: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed-bottom a img {
|
|
||||||
width: 25px;
|
|
||||||
height: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#avatar {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#profile {
|
|
||||||
height: 130px;
|
|
||||||
background-color: #009688;
|
|
||||||
}
|
|
||||||
|
|
||||||
#user-name {
|
|
||||||
left: 90px;
|
|
||||||
bottom: 77px;
|
|
||||||
position: relative;
|
|
||||||
width: 159px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#user-actions {
|
|
||||||
left: 90px;
|
|
||||||
bottom: 71px;
|
|
||||||
position: relative;
|
|
||||||
width: 171px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#menu-collapse {
|
|
||||||
margin-top: 5%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed-left:hover {
|
|
||||||
cursor: ew-resize;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
small {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
12
src/middleware/auth.js
Normal file
12
src/middleware/auth.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
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 next();
|
||||||
|
}
|
||||||
@@ -2,8 +2,32 @@ export interface IPost {
|
|||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IConnData {
|
||||||
|
downloading_server: number
|
||||||
|
downloading_indexeddb: number
|
||||||
|
uploading_server: number
|
||||||
|
uploading_indexeddb: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICfgServer {
|
||||||
|
chiave: string
|
||||||
|
userId: string
|
||||||
|
valore: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITestp1 {
|
||||||
|
contatore: number
|
||||||
|
mioarray: ICfgServer[]
|
||||||
|
}
|
||||||
|
|
||||||
export type StateConnection = 'online' | 'offline'
|
export type StateConnection = 'online' | 'offline'
|
||||||
|
|
||||||
|
export interface IConfig {
|
||||||
|
_id: string,
|
||||||
|
key?: string,
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface IGlobalState {
|
export interface IGlobalState {
|
||||||
conta: number
|
conta: number
|
||||||
wasAlreadySubOnDb: boolean
|
wasAlreadySubOnDb: boolean
|
||||||
@@ -15,8 +39,13 @@ export interface IGlobalState {
|
|||||||
leftDrawerOpen: boolean
|
leftDrawerOpen: boolean
|
||||||
category: string
|
category: string
|
||||||
stateConnection: string
|
stateConnection: string
|
||||||
|
networkDataReceived: boolean
|
||||||
|
cfgServer: ICfgServer[]
|
||||||
|
testp1: ITestp1
|
||||||
|
connData: IConnData
|
||||||
posts: IPost[]
|
posts: IPost[]
|
||||||
listatodo: ITodoList[]
|
listatodo: ITodoList[]
|
||||||
|
arrConfig: IConfig[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,47 @@
|
|||||||
export interface ITodo {
|
export interface ITodo {
|
||||||
_id?: any,
|
_id?: any,
|
||||||
userId: string
|
userId?: string
|
||||||
category?: string
|
category?: string
|
||||||
descr?: string,
|
descr?: string,
|
||||||
priority: number,
|
priority?: number,
|
||||||
completed: boolean,
|
completed?: boolean,
|
||||||
created_at: Date,
|
created_at?: Date,
|
||||||
modify_at: Date,
|
modify_at?: Date,
|
||||||
completed_at: Date,
|
completed_at?: Date,
|
||||||
expiring_at: Date,
|
expiring_at?: Date,
|
||||||
enableExpiring?: boolean,
|
enableExpiring?: boolean,
|
||||||
id_prev?: string,
|
id_prev?: string,
|
||||||
id_next?: string,
|
|
||||||
modified?: boolean,
|
modified?: boolean,
|
||||||
pos?: number,
|
pos?: number,
|
||||||
|
order?: number,
|
||||||
progress?: number
|
progress?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IParamTodo {
|
||||||
|
categorySel?: string
|
||||||
|
checkPending?: boolean
|
||||||
|
id?: string
|
||||||
|
objtodo?: ITodo
|
||||||
|
atfirst?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDrag {
|
||||||
|
field?: string
|
||||||
|
idelemtochange?: string
|
||||||
|
prioritychosen?: number
|
||||||
|
oldIndex?: number
|
||||||
|
newIndex?: number
|
||||||
|
category: string
|
||||||
|
atfirst?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface ITodosState {
|
export interface ITodosState {
|
||||||
visuOnlyUncompleted: boolean
|
showtype: number
|
||||||
networkDataReceived: boolean
|
todos: {}
|
||||||
todos: ITodo[]
|
categories: string[]
|
||||||
todos_changed: number
|
// todos_changed: number
|
||||||
reload_fromServer: number
|
reload_fromServer: number
|
||||||
testpao: String
|
testpao: String
|
||||||
insidePending: boolean
|
insidePending: boolean
|
||||||
|
visuLastCompleted: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,5 @@ export interface IUserState {
|
|||||||
resStatus?: number
|
resStatus?: number
|
||||||
x_auth_token?: string
|
x_auth_token?: string
|
||||||
isLogged?: boolean
|
isLogged?: boolean
|
||||||
|
isAdmin?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
// apiGraphQL: 'http://localhost:8000/graphql',
|
// apiGraphQL: 'http://localhost:8000/graphql',
|
||||||
i18n: {
|
i18n: {
|
||||||
languages: [
|
|
||||||
{ code: 'it', name: 'Italiano', active: true },
|
|
||||||
{ code: 'en-uk', name: 'English', active: true }
|
|
||||||
],
|
|
||||||
default: 'it',
|
default: 'it',
|
||||||
fallbackTo: 'it'
|
fallbackTo: 'it'
|
||||||
},
|
},
|
||||||
|
|||||||
10
src/plugins/dragula.js
Normal file
10
src/plugins/dragula.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import { Vue2Dragula } from 'vue2-dragula'
|
||||||
|
|
||||||
|
export default ({ Vue }) => {
|
||||||
|
Vue.use(Vue2Dragula, {
|
||||||
|
logging: {
|
||||||
|
service: false // to only log methods in service (DragulaService)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -8,8 +8,47 @@ export default ({ app, router, store, Vue }) => {
|
|||||||
// *** Per non permettere di accedere alle pagine in cui è necessario essere Loggati ! ***
|
// *** Per non permettere di accedere alle pagine in cui è necessario essere Loggati ! ***
|
||||||
// ******************************************
|
// ******************************************
|
||||||
|
|
||||||
/*
|
// 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) => {
|
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
|
var accessToken = store.state.session.userSession.accessToken
|
||||||
// ESTANDO LOGEADO
|
// ESTANDO LOGEADO
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
@@ -45,6 +84,6 @@ export default ({ app, router, store, Vue }) => {
|
|||||||
next('/')
|
next('/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
// src/plugins/i18n.js
|
// src/plugins/i18n.js
|
||||||
import VueI18n from 'vue-i18n';
|
import VueI18n from 'vue-i18n';
|
||||||
import messages from 'src/statics/i18n';
|
import messages from 'src/statics/i18n';
|
||||||
|
import { tools } from "../store/Modules/tools";
|
||||||
|
|
||||||
export default ({ app, store, Vue }) => {
|
export default ({ app, store, Vue }) => {
|
||||||
Vue.use(VueI18n);
|
Vue.use(VueI18n);
|
||||||
Vue.config.lang = process.env.LANG_DEFAULT;
|
// Vue.config.lang = process.env.LANG_DEFAULT;
|
||||||
|
|
||||||
|
let mylang = tools.getItemLS(tools.localStorage.lang)
|
||||||
|
|
||||||
|
if ((navigator) && (mylang === '')) {
|
||||||
|
mylang = navigator.language
|
||||||
|
console.log(`LANG NAVIGATOR ${mylang}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mylang === '')
|
||||||
|
mylang = process.env.LANG_DEFAULT;
|
||||||
|
|
||||||
|
if (mylang.toLowerCase() === 'es-es')
|
||||||
|
mylang = 'esEs'
|
||||||
|
|
||||||
|
console.log('MYLANG2=', mylang)
|
||||||
|
console.log('process.env.LANG_DEFAULT=', process.env.LANG_DEFAULT)
|
||||||
|
Vue.config.lang = mylang
|
||||||
|
|
||||||
// console.log("PLUGINS INIT....");
|
// console.log("PLUGINS INIT....");
|
||||||
|
|
||||||
@@ -13,8 +31,9 @@ export default ({ app, store, Vue }) => {
|
|||||||
|
|
||||||
// Set i18n instance on app
|
// Set i18n instance on app
|
||||||
app.i18n = new VueI18n({
|
app.i18n = new VueI18n({
|
||||||
locale: process.env.LANG_DEFAULT,
|
locale: mylang,
|
||||||
fallbackLocale: process.env.LANG_DEFAULT,
|
fallbackLocale: mylang,
|
||||||
messages
|
messages
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,219 @@
|
|||||||
.mycard {
|
.mycard {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.landing {
|
||||||
|
background: #000 url(../../statics/images/cover.jpg) no-repeat 50% fixed;
|
||||||
|
background-size: cover
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing > section {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
-ms-flex-pack: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0 16px
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing > section.padding {
|
||||||
|
padding: 180px 16px
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing > section > div {
|
||||||
|
position: relative;
|
||||||
|
max-width: 1040px;
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__toolbar {
|
||||||
|
background: -webkit-gradient(linear, left top, left bottom, from(#000), to(transparent));
|
||||||
|
background: linear-gradient(180deg, #000, transparent);
|
||||||
|
padding: 0 !important
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__toolbar .q-btn {
|
||||||
|
border-radius: 0 0 5px 5px;
|
||||||
|
-ms-flex-item-align: stretch;
|
||||||
|
align-self: stretch
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__hero {
|
||||||
|
min-height: 100vh
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__header {
|
||||||
|
height: 18vh
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__arrow {
|
||||||
|
bottom: 8px;
|
||||||
|
opacity: .4
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__front {
|
||||||
|
background: -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(15%, rgba(0, 0, 0, .6)));
|
||||||
|
background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .6) 15%)
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__logo {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
margin-top: 21px;
|
||||||
|
-webkit-animation: logo-rotate 240s linear infinite;
|
||||||
|
animation: logo-rotate 240s linear infinite
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__features .q-icon {
|
||||||
|
font-size: 64px
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__features h4, .landing__features h6 {
|
||||||
|
margin: 26px 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__features p {
|
||||||
|
opacity: .6;
|
||||||
|
font-size: 16px
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__footer {
|
||||||
|
background: -webkit-gradient(linear, left top, left bottom, color-stop(65%, rgba(0, 0, 0, .1)), to(#000));
|
||||||
|
background: linear-gradient(180deg, rgba(0, 0, 0, .1) 65%, #000);
|
||||||
|
padding-top: 72px !important;
|
||||||
|
//padding-bottom: 72px !important
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__footer .doc-link {
|
||||||
|
color: #fff
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__footer .doc-link:hover {
|
||||||
|
opacity: .8
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing__swirl-bg {
|
||||||
|
background-repeat: no-repeat !important;
|
||||||
|
background-position: top;
|
||||||
|
background-size: contain !important;
|
||||||
|
background-image: url(https://cdn.quasar-framework.org/img/landing_first_section.png) !important
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 718px) {
|
||||||
|
.landing__hero {
|
||||||
|
text-align: center
|
||||||
|
}
|
||||||
|
.landing__header {
|
||||||
|
height: 9vh
|
||||||
|
}
|
||||||
|
.landing__hero .text-h1 {
|
||||||
|
font-size: 3rem;
|
||||||
|
line-height: 3.05rem;
|
||||||
|
margin-bottom: 24px
|
||||||
|
}
|
||||||
|
.landing > section.padding {
|
||||||
|
padding-top: 50px;
|
||||||
|
//padding-bottom: 90px
|
||||||
|
}
|
||||||
|
.landing .feature-item {
|
||||||
|
text-align: center
|
||||||
|
}
|
||||||
|
.landing__hero-content {
|
||||||
|
//padding-bottom: 180px
|
||||||
|
}
|
||||||
|
.landing__hero-btns {
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
-ms-flex-pack: center;
|
||||||
|
justify-content: center
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body.mobile .landing {
|
||||||
|
background: unset
|
||||||
|
}
|
||||||
|
|
||||||
|
body.mobile .landing:before {
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
height: 100vh;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: -1;
|
||||||
|
background: #000 url(../../statics/images/cover.jpg) 50%;
|
||||||
|
background-size: cover
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes logo-rotate {
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(-1turn);
|
||||||
|
transform: rotate(-1turn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes logo-rotate {
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(-1turn);
|
||||||
|
transform: rotate(-1turn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.home {
|
||||||
|
//background-color: rgb(250, 250, 250);
|
||||||
|
padding: 5px;
|
||||||
|
display: flex;
|
||||||
|
//flex-wrap: nowrap;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-start {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shadow {
|
||||||
|
//color: white;
|
||||||
|
text-shadow: 2px 2px 4px #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shadow-max {
|
||||||
|
//color: white;
|
||||||
|
text-shadow: 4px 4px 8px #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.text-h1 {
|
||||||
|
font-size: 6rem;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: 6rem;
|
||||||
|
letter-spacing: -.01562em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-weight-bold {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-subtitle1 {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.75rem;
|
||||||
|
letter-spacing: .00937em;
|
||||||
|
&.big {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.text-subtitle2 {
|
||||||
|
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.75rem;
|
||||||
|
letter-spacing: .00937em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component } from 'vue-property-decorator'
|
import { Component } from 'vue-property-decorator'
|
||||||
import { GlobalStore } from '@store'
|
import { GlobalStore, UserStore } from '@store'
|
||||||
|
|
||||||
import { Logo } from '../../components/logo'
|
import { Logo } from '../../components/logo'
|
||||||
|
|
||||||
@@ -26,9 +26,29 @@ export default class Home extends Vue {
|
|||||||
created() {
|
created() {
|
||||||
// console.log('Home created...')
|
// console.log('Home created...')
|
||||||
|
|
||||||
|
|
||||||
GlobalStore.actions.prova()
|
GlobalStore.actions.prova()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isLogged(){
|
||||||
|
return UserStore.state.isLogged
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
meta() {
|
||||||
|
return {
|
||||||
|
keywords: { name: 'keywords', content: 'Quasar website' },
|
||||||
|
// meta tags
|
||||||
|
meta: {
|
||||||
|
mykey: { name: 'mykey', content: 'Key 1' },
|
||||||
|
description: { name: 'description', content: 'Page 1' },
|
||||||
|
keywords: { name: 'keywords', content: 'Quasar website' },
|
||||||
|
equiv: { 'http-equiv': 'Content-Type', content: 'text/html; charset=UTF-8' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mystilecard() {
|
mystilecard() {
|
||||||
return {
|
return {
|
||||||
visibility: this.cardvisible,
|
visibility: this.cardvisible,
|
||||||
@@ -43,10 +63,10 @@ export default class Home extends Vue {
|
|||||||
set conta(valore) {
|
set conta(valore) {
|
||||||
GlobalStore.actions.setConta(valore)
|
GlobalStore.actions.setConta(valore)
|
||||||
let my = this.$q.i18n.lang
|
let my = this.$q.i18n.lang
|
||||||
this.showNotification(String(my))
|
this.showNotif(String(my))
|
||||||
}
|
}
|
||||||
|
|
||||||
showNotification(message: string, color = 'primary', icon = '') {
|
showNotif(message: string, color = 'primary', icon = '') {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
color,
|
color,
|
||||||
icon,
|
icon,
|
||||||
@@ -66,6 +86,10 @@ export default class Home extends Vue {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isInCostruction () {
|
||||||
|
return process.env.IN_CONSTRUCTION === '1'
|
||||||
|
}
|
||||||
|
|
||||||
getPermission() {
|
getPermission() {
|
||||||
return Notification.permission
|
return Notification.permission
|
||||||
}
|
}
|
||||||
@@ -74,15 +98,23 @@ export default class Home extends Vue {
|
|||||||
return (!('serviceWorker' in navigator))
|
return (!('serviceWorker' in navigator))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PagLogin () {
|
||||||
|
this.$router.replace('/signin')
|
||||||
|
}
|
||||||
|
|
||||||
|
PagReg () {
|
||||||
|
this.$router.replace('/signup')
|
||||||
|
}
|
||||||
|
|
||||||
displayConfirmNotification() {
|
displayConfirmNotification() {
|
||||||
let options = null
|
let options = null
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
options = {
|
options = {
|
||||||
body: 'You successfully subscribed to our Notification service!',
|
body: 'You successfully subscribed to our Notification service!',
|
||||||
icon: '/statics/icons/app-icon-96x96.png',
|
icon: '/statics/icons/app-icon-96x96.png',
|
||||||
image: '/src/images/sf-boat.jpg',
|
image: '/statics/images/sf-boat.jpg',
|
||||||
dir: 'ltr',
|
dir: 'ltr',
|
||||||
lang: 'en-US', // BCP 47,
|
lang: 'enUs', // BCP 47,
|
||||||
vibrate: [100, 50, 200],
|
vibrate: [100, 50, 200],
|
||||||
badge: '/statics/icons/app-icon-96x96.png',
|
badge: '/statics/icons/app-icon-96x96.png',
|
||||||
tag: 'confirm-notification',
|
tag: 'confirm-notification',
|
||||||
@@ -139,7 +171,7 @@ export default class Home extends Vue {
|
|||||||
icon: '/statics/icons/android-chrome-192x192.png',
|
icon: '/statics/icons/android-chrome-192x192.png',
|
||||||
image: '/statics/images/freeplanet.png',
|
image: '/statics/images/freeplanet.png',
|
||||||
dir: 'ltr',
|
dir: 'ltr',
|
||||||
lang: 'en-US', // BCP 47,
|
lang: 'enUs', // BCP 47,
|
||||||
vibrate: [100, 50, 200],
|
vibrate: [100, 50, 200],
|
||||||
badge: '/statics/icons/android-chrome-192x192.png',
|
badge: '/statics/icons/android-chrome-192x192.png',
|
||||||
tag: 'confirm-notification',
|
tag: 'confirm-notification',
|
||||||
@@ -157,16 +189,18 @@ export default class Home extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
askfornotification() {
|
askfornotification() {
|
||||||
this.showNotification(this.$t('notification.waitingconfirm'), 'positive', 'notifications')
|
this.showNotif(this.$t('notification.waitingconfirm'), 'positive', 'notifications')
|
||||||
|
|
||||||
let mythis = this
|
let mythis = this
|
||||||
Notification.requestPermission(function (result) {
|
Notification.requestPermission(function (result) {
|
||||||
console.log('User Choice', result)
|
console.log('User Choice', result)
|
||||||
if (result === 'granted') {
|
if (result === 'granted') {
|
||||||
mythis.showNotification(mythis.$t('notification.confirmed'), 'positive', 'notifications')
|
mythis.showNotif(mythis.$t('notification.confirmed'), 'positive', 'notifications')
|
||||||
} else {
|
} else {
|
||||||
mythis.showNotification(mythis.$t('notification.denied'), 'negative', 'notifications')
|
mythis.showNotif(mythis.$t('notification.denied'), 'negative', 'notifications')
|
||||||
|
|
||||||
// displayConfirmNotification();
|
// displayConfirmNotification();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,106 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-page class="flex flex-center">
|
<q-page class="text-white">
|
||||||
|
<div class="landing">
|
||||||
|
<section>
|
||||||
|
<div class="landing__hero">
|
||||||
|
<div class="landing__header"></div>
|
||||||
|
<div class="landing__hero-content row justify-center q-gutter-xl">
|
||||||
|
<div class="row">
|
||||||
<logo></logo>
|
<logo></logo>
|
||||||
|
</div>
|
||||||
<q-btn v-if="getPermission() !== 'granted'" class="enable-notifications" color="primary" rounded size="lg" icon="notifications" @click="askfornotification" :label="$t('notification.ask')"/>
|
<div class="flex justify-end">
|
||||||
<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="primary" rounded size="lg" icon="notifications" @click="showNotificationExample" label="Send Notification"/>
|
<div class="q-gutter-sm">
|
||||||
<!--<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="secondary" rounded size="lg" icon="notifications" @click="createPushSubscription" label="Create Push Subscription !"/>-->
|
<div class="text-h1 shadow-max">FreePlanet</div>
|
||||||
|
<div class="text-subtitle1 shadow text-italic q-pl-sm">{{$t('msg.sottoTitoloApp')}}
|
||||||
|
</div>
|
||||||
|
<div class="text-subtitle1 shadow big text-italic q-pl-sm"><strong>{{$t('msg.sottoTitoloApp2')}}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="text-subtitle2 shadow text-italic q-pl-sm ">{{$t('msg.sottoTitoloApp3')}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<q-btn>
|
||||||
|
|
||||||
|
Canale Telegram: <a href="https://t.me/freeplanet_channel" target="_blank"
|
||||||
|
style="color: white;">
|
||||||
|
<q-icon class="fab fa-telegram" size="2rem"/>
|
||||||
|
</a>
|
||||||
|
</q-btn>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<div v-if="isInCostruction" style="margin: 5px;">
|
||||||
|
<q-alert
|
||||||
|
type="info"
|
||||||
|
class="q-mb-sm">
|
||||||
|
{{$t('msg.underconstruction')}}
|
||||||
|
</q-alert>
|
||||||
<br>
|
<br>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-if="!isLogged" style="margin: 5px; padding: 5px;" class="home">
|
||||||
|
<q-btn rounded size="lg" color="primary" @click="PagLogin" class="btn-start">
|
||||||
|
{{$t('login.enter')}}
|
||||||
|
</q-btn>
|
||||||
|
<q-btn rounded size="lg" color="positive" @click="PagReg" class="btn-start">
|
||||||
|
{{$t('reg.submit')}}
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<q-chip square color="secondary">
|
|
||||||
Status:
|
|
||||||
</q-chip>
|
|
||||||
<q-field
|
<q-field
|
||||||
v-if="getPermission() === 'granted'"
|
v-if="getPermission() === 'granted'"
|
||||||
icon="notifications"
|
icon="notifications"
|
||||||
|
class="shadow"
|
||||||
:label="$t('notification.titlegranted')"
|
:label="$t('notification.titlegranted')"
|
||||||
helper="Stato Notifiche">
|
:helper="$t('notification.statusnot')">
|
||||||
</q-field>
|
</q-field>
|
||||||
<q-field
|
<q-field
|
||||||
v-if="NotServiceWorker()"
|
v-if="NotServiceWorker()"
|
||||||
|
class="shadow"
|
||||||
icon="notifications"
|
icon="notifications"
|
||||||
label="Service Worker not present"
|
label="Service Worker not present"
|
||||||
>
|
>
|
||||||
</q-field>
|
</q-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<q-btn v-if="getPermission() !== 'granted'" class="enable-notifications shadow"
|
||||||
|
color="primary" rounded
|
||||||
|
size="lg"
|
||||||
|
icon="notifications" @click="askfornotification"
|
||||||
|
:label="$t('notification.ask')"/>
|
||||||
|
<!--<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="primary" rounded size="lg" icon="notifications" @click="showNotificationExample" label="Send Notification"/>-->
|
||||||
|
<!--<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="secondary" rounded size="lg" icon="notifications" @click="createPushSubscription" label="Create Push Subscription !"/>-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="q-pt-md q-pl-sm">-->
|
||||||
|
<!--<div class="landing__hero-btns q-gutter-md row items-center"><a tabindex="0"-->
|
||||||
|
<!--type="button"-->
|
||||||
|
<!--href="/introduction-to-quasar"-->
|
||||||
|
<!--class="q-btn inline relative-position q-btn-item non-selectable q-btn--rectangle bg-white text-primary q-focusable q-hoverable q-btn--push">-->
|
||||||
|
<!--<div class="q-focus-helper"></div>-->
|
||||||
|
<!--<div class="q-btn__content text-center col items-center q-anchor--skip justify-center row">-->
|
||||||
|
<!--<div>About</div>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--</a><a tabindex="0" type="button" href="/start"-->
|
||||||
|
<!--class="q-btn inline relative-position q-btn-item non-selectable q-btn--rectangle bg-white text-primary q-focusable q-hoverable q-btn--push">-->
|
||||||
|
<!--<div class="q-focus-helper"></div>-->
|
||||||
|
<!--<div class="q-btn__content text-center col items-center q-anchor--skip justify-center row">-->
|
||||||
|
<!--<div>Get started</div>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--</a>-->
|
||||||
|
<!--<div class="text-body2">v1.0.0-beta.4</div>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--</div>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
98
src/root/home/old-home.vue
Normal file
98
src/root/home/old-home.vue
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<template>
|
||||||
|
<q-page class="landing text-white">
|
||||||
|
<section>
|
||||||
|
<div class="landing__hero">
|
||||||
|
<div style="height: 28vh;"></div>
|
||||||
|
<div class="landing__hero-content row justify-center q-gutter-xl">
|
||||||
|
<div class="row"><img src="https://cdn.quasar-framework.org/logo/svg/quasar-logo.svg"
|
||||||
|
class="landing__logo"></div>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<div class="q-gutter-sm">
|
||||||
|
<div class="text-h1">
|
||||||
|
<div class="text-weight-bold">Quasar</div>
|
||||||
|
<div>Framework</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-subtitle1 text-italic q-pl-sm">High performance, <strong>Material
|
||||||
|
Design
|
||||||
|
2</strong>, full front end stack with <strong>Vuejs</strong></div>
|
||||||
|
<div class="q-pt-md q-pl-sm">
|
||||||
|
<div class="landing__hero-btns q-gutter-md row items-center"><a tabindex="0"
|
||||||
|
type="button"
|
||||||
|
href="/introduction-to-quasar"
|
||||||
|
class="q-btn inline relative-position q-btn-item non-selectable q-btn--rectangle bg-white text-primary q-focusable q-hoverable q-btn--push">
|
||||||
|
<div class="q-focus-helper"></div>
|
||||||
|
<div class="q-btn__content text-center col items-center q-anchor--skip justify-center row">
|
||||||
|
<div>About</div>
|
||||||
|
</div>
|
||||||
|
</a><a tabindex="0" type="button" href="/start"
|
||||||
|
class="q-btn inline relative-position q-btn-item non-selectable q-btn--rectangle bg-white text-primary q-focusable q-hoverable q-btn--push">
|
||||||
|
<div class="q-focus-helper"></div>
|
||||||
|
<div class="q-btn__content text-center col items-center q-anchor--skip justify-center row">
|
||||||
|
<div>Get started</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="text-body2">v1.0.0-beta.4</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="landing__arrow absolute-bottom text-center"><i aria-hidden="true"
|
||||||
|
class="q-icon text-h2 text-white material-icons">expand_more</i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<logo></logo>-->
|
||||||
|
|
||||||
|
<!--</div>-->
|
||||||
|
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<!– the row with a type of gutter –>-->
|
||||||
|
<!--<q-alert-->
|
||||||
|
<!--avatar="statics/boy-avatar.png"-->
|
||||||
|
<!--color="primary"-->
|
||||||
|
<!--message="Jack"-->
|
||||||
|
<!--detail="Per un mondo più Consapevole"-->
|
||||||
|
<!--/>-->
|
||||||
|
<!--</div>-->
|
||||||
|
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<q-btn v-if="getPermission() !== 'granted'" class="enable-notifications" color="primary" rounded-->
|
||||||
|
<!--size="lg"-->
|
||||||
|
<!--icon="notifications" @click="askfornotification" :label="$t('notification.ask')"/>-->
|
||||||
|
<!--<!–<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="primary" rounded size="lg" icon="notifications" @click="showNotificationExample" label="Send Notification"/>–>-->
|
||||||
|
<!--<!–<q-btn v-if="getPermission() === 'granted'" class="enable-notifications" color="secondary" rounded size="lg" icon="notifications" @click="createPushSubscription" label="Create Push Subscription !"/>–>-->
|
||||||
|
|
||||||
|
<!--</div>-->
|
||||||
|
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<q-chip square color="secondary">-->
|
||||||
|
<!--{{$t('notification.status')}}-->
|
||||||
|
<!--</q-chip>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<q-field-->
|
||||||
|
<!--v-if="getPermission() === 'granted'"-->
|
||||||
|
<!--icon="notifications"-->
|
||||||
|
<!--:label="$t('notification.titlegranted')"-->
|
||||||
|
<!--helper="Stato Notifiche">-->
|
||||||
|
<!--</q-field>-->
|
||||||
|
<!--<q-field-->
|
||||||
|
<!--v-if="NotServiceWorker()"-->
|
||||||
|
<!--icon="notifications"-->
|
||||||
|
<!--label="Service Worker not present"-->
|
||||||
|
<!-->-->
|
||||||
|
<!--</q-field>-->
|
||||||
|
<!--</div>-->
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</q-page>
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script lang="ts" src="./home.ts">
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './home.scss';
|
||||||
|
</style>
|
||||||
@@ -1,44 +1,59 @@
|
|||||||
import { RouteConfig as VueRouteConfig } from 'vue-router'
|
import { RouteConfig as VueRouteConfig } from 'vue-router'
|
||||||
|
|
||||||
import { RouteNames } from './route-names'
|
import { RouteNames } from './route-names'
|
||||||
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
|
||||||
|
import auth from '../middleware/auth'
|
||||||
|
|
||||||
|
|
||||||
export const RouteConfig: VueRouteConfig[] = [
|
export const RouteConfig: VueRouteConfig[] = [
|
||||||
{
|
{
|
||||||
component: () => import('@/root/home/home.vue'),
|
|
||||||
name: RouteNames.home,
|
|
||||||
path: '/',
|
path: '/',
|
||||||
meta: { name: 'Home' }
|
name: RouteNames.home,
|
||||||
|
component: () => import('@/root/home/home.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/signup',
|
path: '/signup',
|
||||||
component: () => import('@/views/login/signup/signup.vue'),
|
name: 'Registration',
|
||||||
meta: { name: 'Registration' }
|
component: () => import('@/views/login/signup/signup.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/signin',
|
path: '/signin',
|
||||||
component: () => import('@/views/login/signin/signin.vue'),
|
name: RouteNames.login,
|
||||||
meta: { name: 'Login' }
|
component: () => import('@/views/login/signin/signin.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/vreg',
|
path: '/vreg',
|
||||||
component: () => import('@/views/login/vreg/vreg.vue'),
|
name: 'Verify Reg',
|
||||||
meta: { name: 'Verify Reg' }
|
component: () => import('@/views/login/vreg/vreg.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/todo/:category',
|
path: '/todo/:category',
|
||||||
|
name: 'Todos',
|
||||||
component: () => import('@/components/todos/todo/todo.vue'),
|
component: () => import('@/components/todos/todo/todo.vue'),
|
||||||
// props: { category: 'personal' },
|
meta: {
|
||||||
meta: { name: 'Todos' }
|
middleware: [auth]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/category',
|
path: '/category',
|
||||||
component: () => import('@/components/categories/category/category.vue'),
|
name: 'category',
|
||||||
meta: { name: 'Categories' }
|
component: () => import('@/components/categories/category/category.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/admin/cfgserv',
|
||||||
|
name: 'cfgserv',
|
||||||
|
component: () => import('@/components/admin/cfgServer/cfgServer.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/admin/testp1/:category',
|
||||||
|
name: 'Categories',
|
||||||
|
component: () => import('@/components/admin/testp1/testp1.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/offline',
|
path: '/offline',
|
||||||
component: () => import('@/components/offline/offline.vue'),
|
name: 'Offline',
|
||||||
meta: { name: 'Offline' }
|
component: () => import('@/components/offline/offline.vue')
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@@ -64,4 +79,3 @@ export const RouteConfig: VueRouteConfig[] = [
|
|||||||
meta: { name: 'Embeeded' }
|
meta: { name: 'Embeeded' }
|
||||||
}*/
|
}*/
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 163 KiB |
File diff suppressed because one or more lines are too long
@@ -1,382 +0,0 @@
|
|||||||
const messages = {
|
|
||||||
it: {
|
|
||||||
dialog: {
|
|
||||||
ok: 'Ok',
|
|
||||||
yes: 'Si',
|
|
||||||
no: 'No',
|
|
||||||
delete: 'Elimina',
|
|
||||||
cancel: 'Annulla',
|
|
||||||
msg: {
|
|
||||||
titledeleteTask: 'Elimina Task',
|
|
||||||
deleteTask: 'Vuoi Eliminare questo Task?'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
comp:{
|
|
||||||
Conta: "Conta",
|
|
||||||
},
|
|
||||||
msg: {
|
|
||||||
hello: 'Buongiorno',
|
|
||||||
myAppName: 'FreePlanet',
|
|
||||||
myDescriz: ''
|
|
||||||
},
|
|
||||||
pages: {
|
|
||||||
home: 'Principale',
|
|
||||||
SignUp: 'Registrazione',
|
|
||||||
SignIn: 'Login',
|
|
||||||
vreg: 'Verifica Reg',
|
|
||||||
Test: 'Test',
|
|
||||||
Category: 'Categorie',
|
|
||||||
Todo: 'Todo',
|
|
||||||
personal: 'Personale',
|
|
||||||
work: 'Lavoro',
|
|
||||||
shopping: 'Spesa',
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
authentication:{
|
|
||||||
login: {
|
|
||||||
facebook: 'Facebook'
|
|
||||||
},
|
|
||||||
email_verification: {
|
|
||||||
title: 'Inizia la tua registrazione',
|
|
||||||
introduce_email: 'inserisci la tua email',
|
|
||||||
email: 'Email',
|
|
||||||
invalid_email: 'La tua email è invalida',
|
|
||||||
verify_email: 'Verifica la tua email',
|
|
||||||
go_login: 'Torna al Login',
|
|
||||||
incorrect_input: 'Inserimento incorretto.',
|
|
||||||
link_sent: 'Per confermare la Registrazione, leggi la tua casella di posta e Clicca su "Verifica Email".\nSe non la trovi, cerca nella cartella Spam.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetch: {
|
|
||||||
errore_generico: 'Errore Generico',
|
|
||||||
errore_server: 'Impossibile accedere al Server. Riprovare Grazie',
|
|
||||||
error_doppiologin: 'Rieseguire il Login. Accesso aperto da un altro dispositivo.',
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
notregistered: 'Devi registrarti al servizio prima di porter memorizzare i dati'
|
|
||||||
},
|
|
||||||
reg: {
|
|
||||||
incorso: 'Registrazione in corso...',
|
|
||||||
richiesto: 'Campo Richiesto',
|
|
||||||
email: 'Email',
|
|
||||||
username : 'Nome Utente',
|
|
||||||
password: 'Password',
|
|
||||||
repeatPassword: 'Ripeti password',
|
|
||||||
terms: "Accetto i termini e le condizioni",
|
|
||||||
submit: "Registrati",
|
|
||||||
title_verif_reg: "Verifica Registrazione",
|
|
||||||
verificato: "Verificato",
|
|
||||||
non_verificato: "Non Verificato",
|
|
||||||
forgetpassword:"Password dimenticata?",
|
|
||||||
err: {
|
|
||||||
required: 'è richiesto',
|
|
||||||
email: 'dev\'essere una email valida',
|
|
||||||
errore_generico: 'Si prega di compilare correttamente i campi',
|
|
||||||
atleast: 'dev\'essere lungo almeno di',
|
|
||||||
complexity: 'deve contenere almeno 1 carattere minuscolo, 1 maiuscola e 1 cifra',
|
|
||||||
notmore: 'non dev\'essere lungo più di',
|
|
||||||
char: 'caratteri',
|
|
||||||
terms: 'Devi accettare le condizioni, per continuare.',
|
|
||||||
duplicate_email: 'l\'Email è già stata registrata',
|
|
||||||
duplicate_username: 'L\'Username è stato già utilizzato',
|
|
||||||
sameaspassword: 'Le password devono essere identiche',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
login:{
|
|
||||||
incorso: 'Login in corso',
|
|
||||||
enter: 'Login',
|
|
||||||
errato: "Username o password errata. Riprovare",
|
|
||||||
completato: 'Login effettuato!',
|
|
||||||
},
|
|
||||||
reset: {
|
|
||||||
title_reset_pwd: "Reimposta la tua Password",
|
|
||||||
send_reset_pwd: 'Invia Reimposta la password',
|
|
||||||
incorso: 'Richiesta Nuova Email...',
|
|
||||||
email_sent:'Email inviata',
|
|
||||||
check_email: 'Controlla la tua email, ti arriverà un messaggio con un link per reimpostare la tua password. Questo link, per sicurezza, scadrà dopo 4 ore.',
|
|
||||||
title_update_pwd: 'Aggiorna la tua password',
|
|
||||||
update_password: 'Aggiorna Password',
|
|
||||||
},
|
|
||||||
logout:{
|
|
||||||
uscito: 'Sei Uscito',
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
graphql: {
|
|
||||||
undefined: 'non definito'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
todo: {
|
|
||||||
titleprioritymenu: 'Priorità:',
|
|
||||||
insert: 'Inserisci il Task',
|
|
||||||
edit: 'Descrizione Task:',
|
|
||||||
completed: 'Completati',
|
|
||||||
usernotdefined: 'Attenzione, occorre essere Loggati per poter aggiungere un Todo'
|
|
||||||
},
|
|
||||||
notification : {
|
|
||||||
ask: 'Attiva le Notifiche',
|
|
||||||
waitingconfirm: 'Conferma la richiesta di Notifica',
|
|
||||||
confirmed: 'Notifiche Attivate!',
|
|
||||||
denied: 'Notifiche Disabilitate! Attenzione così non vedrai arrivarti i messaggi. Riabilitali per vederli.',
|
|
||||||
titlegranted: 'Permesso Notifiche Abilitato!',
|
|
||||||
titledenied: 'Permesso Notifiche Disabilitato!',
|
|
||||||
title_subscribed: 'Sottoscrizione a FreePlanet.app!',
|
|
||||||
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.'
|
|
||||||
},
|
|
||||||
connection: 'Connessione',
|
|
||||||
},
|
|
||||||
es: {
|
|
||||||
dialog: {
|
|
||||||
ok: 'Vale',
|
|
||||||
yes: 'Sí',
|
|
||||||
no: 'No',
|
|
||||||
delete: 'Borrar',
|
|
||||||
cancel: 'Cancelar',
|
|
||||||
msg: {
|
|
||||||
titledeleteTask: 'Borrar Tarea',
|
|
||||||
deleteTask: 'Quieres borrar este tarea?'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
comp:{
|
|
||||||
Conta: "Conta",
|
|
||||||
},
|
|
||||||
msg: {
|
|
||||||
hello: 'Buenos Días',
|
|
||||||
myAppName: 'FreePlanet',
|
|
||||||
myDescriz: ''
|
|
||||||
},
|
|
||||||
pages: {
|
|
||||||
home: 'Principal',
|
|
||||||
SignUp: 'Registrarte',
|
|
||||||
SignIn: 'Login',
|
|
||||||
vreg: 'Verifica Reg',
|
|
||||||
Test: 'Test',
|
|
||||||
Category: 'Categorías',
|
|
||||||
Todo: 'Tareas',
|
|
||||||
personal: 'Personal',
|
|
||||||
work: 'Trabajo',
|
|
||||||
shopping: 'Compras',
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
authentication:{
|
|
||||||
login: {
|
|
||||||
facebook: 'Facebook'
|
|
||||||
},
|
|
||||||
email_verification: {
|
|
||||||
title: 'Crea una cuenta',
|
|
||||||
introduce_email: 'ingrese su dirección de correo electrónico',
|
|
||||||
email: 'Email',
|
|
||||||
invalid_email: 'Tu correo electrónico no es válido',
|
|
||||||
verify_email: 'Revisa tu email',
|
|
||||||
go_login: 'Vuelve al Login',
|
|
||||||
incorrect_input: 'Entrada correcta.',
|
|
||||||
link_sent: 'Para confirmar el registro, lea su buzón y haga clic en "Verificar correo electrónico".\n' + 'Si no lo encuentras, busca en la carpeta Spam.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetch: {
|
|
||||||
errore_generico: 'Error genérico',
|
|
||||||
errore_server: 'No se puede acceder al Servidor. Inténtalo de nuevo, Gracias',
|
|
||||||
error_doppiologin: 'Vuelva a iniciar sesión. Acceso abierto por otro dispositivo.',
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
notregistered: 'Debe registrarse en el servicio antes de poder almacenar los datos'
|
|
||||||
},
|
|
||||||
reg: {
|
|
||||||
incorso: 'Registro en curso...',
|
|
||||||
richiesto: 'Campo requerido',
|
|
||||||
email: 'Email',
|
|
||||||
username : 'Nombre usuario',
|
|
||||||
password: 'contraseña',
|
|
||||||
repeatPassword: 'Repetir contraseña',
|
|
||||||
terms: "Acepto los términos y condiciones",
|
|
||||||
submit: "Registrarse",
|
|
||||||
title_verif_reg: "Verifica registro",
|
|
||||||
verificato: "Verificado",
|
|
||||||
non_verificato: "No Verificado",
|
|
||||||
forgetpassword:"¿Olvidaste tu contraseña?",
|
|
||||||
err: {
|
|
||||||
required: 'se requiere',
|
|
||||||
email: 'Debe ser una email válida.',
|
|
||||||
errore_generico: 'Por favor, rellene los campos correctamente',
|
|
||||||
atleast: 'debe ser al menos largo',
|
|
||||||
complexity: 'debe contener al menos 1 minúscula, 1 mayúscula y 1 dígito',
|
|
||||||
notmore: 'no tiene que ser más largo que',
|
|
||||||
char: 'caracteres',
|
|
||||||
terms: 'Debes aceptar las condiciones, para continuar..',
|
|
||||||
duplicate_email: 'La email ya ha sido registrada',
|
|
||||||
duplicate_username: 'El nombre de usuario ya ha sido utilizado',
|
|
||||||
sameaspassword: 'Las contraseñas deben ser idénticas',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
login:{
|
|
||||||
incorso: 'Login en curso',
|
|
||||||
enter: 'Login',
|
|
||||||
errato: "Nombre de usuario o contraseña incorrectos. inténtelo de nuevo",
|
|
||||||
completato: 'Login realizado!',
|
|
||||||
},
|
|
||||||
reset: {
|
|
||||||
title_reset_pwd: "Restablece tu contraseña",
|
|
||||||
send_reset_pwd: 'Enviar restablecer contraseña',
|
|
||||||
incorso: 'Solicitar nueva Email...',
|
|
||||||
email_sent:'Email enviada',
|
|
||||||
check_email: 'Revise su correo electrónico, recibirá un mensaje con un enlace para restablecer su contraseña. Este enlace, por razones de seguridad, expirará después de 4 horas.',
|
|
||||||
title_update_pwd: 'Actualiza tu contraseña',
|
|
||||||
update_password: 'Actualizar contraseña',
|
|
||||||
},
|
|
||||||
logout:{
|
|
||||||
uscito: 'Estás desconectado',
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
graphql: {
|
|
||||||
undefined: 'no definido'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
todo: {
|
|
||||||
titleprioritymenu: 'Prioridad:',
|
|
||||||
insert: 'Ingrese una nueva Tarea',
|
|
||||||
edit: 'Descripción Tarea:',
|
|
||||||
completed: 'Completados',
|
|
||||||
usernotdefined: 'Atención, debes iniciar sesión para agregar una Tarea'
|
|
||||||
},
|
|
||||||
notification : {
|
|
||||||
ask: 'Activar notificaciones',
|
|
||||||
waitingconfirm: 'Confirmar la solicitud de notificación.',
|
|
||||||
confirmed: 'Notificaciones activadas!',
|
|
||||||
denied: 'Notificaciones deshabilitadas! Ten cuidado, así no verás llegar los mensajes. Rehabilítalos para verlos.',
|
|
||||||
titlegranted: 'Notificaciones permitidas habilitadas!',
|
|
||||||
titledenied: 'Notificaciones permitidas deshabilitadas!',
|
|
||||||
title_subscribed: 'Suscripción a FreePlanet.app!',
|
|
||||||
subscribed: 'Ahora puedes recibir mensajes y notificaciones.'
|
|
||||||
},
|
|
||||||
connection: 'Connection',
|
|
||||||
},
|
|
||||||
enUk: {
|
|
||||||
dialog: {
|
|
||||||
ok: 'Ok',
|
|
||||||
yes: 'Yes',
|
|
||||||
no: 'No',
|
|
||||||
delete: 'Delete',
|
|
||||||
cancel: 'Cancel',
|
|
||||||
msg: {
|
|
||||||
titledeleteTask: 'Delete Task',
|
|
||||||
deleteTask: 'Delete this Task?'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
comp:{
|
|
||||||
Conta: "Count",
|
|
||||||
},
|
|
||||||
msg: {
|
|
||||||
hello: 'Hello!',
|
|
||||||
myAppName: 'FreePlanet',
|
|
||||||
myDescriz: ''
|
|
||||||
},
|
|
||||||
pages: {
|
|
||||||
home: 'Dashboard One',
|
|
||||||
SignUp: 'SignUp',
|
|
||||||
SignIn: 'SignIn',
|
|
||||||
vreg: 'Verify Reg',
|
|
||||||
Test: 'Test',
|
|
||||||
Category: 'Category',
|
|
||||||
Todo: 'Todo',
|
|
||||||
personal: 'Personal',
|
|
||||||
work: 'Work',
|
|
||||||
shopping: 'Shopping',
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
authentication:{
|
|
||||||
login: {
|
|
||||||
facebook: 'Facebook'
|
|
||||||
},
|
|
||||||
email_verification: {
|
|
||||||
title: 'Begin your registration',
|
|
||||||
introduce_email: 'Enter your email',
|
|
||||||
email: 'Email',
|
|
||||||
invalid_email: 'Your email is invalid',
|
|
||||||
verify_email: 'Verify your email',
|
|
||||||
go_login: 'Back to Login',
|
|
||||||
incorrect_input: 'Incorrect input.',
|
|
||||||
link_sent: 'To confirm the Registration, read your mailbox and click on "Verify email".\nIf you can not find it check your junk mail or spam.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetch: {
|
|
||||||
errore_generico: 'Generic Error',
|
|
||||||
errore_server: 'Unable to access to the Server. Retry. Thank you.',
|
|
||||||
error_doppiologin: 'Signup again. Another access was made with another device.',
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
notregistered: 'You need first to SignUp before storing data'
|
|
||||||
},
|
|
||||||
reg: {
|
|
||||||
incorso: 'Registration please wait...',
|
|
||||||
richiesto: 'Field Required',
|
|
||||||
email: 'Email',
|
|
||||||
username : 'Username',
|
|
||||||
password: 'Password',
|
|
||||||
repeatPassword: 'Repeat password',
|
|
||||||
terms: "I agree with the terms and conditions",
|
|
||||||
submit: "Submit",
|
|
||||||
title_verif_reg: "Verify Registration",
|
|
||||||
verificato: "Verified",
|
|
||||||
non_verificato: "Not Verified",
|
|
||||||
forgetpassword:"Forget Password?",
|
|
||||||
err: {
|
|
||||||
required: 'is required',
|
|
||||||
email: 'must be a valid email',
|
|
||||||
errore_generico: 'Please review fields again',
|
|
||||||
atleast: 'must be at least',
|
|
||||||
complexity: 'must contains at least 1 lowercase letter, 1 uppercase letter, and 1 digit',
|
|
||||||
notmore: 'must not be more than',
|
|
||||||
char: 'characters long',
|
|
||||||
terms: 'You need to agree with the terms & conditions.',
|
|
||||||
duplicate_email: 'Email was already registered',
|
|
||||||
duplicate_username: 'Username is already taken',
|
|
||||||
sameaspassword: 'Passwords must be identical',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
login:{
|
|
||||||
incorso: 'Login...',
|
|
||||||
enter: 'Login',
|
|
||||||
errato: "Username or password wrong. Please retry again",
|
|
||||||
completato: 'Login successfully!',
|
|
||||||
},
|
|
||||||
reset: {
|
|
||||||
title_reset_pwd: "Reset your Password",
|
|
||||||
send_reset_pwd: 'Send password request',
|
|
||||||
incorso: 'Request New Email...',
|
|
||||||
email_sent:'Email sent',
|
|
||||||
check_email: 'Check your email for a message with a link to update your password. This link will expire in 4 hours for security reasons.',
|
|
||||||
title_update_pwd: 'Update your password',
|
|
||||||
update_password: 'Update Password',
|
|
||||||
},
|
|
||||||
logout:{
|
|
||||||
uscito: 'Logout successfully',
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
graphql: {
|
|
||||||
undefined: 'undefined'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
todo: {
|
|
||||||
titleprioritymenu: 'Priority:',
|
|
||||||
insert: 'Insert Task',
|
|
||||||
edit: 'Task Description:',
|
|
||||||
completed: 'Completed',
|
|
||||||
usernotdefined: 'Attention, you need to be Signed In to add a new Task'
|
|
||||||
},
|
|
||||||
notification : {
|
|
||||||
ask: 'Enable Notification',
|
|
||||||
waitingconfirm: 'Confirm the Request Notification',
|
|
||||||
confirmed: 'Notifications Enabled!',
|
|
||||||
denied: 'Notifications Disabled! Attention, you will not see your messages incoming. Reenable it for see it',
|
|
||||||
titlegranted: 'Notification Permission Granted!',
|
|
||||||
titledenied: 'Notification Permission Denied!',
|
|
||||||
title_subscribed: 'Subscribed to FreePlanet.app!',
|
|
||||||
subscribed: 'You can now receive Notification and Messages.'
|
|
||||||
},
|
|
||||||
connection: 'Conexión',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default messages;
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 190 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 40 KiB |
@@ -1,461 +0,0 @@
|
|||||||
(function(self) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
if (self.fetch) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var support = {
|
|
||||||
searchParams: 'URLSearchParams' in self,
|
|
||||||
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
|
||||||
blob: 'FileReader' in self && 'Blob' in self && (function() {
|
|
||||||
try {
|
|
||||||
new Blob()
|
|
||||||
return true
|
|
||||||
} catch(e) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})(),
|
|
||||||
formData: 'FormData' in self,
|
|
||||||
arrayBuffer: 'ArrayBuffer' in self
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support.arrayBuffer) {
|
|
||||||
var viewClasses = [
|
|
||||||
'[object Int8Array]',
|
|
||||||
'[object Uint8Array]',
|
|
||||||
'[object Uint8ClampedArray]',
|
|
||||||
'[object Int16Array]',
|
|
||||||
'[object Uint16Array]',
|
|
||||||
'[object Int32Array]',
|
|
||||||
'[object Uint32Array]',
|
|
||||||
'[object Float32Array]',
|
|
||||||
'[object Float64Array]'
|
|
||||||
]
|
|
||||||
|
|
||||||
var isDataView = function(obj) {
|
|
||||||
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
|
|
||||||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeName(name) {
|
|
||||||
if (typeof name !== 'string') {
|
|
||||||
name = String(name)
|
|
||||||
}
|
|
||||||
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
|
|
||||||
throw new TypeError('Invalid character in header field name')
|
|
||||||
}
|
|
||||||
return name.toLowerCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeValue(value) {
|
|
||||||
if (typeof value !== 'string') {
|
|
||||||
value = String(value)
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build a destructive iterator for the value list
|
|
||||||
function iteratorFor(items) {
|
|
||||||
var iterator = {
|
|
||||||
next: function() {
|
|
||||||
var value = items.shift()
|
|
||||||
return {done: value === undefined, value: value}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support.iterable) {
|
|
||||||
iterator[Symbol.iterator] = function() {
|
|
||||||
return iterator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
function Headers(headers) {
|
|
||||||
this.map = {}
|
|
||||||
|
|
||||||
if (headers instanceof Headers) {
|
|
||||||
headers.forEach(function(value, name) {
|
|
||||||
this.append(name, value)
|
|
||||||
}, this)
|
|
||||||
} else if (Array.isArray(headers)) {
|
|
||||||
headers.forEach(function(header) {
|
|
||||||
this.append(header[0], header[1])
|
|
||||||
}, this)
|
|
||||||
} else if (headers) {
|
|
||||||
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
||||||
this.append(name, headers[name])
|
|
||||||
}, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.append = function(name, value) {
|
|
||||||
name = normalizeName(name)
|
|
||||||
value = normalizeValue(value)
|
|
||||||
var oldValue = this.map[name]
|
|
||||||
this.map[name] = oldValue ? oldValue+','+value : value
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype['delete'] = function(name) {
|
|
||||||
delete this.map[normalizeName(name)]
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.get = function(name) {
|
|
||||||
name = normalizeName(name)
|
|
||||||
return this.has(name) ? this.map[name] : null
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.has = function(name) {
|
|
||||||
return this.map.hasOwnProperty(normalizeName(name))
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.set = function(name, value) {
|
|
||||||
this.map[normalizeName(name)] = normalizeValue(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.forEach = function(callback, thisArg) {
|
|
||||||
for (var name in this.map) {
|
|
||||||
if (this.map.hasOwnProperty(name)) {
|
|
||||||
callback.call(thisArg, this.map[name], name, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.keys = function() {
|
|
||||||
var items = []
|
|
||||||
this.forEach(function(value, name) { items.push(name) })
|
|
||||||
return iteratorFor(items)
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.values = function() {
|
|
||||||
var items = []
|
|
||||||
this.forEach(function(value) { items.push(value) })
|
|
||||||
return iteratorFor(items)
|
|
||||||
}
|
|
||||||
|
|
||||||
Headers.prototype.entries = function() {
|
|
||||||
var items = []
|
|
||||||
this.forEach(function(value, name) { items.push([name, value]) })
|
|
||||||
return iteratorFor(items)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support.iterable) {
|
|
||||||
Headers.prototype[Symbol.iterator] = Headers.prototype.entries
|
|
||||||
}
|
|
||||||
|
|
||||||
function consumed(body) {
|
|
||||||
if (body.bodyUsed) {
|
|
||||||
return Promise.reject(new TypeError('Already read'))
|
|
||||||
}
|
|
||||||
body.bodyUsed = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function fileReaderReady(reader) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
reader.onload = function() {
|
|
||||||
resolve(reader.result)
|
|
||||||
}
|
|
||||||
reader.onerror = function() {
|
|
||||||
reject(reader.error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function readBlobAsArrayBuffer(blob) {
|
|
||||||
var reader = new FileReader()
|
|
||||||
var promise = fileReaderReady(reader)
|
|
||||||
reader.readAsArrayBuffer(blob)
|
|
||||||
return promise
|
|
||||||
}
|
|
||||||
|
|
||||||
function readBlobAsText(blob) {
|
|
||||||
var reader = new FileReader()
|
|
||||||
var promise = fileReaderReady(reader)
|
|
||||||
reader.readAsText(blob)
|
|
||||||
return promise
|
|
||||||
}
|
|
||||||
|
|
||||||
function readArrayBufferAsText(buf) {
|
|
||||||
var view = new Uint8Array(buf)
|
|
||||||
var chars = new Array(view.length)
|
|
||||||
|
|
||||||
for (var i = 0; i < view.length; i++) {
|
|
||||||
chars[i] = String.fromCharCode(view[i])
|
|
||||||
}
|
|
||||||
return chars.join('')
|
|
||||||
}
|
|
||||||
|
|
||||||
function bufferClone(buf) {
|
|
||||||
if (buf.slice) {
|
|
||||||
return buf.slice(0)
|
|
||||||
} else {
|
|
||||||
var view = new Uint8Array(buf.byteLength)
|
|
||||||
view.set(new Uint8Array(buf))
|
|
||||||
return view.buffer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Body() {
|
|
||||||
this.bodyUsed = false
|
|
||||||
|
|
||||||
this._initBody = function(body) {
|
|
||||||
this._bodyInit = body
|
|
||||||
if (!body) {
|
|
||||||
this._bodyText = ''
|
|
||||||
} else if (typeof body === 'string') {
|
|
||||||
this._bodyText = body
|
|
||||||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
||||||
this._bodyBlob = body
|
|
||||||
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
||||||
this._bodyFormData = body
|
|
||||||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
||||||
this._bodyText = body.toString()
|
|
||||||
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
||||||
this._bodyArrayBuffer = bufferClone(body.buffer)
|
|
||||||
// IE 10-11 can't handle a DataView body.
|
|
||||||
this._bodyInit = new Blob([this._bodyArrayBuffer])
|
|
||||||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
||||||
this._bodyArrayBuffer = bufferClone(body)
|
|
||||||
} else {
|
|
||||||
throw new Error('unsupported BodyInit type')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.headers.get('content-type')) {
|
|
||||||
if (typeof body === 'string') {
|
|
||||||
this.headers.set('content-type', 'text/plain;charset=UTF-8')
|
|
||||||
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
||||||
this.headers.set('content-type', this._bodyBlob.type)
|
|
||||||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
||||||
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support.blob) {
|
|
||||||
this.blob = function() {
|
|
||||||
var rejected = consumed(this)
|
|
||||||
if (rejected) {
|
|
||||||
return rejected
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._bodyBlob) {
|
|
||||||
return Promise.resolve(this._bodyBlob)
|
|
||||||
} else if (this._bodyArrayBuffer) {
|
|
||||||
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
||||||
} else if (this._bodyFormData) {
|
|
||||||
throw new Error('could not read FormData body as blob')
|
|
||||||
} else {
|
|
||||||
return Promise.resolve(new Blob([this._bodyText]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.arrayBuffer = function() {
|
|
||||||
if (this._bodyArrayBuffer) {
|
|
||||||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
||||||
} else {
|
|
||||||
return this.blob().then(readBlobAsArrayBuffer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.text = function() {
|
|
||||||
var rejected = consumed(this)
|
|
||||||
if (rejected) {
|
|
||||||
return rejected
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._bodyBlob) {
|
|
||||||
return readBlobAsText(this._bodyBlob)
|
|
||||||
} else if (this._bodyArrayBuffer) {
|
|
||||||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
||||||
} else if (this._bodyFormData) {
|
|
||||||
throw new Error('could not read FormData body as text')
|
|
||||||
} else {
|
|
||||||
return Promise.resolve(this._bodyText)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support.formData) {
|
|
||||||
this.formData = function() {
|
|
||||||
return this.text().then(decode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.json = function() {
|
|
||||||
return this.text().then(JSON.parse)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTP methods whose capitalization should be normalized
|
|
||||||
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']
|
|
||||||
|
|
||||||
function normalizeMethod(method) {
|
|
||||||
var upcased = method.toUpperCase()
|
|
||||||
return (methods.indexOf(upcased) > -1) ? upcased : method
|
|
||||||
}
|
|
||||||
|
|
||||||
function Request(input, options) {
|
|
||||||
options = options || {}
|
|
||||||
var body = options.body
|
|
||||||
|
|
||||||
if (input instanceof Request) {
|
|
||||||
if (input.bodyUsed) {
|
|
||||||
throw new TypeError('Already read')
|
|
||||||
}
|
|
||||||
this.url = input.url
|
|
||||||
this.credentials = input.credentials
|
|
||||||
if (!options.headers) {
|
|
||||||
this.headers = new Headers(input.headers)
|
|
||||||
}
|
|
||||||
this.method = input.method
|
|
||||||
this.mode = input.mode
|
|
||||||
if (!body && input._bodyInit != null) {
|
|
||||||
body = input._bodyInit
|
|
||||||
input.bodyUsed = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.url = String(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.credentials = options.credentials || this.credentials || 'omit'
|
|
||||||
if (options.headers || !this.headers) {
|
|
||||||
this.headers = new Headers(options.headers)
|
|
||||||
}
|
|
||||||
this.method = normalizeMethod(options.method || this.method || 'GET')
|
|
||||||
this.mode = options.mode || this.mode || null
|
|
||||||
this.referrer = null
|
|
||||||
|
|
||||||
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
||||||
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
||||||
}
|
|
||||||
this._initBody(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
Request.prototype.clone = function() {
|
|
||||||
return new Request(this, { body: this._bodyInit })
|
|
||||||
}
|
|
||||||
|
|
||||||
function decode(body) {
|
|
||||||
var form = new FormData()
|
|
||||||
body.trim().split('&').forEach(function(bytes) {
|
|
||||||
if (bytes) {
|
|
||||||
var split = bytes.split('=')
|
|
||||||
var name = split.shift().replace(/\+/g, ' ')
|
|
||||||
var value = split.join('=').replace(/\+/g, ' ')
|
|
||||||
form.append(decodeURIComponent(name), decodeURIComponent(value))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return form
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseHeaders(rawHeaders) {
|
|
||||||
var headers = new Headers()
|
|
||||||
rawHeaders.split(/\r?\n/).forEach(function(line) {
|
|
||||||
var parts = line.split(':')
|
|
||||||
var key = parts.shift().trim()
|
|
||||||
if (key) {
|
|
||||||
var value = parts.join(':').trim()
|
|
||||||
headers.append(key, value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return headers
|
|
||||||
}
|
|
||||||
|
|
||||||
Body.call(Request.prototype)
|
|
||||||
|
|
||||||
function Response(bodyInit, options) {
|
|
||||||
if (!options) {
|
|
||||||
options = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.type = 'default'
|
|
||||||
this.status = 'status' in options ? options.status : 200
|
|
||||||
this.ok = this.status >= 200 && this.status < 300
|
|
||||||
this.statusText = 'statusText' in options ? options.statusText : 'OK'
|
|
||||||
this.headers = new Headers(options.headers)
|
|
||||||
this.url = options.url || ''
|
|
||||||
this._initBody(bodyInit)
|
|
||||||
}
|
|
||||||
|
|
||||||
Body.call(Response.prototype)
|
|
||||||
|
|
||||||
Response.prototype.clone = function() {
|
|
||||||
return new Response(this._bodyInit, {
|
|
||||||
status: this.status,
|
|
||||||
statusText: this.statusText,
|
|
||||||
headers: new Headers(this.headers),
|
|
||||||
url: this.url
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Response.error = function() {
|
|
||||||
var response = new Response(null, {status: 0, statusText: ''})
|
|
||||||
response.type = 'error'
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
var redirectStatuses = [301, 302, 303, 307, 308]
|
|
||||||
|
|
||||||
Response.redirect = function(url, status) {
|
|
||||||
if (redirectStatuses.indexOf(status) === -1) {
|
|
||||||
throw new RangeError('Invalid status code')
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response(null, {status: status, headers: {location: url}})
|
|
||||||
}
|
|
||||||
|
|
||||||
self.Headers = Headers
|
|
||||||
self.Request = Request
|
|
||||||
self.Response = Response
|
|
||||||
|
|
||||||
self.fetch = function(input, init) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var request = new Request(input, init)
|
|
||||||
var xhr = new XMLHttpRequest()
|
|
||||||
|
|
||||||
xhr.onload = function() {
|
|
||||||
var options = {
|
|
||||||
status: xhr.status,
|
|
||||||
statusText: xhr.statusText,
|
|
||||||
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
||||||
}
|
|
||||||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
|
|
||||||
var body = 'response' in xhr ? xhr.response : xhr.responseText
|
|
||||||
resolve(new Response(body, options))
|
|
||||||
}
|
|
||||||
|
|
||||||
xhr.onerror = function() {
|
|
||||||
reject(new TypeError('Network request failed'))
|
|
||||||
}
|
|
||||||
|
|
||||||
xhr.ontimeout = function() {
|
|
||||||
reject(new TypeError('Network request failed'))
|
|
||||||
}
|
|
||||||
|
|
||||||
xhr.open(request.method, request.url, true)
|
|
||||||
|
|
||||||
if (request.credentials === 'include') {
|
|
||||||
xhr.withCredentials = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('responseType' in xhr && support.blob) {
|
|
||||||
xhr.responseType = 'blob'
|
|
||||||
}
|
|
||||||
|
|
||||||
request.headers.forEach(function(value, name) {
|
|
||||||
xhr.setRequestHeader(name, value)
|
|
||||||
})
|
|
||||||
|
|
||||||
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
self.fetch.polyfill = true
|
|
||||||
})(typeof self !== 'undefined' ? self : this);
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
function toArray(arr) {
|
|
||||||
return Array.prototype.slice.call(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisifyRequest(request) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
request.onsuccess = function() {
|
|
||||||
resolve(request.result);
|
|
||||||
};
|
|
||||||
|
|
||||||
request.onerror = function() {
|
|
||||||
reject(request.error);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisifyRequestCall(obj, method, args) {
|
|
||||||
var request;
|
|
||||||
var p = new Promise(function(resolve, reject) {
|
|
||||||
request = obj[method].apply(obj, args);
|
|
||||||
promisifyRequest(request).then(resolve, reject);
|
|
||||||
});
|
|
||||||
|
|
||||||
p.request = request;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisifyCursorRequestCall(obj, method, args) {
|
|
||||||
var p = promisifyRequestCall(obj, method, args);
|
|
||||||
return p.then(function(value) {
|
|
||||||
if (!value) return;
|
|
||||||
return new Cursor(value, p.request);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function proxyProperties(ProxyClass, targetProp, properties) {
|
|
||||||
properties.forEach(function(prop) {
|
|
||||||
Object.defineProperty(ProxyClass.prototype, prop, {
|
|
||||||
get: function() {
|
|
||||||
return this[targetProp][prop];
|
|
||||||
},
|
|
||||||
set: function(val) {
|
|
||||||
this[targetProp][prop] = val;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function proxyRequestMethods(ProxyClass, targetProp, Constructor, properties) {
|
|
||||||
properties.forEach(function(prop) {
|
|
||||||
if (!(prop in Constructor.prototype)) return;
|
|
||||||
ProxyClass.prototype[prop] = function() {
|
|
||||||
return promisifyRequestCall(this[targetProp], prop, arguments);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function proxyMethods(ProxyClass, targetProp, Constructor, properties) {
|
|
||||||
properties.forEach(function(prop) {
|
|
||||||
if (!(prop in Constructor.prototype)) return;
|
|
||||||
ProxyClass.prototype[prop] = function() {
|
|
||||||
return this[targetProp][prop].apply(this[targetProp], arguments);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function proxyCursorRequestMethods(ProxyClass, targetProp, Constructor, properties) {
|
|
||||||
properties.forEach(function(prop) {
|
|
||||||
if (!(prop in Constructor.prototype)) return;
|
|
||||||
ProxyClass.prototype[prop] = function() {
|
|
||||||
return promisifyCursorRequestCall(this[targetProp], prop, arguments);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function Index(index) {
|
|
||||||
this._index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxyProperties(Index, '_index', [
|
|
||||||
'name',
|
|
||||||
'keyPath',
|
|
||||||
'multiEntry',
|
|
||||||
'unique'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyRequestMethods(Index, '_index', IDBIndex, [
|
|
||||||
'get',
|
|
||||||
'getKey',
|
|
||||||
'getAll',
|
|
||||||
'getAllKeys',
|
|
||||||
'count'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyCursorRequestMethods(Index, '_index', IDBIndex, [
|
|
||||||
'openCursor',
|
|
||||||
'openKeyCursor'
|
|
||||||
]);
|
|
||||||
|
|
||||||
function Cursor(cursor, request) {
|
|
||||||
this._cursor = cursor;
|
|
||||||
this._request = request;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxyProperties(Cursor, '_cursor', [
|
|
||||||
'direction',
|
|
||||||
'key',
|
|
||||||
'primaryKey',
|
|
||||||
'value'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyRequestMethods(Cursor, '_cursor', IDBCursor, [
|
|
||||||
'update',
|
|
||||||
'delete'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// proxy 'next' methods
|
|
||||||
['advance', 'continue', 'continuePrimaryKey'].forEach(function(methodName) {
|
|
||||||
if (!(methodName in IDBCursor.prototype)) return;
|
|
||||||
Cursor.prototype[methodName] = function() {
|
|
||||||
var cursor = this;
|
|
||||||
var args = arguments;
|
|
||||||
return Promise.resolve().then(function() {
|
|
||||||
cursor._cursor[methodName].apply(cursor._cursor, args);
|
|
||||||
return promisifyRequest(cursor._request).then(function(value) {
|
|
||||||
if (!value) return;
|
|
||||||
return new Cursor(value, cursor._request);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function ObjectStore(store) {
|
|
||||||
this._store = store;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectStore.prototype.createIndex = function() {
|
|
||||||
return new Index(this._store.createIndex.apply(this._store, arguments));
|
|
||||||
};
|
|
||||||
|
|
||||||
ObjectStore.prototype.index = function() {
|
|
||||||
return new Index(this._store.index.apply(this._store, arguments));
|
|
||||||
};
|
|
||||||
|
|
||||||
proxyProperties(ObjectStore, '_store', [
|
|
||||||
'name',
|
|
||||||
'keyPath',
|
|
||||||
'indexNames',
|
|
||||||
'autoIncrement'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyRequestMethods(ObjectStore, '_store', IDBObjectStore, [
|
|
||||||
'put',
|
|
||||||
'add',
|
|
||||||
'delete',
|
|
||||||
'clear',
|
|
||||||
'get',
|
|
||||||
'getAll',
|
|
||||||
'getKey',
|
|
||||||
'getAllKeys',
|
|
||||||
'count'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyCursorRequestMethods(ObjectStore, '_store', IDBObjectStore, [
|
|
||||||
'openCursor',
|
|
||||||
'openKeyCursor'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyMethods(ObjectStore, '_store', IDBObjectStore, [
|
|
||||||
'deleteIndex'
|
|
||||||
]);
|
|
||||||
|
|
||||||
function Transaction(idbTransaction) {
|
|
||||||
this._tx = idbTransaction;
|
|
||||||
this.complete = new Promise(function(resolve, reject) {
|
|
||||||
idbTransaction.oncomplete = function() {
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
idbTransaction.onerror = function() {
|
|
||||||
reject(idbTransaction.error);
|
|
||||||
};
|
|
||||||
idbTransaction.onabort = function() {
|
|
||||||
reject(idbTransaction.error);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Transaction.prototype.objectStore = function() {
|
|
||||||
return new ObjectStore(this._tx.objectStore.apply(this._tx, arguments));
|
|
||||||
};
|
|
||||||
|
|
||||||
proxyProperties(Transaction, '_tx', [
|
|
||||||
'objectStoreNames',
|
|
||||||
'mode'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyMethods(Transaction, '_tx', IDBTransaction, [
|
|
||||||
'abort'
|
|
||||||
]);
|
|
||||||
|
|
||||||
function UpgradeDB(db, oldVersion, transaction) {
|
|
||||||
this._db = db;
|
|
||||||
this.oldVersion = oldVersion;
|
|
||||||
this.transaction = new Transaction(transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpgradeDB.prototype.createObjectStore = function() {
|
|
||||||
return new ObjectStore(this._db.createObjectStore.apply(this._db, arguments));
|
|
||||||
};
|
|
||||||
|
|
||||||
proxyProperties(UpgradeDB, '_db', [
|
|
||||||
'name',
|
|
||||||
'version',
|
|
||||||
'objectStoreNames'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyMethods(UpgradeDB, '_db', IDBDatabase, [
|
|
||||||
'deleteObjectStore',
|
|
||||||
'close'
|
|
||||||
]);
|
|
||||||
|
|
||||||
function DB(db) {
|
|
||||||
this._db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB.prototype.transaction = function() {
|
|
||||||
return new Transaction(this._db.transaction.apply(this._db, arguments));
|
|
||||||
};
|
|
||||||
|
|
||||||
proxyProperties(DB, '_db', [
|
|
||||||
'name',
|
|
||||||
'version',
|
|
||||||
'objectStoreNames'
|
|
||||||
]);
|
|
||||||
|
|
||||||
proxyMethods(DB, '_db', IDBDatabase, [
|
|
||||||
'close'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Add cursor iterators
|
|
||||||
// TODO: remove this once browsers do the right thing with promises
|
|
||||||
['openCursor', 'openKeyCursor'].forEach(function(funcName) {
|
|
||||||
[ObjectStore, Index].forEach(function(Constructor) {
|
|
||||||
Constructor.prototype[funcName.replace('open', 'iterate')] = function() {
|
|
||||||
var args = toArray(arguments);
|
|
||||||
var callback = args[args.length - 1];
|
|
||||||
var nativeObject = this._store || this._index;
|
|
||||||
var request = nativeObject[funcName].apply(nativeObject, args.slice(0, -1));
|
|
||||||
request.onsuccess = function() {
|
|
||||||
callback(request.result);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// polyfill getAll
|
|
||||||
[Index, ObjectStore].forEach(function(Constructor) {
|
|
||||||
if (Constructor.prototype.getAll) return;
|
|
||||||
Constructor.prototype.getAll = function(query, count) {
|
|
||||||
var instance = this;
|
|
||||||
var items = [];
|
|
||||||
|
|
||||||
return new Promise(function(resolve) {
|
|
||||||
instance.iterateCursor(query, function(cursor) {
|
|
||||||
if (!cursor) {
|
|
||||||
resolve(items);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
items.push(cursor.value);
|
|
||||||
|
|
||||||
if (count !== undefined && items.length == count) {
|
|
||||||
resolve(items);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cursor.continue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
var exp = {
|
|
||||||
open: function(name, version, upgradeCallback) {
|
|
||||||
var p = promisifyRequestCall(indexedDB, 'open', [name, version]);
|
|
||||||
var request = p.request;
|
|
||||||
|
|
||||||
request.onupgradeneeded = function(event) {
|
|
||||||
if (upgradeCallback) {
|
|
||||||
upgradeCallback(new UpgradeDB(request.result, event.oldVersion, request.transaction));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return p.then(function(db) {
|
|
||||||
return new DB(db);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
delete: function(name) {
|
|
||||||
return promisifyRequestCall(indexedDB, 'deleteDatabase', [name]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
|
||||||
module.exports = exp;
|
|
||||||
module.exports.default = module.exports;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.idb = exp;
|
|
||||||
}
|
|
||||||
}());
|
|
||||||
8
src/statics/js/immortal-db.min.js
vendored
8
src/statics/js/immortal-db.min.js
vendored
File diff suppressed because one or more lines are too long
10
src/statics/js/material.min.js
vendored
10
src/statics/js/material.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,372 +0,0 @@
|
|||||||
/**
|
|
||||||
* setImmediate polyfill v1.0.1, supports IE9+
|
|
||||||
* © 2014–2015 Dmitry Korobkin
|
|
||||||
* Released under the MIT license
|
|
||||||
* github.com/Octane/setImmediate
|
|
||||||
*/
|
|
||||||
window.setImmediate || function () {'use strict';
|
|
||||||
|
|
||||||
var uid = 0;
|
|
||||||
var storage = {};
|
|
||||||
var firstCall = true;
|
|
||||||
var slice = Array.prototype.slice;
|
|
||||||
var message = 'setImmediatePolyfillMessage';
|
|
||||||
|
|
||||||
function fastApply(args) {
|
|
||||||
var func = args[0];
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
return func();
|
|
||||||
case 2:
|
|
||||||
return func(args[1]);
|
|
||||||
case 3:
|
|
||||||
return func(args[1], args[2]);
|
|
||||||
}
|
|
||||||
return func.apply(window, slice.call(args, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
function callback(event) {
|
|
||||||
var key = event.data;
|
|
||||||
var data;
|
|
||||||
if (typeof key == 'string' && key.indexOf(message) == 0) {
|
|
||||||
data = storage[key];
|
|
||||||
if (data) {
|
|
||||||
delete storage[key];
|
|
||||||
fastApply(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.setImmediate = function setImmediate() {
|
|
||||||
var id = uid++;
|
|
||||||
var key = message + id;
|
|
||||||
var i = arguments.length;
|
|
||||||
var args = new Array(i);
|
|
||||||
while (i--) {
|
|
||||||
args[i] = arguments[i];
|
|
||||||
}
|
|
||||||
storage[key] = args;
|
|
||||||
if (firstCall) {
|
|
||||||
firstCall = false;
|
|
||||||
window.addEventListener('message', callback);
|
|
||||||
}
|
|
||||||
window.postMessage(key, '*');
|
|
||||||
return id;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.clearImmediate = function clearImmediate(id) {
|
|
||||||
delete storage[message + id];
|
|
||||||
};
|
|
||||||
|
|
||||||
}();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Promise polyfill v1.0.10
|
|
||||||
* requires setImmediate
|
|
||||||
*
|
|
||||||
* © 2014–2015 Dmitry Korobkin
|
|
||||||
* Released under the MIT license
|
|
||||||
* github.com/Octane/Promise
|
|
||||||
*/
|
|
||||||
(function (global) {'use strict';
|
|
||||||
|
|
||||||
var STATUS = '[[PromiseStatus]]';
|
|
||||||
var VALUE = '[[PromiseValue]]';
|
|
||||||
var ON_FUlFILLED = '[[OnFulfilled]]';
|
|
||||||
var ON_REJECTED = '[[OnRejected]]';
|
|
||||||
var ORIGINAL_ERROR = '[[OriginalError]]';
|
|
||||||
var PENDING = 'pending';
|
|
||||||
var INTERNAL_PENDING = 'internal pending';
|
|
||||||
var FULFILLED = 'fulfilled';
|
|
||||||
var REJECTED = 'rejected';
|
|
||||||
var NOT_ARRAY = 'not an array.';
|
|
||||||
var REQUIRES_NEW = 'constructor Promise requires "new".';
|
|
||||||
var CHAINING_CYCLE = 'then() cannot return same Promise that it resolves.';
|
|
||||||
|
|
||||||
var setImmediate = global.setImmediate || require('timers').setImmediate;
|
|
||||||
var isArray = Array.isArray || function (anything) {
|
|
||||||
return Object.prototype.toString.call(anything) == '[object Array]';
|
|
||||||
};
|
|
||||||
|
|
||||||
function InternalError(originalError) {
|
|
||||||
this[ORIGINAL_ERROR] = originalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isInternalError(anything) {
|
|
||||||
return anything instanceof InternalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isObject(anything) {
|
|
||||||
//Object.create(null) instanceof Object → false
|
|
||||||
return Object(anything) === anything;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCallable(anything) {
|
|
||||||
return typeof anything == 'function';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPromise(anything) {
|
|
||||||
return anything instanceof Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
function identity(value) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function thrower(reason) {
|
|
||||||
throw reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
function enqueue(promise, onFulfilled, onRejected) {
|
|
||||||
if (!promise[ON_FUlFILLED]) {
|
|
||||||
promise[ON_FUlFILLED] = [];
|
|
||||||
promise[ON_REJECTED] = [];
|
|
||||||
}
|
|
||||||
promise[ON_FUlFILLED].push(onFulfilled);
|
|
||||||
promise[ON_REJECTED].push(onRejected);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAllQueues(promise) {
|
|
||||||
delete promise[ON_FUlFILLED];
|
|
||||||
delete promise[ON_REJECTED];
|
|
||||||
}
|
|
||||||
|
|
||||||
function callEach(queue) {
|
|
||||||
var i;
|
|
||||||
var length = queue.length;
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
queue[i]();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function call(resolve, reject, value) {
|
|
||||||
var anything = toPromise(value);
|
|
||||||
if (isPromise(anything)) {
|
|
||||||
anything.then(resolve, reject);
|
|
||||||
} else if (isInternalError(anything)) {
|
|
||||||
reject(anything[ORIGINAL_ERROR]);
|
|
||||||
} else {
|
|
||||||
resolve(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toPromise(anything) {
|
|
||||||
var then;
|
|
||||||
if (isPromise(anything)) {
|
|
||||||
return anything;
|
|
||||||
}
|
|
||||||
if(isObject(anything)) {
|
|
||||||
try {
|
|
||||||
then = anything.then;
|
|
||||||
} catch (error) {
|
|
||||||
return new InternalError(error);
|
|
||||||
}
|
|
||||||
if (isCallable(then)) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
setImmediate(function () {
|
|
||||||
try {
|
|
||||||
then.call(anything, resolve, reject);
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolvePromise(promise, resolver) {
|
|
||||||
function resolve(value) {
|
|
||||||
if (promise[STATUS] == PENDING) {
|
|
||||||
fulfillPromise(promise, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function reject(reason) {
|
|
||||||
if (promise[STATUS] == PENDING) {
|
|
||||||
rejectPromise(promise, reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
resolver(resolve, reject);
|
|
||||||
} catch(error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fulfillPromise(promise, value) {
|
|
||||||
var queue;
|
|
||||||
var anything = toPromise(value);
|
|
||||||
if (isPromise(anything)) {
|
|
||||||
promise[STATUS] = INTERNAL_PENDING;
|
|
||||||
anything.then(
|
|
||||||
function (value) {
|
|
||||||
fulfillPromise(promise, value);
|
|
||||||
},
|
|
||||||
function (reason) {
|
|
||||||
rejectPromise(promise, reason);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else if (isInternalError(anything)) {
|
|
||||||
rejectPromise(promise, anything[ORIGINAL_ERROR]);
|
|
||||||
} else {
|
|
||||||
promise[STATUS] = FULFILLED;
|
|
||||||
promise[VALUE] = value;
|
|
||||||
queue = promise[ON_FUlFILLED];
|
|
||||||
if (queue && queue.length) {
|
|
||||||
clearAllQueues(promise);
|
|
||||||
callEach(queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function rejectPromise(promise, reason) {
|
|
||||||
var queue = promise[ON_REJECTED];
|
|
||||||
promise[STATUS] = REJECTED;
|
|
||||||
promise[VALUE] = reason;
|
|
||||||
if (queue && queue.length) {
|
|
||||||
clearAllQueues(promise);
|
|
||||||
callEach(queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Promise(resolver) {
|
|
||||||
var promise = this;
|
|
||||||
if (!isPromise(promise)) {
|
|
||||||
throw new TypeError(REQUIRES_NEW);
|
|
||||||
}
|
|
||||||
promise[STATUS] = PENDING;
|
|
||||||
promise[VALUE] = undefined;
|
|
||||||
resolvePromise(promise, resolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.then = function (onFulfilled, onRejected) {
|
|
||||||
var promise = this;
|
|
||||||
var nextPromise;
|
|
||||||
onFulfilled = isCallable(onFulfilled) ? onFulfilled : identity;
|
|
||||||
onRejected = isCallable(onRejected) ? onRejected : thrower;
|
|
||||||
nextPromise = new Promise(function (resolve, reject) {
|
|
||||||
function tryCall(func) {
|
|
||||||
var value;
|
|
||||||
try {
|
|
||||||
value = func(promise[VALUE]);
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value === nextPromise) {
|
|
||||||
reject(new TypeError(CHAINING_CYCLE));
|
|
||||||
} else {
|
|
||||||
call(resolve, reject, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function asyncOnFulfilled() {
|
|
||||||
setImmediate(tryCall, onFulfilled);
|
|
||||||
}
|
|
||||||
function asyncOnRejected() {
|
|
||||||
setImmediate(tryCall, onRejected);
|
|
||||||
}
|
|
||||||
switch (promise[STATUS]) {
|
|
||||||
case FULFILLED:
|
|
||||||
asyncOnFulfilled();
|
|
||||||
break;
|
|
||||||
case REJECTED:
|
|
||||||
asyncOnRejected();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
enqueue(promise, asyncOnFulfilled, asyncOnRejected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return nextPromise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype['catch'] = function (onRejected) {
|
|
||||||
return this.then(identity, onRejected);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.resolve = function (value) {
|
|
||||||
var anything = toPromise(value);
|
|
||||||
if (isPromise(anything)) {
|
|
||||||
return anything;
|
|
||||||
}
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
if (isInternalError(anything)) {
|
|
||||||
reject(anything[ORIGINAL_ERROR]);
|
|
||||||
} else {
|
|
||||||
resolve(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.reject = function (reason) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.race = function (values) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
var i;
|
|
||||||
var length;
|
|
||||||
if (isArray(values)) {
|
|
||||||
length = values.length;
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
call(resolve, reject, values[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
reject(new TypeError(NOT_ARRAY));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.all = function (values) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
var fulfilledCount = 0;
|
|
||||||
var promiseCount = 0;
|
|
||||||
var anything;
|
|
||||||
var length;
|
|
||||||
var value;
|
|
||||||
var i;
|
|
||||||
if (isArray(values)) {
|
|
||||||
values = values.slice(0);
|
|
||||||
length = values.length;
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
value = values[i];
|
|
||||||
anything = toPromise(value);
|
|
||||||
if (isPromise(anything)) {
|
|
||||||
promiseCount++;
|
|
||||||
anything.then(
|
|
||||||
function (index) {
|
|
||||||
return function (value) {
|
|
||||||
values[index] = value;
|
|
||||||
fulfilledCount++;
|
|
||||||
if (fulfilledCount == promiseCount) {
|
|
||||||
resolve(values);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}(i),
|
|
||||||
reject
|
|
||||||
);
|
|
||||||
} else if (isInternalError(anything)) {
|
|
||||||
reject(anything[ORIGINAL_ERROR]);
|
|
||||||
} else {
|
|
||||||
//[1, , 3] → [1, undefined, 3]
|
|
||||||
values[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!promiseCount) {
|
|
||||||
resolve(values);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
reject(new TypeError(NOT_ARRAY));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof module != 'undefined' && module.exports) {
|
|
||||||
module.exports = global.Promise || Promise;
|
|
||||||
} else if (!global.Promise) {
|
|
||||||
global.Promise = Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
}(this));
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
let idbKeyval = (() => {
|
|
||||||
let db;
|
|
||||||
// console.log('idbKeyval...')
|
|
||||||
|
|
||||||
function getDB() {
|
|
||||||
if (!db) {
|
|
||||||
// console.log('CREO DB STORAGE JS !')
|
|
||||||
db = new Promise((resolve, reject) => {
|
|
||||||
const openreq = indexedDB.open('mydb3', 11);
|
|
||||||
|
|
||||||
openreq.onerror = () => {
|
|
||||||
reject(openreq.error);
|
|
||||||
};
|
|
||||||
|
|
||||||
openreq.onupgradeneeded = () => {
|
|
||||||
// First time setup: create an empty object store
|
|
||||||
openreq.result.createObjectStore('todos', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('sync_todos', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('sync_todos_patch', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('delete_todos', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('config', { keyPath: '_id' });
|
|
||||||
openreq.result.createObjectStore('swmsg', { keyPath: '_id' });
|
|
||||||
};
|
|
||||||
|
|
||||||
openreq.onsuccess = () => {
|
|
||||||
resolve(openreq.result);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function withStore(type, table, callback, ) {
|
|
||||||
const db = await getDB();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const transaction = db.transaction(table, type);
|
|
||||||
transaction.oncomplete = () => resolve();
|
|
||||||
transaction.onerror = () => reject(transaction.error);
|
|
||||||
callback(transaction.objectStore(table));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
async get(key) {
|
|
||||||
let req;
|
|
||||||
await withStore('readonly', 'keyval', store => {
|
|
||||||
req = store.get(key);
|
|
||||||
});
|
|
||||||
return req.result;
|
|
||||||
},
|
|
||||||
|
|
||||||
// jsonCopy(src) {
|
|
||||||
// return JSON.parse(JSON.stringify(src));
|
|
||||||
// },
|
|
||||||
|
|
||||||
// contains(a, b) {
|
|
||||||
// // array matches
|
|
||||||
// if (Array.isArray(b)) {
|
|
||||||
// return b.some(x => a.indexOf(x) > -1);
|
|
||||||
// }
|
|
||||||
// // string match
|
|
||||||
// return a.indexOf(b) > -1;
|
|
||||||
// },
|
|
||||||
|
|
||||||
async getdata(table, key) {
|
|
||||||
let req;
|
|
||||||
|
|
||||||
await withStore('readonly', table, store => {
|
|
||||||
// console.log('store', store, 'key', key)
|
|
||||||
req = store.get(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
return req.result;
|
|
||||||
},
|
|
||||||
async getalldata(table) {
|
|
||||||
let req;
|
|
||||||
await withStore('readonly', table, store => {
|
|
||||||
req = store.getAll();
|
|
||||||
});
|
|
||||||
return req.result;
|
|
||||||
},
|
|
||||||
async set(key, value) {
|
|
||||||
let req;
|
|
||||||
await withStore('readwrite', 'keyval', store => {
|
|
||||||
req = store.put(value, key);
|
|
||||||
});
|
|
||||||
return req.result;
|
|
||||||
},
|
|
||||||
async setdata(table, value) {
|
|
||||||
let req;
|
|
||||||
// console.log('setdata', table, value)
|
|
||||||
|
|
||||||
await withStore('readwrite', table, store => {
|
|
||||||
req = store.put(value);
|
|
||||||
});
|
|
||||||
return req.result;
|
|
||||||
},
|
|
||||||
async delete(key) {
|
|
||||||
return await withStore('readwrite', 'keyval', store => {
|
|
||||||
store.delete(key);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async deletedata(table, key) {
|
|
||||||
return await withStore('readwrite', table, store => {
|
|
||||||
store.delete(key);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async clearalldata(table) {
|
|
||||||
// console.log('clearalldata', table)
|
|
||||||
return await withStore('readwrite', table, store => {
|
|
||||||
store.clear();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// iOS add-to-homescreen is missing IDB, or at least it used to.
|
|
||||||
// I haven't tested this in a while.
|
|
||||||
if (!self.indexedDB) {
|
|
||||||
idbKeyval = {
|
|
||||||
get: key => Promise.resolve(localStorage.getItem(key)),
|
|
||||||
set: (key, val) => Promise.resolve(localStorage.setItem(key, val)),
|
|
||||||
delete: key => Promise.resolve(localStorage.removeItem(key))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -5,19 +5,24 @@ export class AxiosSuccess {
|
|||||||
public status: number
|
public status: number
|
||||||
public data: any
|
public data: any
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any, status: number) {
|
||||||
this.data = data
|
this.data = data
|
||||||
|
this.status = status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AxiosError {
|
export class AxiosError {
|
||||||
public success: boolean = false
|
public success: boolean = false
|
||||||
public status: number
|
public status: number = 0
|
||||||
public data: any
|
public data: any
|
||||||
|
public code: any = 0
|
||||||
|
public msgerr: string = ''
|
||||||
|
|
||||||
constructor(status: number, data?: any) {
|
constructor(status: number, data?: any, code?: any, msgerr?: string) {
|
||||||
this.status = status
|
this.status = status
|
||||||
this.data = data
|
this.data = data
|
||||||
|
this.code = code
|
||||||
|
this.msgerr = msgerr
|
||||||
if (status !== 401) {
|
if (status !== 401) {
|
||||||
// if (status == 0) message = 'Vérifiez votre connexion Internet';
|
// if (status == 0) message = 'Vérifiez votre connexion Internet';
|
||||||
// NotificationsStore.actions.addNotification({ type: 'warning', message: message })
|
// NotificationsStore.actions.addNotification({ type: 'warning', message: message })
|
||||||
@@ -28,6 +33,22 @@ export class AxiosError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getMsgError() {
|
||||||
|
if (this.data && this.data.error)
|
||||||
|
return this.data.error.message
|
||||||
|
|
||||||
|
return this.msgerr
|
||||||
|
}
|
||||||
|
public getCode() {
|
||||||
|
if (this.code === 0) {
|
||||||
|
if (this.data.code) {
|
||||||
|
return this.data.code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.code
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// export class ApiResponse {
|
// export class ApiResponse {
|
||||||
|
|||||||
@@ -1,50 +1,28 @@
|
|||||||
import axios, { AxiosInstance, AxiosPromise, AxiosResponse, AxiosInterceptorManager } from 'axios'
|
import axios, { AxiosInstance, AxiosPromise, AxiosResponse, AxiosInterceptorManager } from 'axios'
|
||||||
|
import Api from '@api'
|
||||||
|
import * as Types from '@src/store/Api/ApiTypes'
|
||||||
|
|
||||||
async function sendRequest(url: string, lang: string, mytok: string, method: string, mydata: any) {
|
async function sendRequest(url: string, method: string, mydata: any) {
|
||||||
|
|
||||||
console.log('sendRequest', method, url, '[', lang, ']')
|
if (!process.env.DEBUG)
|
||||||
|
console.log('sendRequest', method, url)
|
||||||
|
|
||||||
const authHeader = new Headers()
|
let request
|
||||||
authHeader.append('content-Type', 'application/json')
|
if (method === 'GET')
|
||||||
authHeader.append('Accept', 'application/json')
|
request = Api.get(url, mydata)
|
||||||
if (url !== process.env.MONGODB_HOST + '/users/login') {
|
else if (method === 'POST')
|
||||||
authHeader.append('x-auth', mytok)
|
request = Api.post(url, mydata)
|
||||||
// console.log('TOK PASSATO ALLA FETCH:', mytok)
|
else if (method === 'DELETE')
|
||||||
}
|
request = Api.Delete(url, mydata)
|
||||||
// authHeader.append('accept-language', lang)
|
else if (method === 'PUT')
|
||||||
|
request = Api.put(url, mydata)
|
||||||
|
else if (method === 'PATCH')
|
||||||
|
request = Api.patch(url, mydata)
|
||||||
|
|
||||||
let configInit: RequestInit
|
const req: Promise<Types.AxiosSuccess | Types.AxiosError> = request
|
||||||
|
return req
|
||||||
if (method === 'GET') {
|
|
||||||
configInit = {
|
|
||||||
method: method,
|
|
||||||
cache: 'no-cache',
|
|
||||||
mode: 'cors',
|
|
||||||
headers: authHeader
|
|
||||||
}
|
|
||||||
} else if (method === 'DELETE') {
|
|
||||||
configInit = {
|
|
||||||
method: method,
|
|
||||||
cache: 'no-cache',
|
|
||||||
mode: 'cors',
|
|
||||||
headers: authHeader
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
configInit = {
|
|
||||||
method: method,
|
|
||||||
cache: 'no-cache',
|
|
||||||
mode: 'cors',
|
|
||||||
headers: authHeader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mydata !== null)
|
|
||||||
configInit.body = JSON.stringify(mydata)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const request: Promise<Response> = fetch(url, configInit)
|
|
||||||
return request
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default sendRequest
|
export default sendRequest
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ import axios, { AxiosInstance, AxiosPromise, AxiosResponse, AxiosInterceptorMana
|
|||||||
import router from '@router'
|
import router from '@router'
|
||||||
import { clone } from 'lodash'
|
import { clone } from 'lodash'
|
||||||
import * as Types from './ApiTypes'
|
import * as Types from './ApiTypes'
|
||||||
|
import { GlobalStore, UserStore } from '@store'
|
||||||
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||||
|
|
||||||
export const API_URL = process.env.API_URL
|
export const API_URL = process.env.MONGODB_HOST
|
||||||
export const axiosInstance: AxiosInstance = axios.create({
|
export const axiosInstance: AxiosInstance = axios.create({
|
||||||
baseURL: API_URL,
|
baseURL: API_URL,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -14,12 +17,16 @@ export const axiosInstance: AxiosInstance = axios.create({
|
|||||||
|
|
||||||
axiosInstance.interceptors.response.use(
|
axiosInstance.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
|
if (process.env.DEBUG === '1')
|
||||||
console.log(response)
|
console.log(response)
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
if (error.response) {
|
||||||
|
if (process.env.DEBUG === '1')
|
||||||
console.log(error.response.status)
|
console.log(error.response.status)
|
||||||
console.log('Request Error: ', error.response)
|
console.log('Request Error: ', error.response)
|
||||||
|
}
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -32,39 +39,104 @@ export const removeAuthHeaders = () => {
|
|||||||
delete axiosInstance.defaults.headers.Authorization
|
delete axiosInstance.defaults.headers.Authorization
|
||||||
}
|
}
|
||||||
|
|
||||||
async function Request(type: string, path: string, payload: any, noAuth?: boolean): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
async function Request(type: string, path: string, payload: any, setAuthToken?: boolean): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||||
|
let ricevuto = false
|
||||||
try {
|
try {
|
||||||
console.log(`Axios Request [${type}]:`, axiosInstance.defaults)
|
// console.log(`Axios Request [${type}]:`, axiosInstance.defaults)
|
||||||
let response: AxiosResponse
|
let response: AxiosResponse
|
||||||
if (type === 'post' || type === 'put') {
|
if (type === 'post' || type === 'put' || type === 'patch') {
|
||||||
response = await axiosInstance[type](path, payload, {
|
response = await axiosInstance[type](path, payload, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'x-auth': UserStore.state.x_auth_token
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(new Types.AxiosSuccess(response.data))
|
ricevuto = true
|
||||||
return new Types.AxiosSuccess(response.data)
|
// console.log('Request Response: ', response)
|
||||||
|
// console.log(new Types.AxiosSuccess(response.data, response.status))
|
||||||
|
|
||||||
|
const setAuthToken = (path === '/updatepwd')
|
||||||
|
|
||||||
|
if (response && (response.status === 200)) {
|
||||||
|
let x_auth_token = ''
|
||||||
|
try {
|
||||||
|
if (setAuthToken || (path === '/users/login')) {
|
||||||
|
x_auth_token = String(response.headers['x-auth'])
|
||||||
|
|
||||||
|
if (x_auth_token === '') {
|
||||||
|
UserStore.mutations.setServerCode(tools.ERR_AUTHENTICATION)
|
||||||
|
}
|
||||||
|
if (setAuthToken) {
|
||||||
|
UserStore.mutations.UpdatePwd(x_auth_token)
|
||||||
|
localStorage.setItem(tools.localStorage.token, x_auth_token)
|
||||||
|
}
|
||||||
|
|
||||||
|
UserStore.mutations.setAuth(x_auth_token)
|
||||||
|
localStorage.setItem(tools.localStorage.token, x_auth_token)
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
UserStore.mutations.setServerCode(tools.OK)
|
||||||
|
} catch (e) {
|
||||||
|
if (setAuthToken) {
|
||||||
|
UserStore.mutations.setServerCode(tools.ERR_AUTHENTICATION)
|
||||||
|
UserStore.mutations.setAuth('')
|
||||||
|
}
|
||||||
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
return Promise.reject(new Types.AxiosError(serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN, null, tools.ERR_AUTHENTICATION))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Types.AxiosSuccess(response.data, response.status)
|
||||||
} else if (type === 'get' || type === 'delete') {
|
} else if (type === 'get' || type === 'delete') {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
response = await axiosInstance[type](path, {
|
response = await axiosInstance[type](path, {
|
||||||
params: payload,
|
params: payload,
|
||||||
headers: {'Content-Type': 'application/json'}
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-auth': UserStore.state.x_auth_token
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return new Types.AxiosSuccess(response.data)
|
return new Types.AxiosSuccess(response.data, response.status)
|
||||||
} else if (type === 'postFormData') {
|
} else if (type === 'postFormData') {
|
||||||
response = await axiosInstance.post(path, payload, {
|
response = await axiosInstance.post(path, payload, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data',
|
||||||
|
'x-auth': UserStore.state.x_auth_token
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return new Types.AxiosSuccess(response.data)
|
return new Types.AxiosSuccess(response.data, response.status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (error.response) {
|
setTimeout(function () {
|
||||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data))
|
GlobalStore.state.connData.uploading_server = (GlobalStore.state.connData.uploading_server === 1) ? -1 : GlobalStore.state.connData.uploading_server
|
||||||
|
GlobalStore.state.connData.downloading_server = (GlobalStore.state.connData.downloading_server === 1) ? -1 : GlobalStore.state.connData.downloading_server
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('ERROR using', path)
|
||||||
|
// console.log('Error received: ', error)
|
||||||
|
// console.log('ricevuto=', ricevuto)
|
||||||
|
console.log('error.response=', error.response)
|
||||||
|
}
|
||||||
|
let mycode = 0
|
||||||
|
if (!ricevuto) {
|
||||||
|
mycode = tools.ERR_SERVERFETCH
|
||||||
|
UserStore.mutations.setServerCode(tools.ERR_SERVERFETCH)
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Types.AxiosError(0))
|
mycode = tools.ERR_GENERICO
|
||||||
|
UserStore.mutations.setServerCode(tools.ERR_GENERICO)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.response) {
|
||||||
|
if (error.response.data && error.response.data.code) {
|
||||||
|
mycode = error.response.data.code
|
||||||
|
UserStore.mutations.setServerCode(mycode)
|
||||||
|
}
|
||||||
|
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, error.response.data.code))
|
||||||
|
} else {
|
||||||
|
return Promise.reject(new Types.AxiosError(0, null, mycode, error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,33 +7,48 @@ import axios from 'axios'
|
|||||||
export { addAuthHeaders, removeAuthHeaders, API_URL } from './Instance'
|
export { addAuthHeaders, removeAuthHeaders, API_URL } from './Instance'
|
||||||
// import {AlgoliaSearch} from './AlgoliaController'
|
// import {AlgoliaSearch} from './AlgoliaController'
|
||||||
import Paths from '@paths'
|
import Paths from '@paths'
|
||||||
import { rescodes } from '@src/store/Modules/rescodes'
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
|
||||||
import { GlobalStore, UserStore } from '@modules'
|
import { GlobalStore, UserStore } from '@modules'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||||
import router from '@router'
|
import router from '@router'
|
||||||
|
import * as Types from '@src/store/Api/ApiTypes'
|
||||||
|
import { costanti } from '@src/store/Modules/costanti'
|
||||||
|
|
||||||
|
|
||||||
// const algoliaApi = new AlgoliaSearch()
|
// const algoliaApi = new AlgoliaSearch()
|
||||||
export namespace ApiTool {
|
export namespace ApiTool {
|
||||||
export async function post(path: string, payload?: any) {
|
export async function post(path: string, payload?: any) {
|
||||||
|
GlobalStore.state.connData.downloading_server = 1
|
||||||
|
GlobalStore.state.connData.uploading_server = 1
|
||||||
return await Request('post', path, payload)
|
return await Request('post', path, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postFormData(path: string, payload?: any) {
|
export async function postFormData(path: string, payload?: any) {
|
||||||
|
GlobalStore.state.connData.uploading_server = 1
|
||||||
|
GlobalStore.state.connData.downloading_server = 1
|
||||||
return await Request('postFormData', path, payload)
|
return await Request('postFormData', path, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get(path: string, payload?: any) {
|
export async function get(path: string, payload?: any) {
|
||||||
|
GlobalStore.state.connData.downloading_server = 1
|
||||||
|
GlobalStore.state.connData.uploading_server = 0
|
||||||
return await Request('get', path, payload)
|
return await Request('get', path, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function put(path: string, payload?: any) {
|
export async function put(path: string, payload?: any) {
|
||||||
|
GlobalStore.state.connData.uploading_server = 1
|
||||||
return await Request('put', path, payload)
|
return await Request('put', path, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function patch(path: string, payload?: any) {
|
||||||
|
GlobalStore.state.connData.uploading_server = 1
|
||||||
|
return await Request('patch', path, payload)
|
||||||
|
}
|
||||||
|
|
||||||
export async function Delete(path: string, payload: any) {
|
export async function Delete(path: string, payload: any) {
|
||||||
|
GlobalStore.state.connData.uploading_server = 1
|
||||||
return await Request('delete', path, payload)
|
return await Request('delete', path, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,92 +62,57 @@ export namespace ApiTool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function SendReq(url: string, method: string, mydata: any, setAuthToken: boolean = false) {
|
export async function SendReq(url: string, method: string, mydata: any, setAuthToken: boolean = false): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||||
UserStore.mutations.setServerCode(rescodes.EMPTY)
|
UserStore.mutations.setServerCode(tools.EMPTY)
|
||||||
UserStore.mutations.setResStatus(0)
|
UserStore.mutations.setResStatus(0)
|
||||||
return await new Promise(function (resolve, reject) {
|
return await new Promise(function (resolve, reject) {
|
||||||
let ricevuto = false
|
|
||||||
|
|
||||||
return sendRequest(url, UserStore.state.lang, UserStore.state.x_auth_token, method, mydata)
|
|
||||||
.then(resreceived => {
|
return sendRequest(url, method, mydata)
|
||||||
console.log('resreceived', resreceived)
|
.then(res => {
|
||||||
ricevuto = true
|
// console.log('res', res)
|
||||||
let res = resreceived.clone()
|
|
||||||
if (process.env.DEV) {
|
setTimeout(function () {
|
||||||
// console.log('SendReq RES [', res.status, ']', res)
|
if (method === 'get')
|
||||||
|
GlobalStore.state.connData.downloading_server = 0
|
||||||
|
else {
|
||||||
|
GlobalStore.state.connData.uploading_server = 0
|
||||||
|
GlobalStore.state.connData.downloading_server = 0
|
||||||
}
|
}
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
|
||||||
UserStore.mutations.setResStatus(res.status)
|
UserStore.mutations.setResStatus(res.status)
|
||||||
if (res.status === 200) {
|
if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
let x_auth_token = ''
|
|
||||||
try {
|
|
||||||
if (setAuthToken) {
|
|
||||||
x_auth_token = String(res.headers.get('x-auth'))
|
|
||||||
|
|
||||||
if (x_auth_token === '') {
|
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
|
||||||
}
|
|
||||||
UserStore.mutations.setAuth(x_auth_token)
|
|
||||||
|
|
||||||
if (url === process.env.MONGODB_HOST + '/updatepwd') {
|
|
||||||
UserStore.mutations.UpdatePwd({ x_auth_token })
|
|
||||||
localStorage.setItem(rescodes.localStorage.token, x_auth_token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UserStore.mutations.setServerCode(rescodes.OK)
|
|
||||||
} catch (e) {
|
|
||||||
if (setAuthToken) {
|
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
|
||||||
UserStore.mutations.setAuth('')
|
|
||||||
}
|
|
||||||
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
|
||||||
return reject({ code: rescodes.ERR_AUTHENTICATION })
|
|
||||||
}
|
|
||||||
} else if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
|
||||||
// Forbidden
|
// Forbidden
|
||||||
// You probably is connectiong with other page...
|
// You probably is connectiong with other page...
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
UserStore.mutations.setServerCode(tools.ERR_AUTHENTICATION)
|
||||||
UserStore.mutations.setAuth('')
|
UserStore.mutations.setAuth('')
|
||||||
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
|
||||||
router.push('/signin')
|
router.push('/signin')
|
||||||
return reject({ code: rescodes.ERR_AUTHENTICATION })
|
return reject({ code: tools.ERR_AUTHENTICATION })
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
return resolve(res)
|
||||||
|
|
||||||
return res.json()
|
|
||||||
.then((body) => {
|
|
||||||
// console.log('BODY RES = ', body)
|
|
||||||
return resolve({ res, body, status: res.status })
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
return resolve({ res, body: {}, status: res.status })
|
|
||||||
// Array not found...
|
|
||||||
// UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
|
||||||
// return reject({ code: rescodes.ERR_GENERICO, status: res.status })
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (process.env.DEV) {
|
setTimeout(function () {
|
||||||
console.log('ERROR using', url, error, 'ricevuto=', ricevuto)
|
if (method === 'get')
|
||||||
}
|
GlobalStore.state.connData.downloading_server = -1
|
||||||
if (!ricevuto) {
|
else {
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_SERVERFETCH)
|
GlobalStore.state.connData.uploading_server = -1
|
||||||
} else {
|
GlobalStore.state.connData.downloading_server = -1
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
|
||||||
}
|
}
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
console.log('error', error)
|
||||||
|
return reject(error)
|
||||||
return reject({ code: error })
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function syncAlternative(mystrparam) {
|
export async function syncAlternative(mystrparam) {
|
||||||
console.log('[ALTERNATIVE Background syncing', mystrparam)
|
// console.log('[ALTERNATIVE Background syncing', mystrparam)
|
||||||
|
|
||||||
let multiparams = mystrparam.split('|')
|
let multiparams = mystrparam.split('|')
|
||||||
if (multiparams) {
|
if (multiparams) {
|
||||||
@@ -146,10 +126,10 @@ export namespace ApiTool {
|
|||||||
if (cmd === 'sync-todos') {
|
if (cmd === 'sync-todos') {
|
||||||
// console.log('[Alternative] Syncing', cmd, table, method)
|
// console.log('[Alternative] Syncing', cmd, table, method)
|
||||||
|
|
||||||
const headers = new Headers()
|
// const headers = new Headers()
|
||||||
headers.append('content-Type', 'application/json')
|
// headers.append('content-Type', 'application/json')
|
||||||
headers.append('Accept', 'application/json')
|
// headers.append('Accept', 'application/json')
|
||||||
headers.append('x-auth', token)
|
// headers.append('x-auth', token)
|
||||||
|
|
||||||
let errorfromserver = false
|
let errorfromserver = false
|
||||||
let lettoqualcosa = false
|
let lettoqualcosa = false
|
||||||
@@ -162,7 +142,8 @@ export namespace ApiTool {
|
|||||||
|
|
||||||
const promises = myrecs.map(rec => {
|
const promises = myrecs.map(rec => {
|
||||||
// console.log('syncing', table, '', rec.descr)
|
// console.log('syncing', table, '', rec.descr)
|
||||||
let link = process.env.MONGODB_HOST + '/todos'
|
// let link = String(process.env.MONGODB_HOST) + '/todos'
|
||||||
|
let link = '/todos'
|
||||||
|
|
||||||
if (method !== 'POST')
|
if (method !== 'POST')
|
||||||
link += '/' + rec._id
|
link += '/' + rec._id
|
||||||
@@ -170,13 +151,14 @@ export namespace ApiTool {
|
|||||||
// console.log(' [Alternative] ++++++++++++++++++ SYNCING !!!! ', rec.descr, table, 'FETCH: ', method, link, 'data:')
|
// console.log(' [Alternative] ++++++++++++++++++ SYNCING !!!! ', rec.descr, table, 'FETCH: ', method, link, 'data:')
|
||||||
|
|
||||||
// Insert/Delete/Update table to the server
|
// Insert/Delete/Update table to the server
|
||||||
return fetch(link, {
|
return SendReq(link, method, rec)
|
||||||
method: method,
|
// return fetch(link, {
|
||||||
headers: headers,
|
// method: method,
|
||||||
cache: 'no-cache',
|
// headers: headers,
|
||||||
mode: 'cors', // 'no-cors',
|
// cache: 'no-cache',
|
||||||
body: JSON.stringify(rec)
|
// mode: 'cors', // 'no-cors',
|
||||||
})
|
// body: JSON.stringify(rec)
|
||||||
|
// })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
lettoqualcosa = true
|
lettoqualcosa = true
|
||||||
return globalroutines(null, 'delete', table, null, rec._id)
|
return globalroutines(null, 'delete', table, null, rec._id)
|
||||||
@@ -207,7 +189,8 @@ export namespace ApiTool {
|
|||||||
// console.log('¨¨¨¨¨¨¨¨¨¨¨¨¨¨ errorfromserver:', errorfromserver)
|
// console.log('¨¨¨¨¨¨¨¨¨¨¨¨¨¨ errorfromserver:', errorfromserver)
|
||||||
const mystate = errorfromserver ? 'offline' : 'online'
|
const mystate = errorfromserver ? 'offline' : 'online'
|
||||||
GlobalStore.mutations.setStateConnection(mystate)
|
GlobalStore.mutations.setStateConnection(mystate)
|
||||||
return globalroutines(null, 'write', 'config', { _id: 2, stateconn: mystate })
|
GlobalStore.mutations.saveConfig( { _id: costanti.CONFIG_ID_STATE_CONN, value: mystate })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!!')
|
// console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!!')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IGlobalState, StateConnection } from 'model'
|
import { ICfgServer, IConfig, IGlobalState, StateConnection } from 'model'
|
||||||
import { storeBuilder } from './Store/Store'
|
import { storeBuilder } from './Store/Store'
|
||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
@@ -8,22 +8,16 @@ import translate from './../../globalroutines/util'
|
|||||||
import urlBase64ToUint8Array from '../../js/utility'
|
import urlBase64ToUint8Array from '../../js/utility'
|
||||||
|
|
||||||
import messages from '../../statics/i18n'
|
import messages from '../../statics/i18n'
|
||||||
import { GlobalStore, UserStore } from '@store'
|
import { GlobalStore, Todos, UserStore } from '@store'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
import Api from "@api"
|
import Api from '@api'
|
||||||
import { rescodes } from "@src/store/Modules/rescodes"
|
import { tools } from '@src/store/Modules/tools'
|
||||||
|
import { costanti } from '@src/store/Modules/costanti'
|
||||||
|
import * as Types from '@src/store/Api/ApiTypes'
|
||||||
|
|
||||||
const allTables = ['todos', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
const allTables = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
||||||
const allTablesAfterLogin = ['todos', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
const allTablesAfterLogin = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
||||||
|
|
||||||
async function getstateConnSaved() {
|
|
||||||
const config = await globalroutines(null, 'readall', 'config', null)
|
|
||||||
if (config.length > 1) {
|
|
||||||
return config[1].stateconn
|
|
||||||
} else {
|
|
||||||
return 'online'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let stateConnDefault = 'online'
|
let stateConnDefault = 'online'
|
||||||
|
|
||||||
@@ -42,13 +36,42 @@ const state: IGlobalState = {
|
|||||||
menuCollapse: true,
|
menuCollapse: true,
|
||||||
leftDrawerOpen: true,
|
leftDrawerOpen: true,
|
||||||
stateConnection: stateConnDefault,
|
stateConnection: stateConnDefault,
|
||||||
|
networkDataReceived: false,
|
||||||
|
cfgServer: [],
|
||||||
|
testp1: { contatore: 0, mioarray: [] },
|
||||||
category: 'personal',
|
category: 'personal',
|
||||||
posts: [],
|
posts: [],
|
||||||
listatodo: [
|
listatodo: [
|
||||||
{ namecat: 'personal', description: 'personal' },
|
{ namecat: 'personal', description: 'personal' },
|
||||||
{ namecat: 'work', description: 'work' },
|
{ namecat: 'work', description: 'work' },
|
||||||
{ namecat: 'shopping', description: 'shopping' }
|
{ namecat: 'shopping', description: 'shopping' }
|
||||||
]
|
],
|
||||||
|
connData: {
|
||||||
|
uploading_server: 0,
|
||||||
|
uploading_indexeddb: 0,
|
||||||
|
downloading_server: 0,
|
||||||
|
downloading_indexeddb: 0
|
||||||
|
},
|
||||||
|
arrConfig: []
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getConfig(id) {
|
||||||
|
return await globalroutines(null, 'read', 'config', null, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getstateConnSaved() {
|
||||||
|
const config = await getConfig(costanti.CONFIG_ID_CFG)
|
||||||
|
console.log('config', config)
|
||||||
|
if (config) {
|
||||||
|
if (config.length > 1) {
|
||||||
|
const cfgstateconn = config[1]
|
||||||
|
return cfgstateconn.stateconn
|
||||||
|
} else {
|
||||||
|
return 'online'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 'offline'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +84,37 @@ namespace Getters {
|
|||||||
const listatodo = b.read(state => state.listatodo, 'listatodo')
|
const listatodo = b.read(state => state.listatodo, 'listatodo')
|
||||||
const category = b.read(state => state.category, 'category')
|
const category = b.read(state => state.category, 'category')
|
||||||
|
|
||||||
|
const testpao1_getter_contatore = b.read(state => param1 => state.testp1.contatore + 100 + param1, 'testpao1_getter_contatore')
|
||||||
|
const testpao1_getter_array = b.read(state => param1 => state.testp1.mioarray.filter(item => item).map(item => item.valore), 'testpao1_getter_array')
|
||||||
|
|
||||||
|
const getConfigbyId = b.read(state => id => state.arrConfig.find(item => item._id === id), 'getConfigbyId')
|
||||||
|
const getConfigStringbyId = b.read(state => params => {
|
||||||
|
const config = state.arrConfig.find(item => item._id === params.id)
|
||||||
|
if (config) {
|
||||||
|
return config.value
|
||||||
|
} else {
|
||||||
|
return params.default
|
||||||
|
}
|
||||||
|
}, 'getConfigStringbyId')
|
||||||
|
|
||||||
|
const showtype = b.read(state => {
|
||||||
|
// const config = state.arrConfig.find(item => item._id === cat + costanti.CONFIG_ID_SHOW_TYPE_TODOS)
|
||||||
|
const config = state.arrConfig.find(item => item._id === costanti.CONFIG_ID_SHOW_TYPE_TODOS)
|
||||||
|
if (config)
|
||||||
|
return config.value
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
|
||||||
|
}, 'showtype')
|
||||||
|
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
|
get testpao1_getter_contatore() {
|
||||||
|
return testpao1_getter_contatore()
|
||||||
|
},
|
||||||
|
get testpao1_getter_array() {
|
||||||
|
return testpao1_getter_array()
|
||||||
|
},
|
||||||
get conta() {
|
get conta() {
|
||||||
return conta()
|
return conta()
|
||||||
},
|
},
|
||||||
@@ -74,13 +127,51 @@ namespace Getters {
|
|||||||
return category()
|
return category()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get getConfigbyId() {
|
||||||
|
return getConfigbyId()
|
||||||
|
},
|
||||||
|
|
||||||
|
get getConfigStringbyId() {
|
||||||
|
return getConfigStringbyId()
|
||||||
|
},
|
||||||
|
|
||||||
|
get showtype() {
|
||||||
|
return showtype()
|
||||||
|
},
|
||||||
|
|
||||||
get isOnline() {
|
get isOnline() {
|
||||||
|
console.log('*********************** isOnline')
|
||||||
return state.stateConnection === 'online'
|
return state.stateConnection === 'online'
|
||||||
|
},
|
||||||
|
|
||||||
|
get isNewVersionAvailable() {
|
||||||
|
console.log('state.cfgServer', state.cfgServer)
|
||||||
|
const serversrec = state.cfgServer.find(x => x.chiave === tools.SERVKEY_VERS)
|
||||||
|
console.log('Record ', serversrec)
|
||||||
|
if (serversrec) {
|
||||||
|
console.log('Vers Server ', serversrec.valore, 'Vers locale:', process.env.APP_VERSION)
|
||||||
|
return serversrec.valore !== process.env.APP_VERSION
|
||||||
|
} else
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Mutations {
|
namespace Mutations {
|
||||||
|
function setPaoArray(state: IGlobalState, miorec: ICfgServer) {
|
||||||
|
state.testp1.mioarray[state.testp1.mioarray.length - 1] = miorec
|
||||||
|
|
||||||
|
tools.notifyarraychanged(state.testp1.mioarray)
|
||||||
|
console.log('last elem = ', state.testp1.mioarray[state.testp1.mioarray.length - 1])
|
||||||
|
}
|
||||||
|
|
||||||
|
function NewArray(state: IGlobalState, newarr: ICfgServer[]) {
|
||||||
|
state.testp1.mioarray = newarr
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPaoArray_Delete(state: IGlobalState) {
|
||||||
|
state.testp1.mioarray.pop()
|
||||||
|
}
|
||||||
|
|
||||||
function setConta(state: IGlobalState, num: number) {
|
function setConta(state: IGlobalState, num: number) {
|
||||||
state.conta = num
|
state.conta = num
|
||||||
@@ -101,16 +192,42 @@ namespace Mutations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveConfig(state: IGlobalState, data: IConfig) {
|
||||||
|
let dataout
|
||||||
|
// this.$set(dataout, data.value, {'value': 'default value'})
|
||||||
|
return globalroutines(null, 'write', 'config', { _id: data._id, value: data.value })
|
||||||
|
}
|
||||||
|
|
||||||
function SetwasAlreadySubOnDb(state: IGlobalState, subscrib: boolean) {
|
function SetwasAlreadySubOnDb(state: IGlobalState, subscrib: boolean) {
|
||||||
state.wasAlreadySubOnDb = subscrib
|
state.wasAlreadySubOnDb = subscrib
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setShowType(state: IGlobalState, showtype: number) {
|
||||||
|
console.log('setShowType', showtype)
|
||||||
|
const config = Getters.getters.getConfigbyId(costanti.CONFIG_ID_SHOW_TYPE_TODOS)
|
||||||
|
console.log('config', config)
|
||||||
|
if (config) {
|
||||||
|
config.value = String(showtype)
|
||||||
|
Todos.state.showtype = parseInt(config.value)
|
||||||
|
} else {
|
||||||
|
Todos.state.showtype = showtype
|
||||||
|
}
|
||||||
|
console.log('Todos.state.showtype', Todos.state.showtype)
|
||||||
|
GlobalStore.mutations.saveConfig({ _id: costanti.CONFIG_ID_SHOW_TYPE_TODOS, value: String(showtype) })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
setConta: b.commit(setConta),
|
setConta: b.commit(setConta),
|
||||||
setleftDrawerOpen: b.commit(setleftDrawerOpen),
|
setleftDrawerOpen: b.commit(setleftDrawerOpen),
|
||||||
setCategorySel: b.commit(setCategorySel),
|
setCategorySel: b.commit(setCategorySel),
|
||||||
setStateConnection: b.commit(setStateConnection),
|
setStateConnection: b.commit(setStateConnection),
|
||||||
SetwasAlreadySubOnDb: b.commit(SetwasAlreadySubOnDb)
|
SetwasAlreadySubOnDb: b.commit(SetwasAlreadySubOnDb),
|
||||||
|
saveConfig: b.commit(saveConfig),
|
||||||
|
setPaoArray: b.commit(setPaoArray),
|
||||||
|
setPaoArray_Delete: b.commit(setPaoArray_Delete),
|
||||||
|
NewArray: b.commit(NewArray),
|
||||||
|
setShowType: b.commit(setShowType)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -136,7 +253,7 @@ namespace Actions {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('createPushSubscription')
|
// console.log('createPushSubscription')
|
||||||
|
|
||||||
let reg
|
let reg
|
||||||
const mykey = process.env.PUBLICKEY_PUSH
|
const mykey = process.env.PUBLICKEY_PUSH
|
||||||
@@ -150,7 +267,7 @@ namespace Actions {
|
|||||||
mystate.wasAlreadySubscribed = !(subscription === null)
|
mystate.wasAlreadySubscribed = !(subscription === null)
|
||||||
|
|
||||||
if (mystate.wasAlreadySubscribed) {
|
if (mystate.wasAlreadySubscribed) {
|
||||||
console.log('User is already SAVED Subscribe on DB!')
|
// console.log('User is already SAVED Subscribe on DB!')
|
||||||
// return null
|
// return null
|
||||||
return subscription
|
return subscription
|
||||||
} else {
|
} else {
|
||||||
@@ -177,7 +294,7 @@ namespace Actions {
|
|||||||
if (!newSub)
|
if (!newSub)
|
||||||
return
|
return
|
||||||
|
|
||||||
console.log('saveSubscriptionToServer: ', newSub)
|
// console.log('saveSubscriptionToServer: ', newSub)
|
||||||
// console.log('context', context)
|
// console.log('context', context)
|
||||||
|
|
||||||
let options = null
|
let options = null
|
||||||
@@ -197,17 +314,15 @@ namespace Actions {
|
|||||||
others: {
|
others: {
|
||||||
userId: UserStore.state.userId,
|
userId: UserStore.state.userId,
|
||||||
access: UserStore.state.tokens[0].access
|
access: UserStore.state.tokens[0].access
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let call = process.env.MONGODB_HOST + '/subscribe'
|
return Api.SendReq('/subscribe', 'POST', myres)
|
||||||
|
.then(res => {
|
||||||
return Api.SendReq(call, 'POST', myres)
|
|
||||||
.then(({ res, body }) => {
|
|
||||||
state.wasAlreadySubscribed = true
|
state.wasAlreadySubscribed = true
|
||||||
state.wasAlreadySubOnDb = true
|
state.wasAlreadySubOnDb = true
|
||||||
|
|
||||||
localStorage.setItem(rescodes.localStorage.wasAlreadySubOnDb, String(state.wasAlreadySubOnDb))
|
localStorage.setItem(tools.localStorage.wasAlreadySubOnDb, String(state.wasAlreadySubOnDb))
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.log('Error during Subscription!', e)
|
console.log('Error during Subscription!', e)
|
||||||
@@ -244,6 +359,7 @@ namespace Actions {
|
|||||||
|
|
||||||
function prova(context) {
|
function prova(context) {
|
||||||
// console.log('prova')
|
// console.log('prova')
|
||||||
|
// state.testp1.mioarray[state.testp1.mioarray.length - 1].valore = 'VALMODIF';
|
||||||
|
|
||||||
// let msg = t('notification.title_subscribed')
|
// let msg = t('notification.title_subscribed')
|
||||||
|
|
||||||
@@ -255,9 +371,9 @@ namespace Actions {
|
|||||||
console.log('clearDataAfterLogout')
|
console.log('clearDataAfterLogout')
|
||||||
|
|
||||||
// Clear all data from the IndexedDB
|
// Clear all data from the IndexedDB
|
||||||
await allTables.forEach(table => {
|
for (const table of allTables) {
|
||||||
globalroutines(null, 'clearalldata', table, null)
|
await globalroutines(null, 'clearalldata', table, null)
|
||||||
})
|
}
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
// REMOVE ALL SUBSCRIPTION
|
// REMOVE ALL SUBSCRIPTION
|
||||||
@@ -294,9 +410,52 @@ namespace Actions {
|
|||||||
|
|
||||||
|
|
||||||
async function loadAfterLogin(context) {
|
async function loadAfterLogin(context) {
|
||||||
|
console.log('loadAfterLogin')
|
||||||
actions.clearDataAfterLoginOnlyIfActiveConnection()
|
actions.clearDataAfterLoginOnlyIfActiveConnection()
|
||||||
|
|
||||||
|
state.arrConfig = await globalroutines(null, 'readall', 'config', null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveCfgServerKey(context, dataval: ICfgServer) {
|
||||||
|
console.log('saveCfgServerKey dataval', dataval)
|
||||||
|
|
||||||
|
let ris = await Api.SendReq('/admin/updateval', 'POST', { pairval: dataval })
|
||||||
|
.then(res => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkUpdates(context) {
|
||||||
|
console.log('checkUpdates')
|
||||||
|
|
||||||
|
// if (UserStore.state.userId === '')
|
||||||
|
// return false // Login not made
|
||||||
|
|
||||||
|
state.networkDataReceived = false
|
||||||
|
|
||||||
|
let ris = await Api.SendReq('/checkupdates', 'GET', null)
|
||||||
|
.then(res => {
|
||||||
|
state.networkDataReceived = true
|
||||||
|
|
||||||
|
console.log('******* checkUpdates RES :', res.data.cfgServer)
|
||||||
|
if (res.data.cfgServer) {
|
||||||
|
state.cfgServer = [...res.data.cfgServer]
|
||||||
|
console.log('res.data.cfgServer', res.data.cfgServer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('********** res', 'state.todos', state.todos, 'checkPending', checkPending)
|
||||||
|
// After Login will store into the indexedDb...
|
||||||
|
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log('error checkUpdates', error)
|
||||||
|
UserStore.mutations.setErrorCatch(error)
|
||||||
|
return error
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
setConta: b.dispatch(setConta),
|
setConta: b.dispatch(setConta),
|
||||||
@@ -304,7 +463,9 @@ namespace Actions {
|
|||||||
loadAfterLogin: b.dispatch(loadAfterLogin),
|
loadAfterLogin: b.dispatch(loadAfterLogin),
|
||||||
clearDataAfterLogout: b.dispatch(clearDataAfterLogout),
|
clearDataAfterLogout: b.dispatch(clearDataAfterLogout),
|
||||||
clearDataAfterLoginOnlyIfActiveConnection: b.dispatch(clearDataAfterLoginOnlyIfActiveConnection),
|
clearDataAfterLoginOnlyIfActiveConnection: b.dispatch(clearDataAfterLoginOnlyIfActiveConnection),
|
||||||
prova: b.dispatch(prova)
|
prova: b.dispatch(prova),
|
||||||
|
saveCfgServerKey: b.dispatch(saveCfgServerKey),
|
||||||
|
checkUpdates: b.dispatch(checkUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +1,348 @@
|
|||||||
import { IGlobalState, ITodo, ITodosState } from 'model'
|
import { ITodo, ITodosState, IParamTodo, IDrag } from 'model'
|
||||||
import { storeBuilder } from './Store/Store'
|
import { storeBuilder } from './Store/Store'
|
||||||
|
|
||||||
import Api from '@api'
|
import Api from '@api'
|
||||||
import { rescodes } from './rescodes'
|
import { tools } from './tools'
|
||||||
import { GlobalStore, Todos, UserStore } from '@store'
|
import { GlobalStore, Todos, UserStore } from '@store'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
import { Mutation } from 'vuex-module-decorators'
|
import { Mutation } from 'vuex-module-decorators'
|
||||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||||
|
import { GetterTree } from 'vuex'
|
||||||
|
import objectId from '@src/js/objectId'
|
||||||
|
import { costanti } from '@src/store/Modules/costanti'
|
||||||
|
|
||||||
|
// import _ from 'lodash'
|
||||||
|
|
||||||
const state: ITodosState = {
|
const state: ITodosState = {
|
||||||
visuOnlyUncompleted: false,
|
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||||
networkDataReceived: false,
|
todos: {},
|
||||||
todos: [],
|
categories: [],
|
||||||
todos_changed: 1,
|
// todos_changed: 1,
|
||||||
reload_fromServer: 0,
|
reload_fromServer: 0,
|
||||||
testpao: 'Test',
|
testpao: 'Test',
|
||||||
insidePending: false
|
insidePending: false,
|
||||||
|
visuLastCompleted: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
const b = storeBuilder.module<ITodosState>('TodosModule', state)
|
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()
|
const stateGetter = b.state()
|
||||||
|
|
||||||
// Getters
|
function getindexbycategory(category: string) {
|
||||||
namespace Getters {
|
return state.categories.indexOf(category)
|
||||||
|
}
|
||||||
|
|
||||||
|
function gettodosByCategory(category: string) {
|
||||||
|
const indcat = state.categories.indexOf(category)
|
||||||
|
if (!state.todos[indcat])
|
||||||
|
return []
|
||||||
|
return state.todos[indcat]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidIndex(cat, index) {
|
||||||
|
const myarr = gettodosByCategory(cat)
|
||||||
|
return (index >= 0 && index < myarr.length)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getElemByIndex(cat, index) {
|
||||||
|
const myarr = gettodosByCategory(cat)
|
||||||
|
|
||||||
|
if (index >= 0 && index < myarr.length)
|
||||||
|
return myarr[index]
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolean, escludiId: string) {
|
||||||
|
const myarr = gettodosByCategory(cat)
|
||||||
|
if (myarr === null)
|
||||||
|
return -1
|
||||||
|
|
||||||
|
let trovato: boolean = false
|
||||||
|
|
||||||
|
console.log('priority', priority)
|
||||||
|
|
||||||
|
for (let indrec = 0; indrec < myarr.length; indrec++) {
|
||||||
|
if ((myarr[indrec].priority === priority) && (myarr[indrec]._id !== escludiId)) {
|
||||||
|
trovato = true
|
||||||
|
if (atfirst) {
|
||||||
|
return indrec - 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (trovato) {
|
||||||
|
return indrec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('trovato?', trovato, 'indrec')
|
||||||
|
|
||||||
|
if (trovato) {
|
||||||
|
return myarr.length - 1
|
||||||
|
} else {
|
||||||
|
if (priority === tools.Todos.PRIORITY_LOW)
|
||||||
|
return myarr.length - 1
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLastListNotCompleted(cat) {
|
||||||
|
const arr = Todos.getters.todos_dacompletare(cat)
|
||||||
|
// console.log('cat', cat, 'arr', arr)
|
||||||
|
if (arr.length > 0)
|
||||||
|
return arr[arr.length - 1]
|
||||||
|
else
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
function getstrelem(elem) {
|
||||||
|
return 'ID [' + elem._id + '] ' + elem.descr + ' [ID_PREV=' + elem.id_prev + '] modif=' + elem.modified
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_idprev(indcat, indelemchange, indelemId) {
|
||||||
|
if (indelemchange >= 0 && indelemchange < state.todos[indcat].length) {
|
||||||
|
const id_prev = (indelemId >= 0) ? state.todos[indcat][indelemId]._id : tools.LIST_START
|
||||||
|
if (state.todos[indcat][indelemchange].id_prev !== id_prev) {
|
||||||
|
state.todos[indcat][indelemchange].id_prev = id_prev
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][indelemchange])
|
||||||
|
// state.todos[indcat][indelemchange].modified = true
|
||||||
|
console.log('Index=', indelemchange, 'indtoget', indelemId, getstrelem(state.todos[indcat][indelemchange]))
|
||||||
|
return state.todos[indcat][indelemchange]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function initcat() {
|
||||||
|
|
||||||
|
let tomorrow = new Date()
|
||||||
|
tomorrow.setDate(tomorrow.getDate() + 1)
|
||||||
|
|
||||||
|
const objtodo: ITodo = {
|
||||||
|
// _id: new Date().toISOString(), // Create NEW
|
||||||
|
_id: objectId(),
|
||||||
|
userId: UserStore.state.userId,
|
||||||
|
descr: '',
|
||||||
|
priority: tools.Todos.PRIORITY_NORMAL,
|
||||||
|
completed: false,
|
||||||
|
created_at: new Date(),
|
||||||
|
modify_at: new Date(),
|
||||||
|
completed_at: new Date(),
|
||||||
|
category: '',
|
||||||
|
expiring_at: tomorrow,
|
||||||
|
enableExpiring: false,
|
||||||
|
id_prev: '',
|
||||||
|
pos: 0,
|
||||||
|
modified: false,
|
||||||
|
progress: 0
|
||||||
|
}
|
||||||
|
// return this.copy(objtodo)
|
||||||
|
return objtodo
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 []
|
||||||
|
}, '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
|
||||||
|
return []
|
||||||
|
} else return []
|
||||||
|
}, 'todos_completati')
|
||||||
|
|
||||||
|
const doneTodosCount = b.read((state: ITodosState) => (cat: string): number => {
|
||||||
|
return getters.todos_completati(cat).length
|
||||||
|
}, 'doneTodosCount')
|
||||||
|
const TodosCount = b.read((state: ITodosState) => (cat: string): number => {
|
||||||
|
const indcat = getindexbycategory(cat)
|
||||||
|
if (state.todos[indcat]) {
|
||||||
|
return state.todos[indcat].length
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}, 'TodosCount')
|
||||||
|
|
||||||
const visuOnlyUncompleted = b.read(state => state.visuOnlyUncompleted, 'visuOnlyUncompleted')
|
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
get visuOnlyUncompleted() {
|
// get fullName() { return fullName();},
|
||||||
return visuOnlyUncompleted
|
get todos_dacompletare() {
|
||||||
|
return todos_dacompletare()
|
||||||
|
},
|
||||||
|
get todos_completati() {
|
||||||
|
return todos_completati()
|
||||||
|
},
|
||||||
|
get doneTodosCount() {
|
||||||
|
return doneTodosCount()
|
||||||
|
},
|
||||||
|
get TodosCount() {
|
||||||
|
return TodosCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Mutations {
|
namespace Mutations {
|
||||||
|
|
||||||
function setTestpao(state: ITodosState, testpao: String) {
|
function setTestpao(state: ITodosState, testpao: String) {
|
||||||
state.testpao = testpao
|
state.testpao = testpao
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTodos_changed(state: ITodosState) {
|
function findTodoById(state: ITodosState, data: IParamTodo) {
|
||||||
state.todos_changed++
|
const indcat = state.categories.indexOf(data.categorySel)
|
||||||
mutations.setTestpao('Cambiato : ' + String(state.todos_changed))
|
if (indcat >= 0) {
|
||||||
// console.log('******* state.todos_changed', state.todos_changed)
|
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 -1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function createNewItem(state: ITodosState, { objtodo, atfirst, categorySel }) {
|
||||||
|
let indcat = state.categories.indexOf(categorySel)
|
||||||
|
if (indcat == -1) {
|
||||||
|
state.categories.push(categorySel)
|
||||||
|
indcat = state.categories.indexOf(categorySel)
|
||||||
|
}
|
||||||
|
console.log('createNewItem', objtodo, 'cat=', categorySel, 'state.todos[indcat]', state.todos[indcat])
|
||||||
|
if (state.todos[indcat] === undefined) {
|
||||||
|
state.todos[indcat] = []
|
||||||
|
state.todos[indcat].push(objtodo)
|
||||||
|
console.log('push state.todos[indcat]', state.todos)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (atfirst)
|
||||||
|
state.todos[indcat].unshift(objtodo)
|
||||||
|
else
|
||||||
|
state.todos[indcat].push(objtodo)
|
||||||
|
|
||||||
|
console.log('state.todos[indcat]', state.todos[indcat])
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletemyitem(state: ITodosState, myitem: ITodo) {
|
||||||
|
// Find record
|
||||||
|
const indcat = state.categories.indexOf(myitem.category)
|
||||||
|
const ind = findTodoById(state, { id: myitem._id, categorySel: myitem.category })
|
||||||
|
|
||||||
|
console.log('PRIMA state.todos', state.todos)
|
||||||
|
// Delete Item in to Array
|
||||||
|
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 = {
|
export const mutations = {
|
||||||
setTestpao: b.commit(setTestpao),
|
setTestpao: b.commit(setTestpao),
|
||||||
setTodos_changed: b.commit(setTodos_changed)
|
deletemyitem: b.commit(deletemyitem),
|
||||||
|
createNewItem: b.commit(createNewItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function consolelogpao(strlog, strlog2 = '', strlog3 = '') {
|
function consolelogpao(strlog, strlog2 = '', strlog3 = '') {
|
||||||
globalroutines(null, 'log', strlog + strlog2 + strlog3, null)
|
globalroutines(null, 'log', strlog + ' ' + strlog2 + ' ' + strlog3, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Actions {
|
namespace Actions {
|
||||||
|
|
||||||
function json2array(json) {
|
|
||||||
let result = []
|
|
||||||
let keys = Object.keys(json)
|
|
||||||
keys.forEach(function (key) {
|
|
||||||
result.push(json[key])
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// If something in the call of Service Worker went wrong (Network or Server Down), then retry !
|
// If something in the call of Service Worker went wrong (Network or Server Down), then retry !
|
||||||
async function sendSwMsgIfAvailable() {
|
async function sendSwMsgIfAvailable() {
|
||||||
let something = false
|
let something = false
|
||||||
@@ -86,21 +360,26 @@ namespace Actions {
|
|||||||
// let recclone = [...arr_recmsg]
|
// let recclone = [...arr_recmsg]
|
||||||
if (arr_recmsg.length > 0) {
|
if (arr_recmsg.length > 0) {
|
||||||
|
|
||||||
// console.log(' TROVATI MSG PENDENTI ! ORA LI MANDO: ', arr_recmsg)
|
|
||||||
|
|
||||||
// console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
// console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
||||||
|
let promiseChain = Promise.resolve()
|
||||||
|
|
||||||
something = true
|
for (let indrec in arr_recmsg) {
|
||||||
for (let rec of arr_recmsg) {
|
|
||||||
// console.log(' .... sw.sync.register ( ', rec._id)
|
// console.log(' .... sw.sync.register ( ', rec._id)
|
||||||
// if ('SyncManager' in window) {
|
// if ('SyncManager' in window) {
|
||||||
// sw.sync.register(rec._id)
|
// sw.sync.register(rec._id)
|
||||||
// } else {
|
// } else {
|
||||||
// #Todo ++ Alternative to SyncManager
|
|
||||||
Api.syncAlternative(rec._id)
|
// #Alternative to SyncManager
|
||||||
|
promiseChain = promiseChain.then(() => {
|
||||||
|
return Api.syncAlternative(arr_recmsg[indrec]._id)
|
||||||
|
.then(() => {
|
||||||
|
something = true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
return something
|
return promiseChain
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -108,39 +387,47 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return something
|
return new Promise(function (resolve, reject) {
|
||||||
|
resolve(something)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function waitAndcheckPendingMsg(context) {
|
async function waitAndcheckPendingMsg(context) {
|
||||||
|
|
||||||
await aspettansec(1000)
|
// await aspettansec(1000)
|
||||||
|
|
||||||
return await checkPendingMsg(context)
|
return await checkPendingMsg(context)
|
||||||
.then(ris => {
|
.then(ris => {
|
||||||
if (ris) {
|
if (ris) {
|
||||||
console.log('risPending = ', ris)
|
// console.log('risPending = ', ris)
|
||||||
return sendSwMsgIfAvailable()
|
return sendSwMsgIfAvailable()
|
||||||
.then(something => {
|
.then(something => {
|
||||||
if (something) {
|
if (something) {
|
||||||
|
if (process.env.DEBUG === '1')
|
||||||
|
console.log('something')
|
||||||
// Refresh data
|
// Refresh data
|
||||||
return waitAndRefreshData(context)
|
return waitAndRefreshData(context)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitAndRefreshData(context) {
|
async function waitAndRefreshData(context) {
|
||||||
await aspettansec(3000)
|
// await aspettansec(3000)
|
||||||
|
|
||||||
return await dbLoadTodo(context, false)
|
return await dbLoadTodo(context, { checkPending: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readConfig(id) {
|
||||||
|
return await globalroutines(null, 'read', 'config', null, String(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkPendingMsg(context) {
|
async function checkPendingMsg(context) {
|
||||||
// console.log('checkPendingMsg')
|
// console.log('checkPendingMsg')
|
||||||
|
|
||||||
const config = await globalroutines(null, 'readall', 'config', null)
|
const config = await globalroutines(null, 'read', 'config', null, '1')
|
||||||
// console.log('config', config)
|
// console.log('config', config)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -155,22 +442,14 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
/*
|
|
||||||
globalroutines(null, 'readall', 'swmsg')
|
|
||||||
.then(function (arr_recmsg) {
|
|
||||||
if (arr_recmsg.length > 0) {
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Check if there is something
|
// Check if there is something
|
||||||
globalroutines(null, 'count', 'swmsg')
|
return globalroutines(null, 'count', 'swmsg')
|
||||||
.then(function (count) {
|
.then(function (count) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
console.log('count = ', count)
|
// console.log('count = ', count)
|
||||||
return resolve(true)
|
return resolve(true)
|
||||||
} else {
|
} else {
|
||||||
return resolve(false)
|
return resolve(false)
|
||||||
@@ -184,62 +463,66 @@ namespace Actions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dbLoadTodo(context, checkPending: boolean = false) {
|
async function dbLoadTodo(context, { checkPending }) {
|
||||||
console.log('dbLoadTodo', checkPending)
|
console.log('dbLoadTodo', checkPending, 'userid=', UserStore.state.userId)
|
||||||
|
|
||||||
if (UserStore.state.userId === '')
|
if (UserStore.state.userId === '')
|
||||||
return false // Login not made
|
return false // Login not made
|
||||||
|
|
||||||
let call = process.env.MONGODB_HOST + '/todos/' + UserStore.state.userId
|
let 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.networkDataReceived = false
|
state.todos = res.data.todos
|
||||||
|
state.categories = res.data.categories
|
||||||
let ris = await Api.SendReq(call, 'GET', null)
|
} else {
|
||||||
.then(({ res, body, status }) => {
|
state.todos = [[]]
|
||||||
state.networkDataReceived = true
|
|
||||||
|
|
||||||
// console.log('******* UPDATE TODOS.STATE.TODOS !:', res.todos)
|
|
||||||
if (body.todos) {
|
|
||||||
state.todos = [...body.todos]
|
|
||||||
// Todos.mutations.setTodos_changed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('********** res', 'state.todos', state.todos, 'checkPending', checkPending)
|
// console.log('PRIMA showtype = ', state.showtype)
|
||||||
|
|
||||||
// After Login will store into the indexedDb...
|
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({id: costanti.CONFIG_ID_SHOW_TYPE_TODOS, default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED }))
|
||||||
|
|
||||||
return { status }
|
// console.log('showtype = ', state.showtype)
|
||||||
|
|
||||||
|
// console.log('ARRAY TODOS = ', state.todos)
|
||||||
|
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=', error)
|
console.log('error dbLoadTodo', error)
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return { status }
|
return error
|
||||||
})
|
})
|
||||||
|
|
||||||
// console.log('ris : ', ris)
|
if (ris.status !== 200) {
|
||||||
// console.log('ris STATUS: ', ris.status)
|
if (process.env.DEBUG === '1')
|
||||||
|
console.log('ris.status', ris.status)
|
||||||
if (!Todos.state.networkDataReceived) {
|
|
||||||
|
|
||||||
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||||
} else {
|
} else {
|
||||||
consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.status)
|
consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.status)
|
||||||
}
|
}
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
// Read all data from IndexedDB Store into Memory
|
// Read all data from IndexedDB Store into Memory
|
||||||
await updateArrayInMemory(context)
|
await updatefromIndexedDbToStateTodo(context)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ris.status === rescodes.OK && checkPending) {
|
if (ris.status === tools.OK && checkPending) {
|
||||||
waitAndcheckPendingMsg(context)
|
waitAndcheckPendingMsg(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateArrayInMemory(context) {
|
async function updatefromIndexedDbToStateTodo(context) {
|
||||||
// console.log('Update the array in memory, from todos table from IndexedDb')
|
// console.log('Update the array in memory, from todos table from IndexedDb')
|
||||||
await globalroutines(null, 'updateinMemory', 'todos', null)
|
await globalroutines(null, 'updatefromIndexedDbToStateTodo', 'categories', null)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// console.log('updateArrayInMemory! ')
|
console.log('updatefromIndexedDbToStateTodo! ')
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -255,7 +538,6 @@ namespace Actions {
|
|||||||
async function testfunc() {
|
async function testfunc() {
|
||||||
while (true) {
|
while (true) {
|
||||||
consolelogpao('testfunc')
|
consolelogpao('testfunc')
|
||||||
Todos.mutations.setTodos_changed()
|
|
||||||
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
|
||||||
await aspettansec(5000)
|
await aspettansec(5000)
|
||||||
}
|
}
|
||||||
@@ -269,27 +551,12 @@ namespace Actions {
|
|||||||
return await dbInsertSaveTodo(context, itemtodo, 'POST')
|
return await dbInsertSaveTodo(context, itemtodo, 'POST')
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateNewIdFromDB(oldItem, newItem, method) {
|
|
||||||
// console.log('PRIMA state.todos', state.todos)
|
|
||||||
// console.log('ITEM', newItem)
|
|
||||||
if (method === 'POST') {
|
|
||||||
state.todos.push(newItem)
|
|
||||||
Todos.mutations.setTodos_changed()
|
|
||||||
// } else if (method === 'PATCH') {
|
|
||||||
// state.todos.map(item => {
|
|
||||||
// if (item._id === newItem._id) {
|
|
||||||
// return newItem
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// console.log('DOPO state.todos', state.todos)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
|
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
|
||||||
|
|
||||||
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
|
||||||
console.log('dbInsertSaveTodo', itemtodo, method)
|
console.log('dbInsertSaveTodo', itemtodo, method)
|
||||||
let call = process.env.MONGODB_HOST + '/todos'
|
let call = '/todos'
|
||||||
|
|
||||||
if (UserStore.state.userId === '')
|
if (UserStore.state.userId === '')
|
||||||
return false // Login not made
|
return false // Login not made
|
||||||
@@ -300,40 +567,31 @@ namespace Actions {
|
|||||||
console.log('TODO TO SAVE: ', itemtodo)
|
console.log('TODO TO SAVE: ', itemtodo)
|
||||||
|
|
||||||
let res = await Api.SendReq(call, method, itemtodo)
|
let res = await Api.SendReq(call, method, itemtodo)
|
||||||
.then(({ res, newItem }) => {
|
.then(res => {
|
||||||
console.log('dbInsertSaveTodo RIS =', newItem)
|
console.log('dbInsertSaveTodo to the Server', res.data)
|
||||||
if (newItem) {
|
|
||||||
|
|
||||||
// Update ID on local
|
return (res.status === 200)
|
||||||
UpdateNewIdFromDB(itemtodo, newItem, method)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return UserStore.getters.getServerCode
|
// return UserStore.getters.getServerCode
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dbDeleteTodo(context, item: ITodo) {
|
return true
|
||||||
// console.log('dbDeleteTodo', item)
|
}
|
||||||
let call = process.env.MONGODB_HOST + '/todos/' + item._id
|
|
||||||
|
|
||||||
|
async function dbdeleteItem(context, item: ITodo) {
|
||||||
|
|
||||||
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
// console.log('dbdeleteItem', item)
|
||||||
if (UserStore.state.userId === '')
|
if (UserStore.state.userId === '')
|
||||||
return false // Login not made
|
return false // Login not made
|
||||||
|
|
||||||
let res = await Api.SendReq(call, 'DELETE', item)
|
let res = await Api.SendReq('/todos/' + item._id, 'DELETE', item)
|
||||||
.then(function ({ res, itemris }) {
|
.then(res => {
|
||||||
|
console.log('dbdeleteItem to the Server')
|
||||||
if (res.status === 200) {
|
|
||||||
// Delete Item in to Array
|
|
||||||
state.todos.splice(state.todos.indexOf(item), 1)
|
|
||||||
|
|
||||||
Todos.mutations.setTodos_changed()
|
|
||||||
}
|
|
||||||
|
|
||||||
return rescodes.OK
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
@@ -342,24 +600,289 @@ namespace Actions {
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getTodosByCategory(context, category: string) {
|
function setmodifiedIfchanged(recOut, recIn, field) {
|
||||||
let myarr = state.todos.filter((p) => {
|
if (String(recOut[field]) !== String(recIn[field])) {
|
||||||
return p.category === category
|
// console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
||||||
|
recOut.modified = true
|
||||||
|
recOut[field] = recIn[field]
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteItem(context, { cat, idobj }) {
|
||||||
|
console.log('deleteItem: KEY = ', idobj)
|
||||||
|
|
||||||
|
let myobjtrov = getElemById(cat, idobj)
|
||||||
|
|
||||||
|
if (myobjtrov !== null) {
|
||||||
|
let myobjnext = getElemPrevById(cat, myobjtrov._id)
|
||||||
|
|
||||||
|
if (myobjnext !== null) {
|
||||||
|
myobjnext.id_prev = myobjtrov.id_prev
|
||||||
|
myobjnext.modified = true
|
||||||
|
console.log('calling MODIFY 1')
|
||||||
|
await modify(context, { myitem: myobjnext, field: 'id_prev' })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1) Delete from the Todos Array
|
||||||
|
Todos.mutations.deletemyitem(myobjtrov)
|
||||||
|
|
||||||
|
// 2) Delete from the IndexedDb
|
||||||
|
globalroutines(context, 'delete', 'todos', null, idobj)
|
||||||
|
.then((ris) => {
|
||||||
|
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log('err: ', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
return myarr
|
// 3) Delete from the Server (call)
|
||||||
|
deleteItemToSyncAndDb(tools.DB.TABLE_DELETE_TODOS, myobjtrov, idobj)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('FINE deleteItem')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function insertTodo(context, { myobj, atfirst }) {
|
||||||
|
|
||||||
|
const objtodo = initcat()
|
||||||
|
|
||||||
|
objtodo.descr = myobj.descr
|
||||||
|
objtodo.category = myobj.category
|
||||||
|
|
||||||
|
let elemtochange: ITodo = null
|
||||||
|
|
||||||
|
if (atfirst) {
|
||||||
|
console.log('INSERT AT THE TOP')
|
||||||
|
elemtochange = getFirstList(objtodo.category)
|
||||||
|
objtodo.id_prev = tools.LIST_START
|
||||||
|
// objtodo.pos = (elemtochange !== null) ? elemtochange.pos - 1 : 1
|
||||||
|
} else {
|
||||||
|
console.log('INSERT AT THE BOTTOM')
|
||||||
|
// INSERT AT THE BOTTOM , so GET LAST ITEM
|
||||||
|
const lastelem = getLastListNotCompleted(objtodo.category)
|
||||||
|
|
||||||
|
console.log('lastelem', lastelem)
|
||||||
|
|
||||||
|
objtodo.id_prev = (lastelem !== null) ? lastelem._id : tools.LIST_START
|
||||||
|
// objtodo.pos = (elemtochange !== null) ? elemtochange.pos + 1 : 1
|
||||||
|
}
|
||||||
|
console.log('elemtochange TORNATO:', elemtochange)
|
||||||
|
objtodo.modified = false
|
||||||
|
|
||||||
|
console.log('objtodo', objtodo, 'ID_PREV=', objtodo.id_prev)
|
||||||
|
|
||||||
|
// 1) Create record in Memory
|
||||||
|
Todos.mutations.createNewItem({ objtodo, atfirst, categorySel: objtodo.category })
|
||||||
|
|
||||||
|
// 2) Insert into the IndexedDb
|
||||||
|
const id = await globalroutines(context, 'write', 'todos', objtodo)
|
||||||
|
|
||||||
|
let field = ''
|
||||||
|
// update also the last elem
|
||||||
|
if (atfirst) {
|
||||||
|
if (elemtochange !== null) {
|
||||||
|
elemtochange.id_prev = id
|
||||||
|
console.log('elemtochange', elemtochange)
|
||||||
|
field = 'id_prev'
|
||||||
|
|
||||||
|
// Modify the other record
|
||||||
|
await modify(context, { myitem: elemtochange, field })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) send to the Server
|
||||||
|
await saveItemToSyncAndDb(tools.DB.TABLE_SYNC_TODOS, 'POST', objtodo)
|
||||||
|
.then((ris) => {
|
||||||
|
// Check if need to be moved...
|
||||||
|
const indelem = getIndexById(objtodo.category, objtodo._id)
|
||||||
|
let itemdragend = undefined
|
||||||
|
if (atfirst) {
|
||||||
|
// Check the second item, if it's different priority, then move to the first position of the priority
|
||||||
|
const secondindelem = indelem + 1
|
||||||
|
if (isValidIndex(objtodo.category, secondindelem)) {
|
||||||
|
const secondelem = getElemByIndex(objtodo.category, secondindelem)
|
||||||
|
if (secondelem.priority !== objtodo.priority) {
|
||||||
|
itemdragend = {
|
||||||
|
field: 'priority',
|
||||||
|
idelemtochange: objtodo._id,
|
||||||
|
prioritychosen: objtodo.priority,
|
||||||
|
category: objtodo.category,
|
||||||
|
atfirst
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// get previous of the last
|
||||||
|
const prevlastindelem = indelem - 1
|
||||||
|
if (isValidIndex(objtodo.category, prevlastindelem)) {
|
||||||
|
const prevlastelem = getElemByIndex(objtodo.category, prevlastindelem)
|
||||||
|
if (prevlastelem.priority !== objtodo.priority) {
|
||||||
|
itemdragend = {
|
||||||
|
field: 'priority',
|
||||||
|
idelemtochange: objtodo._id,
|
||||||
|
prioritychosen: objtodo.priority,
|
||||||
|
category: objtodo.category,
|
||||||
|
atfirst
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemdragend)
|
||||||
|
swapElems(context, itemdragend)
|
||||||
|
|
||||||
|
return ris
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function modify(context, { myitem, field }) {
|
||||||
|
if (myitem === null)
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
const myobjsaved = tools.jsonCopy(myitem)
|
||||||
|
// get record from IndexedDb
|
||||||
|
const miorec = await globalroutines(context, 'read', 'todos', null, myobjsaved._id)
|
||||||
|
if (miorec === undefined) {
|
||||||
|
console.log('~~~~~~~~~~~~~~~~~~~~ !!!!!!!!!!!!!!!!!! Record not Found !!!!!! id=', myobjsaved._id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setmodifiedIfchanged(miorec, myobjsaved, 'completed'))
|
||||||
|
miorec.completed_at = new Date().getDate()
|
||||||
|
|
||||||
|
fieldtochange.forEach(field => {
|
||||||
|
setmodifiedIfchanged(miorec, myobjsaved, field)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (miorec.modified) {
|
||||||
|
// console.log('Todo MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB todos')
|
||||||
|
miorec.modify_at = new Date().getDate()
|
||||||
|
miorec.modified = false
|
||||||
|
|
||||||
|
// 1) Permit to Update the Views
|
||||||
|
tools.notifyarraychanged(miorec)
|
||||||
|
|
||||||
|
// Todos.mutations.modifymyItem(miorec)
|
||||||
|
|
||||||
|
// this.logelem('modify', miorec)
|
||||||
|
// 2) Modify on IndexedDb
|
||||||
|
return globalroutines(context, 'write', 'todos', miorec)
|
||||||
|
.then(ris => {
|
||||||
|
|
||||||
|
// 3) Modify on the Server (call)
|
||||||
|
saveItemToSyncAndDb(tools.DB.TABLE_SYNC_TODOS_PATCH, '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)
|
||||||
|
console.log('state.categories', state.categories)
|
||||||
|
const cat = itemdragend.category
|
||||||
|
const indcat = state.categories.indexOf(cat)
|
||||||
|
|
||||||
|
if (itemdragend.field === 'priority') {
|
||||||
|
// get last elem priority
|
||||||
|
console.log('get last elem priority')
|
||||||
|
itemdragend.newIndex = getLastFirstElemPriority(itemdragend.category, itemdragend.prioritychosen, itemdragend.atfirst, itemdragend.idelemtochange)
|
||||||
|
itemdragend.oldIndex = getIndexById(itemdragend.category, itemdragend.idelemtochange)
|
||||||
|
|
||||||
|
console.log('swapElems PRIORITY', itemdragend)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('indcat', indcat)
|
||||||
|
|
||||||
|
if (isValidIndex(cat, indcat) && isValidIndex(cat, itemdragend.newIndex) && isValidIndex(cat, itemdragend.oldIndex)) {
|
||||||
|
console.log('isValidIndex')
|
||||||
|
state.todos[indcat].splice(itemdragend.newIndex, 0, state.todos[indcat].splice(itemdragend.oldIndex, 1)[0])
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.oldIndex])
|
||||||
|
|
||||||
|
if (itemdragend.field !== 'priority') {
|
||||||
|
let precind = itemdragend.newIndex - 1
|
||||||
|
let 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)) {
|
||||||
|
console.log(' 1)')
|
||||||
|
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][precind].priority
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!isValidIndex(cat, precind)) {
|
||||||
|
if ((state.todos[indcat][nextind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
|
||||||
|
console.log(' 2)')
|
||||||
|
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][nextind].priority
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if ((state.todos[indcat][precind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
|
||||||
|
console.log(' 3)')
|
||||||
|
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][precind].priority
|
||||||
|
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
const elem3 = update_idprev(indcat, itemdragend.oldIndex, itemdragend.oldIndex - 1)
|
||||||
|
const elem4 = update_idprev(indcat, itemdragend.oldIndex + 1, itemdragend.oldIndex)
|
||||||
|
|
||||||
|
// Update the records:
|
||||||
|
await modify(context, { myitem: elem1, field: 'id_prev' })
|
||||||
|
await modify(context, { myitem: elem2, field: 'id_prev' })
|
||||||
|
await modify(context, { myitem: elem3, field: 'id_prev' })
|
||||||
|
await modify(context, { myitem: elem4, field: 'id_prev' })
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
dbInsertTodo: b.dispatch(dbInsertTodo),
|
dbInsertTodo: b.dispatch(dbInsertTodo),
|
||||||
dbSaveTodo: b.dispatch(dbSaveTodo),
|
dbSaveTodo: b.dispatch(dbSaveTodo),
|
||||||
dbLoadTodo: b.dispatch(dbLoadTodo),
|
dbLoadTodo: b.dispatch(dbLoadTodo),
|
||||||
dbDeleteTodo: b.dispatch(dbDeleteTodo),
|
dbdeleteItem: b.dispatch(dbdeleteItem),
|
||||||
updateArrayInMemory: b.dispatch(updateArrayInMemory),
|
updatefromIndexedDbToStateTodo: b.dispatch(updatefromIndexedDbToStateTodo),
|
||||||
getTodosByCategory: b.dispatch(getTodosByCategory),
|
|
||||||
checkPendingMsg: b.dispatch(checkPendingMsg),
|
checkPendingMsg: b.dispatch(checkPendingMsg),
|
||||||
waitAndcheckPendingMsg: b.dispatch(waitAndcheckPendingMsg)
|
waitAndcheckPendingMsg: b.dispatch(waitAndcheckPendingMsg),
|
||||||
|
swapElems: b.dispatch(swapElems),
|
||||||
|
// updateModifyRecords: b.dispatch(updateModifyRecords),
|
||||||
|
deleteItem: b.dispatch(deleteItem),
|
||||||
|
insertTodo: b.dispatch(insertTodo),
|
||||||
|
modify: b.dispatch(modify)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import { storeBuilder } from './Store/Store'
|
|||||||
import router from '@router'
|
import router from '@router'
|
||||||
|
|
||||||
import { serv_constants } from '../Modules/serv_constants'
|
import { serv_constants } from '../Modules/serv_constants'
|
||||||
import { rescodes } from '../Modules/rescodes'
|
import { tools } from '../Modules/tools'
|
||||||
import { GlobalStore, UserStore, Todos } from '@store'
|
import { GlobalStore, UserStore, Todos } from '@store'
|
||||||
import globalroutines from './../../globalroutines/index'
|
import globalroutines from './../../globalroutines/index'
|
||||||
|
|
||||||
import translate from './../../globalroutines/util'
|
import translate from './../../globalroutines/util'
|
||||||
|
import * as Types from '@src/store/Api/ApiTypes'
|
||||||
|
|
||||||
const bcrypt = require('bcryptjs')
|
const bcrypt = require('bcryptjs')
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ const state: IUserState = {
|
|||||||
verified_email: false,
|
verified_email: false,
|
||||||
categorySel: 'personal',
|
categorySel: 'personal',
|
||||||
servercode: 0,
|
servercode: 0,
|
||||||
x_auth_token: ''
|
x_auth_token: '',
|
||||||
|
isAdmin: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -34,6 +36,9 @@ const b = storeBuilder.module<IUserState>('UserModule', state)
|
|||||||
const stateGetter = b.state()
|
const stateGetter = b.state()
|
||||||
|
|
||||||
namespace Getters {
|
namespace Getters {
|
||||||
|
// const fullName = b.read(function fullName(state): string {
|
||||||
|
// return state.userInfos.firstname?capitalize(state.userInfos.firstname) + " " + capitalize(state.userInfos.lastname):null;
|
||||||
|
// })
|
||||||
|
|
||||||
const lang = b.read(state => {
|
const lang = b.read(state => {
|
||||||
if (state.lang !== '') {
|
if (state.lang !== '') {
|
||||||
@@ -56,7 +61,7 @@ namespace Getters {
|
|||||||
// }, 'tok')
|
// }, 'tok')
|
||||||
|
|
||||||
const isServerError = b.read(state => {
|
const isServerError = b.read(state => {
|
||||||
return (state.servercode === rescodes.ERR_SERVERFETCH)
|
return (state.servercode === tools.ERR_SERVERFETCH)
|
||||||
}, 'isServerError')
|
}, 'isServerError')
|
||||||
|
|
||||||
const getServerCode = b.read(state => {
|
const getServerCode = b.read(state => {
|
||||||
@@ -76,6 +81,7 @@ namespace Getters {
|
|||||||
get getServerCode() {
|
get getServerCode() {
|
||||||
return getServerCode()
|
return getServerCode()
|
||||||
}
|
}
|
||||||
|
// get fullName() { return fullName();},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,13 +89,23 @@ namespace Getters {
|
|||||||
|
|
||||||
|
|
||||||
namespace Mutations {
|
namespace Mutations {
|
||||||
function authUser(state, data: IUserState) {
|
function authUser(state: IUserState, data: IUserState ) {
|
||||||
state.userId = data.userId
|
state.userId = data.userId
|
||||||
state.username = data.username
|
state.username = data.username
|
||||||
|
if (data.verified_email)
|
||||||
state.verified_email = data.verified_email
|
state.verified_email = data.verified_email
|
||||||
state.category = data.categorySel
|
|
||||||
|
if (data.categorySel)
|
||||||
|
state.categorySel = data.categorySel // ??
|
||||||
|
|
||||||
|
|
||||||
resetArrToken(state.tokens)
|
resetArrToken(state.tokens)
|
||||||
state.tokens.push({ access: 'auth', token: state.x_auth_token, date_login: new Date() })
|
state.tokens.push({ access: 'auth', token: state.x_auth_token, data_login: new Date() })
|
||||||
|
|
||||||
|
// ++Todo: Settings Users Admin
|
||||||
|
if (state.username === 'paoloar77')
|
||||||
|
state.isAdmin = true
|
||||||
|
|
||||||
// console.log('state.tokens', state.tokens)
|
// console.log('state.tokens', state.tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,16 +118,17 @@ namespace Mutations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setlang(state: IUserState, newstr: string) {
|
function setlang(state: IUserState, newstr: string) {
|
||||||
|
console.log('SETLANG', newstr)
|
||||||
state.lang = newstr
|
state.lang = newstr
|
||||||
localStorage.setItem('lang', state.lang)
|
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdatePwd(state: IUserState, data: IIdToken) {
|
function UpdatePwd(state: IUserState, x_auth_token: string) {
|
||||||
state.x_auth_token = data.x_auth_token
|
state.x_auth_token = x_auth_token
|
||||||
if (!state.tokens) {
|
if (!state.tokens) {
|
||||||
state.tokens = []
|
state.tokens = []
|
||||||
}
|
}
|
||||||
state.tokens.push({ access: 'auth', token: data.x_auth_token, data_login: new Date() })
|
state.tokens.push({ access: 'auth', token: x_auth_token, data_login: new Date() })
|
||||||
}
|
}
|
||||||
|
|
||||||
function setServerCode(state: IUserState, num: number) {
|
function setServerCode(state: IUserState, num: number) {
|
||||||
@@ -149,18 +166,18 @@ namespace Mutations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setErrorCatch(state: IUserState, err: number) {
|
function setErrorCatch(state: IUserState, axerr: Types.AxiosError) {
|
||||||
if (state.servercode !== rescodes.ERR_SERVERFETCH) {
|
if (state.servercode !== tools.ERR_SERVERFETCH) {
|
||||||
state.servercode = err
|
state.servercode = axerr.getCode()
|
||||||
}
|
}
|
||||||
console.log('Err catch: (servercode:', err, ')')
|
console.log('Err catch: (servercode:', axerr.getCode(), axerr.getMsgError(), ')')
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMsgError(state: IUserState, err: number) {
|
function getMsgError(state: IUserState, err: number) {
|
||||||
let msgerrore = ''
|
let msgerrore = ''
|
||||||
if (err !== rescodes.OK) {
|
if (err !== tools.OK) {
|
||||||
msgerrore = 'Error [' + state.servercode + ']: '
|
msgerrore = 'Error [' + state.servercode + ']: '
|
||||||
if (state.servercode === rescodes.ERR_SERVERFETCH) {
|
if (state.servercode === tools.ERR_SERVERFETCH) {
|
||||||
msgerrore = translate('fetch.errore_server')
|
msgerrore = translate('fetch.errore_server')
|
||||||
} else {
|
} else {
|
||||||
msgerrore = translate('fetch.errore_generico')
|
msgerrore = translate('fetch.errore_generico')
|
||||||
@@ -207,8 +224,6 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function resetpwd(context, paramquery: IUserState) {
|
async function resetpwd(context, paramquery: IUserState) {
|
||||||
let call = process.env.MONGODB_HOST + '/updatepwd'
|
|
||||||
console.log('CALL ' + call)
|
|
||||||
|
|
||||||
let usertosend = {
|
let usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
keyappid: process.env.PAO_APP_ID,
|
||||||
@@ -219,24 +234,21 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(tools.CALLING)
|
||||||
|
|
||||||
return await Api.SendReq(call, 'POST', usertosend, true)
|
return await Api.SendReq('/updatepwd', 'POST', usertosend, true)
|
||||||
.then(({ res, body }) => {
|
.then(res => {
|
||||||
return { code: body.code, msg: body.msg }
|
return { code: res.data.code, msg: res.data.msg }
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error: Types.AxiosError) => {
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return { code: UserStore.getters.getServerCode, msg: error }
|
return { code: UserStore.getters.getServerCode, msg: error.getMsgError() }
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestpwd(context, paramquery: IUserState) {
|
async function requestpwd(context, paramquery: IUserState) {
|
||||||
|
|
||||||
let call = process.env.MONGODB_HOST + '/requestnewpwd'
|
|
||||||
console.log('CALL ' + call)
|
|
||||||
|
|
||||||
let usertosend = {
|
let usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
keyappid: process.env.PAO_APP_ID,
|
||||||
idapp: process.env.APP_ID,
|
idapp: process.env.APP_ID,
|
||||||
@@ -244,11 +256,11 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(tools.CALLING)
|
||||||
|
|
||||||
return await Api.SendReq(call, 'POST', usertosend)
|
return await Api.SendReq('/requestnewpwd', 'POST', usertosend)
|
||||||
.then(({ res, body }) => {
|
.then(res => {
|
||||||
return { code: body.code, msg: body.msg }
|
return { code: res.data.code, msg: res.data.msg }
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return UserStore.getters.getServerCode
|
return UserStore.getters.getServerCode
|
||||||
@@ -257,9 +269,6 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function vreg(context, paramquery: ILinkReg) {
|
async function vreg(context, paramquery: ILinkReg) {
|
||||||
let call = process.env.MONGODB_HOST + '/vreg'
|
|
||||||
console.log('CALL ' + call)
|
|
||||||
|
|
||||||
let usertosend = {
|
let usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
keyappid: process.env.PAO_APP_ID,
|
||||||
idapp: process.env.APP_ID,
|
idapp: process.env.APP_ID,
|
||||||
@@ -267,19 +276,19 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(tools.CALLING)
|
||||||
|
|
||||||
return await Api.SendReq(call, 'POST', usertosend)
|
return await Api.SendReq('/vreg', 'POST', usertosend)
|
||||||
.then(({ res, body }) => {
|
.then(res => {
|
||||||
// console.log("RITORNO 2 ");
|
// console.log("RITORNO 2 ");
|
||||||
// mutations.setServerCode(myres);
|
// mutations.setServerCode(myres);
|
||||||
if (body.code === serv_constants.RIS_CODE_EMAIL_VERIFIED) {
|
if (res.data.code === serv_constants.RIS_CODE_EMAIL_VERIFIED) {
|
||||||
console.log('VERIFICATO !!')
|
console.log('VERIFICATO !!')
|
||||||
localStorage.setItem(rescodes.localStorage.verified_email, String(true))
|
localStorage.setItem(tools.localStorage.verified_email, String(true))
|
||||||
} else {
|
} else {
|
||||||
console.log('Risultato di vreg: ', body.code)
|
console.log('Risultato di vreg: ', res.data.code)
|
||||||
}
|
}
|
||||||
return { code: body.code, msg: body.msg }
|
return { code: res.data.code, msg: res.data.msg }
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return UserStore.getters.getServerCode
|
return UserStore.getters.getServerCode
|
||||||
@@ -287,8 +296,7 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function signup(context, authData: ISignupOptions) {
|
async function signup(context, authData: ISignupOptions) {
|
||||||
let call = process.env.MONGODB_HOST + '/users'
|
console.log('SIGNUP')
|
||||||
console.log('CALL ' + call)
|
|
||||||
|
|
||||||
// console.log("PASSW: " + authData.password);
|
// console.log("PASSW: " + authData.password);
|
||||||
|
|
||||||
@@ -308,21 +316,18 @@ namespace Actions {
|
|||||||
|
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
|
|
||||||
let myres: IResult
|
Mutations.mutations.setServerCode(tools.CALLING)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
return Api.SendReq('/users', 'POST', usertosend)
|
||||||
|
.then(res => {
|
||||||
|
|
||||||
return Api.SendReq(call, 'POST', usertosend)
|
const newuser = res.data
|
||||||
.then(({ res, body }) => {
|
|
||||||
myres = res
|
|
||||||
|
|
||||||
const newuser = body
|
|
||||||
|
|
||||||
console.log('newuser', newuser)
|
console.log('newuser', newuser)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(myres.status)
|
Mutations.mutations.setServerCode(res.status)
|
||||||
|
|
||||||
if (myres.status === 200) {
|
if (res.status === 200) {
|
||||||
let userId = newuser._id
|
let userId = newuser._id
|
||||||
let username = authData.username
|
let username = authData.username
|
||||||
if (process.env.DEV) {
|
if (process.env.DEV) {
|
||||||
@@ -339,18 +344,19 @@ namespace Actions {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||||
const expirationDate = new Date(now.getTime() * 1000)
|
const expirationDate = new Date(now.getTime() * 1000)
|
||||||
localStorage.setItem(rescodes.localStorage.userId, userId)
|
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||||
localStorage.setItem(rescodes.localStorage.username, username)
|
localStorage.setItem(tools.localStorage.userId, userId)
|
||||||
localStorage.setItem(rescodes.localStorage.token, state.x_auth_token)
|
localStorage.setItem(tools.localStorage.username, username)
|
||||||
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
localStorage.setItem(tools.localStorage.token, state.x_auth_token)
|
||||||
localStorage.setItem(rescodes.localStorage.verified_email, String(false))
|
localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString())
|
||||||
|
localStorage.setItem(tools.localStorage.verified_email, String(false))
|
||||||
state.isLogged = true
|
state.isLogged = true
|
||||||
// dispatch('storeUser', authData);
|
// dispatch('storeUser', authData);
|
||||||
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
||||||
|
|
||||||
return rescodes.OK
|
return tools.OK
|
||||||
} else {
|
} else {
|
||||||
return rescodes.ERR_GENERICO
|
return tools.ERR_GENERICO
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -361,23 +367,27 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function signin(context, authData: ISigninOptions) {
|
async function signin(context, authData: ISigninOptions) {
|
||||||
let call = process.env.MONGODB_HOST + '/users/login'
|
// console.log('LOGIN signin')
|
||||||
console.log('LOGIN ' + call)
|
|
||||||
|
|
||||||
console.log('MYLANG = ' + state.lang)
|
// console.log('MYLANG = ' + state.lang)
|
||||||
|
|
||||||
let sub = null
|
let sub = null
|
||||||
|
|
||||||
|
try {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
sub = await navigator.serviceWorker.ready
|
sub = await navigator.serviceWorker.ready
|
||||||
.then(function (swreg) {
|
.then(function (swreg) {
|
||||||
const sub = swreg.pushManager.getSubscription()
|
console.log('swreg')
|
||||||
|
let sub = swreg.pushManager.getSubscription()
|
||||||
return sub
|
return sub
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
sub = null
|
sub = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Err navigator.serviceWorker.ready ... GetSubscription:', e)
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
title: translate('notification.title_subscribed'),
|
title: translate('notification.title_subscribed'),
|
||||||
@@ -395,54 +405,35 @@ namespace Actions {
|
|||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log('PASSO 4')
|
||||||
|
if (process.env.DEBUG === '1')
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(tools.CALLING)
|
||||||
|
|
||||||
let myres: IResult
|
let myres: any
|
||||||
|
|
||||||
return Api.SendReq(call, 'POST', usertosend, true)
|
console.log('Api.SendReq')
|
||||||
.then(({ res, body }) => {
|
|
||||||
|
return Api.SendReq('/users/login', 'POST', usertosend, true)
|
||||||
|
.then(res => {
|
||||||
myres = res
|
myres = res
|
||||||
|
|
||||||
if (body.code === serv_constants.RIS_CODE_LOGIN_ERR) {
|
|
||||||
Mutations.mutations.setServerCode(body.code)
|
|
||||||
return { myres, body }
|
|
||||||
}
|
|
||||||
|
|
||||||
Mutations.mutations.setServerCode(myres.status)
|
|
||||||
|
|
||||||
if (myres.status !== 200) {
|
if (myres.status !== 200) {
|
||||||
return Promise.reject(rescodes.ERR_GENERICO)
|
return Promise.reject(tools.ERR_GENERICO)
|
||||||
}
|
}
|
||||||
return { myres, body }
|
return myres
|
||||||
|
|
||||||
}).then(({ myres, body }) => {
|
}).then(res => {
|
||||||
|
|
||||||
if (myres.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
if (res.success) {
|
||||||
if (process.env.DEV) {
|
GlobalStore.mutations.SetwasAlreadySubOnDb(res.data.subsExistonDb)
|
||||||
console.log('CODE = ' + body.code)
|
|
||||||
}
|
|
||||||
return body.code
|
|
||||||
} else if (myres.status !== 200) {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log('CODE = ' + body.code)
|
|
||||||
}
|
|
||||||
return body.code
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myres.status === 200) {
|
let myuser: IUserState = res.data.usertosend
|
||||||
GlobalStore.mutations.SetwasAlreadySubOnDb(body.subsExistonDb)
|
|
||||||
|
|
||||||
let myuser: IUserState = body.usertosend
|
|
||||||
if (myuser) {
|
if (myuser) {
|
||||||
let userId = myuser.userId
|
let userId = myuser.userId
|
||||||
let username = authData.username
|
let username = authData.username
|
||||||
let verified_email = myuser.verified_email
|
let verified_email = myuser.verified_email
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log('USERNAME = ' + username, 'IDUSER= ' + userId)
|
|
||||||
// console.log('state.x_auth_token= ' + state.x_auth_token)
|
|
||||||
}
|
|
||||||
|
|
||||||
Mutations.mutations.authUser({
|
Mutations.mutations.authUser({
|
||||||
userId,
|
userId,
|
||||||
@@ -453,21 +444,22 @@ namespace Actions {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||||
const expirationDate = new Date(now.getTime() * 1000)
|
const expirationDate = new Date(now.getTime() * 1000)
|
||||||
localStorage.setItem(rescodes.localStorage.userId, userId)
|
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||||
localStorage.setItem(rescodes.localStorage.username, username)
|
localStorage.setItem(tools.localStorage.userId, userId)
|
||||||
localStorage.setItem(rescodes.localStorage.token, state.x_auth_token)
|
localStorage.setItem(tools.localStorage.username, username)
|
||||||
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
localStorage.setItem(tools.localStorage.token, state.x_auth_token)
|
||||||
localStorage.setItem(rescodes.localStorage.isLogged, String(true))
|
localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString())
|
||||||
localStorage.setItem(rescodes.localStorage.verified_email, String(verified_email))
|
localStorage.setItem(tools.localStorage.isLogged, String(true))
|
||||||
localStorage.setItem(rescodes.localStorage.wasAlreadySubOnDb, String(GlobalStore.state.wasAlreadySubOnDb))
|
localStorage.setItem(tools.localStorage.verified_email, String(verified_email))
|
||||||
|
localStorage.setItem(tools.localStorage.wasAlreadySubOnDb, String(GlobalStore.state.wasAlreadySubOnDb))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rescodes.OK
|
return tools.OK
|
||||||
|
|
||||||
}).then(code => {
|
}).then(code => {
|
||||||
if (code === rescodes.OK) {
|
if (code === tools.OK) {
|
||||||
return setGlobal(true)
|
return setGlobal(true)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return code
|
return code
|
||||||
@@ -485,30 +477,28 @@ namespace Actions {
|
|||||||
async function logout(context) {
|
async function logout(context) {
|
||||||
console.log('logout')
|
console.log('logout')
|
||||||
|
|
||||||
localStorage.removeItem(rescodes.localStorage.expirationDate)
|
localStorage.removeItem(tools.localStorage.expirationDate)
|
||||||
localStorage.removeItem(rescodes.localStorage.token)
|
localStorage.removeItem(tools.localStorage.token)
|
||||||
localStorage.removeItem(rescodes.localStorage.userId)
|
localStorage.removeItem(tools.localStorage.userId)
|
||||||
localStorage.removeItem(rescodes.localStorage.username)
|
localStorage.removeItem(tools.localStorage.username)
|
||||||
localStorage.removeItem(rescodes.localStorage.isLogged)
|
localStorage.removeItem(tools.localStorage.isLogged)
|
||||||
// localStorage.removeItem(rescodes.localStorage.leftDrawerOpen)
|
// localStorage.removeItem(rescodes.localStorage.leftDrawerOpen)
|
||||||
localStorage.removeItem(rescodes.localStorage.verified_email)
|
localStorage.removeItem(tools.localStorage.verified_email)
|
||||||
localStorage.removeItem(rescodes.localStorage.categorySel)
|
localStorage.removeItem(tools.localStorage.categorySel)
|
||||||
localStorage.removeItem(rescodes.localStorage.wasAlreadySubOnDb)
|
localStorage.removeItem(tools.localStorage.wasAlreadySubOnDb)
|
||||||
|
|
||||||
|
state.isLogged = false
|
||||||
|
|
||||||
await GlobalStore.actions.clearDataAfterLogout()
|
await GlobalStore.actions.clearDataAfterLogout()
|
||||||
|
|
||||||
let call = process.env.MONGODB_HOST + '/users/me/token'
|
|
||||||
console.log('CALL ' + call)
|
|
||||||
|
|
||||||
let usertosend = {
|
let usertosend = {
|
||||||
keyappid: process.env.PAO_APP_ID,
|
keyappid: process.env.PAO_APP_ID,
|
||||||
idapp: process.env.APP_ID
|
idapp: process.env.APP_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(usertosend)
|
console.log(usertosend)
|
||||||
const riscall = await Api.SendReq(call, 'DELETE', usertosend)
|
const riscall = await Api.SendReq('/users/me/token', 'DELETE', usertosend)
|
||||||
.then(({ res, body }) => {
|
.then(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
Mutations.mutations.clearAuthData()
|
Mutations.mutations.clearAuthData()
|
||||||
@@ -524,13 +514,14 @@ namespace Actions {
|
|||||||
|
|
||||||
async function setGlobal(loggedWithNetwork: boolean) {
|
async function setGlobal(loggedWithNetwork: boolean) {
|
||||||
state.isLogged = true
|
state.isLogged = true
|
||||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(rescodes.localStorage.leftDrawerOpen) === 'true')
|
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(rescodes.localStorage.categorySel))
|
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||||
|
|
||||||
|
GlobalStore.actions.checkUpdates()
|
||||||
|
|
||||||
await GlobalStore.actions.loadAfterLogin()
|
await GlobalStore.actions.loadAfterLogin()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
Todos.actions.dbLoadTodo(true)
|
Todos.actions.dbLoadTodo({ checkPending: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,38 +531,33 @@ namespace Actions {
|
|||||||
// console.log('*** autologin_FromLocalStorage ***')
|
// console.log('*** autologin_FromLocalStorage ***')
|
||||||
// INIT
|
// INIT
|
||||||
|
|
||||||
UserStore.mutations.setlang(process.env.LANG_DEFAULT)
|
UserStore.state.lang = tools.getItemLS(tools.localStorage.lang)
|
||||||
// Estrai la Lang dal Localstorage
|
|
||||||
const lang = localStorage.getItem('lang')
|
|
||||||
if (lang) {
|
|
||||||
UserStore.mutations.setlang(lang)
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = localStorage.getItem(rescodes.localStorage.token)
|
const token = localStorage.getItem(tools.localStorage.token)
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const expirationDateStr = localStorage.getItem(rescodes.localStorage.expirationDate)
|
const expirationDateStr = localStorage.getItem(tools.localStorage.expirationDate)
|
||||||
let expirationDate = new Date(String(expirationDateStr))
|
let expirationDate = new Date(String(expirationDateStr))
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
if (now >= expirationDate) {
|
if (now >= expirationDate) {
|
||||||
console.log('!!! Login Expired')
|
console.log('!!! Login Expired')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const userId = String(localStorage.getItem(rescodes.localStorage.userId))
|
const userId = String(localStorage.getItem(tools.localStorage.userId))
|
||||||
const username = String(localStorage.getItem(rescodes.localStorage.username))
|
const username = String(localStorage.getItem(tools.localStorage.username))
|
||||||
const verified_email = localStorage.getItem(rescodes.localStorage.verified_email) === 'true'
|
const verified_email = localStorage.getItem(tools.localStorage.verified_email) === 'true'
|
||||||
|
|
||||||
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(rescodes.localStorage.wasAlreadySubOnDb) === 'true'
|
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(tools.localStorage.wasAlreadySubOnDb) === 'true'
|
||||||
|
|
||||||
console.log('************* autologin userId', userId)
|
console.log('************* autologin userId', userId)
|
||||||
|
|
||||||
UserStore.mutations.setAuth(token)
|
UserStore.mutations.setAuth(token)
|
||||||
|
|
||||||
Mutations.mutations.authUser({
|
Mutations.mutations.authUser({
|
||||||
userId: userId,
|
userId,
|
||||||
username: username,
|
username,
|
||||||
verified_email: verified_email,
|
verified_email
|
||||||
})
|
})
|
||||||
|
|
||||||
await setGlobal(false)
|
await setGlobal(false)
|
||||||
|
|||||||
10
src/store/Modules/costanti.ts
Normal file
10
src/store/Modules/costanti.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export const costanti = {
|
||||||
|
ShowTypeTask: {
|
||||||
|
SHOW_LAST_N_COMPLETED: 200,
|
||||||
|
SHOW_ONLY_TOCOMPLETE: 201,
|
||||||
|
SHOW_ALL: 202
|
||||||
|
},
|
||||||
|
CONFIG_ID_CFG: '1',
|
||||||
|
CONFIG_ID_STATE_CONN: '2',
|
||||||
|
CONFIG_ID_SHOW_TYPE_TODOS: '3'
|
||||||
|
}
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
export const rescodes = {
|
|
||||||
EMPTY: 0,
|
|
||||||
CALLING: 10,
|
|
||||||
OK: 20,
|
|
||||||
ERR_GENERICO: -1,
|
|
||||||
ERR_SERVERFETCH: -2,
|
|
||||||
ERR_AUTHENTICATION: -5,
|
|
||||||
DUPLICATE_EMAIL_ID: 11000,
|
|
||||||
DUPLICATE_USERNAME_ID: 11100,
|
|
||||||
|
|
||||||
LIST_END: '10000000',
|
|
||||||
LIST_START: '0',
|
|
||||||
|
|
||||||
localStorage: {
|
|
||||||
verified_email: 'vf',
|
|
||||||
wasAlreadySubOnDb: 'sb',
|
|
||||||
categorySel: 'cs',
|
|
||||||
isLogged: 'ilog',
|
|
||||||
expirationDate: 'expdate',
|
|
||||||
leftDrawerOpen: 'ldo',
|
|
||||||
userId: 'uid',
|
|
||||||
token: 'tk',
|
|
||||||
username: 'uname'
|
|
||||||
},
|
|
||||||
|
|
||||||
Todos: {
|
|
||||||
PRIORITY_HIGH: 2,
|
|
||||||
PRIORITY_NORMAL: 1,
|
|
||||||
PRIORITY_LOW: 0
|
|
||||||
},
|
|
||||||
|
|
||||||
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'
|
|
||||||
},
|
|
||||||
|
|
||||||
MenuAction: {
|
|
||||||
DELETE: 100,
|
|
||||||
TOGGLE_EXPIRING: 101,
|
|
||||||
COMPLETED: 110,
|
|
||||||
PROGRESS_BAR: 120,
|
|
||||||
PRIORITY: 130
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
selectPriority: {
|
|
||||||
'it': [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
label: 'Alta',
|
|
||||||
value: 2,
|
|
||||||
icon: 'expand_less'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
label: 'Normale',
|
|
||||||
value: 1,
|
|
||||||
icon: 'remove'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
label: 'Bassa',
|
|
||||||
value: 0,
|
|
||||||
icon: 'expand_more'
|
|
||||||
}],
|
|
||||||
'enUk': [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
label: 'High',
|
|
||||||
value: 2,
|
|
||||||
icon: 'expand_less'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
label: 'Normal',
|
|
||||||
value: 1,
|
|
||||||
icon: 'remove'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
label: 'Low',
|
|
||||||
value: 0,
|
|
||||||
icon: 'expand_more'
|
|
||||||
}]
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
INDEX_MENU_DELETE: 3,
|
|
||||||
|
|
||||||
menuPopupTodo: {
|
|
||||||
'it': [
|
|
||||||
{
|
|
||||||
id: 10,
|
|
||||||
label: '',
|
|
||||||
value: 120, // PROGRESS_BAR
|
|
||||||
icon: 'rowing',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 20,
|
|
||||||
label: 'Imposta Priorità',
|
|
||||||
value: 130, // PRIORITY
|
|
||||||
icon: 'rowing',
|
|
||||||
checked: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 30,
|
|
||||||
label: 'Completato',
|
|
||||||
value: 110, // COMPLETED
|
|
||||||
icon: 'check_circle',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 40,
|
|
||||||
label: 'Imposta Scadenza',
|
|
||||||
value: 101, // TOGGLE_EXPIRING
|
|
||||||
icon: 'date_range',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 50,
|
|
||||||
label: 'Elimina',
|
|
||||||
value: 100, // DELETE
|
|
||||||
icon: 'delete',
|
|
||||||
checked: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'enUk': [
|
|
||||||
{
|
|
||||||
id: 10,
|
|
||||||
label: '',
|
|
||||||
value: 120, // PROGRESS_BAR
|
|
||||||
icon: 'check_circle',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 20,
|
|
||||||
label: 'Set Priority',
|
|
||||||
value: 130, // PRIORITY
|
|
||||||
icon: 'high_priority',
|
|
||||||
checked: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 30,
|
|
||||||
label: 'Completed',
|
|
||||||
value: 110, // COMPLETED
|
|
||||||
icon: 'check_circle',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 40,
|
|
||||||
label: 'Set Expiring',
|
|
||||||
value: 101, // TOGGLE_EXPIRING
|
|
||||||
icon: 'date_range',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 50,
|
|
||||||
label: 'Delete',
|
|
||||||
value: 100, // DELETE
|
|
||||||
icon: 'trash',
|
|
||||||
checked: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
439
src/store/Modules/tools.ts
Normal file
439
src/store/Modules/tools.ts
Normal file
@@ -0,0 +1,439 @@
|
|||||||
|
import { ITodo } from '@src/model'
|
||||||
|
import { costanti } from './costanti'
|
||||||
|
import globalroutines from './../../globalroutines/index'
|
||||||
|
import { Todos, UserStore } from '@store'
|
||||||
|
import Api from '@api'
|
||||||
|
|
||||||
|
export const tools = {
|
||||||
|
EMPTY: 0,
|
||||||
|
CALLING: 10,
|
||||||
|
OK: 20,
|
||||||
|
ERR_GENERICO: -1,
|
||||||
|
ERR_SERVERFETCH: -2,
|
||||||
|
ERR_AUTHENTICATION: -5,
|
||||||
|
DUPLICATE_EMAIL_ID: 11000,
|
||||||
|
DUPLICATE_USERNAME_ID: 11100,
|
||||||
|
|
||||||
|
LIST_END: '10000000',
|
||||||
|
LIST_START: '0',
|
||||||
|
|
||||||
|
SERVKEY_VERS: 'vers',
|
||||||
|
|
||||||
|
localStorage: {
|
||||||
|
verified_email: 'vf',
|
||||||
|
wasAlreadySubOnDb: 'sb',
|
||||||
|
categorySel: 'cs',
|
||||||
|
isLogged: 'ilog',
|
||||||
|
expirationDate: 'expdate',
|
||||||
|
leftDrawerOpen: 'ldo',
|
||||||
|
userId: 'uid',
|
||||||
|
token: 'tk',
|
||||||
|
username: 'uname',
|
||||||
|
lang: 'lg'
|
||||||
|
},
|
||||||
|
|
||||||
|
Todos: {
|
||||||
|
PRIORITY_HIGH: 2,
|
||||||
|
PRIORITY_NORMAL: 1,
|
||||||
|
PRIORITY_LOW: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
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'
|
||||||
|
},
|
||||||
|
|
||||||
|
MenuAction: {
|
||||||
|
DELETE: 100,
|
||||||
|
TOGGLE_EXPIRING: 101,
|
||||||
|
COMPLETED: 110,
|
||||||
|
PROGRESS_BAR: 120,
|
||||||
|
PRIORITY: 130,
|
||||||
|
SHOW_TASK: 150,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
selectPriority: {
|
||||||
|
'it': [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
label: 'Alta',
|
||||||
|
value: 2,
|
||||||
|
icon: 'expand_less'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
label: 'Normale',
|
||||||
|
value: 1,
|
||||||
|
icon: 'remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
label: 'Bassa',
|
||||||
|
value: 0,
|
||||||
|
icon: 'expand_more'
|
||||||
|
}],
|
||||||
|
'esEs': [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
label: 'Alta',
|
||||||
|
value: 2,
|
||||||
|
icon: 'expand_less'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
label: 'Normal',
|
||||||
|
value: 1,
|
||||||
|
icon: 'remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
label: 'Baja',
|
||||||
|
value: 0,
|
||||||
|
icon: 'expand_more'
|
||||||
|
}],
|
||||||
|
'enUs': [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
label: 'High',
|
||||||
|
value: 2,
|
||||||
|
icon: 'expand_less'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
label: 'Normal',
|
||||||
|
value: 1,
|
||||||
|
icon: 'remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
label: 'Low',
|
||||||
|
value: 0,
|
||||||
|
icon: 'expand_more'
|
||||||
|
}],
|
||||||
|
'de': [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
label: 'High',
|
||||||
|
value: 2,
|
||||||
|
icon: 'expand_less'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
label: 'Normal',
|
||||||
|
value: 1,
|
||||||
|
icon: 'remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
label: 'Low',
|
||||||
|
value: 0,
|
||||||
|
icon: 'expand_more'
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
INDEX_MENU_DELETE: 4,
|
||||||
|
|
||||||
|
menuPopupTodo: {
|
||||||
|
'it': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: '',
|
||||||
|
value: 120, // PROGRESS_BAR
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Imposta Priorità',
|
||||||
|
value: 130, // PRIORITY
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'Completato',
|
||||||
|
value: 110, // COMPLETED
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 40,
|
||||||
|
label: 'Imposta Scadenza',
|
||||||
|
value: 101, // TOGGLE_EXPIRING
|
||||||
|
icon: 'date_range',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 50,
|
||||||
|
label: 'Elimina',
|
||||||
|
value: 100, // DELETE
|
||||||
|
icon: 'delete',
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'esEs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: '',
|
||||||
|
value: 120, // PROGRESS_BAR
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Establecer Prioridad',
|
||||||
|
value: 130, // PRIORITY
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'Completado',
|
||||||
|
value: 110, // COMPLETED
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 40,
|
||||||
|
label: 'Establecer expiración',
|
||||||
|
value: 101, // TOGGLE_EXPIRING
|
||||||
|
icon: 'date_range',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 50,
|
||||||
|
label: 'Borrar',
|
||||||
|
value: 100, // DELETE
|
||||||
|
icon: 'delete',
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'enUs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: '',
|
||||||
|
value: 120, // PROGRESS_BAR
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Set Priority',
|
||||||
|
value: 130, // PRIORITY
|
||||||
|
icon: 'high_priority',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'Completed',
|
||||||
|
value: 110, // COMPLETED
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 40,
|
||||||
|
label: 'Set Expiring',
|
||||||
|
value: 101, // TOGGLE_EXPIRING
|
||||||
|
icon: 'date_range',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 50,
|
||||||
|
label: 'Delete',
|
||||||
|
value: 100, // DELETE
|
||||||
|
icon: 'trash',
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
menuPopupConfigTodo: {
|
||||||
|
'it': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Mostra Task',
|
||||||
|
value: 150, // SHOW_TASK
|
||||||
|
icon: 'rowing',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'esEs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Mostrar Tareas',
|
||||||
|
value: 150,
|
||||||
|
icon: 'rowing',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'enUs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Show Task',
|
||||||
|
value: 150,
|
||||||
|
icon: 'rowing',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
listOptionShowTask: {
|
||||||
|
'it': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Mostra gli ultimi N completati',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Compiti da Completare',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'Tutti i compiti',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ALL,
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'esEs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Mostrar los ultimos N completados',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Tareas para completar',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'Todos las Tareas',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ALL,
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'enUs': [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
label: 'Show last N Completed',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
label: 'Task to complete',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
|
||||||
|
icon: 'rowing',
|
||||||
|
checked: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 30,
|
||||||
|
label: 'All Tasks',
|
||||||
|
value: costanti.ShowTypeTask.SHOW_ALL,
|
||||||
|
icon: 'check_circle',
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
jsonCopy(src) {
|
||||||
|
return JSON.parse(JSON.stringify(src))
|
||||||
|
},
|
||||||
|
|
||||||
|
getItemLS(item) {
|
||||||
|
let ris = localStorage.getItem(item)
|
||||||
|
if ((ris == null) || (ris === '') || (ris === 'null'))
|
||||||
|
ris = ''
|
||||||
|
|
||||||
|
return ris
|
||||||
|
},
|
||||||
|
|
||||||
|
notifyarraychanged(array) {
|
||||||
|
if (array.length > 0)
|
||||||
|
array.splice(array.length - 1, 1, array[array.length - 1])
|
||||||
|
},
|
||||||
|
|
||||||
|
existArr(x) {
|
||||||
|
return x = (typeof x !== 'undefined' && x instanceof Array) ? x : []
|
||||||
|
},
|
||||||
|
|
||||||
|
json2array(json) {
|
||||||
|
let result = []
|
||||||
|
let keys = Object.keys(json)
|
||||||
|
keys.forEach(function (key) {
|
||||||
|
result.push(json[key])
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
let cmdSw = cmd
|
||||||
|
if ((cmd === tools.DB.CMD_SYNC_NEW_TODOS) || (cmd === tools.DB.CMD_DELETE_TODOS)) {
|
||||||
|
cmdSw = tools.DB.CMD_SYNC_TODOS
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
return await navigator.serviceWorker.ready
|
||||||
|
.then(function (sw) {
|
||||||
|
// console.log('---------------------- navigator.serviceWorker.ready')
|
||||||
|
|
||||||
|
return globalroutines(null, 'write', table, item, id)
|
||||||
|
.then(function (id) {
|
||||||
|
// console.log('id', id)
|
||||||
|
const sep = '|'
|
||||||
|
|
||||||
|
let multiparams = cmdSw + sep + table + sep + method + sep + UserStore.state.x_auth_token + sep + UserStore.state.lang
|
||||||
|
let mymsgkey = {
|
||||||
|
_id: multiparams,
|
||||||
|
value: multiparams
|
||||||
|
}
|
||||||
|
return globalroutines(null, 'write', 'swmsg', mymsgkey, multiparams)
|
||||||
|
.then(ris => {
|
||||||
|
// if ('SyncManager' in window) {
|
||||||
|
// console.log(' SENDING... sw.sync.register', multiparams)
|
||||||
|
// return sw.sync.register(multiparams)
|
||||||
|
// } else {
|
||||||
|
// #Todo ++ Alternative 2 to SyncManager
|
||||||
|
return Api.syncAlternative(multiparams)
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
let data = null
|
||||||
|
if (msg !== '') {
|
||||||
|
data = { message: msg, position: 'bottom', timeout: 3000 }
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.error('Errore in globalroutines', table, err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
24
src/typings/index.d.ts
vendored
Normal file
24
src/typings/index.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export interface ActionTree<S, R> {
|
||||||
|
[key: string]: Action<S, R>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetterTree<S, R> {
|
||||||
|
[key: string]: Getter<S, R>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MutationTree<S> {
|
||||||
|
[key: string]: Mutation<S>;
|
||||||
|
}
|
||||||
|
export interface ModuleTree<S> {
|
||||||
|
[key: string]: Module<S>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface Module<S, R> {
|
||||||
|
namespaced?: boolean;
|
||||||
|
state?: S | (() => S);
|
||||||
|
getters?: GetterTree<S, R>;
|
||||||
|
actions?: ActionTree<S, R>;
|
||||||
|
mutations?: MutationTree<S>;
|
||||||
|
modules?: ModuleTree<R>;
|
||||||
|
}
|
||||||
8
src/typings/libs/dragula.d.ts
vendored
Normal file
8
src/typings/libs/dragula.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { dragula } from 'vue2-dragula'
|
||||||
|
|
||||||
|
declare module 'vue/types/vue' {
|
||||||
|
interface Vue {
|
||||||
|
$dragula: dragula
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
import {mapActions} from 'vuex'
|
import {mapActions} from 'vuex'
|
||||||
import * as types from '../../store/mutation-types'
|
import * as types from '../../store/mutation-types'
|
||||||
import { rescodes } from '../../../store/Modules/rescodes'
|
import { rescodes } from '../../../store/Modules/tools'
|
||||||
|
|
||||||
import {serv_constants} from '../../store/Modules/serv_constants'
|
import {serv_constants} from '../../store/Modules/serv_constants'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component, Prop, Watch } from 'vue-property-decorator'
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
||||||
import { GlobalStore, UserStore } from '@store'
|
import { GlobalStore, UserStore } from '@store'
|
||||||
import { rescodes } from '../../../store/Modules/rescodes'
|
import { tools } from '../../../store/Modules/tools'
|
||||||
import { serv_constants } from '../../../store/Modules/serv_constants'
|
import { serv_constants } from '../../../store/Modules/serv_constants'
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ export default class Signin extends Vue {
|
|||||||
public $q
|
public $q
|
||||||
loading: boolean
|
loading: boolean
|
||||||
$t: any
|
$t: any
|
||||||
|
public iswaitingforRes: boolean = false
|
||||||
|
|
||||||
public signin: ISigninOptions = {
|
public signin: ISigninOptions = {
|
||||||
username: process.env.TEST_USERNAME || '',
|
username: process.env.TEST_USERNAME || '',
|
||||||
@@ -75,8 +76,9 @@ export default class Signin extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkErrors(riscode) {
|
checkErrors(riscode) {
|
||||||
// console.log("RIS = " + riscode);
|
// console.log('checkErrors: ', riscode)
|
||||||
if (riscode === rescodes.OK) {
|
try {
|
||||||
|
if (riscode === tools.OK) {
|
||||||
this.showNotif({ type: 'positive', message: this.$t('login.completato') })
|
this.showNotif({ type: 'positive', message: this.$t('login.completato') })
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
|
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||||
@@ -85,21 +87,35 @@ export default class Signin extends Vue {
|
|||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
resolve('anything')
|
resolve('anything')
|
||||||
}, 1000)
|
}, 3000)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
setTimeout( () => {
|
||||||
|
this.$q.loading.hide()
|
||||||
|
}, 200)
|
||||||
this.showNotif(this.$t('login.errato'))
|
this.showNotif(this.$t('login.errato'))
|
||||||
|
this.iswaitingforRes = false
|
||||||
this.$router.push('/signin')
|
this.$router.push('/signin')
|
||||||
})
|
})
|
||||||
|
|
||||||
} else if (riscode === rescodes.ERR_SERVERFETCH) {
|
} else if (riscode === tools.ERR_SERVERFETCH) {
|
||||||
this.showNotif(this.$t('fetch.errore_server'))
|
this.showNotif(this.$t('fetch.errore_server'))
|
||||||
} else if (riscode === rescodes.ERR_GENERICO) {
|
} else if (riscode === tools.ERR_GENERICO) {
|
||||||
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
||||||
this.showNotif(msg)
|
this.showNotif(msg)
|
||||||
} else {
|
} else {
|
||||||
this.showNotif('Errore num ' + riscode)
|
this.showNotif('Errore num ' + riscode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (riscode !== serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||||
|
this.iswaitingforRes = false
|
||||||
|
setTimeout( () => {
|
||||||
|
this.$q.loading.hide()
|
||||||
|
}, 200)
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(response) {
|
redirect(response) {
|
||||||
@@ -131,39 +147,52 @@ export default class Signin extends Vue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$q.loading.show({ message: this.$t('login.incorso') })
|
let msg = this.$t('login.incorso')
|
||||||
|
if (process.env.DEBUG)
|
||||||
|
msg += ' ' + process.env.MONGODB_HOST
|
||||||
|
this.$q.loading.show({ message: msg})
|
||||||
|
// disable Button Login:
|
||||||
|
this.iswaitingforRes = true
|
||||||
|
|
||||||
|
if (process.env.DEBUG)
|
||||||
|
console.log('this.signin', this.signin)
|
||||||
|
|
||||||
console.log(this.signin)
|
|
||||||
UserStore.actions.signin(this.signin)
|
UserStore.actions.signin(this.signin)
|
||||||
.then((riscode) => {
|
.then((riscode) => {
|
||||||
// console.log('riscode=', riscode)
|
// console.log('signin FINITO CALL: riscode=', riscode)
|
||||||
if (riscode === rescodes.OK) {
|
if (riscode === tools.OK) {
|
||||||
router.push('/signin')
|
router.push('/signin')
|
||||||
}
|
}
|
||||||
return riscode
|
return riscode
|
||||||
}).then((riscode) => {
|
}).then((riscode) => {
|
||||||
|
if (UserStore.state.lang !== '')
|
||||||
|
this.$i18n.locale = UserStore.state.lang // Set Lang
|
||||||
|
else
|
||||||
|
UserStore.mutations.setlang(this.$i18n.locale) // Set Lang
|
||||||
|
|
||||||
|
// console.log('LANG ORA=', UserStore.state.lang)
|
||||||
|
|
||||||
globalroutines(this, 'loadapp', '')
|
globalroutines(this, 'loadapp', '')
|
||||||
return riscode
|
return riscode
|
||||||
})
|
})
|
||||||
.then((riscode) => {
|
.then((riscode) => {
|
||||||
if (riscode === rescodes.OK) {
|
if (riscode === tools.OK) {
|
||||||
GlobalStore.actions.createPushSubscription()
|
GlobalStore.actions.createPushSubscription()
|
||||||
.then(ris => {
|
.then(rissub => {
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.log('ERROR = ' + e)
|
console.log('ERROR Subscription = ' + e)
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.checkErrors(riscode)
|
|
||||||
this.$q.loading.hide()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.checkErrors(riscode)
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log('ERROR = ' + error)
|
console.log('ERROR SIGNIN = ' + error)
|
||||||
|
|
||||||
this.checkErrors(error)
|
this.checkErrors(error)
|
||||||
this.$q.loading.hide()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
:before="[{icon: 'person', handler () {}}]"
|
:before="[{icon: 'person', handler () {}}]"
|
||||||
@blur="$v.signin.username.$touch"
|
@blur="$v.signin.username.$touch"
|
||||||
:error="$v.signin.username.$error"
|
:error="$v.signin.username.$error"
|
||||||
:float-label="$t('reg.username')"></q-input>
|
:float-label="$t('reg.username_login')"></q-input>
|
||||||
</q-field>
|
</q-field>
|
||||||
|
|
||||||
<q-field
|
<q-field
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</q-card-main>
|
</q-card-main>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error">{{$t('login.enter')}}
|
<q-btn rounded size="lg" color="primary" @click="submit" :disable="$v.$error || iswaitingforRes">{{$t('login.enter')}}
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -3,3 +3,10 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 450px;
|
max-width: 450px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { Component, Prop, Watch } from 'vue-property-decorator'
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
||||||
import { UserStore } from '@store'
|
import { UserStore } from '@store'
|
||||||
import { rescodes } from '../../../store/Modules/rescodes'
|
import { tools } from '../../../store/Modules/tools'
|
||||||
|
|
||||||
import { ISignupOptions, IUserState } from 'model'
|
import { ISignupOptions, IUserState } from 'model'
|
||||||
import { validations, TSignup } from './signup-validate'
|
import { validations, TSignup } from './signup-validate'
|
||||||
@@ -125,16 +125,16 @@ export default class Signup extends Vue {
|
|||||||
|
|
||||||
checkErrors(riscode: number) {
|
checkErrors(riscode: number) {
|
||||||
console.log('checkErrors', riscode)
|
console.log('checkErrors', riscode)
|
||||||
if (riscode === rescodes.DUPLICATE_EMAIL_ID) {
|
if (riscode === tools.DUPLICATE_EMAIL_ID) {
|
||||||
this.showNotif(this.$t('reg.err.duplicate_email'))
|
this.showNotif(this.$t('reg.err.duplicate_email'))
|
||||||
} else if (riscode === rescodes.DUPLICATE_USERNAME_ID) {
|
} else if (riscode === tools.DUPLICATE_USERNAME_ID) {
|
||||||
this.showNotif(this.$t('reg.err.duplicate_username'))
|
this.showNotif(this.$t('reg.err.duplicate_username'))
|
||||||
} else if (riscode === rescodes.ERR_SERVERFETCH) {
|
} else if (riscode === tools.ERR_SERVERFETCH) {
|
||||||
this.showNotif(this.$t('fetch.errore_server'))
|
this.showNotif(this.$t('fetch.errore_server'))
|
||||||
} else if (riscode === rescodes.ERR_GENERICO) {
|
} else if (riscode === tools.ERR_GENERICO) {
|
||||||
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
||||||
this.showNotif(msg)
|
this.showNotif(msg)
|
||||||
} else if (riscode === rescodes.OK) {
|
} else if (riscode === tools.OK) {
|
||||||
this.$router.push('/signin')
|
this.$router.push('/signin')
|
||||||
this.showNotif({type: 'warning', textColor: 'black', message: this.$t('components.authentication.email_verification.link_sent')})
|
this.showNotif({type: 'warning', textColor: 'black', message: this.$t('components.authentication.email_verification.link_sent')})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -79,8 +79,10 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<q-btn rounded size="lg" color="primary" @click="submitOk" :disabled='!allowSubmit'>{{$t('reg.submit')}}
|
<div class="wrapper">
|
||||||
|
<q-btn rounded size="lg" color="positive" @click="submitOk" :disabled='!allowSubmit'>{{$t('reg.submit')}}
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
import {mapActions} from 'vuex'
|
import {mapActions} from 'vuex'
|
||||||
import * as types from '../../store/mutation-types'
|
import * as types from '../../store/mutation-types'
|
||||||
//import {rescodes} from '../../store/Modules/user'
|
//import {tools} from '../../store/Modules/user'
|
||||||
|
|
||||||
import {serv_constants} from '../../store/Modules/serv_constants';
|
import {serv_constants} from '../../store/Modules/serv_constants';
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@src/*": ["./*"],
|
"@src/*": ["./*"],
|
||||||
"@components": ["./components/index.ts"],
|
"@components": ["./components/index.ts"],
|
||||||
|
"@css/*": ["./statics/css/*"],
|
||||||
|
"@icons/*": ["./statics/icons/*"],
|
||||||
|
"@images/*": ["./statics/images/*"],
|
||||||
|
"@js/*": ["./statics/js/*"],
|
||||||
"@classes": ["./classes/index.ts"],
|
"@classes": ["./classes/index.ts"],
|
||||||
"@utils/*": ["./utils/*"],
|
"@utils/*": ["./utils/*"],
|
||||||
"@validators": ["./utils/validators.ts"],
|
"@validators": ["./utils/validators.ts"],
|
||||||
|
|||||||
Reference in New Issue
Block a user