- Manage multiple login, in different browsers... Multi Token...
- visualization of the Connection State (Online, Offline) using fetch.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
APP_VERSION="DEV 0.0.10"
|
APP_VERSION="DEV 0.0.13"
|
||||||
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'
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This file (which will be your service worker)
|
* This file (which will be your service worker)
|
||||||
* is picked up by the build system ONLY if
|
* is picked up by the build system ONLY if
|
||||||
@@ -7,49 +6,48 @@
|
|||||||
|
|
||||||
// Questo è il swSrc
|
// Questo è il swSrc
|
||||||
|
|
||||||
console.log('SW-06 ___________________________ PAO: this is my custom service worker');
|
console.log(' [ VER-0.0.12 ] _---------________-----------_________------------__________________________ PAO: this is my custom service worker');
|
||||||
|
|
||||||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); //++Todo: Replace with local workbox.js
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); //++Todo: Replace with local workbox.js
|
||||||
importScripts('../statics/js/idb.js');
|
importScripts('../statics/js/idb.js');
|
||||||
importScripts('../statics/js/storage.js');
|
importScripts('../statics/js/storage.js');
|
||||||
|
|
||||||
|
|
||||||
console.log('SW-06 1');
|
// console.log('SW-06 1');
|
||||||
const cfgenv = {
|
const cfgenv = {
|
||||||
serverweb: self.location.protocol + "//" + self.location.hostname + ':3000',
|
serverweb: self.location.protocol + "//" + self.location.hostname + ':3000',
|
||||||
dbname: 'mydb3',
|
dbname: 'mydb3',
|
||||||
dbversion: 11,
|
dbversion: 11,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('SW-06 2');
|
// console.log('SW-06 2');
|
||||||
|
|
||||||
console.log('SERVERWEB=', cfgenv.serverweb)
|
// console.log('SERVERWEB=', cfgenv.serverweb)
|
||||||
|
|
||||||
// console.log('serverweb', cfgenv.serverweb)
|
// console.log('serverweb', cfgenv.serverweb)
|
||||||
|
|
||||||
async function writeData(table, data) {
|
async function writeData(table, data) {
|
||||||
console.log('writeData', table, data);
|
// console.log('writeData', table, data);
|
||||||
await idbKeyval.setdata(table, data);
|
await idbKeyval.setdata(table, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readAllData(table) {
|
async function readAllData(table) {
|
||||||
console.log('readAllData', table);
|
// console.log('readAllData', table);
|
||||||
return await idbKeyval.getalldata(table);
|
return await idbKeyval.getalldata(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearAllData(table) {
|
async function clearAllData(table) {
|
||||||
console.log('clearAllData', table);
|
// console.log('clearAllData', table);
|
||||||
await idbKeyval.clearalldata(table)
|
await idbKeyval.clearalldata(table)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteItemFromData(table, id) {
|
async function deleteItemFromData(table, id) {
|
||||||
console.log('deleteItemFromData', table, 'ID:', id);
|
// console.log('deleteItemFromData', table, 'ID:', id);
|
||||||
|
|
||||||
await idbKeyval.deletedata(table, id)
|
await idbKeyval.deletedata(table, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// self.addEventListener('activate', function(event) {
|
// self.addEventListener('activate', function(event) {
|
||||||
// event.waitUntil(
|
// event.waitUntil(
|
||||||
// // createDB()
|
// // createDB()
|
||||||
@@ -58,7 +56,7 @@ async function deleteItemFromData(table, id) {
|
|||||||
|
|
||||||
if (!workbox) {
|
if (!workbox) {
|
||||||
let workbox = new self.WorkboxSW();
|
let workbox = new self.WorkboxSW();
|
||||||
console.log('SW-06 3');
|
// console.log('SW-06 3');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workbox) {
|
if (workbox) {
|
||||||
@@ -109,15 +107,15 @@ if (workbox) {
|
|||||||
workbox.routing.registerRoute(
|
workbox.routing.registerRoute(
|
||||||
new RegExp(cfgenv.serverweb + '/todos/'),
|
new RegExp(cfgenv.serverweb + '/todos/'),
|
||||||
function (args) {
|
function (args) {
|
||||||
console.log('registerRoute!')
|
// console.log('registerRoute!')
|
||||||
return fetch(args.event.request, args.event.headers)
|
return fetch(args.event.request, args.event.headers)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
console.log('1° ******* [[[ SERVICE-WORKER ]]] registerRoute fetch: ', args.event)
|
console.log('1° ******* [[[ SERVICE-WORKER ]]] registerRoute fetch: -> ', args.event.headers)
|
||||||
// LOAD FROM SERVER , AND SAVE INTO INDEXEDDB
|
// LOAD FROM SERVER , AND SAVE INTO INDEXEDDB
|
||||||
console.log('res.status', res.status)
|
console.log('res.status', res.status)
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
var clonedRes = res.clone();
|
const clonedRes = res.clone();
|
||||||
clearAllData('todos')
|
return clearAllData('todos')
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return clonedRes.json();
|
return clonedRes.json();
|
||||||
})
|
})
|
||||||
@@ -129,8 +127,8 @@ if (workbox) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
return res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -201,18 +199,18 @@ if (workbox) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
workbox.routing.registerRoute(
|
// workbox.routing.registerRoute(
|
||||||
new RegExp(/^http/),
|
// new RegExp(/^http/),
|
||||||
workbox.strategies.networkFirst({
|
// workbox.strategies.networkFirst({
|
||||||
cacheName: 'all-stuff',
|
// cacheName: 'all-stuff',
|
||||||
plugins: [
|
// plugins: [
|
||||||
new workbox.expiration.Plugin({
|
// new workbox.expiration.Plugin({
|
||||||
maxAgeSeconds: 10 * 24 * 60 * 60,
|
// maxAgeSeconds: 10 * 24 * 60 * 60,
|
||||||
// Only cache 10 requests.
|
// // Only cache 10 requests.
|
||||||
}),
|
// }),
|
||||||
]
|
// ]
|
||||||
})
|
// })
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
|
||||||
workbox.routing.registerRoute(
|
workbox.routing.registerRoute(
|
||||||
@@ -225,14 +223,14 @@ if (workbox) {
|
|||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
|
|
||||||
console.log('***************** Entering in custom-service-worker.js:')
|
// console.log('***************** Entering in custom-service-worker.js:')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener('fetch', (event) => {
|
self.addEventListener('fetch', (event) => {
|
||||||
if (event.request.url === '/') {
|
if (event.request.url === '/') {
|
||||||
const staleWhileRevalidate = new workbox.strategies.StaleWhileRevalidate();
|
const staleWhileRevalidate = new workbox.strategies.StaleWhileRevalidate();
|
||||||
event.respondWith(staleWhileRevalidate.handle({event}));
|
event.respondWith(staleWhileRevalidate.handle({ event }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -280,13 +278,13 @@ self.addEventListener('sync', function (event) {
|
|||||||
headers.append('Accept', 'application/json')
|
headers.append('Accept', 'application/json')
|
||||||
headers.append('x-auth', token)
|
headers.append('x-auth', token)
|
||||||
|
|
||||||
console.log('A1) INIZIO.............................................................');
|
// console.log('A1) INIZIO.............................................................');
|
||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
readAllData(table)
|
readAllData(table)
|
||||||
.then(function (alldata) {
|
.then(function (alldata) {
|
||||||
const myrecs = [...alldata]
|
const myrecs = [...alldata]
|
||||||
console.log('----------------------- LEGGO QUALCOSA DAL WAITUNTIL ')
|
// console.log('----------------------- LEGGO QUALCOSA DAL WAITUNTIL ')
|
||||||
if (myrecs) {
|
if (myrecs) {
|
||||||
for (let rec of myrecs) {
|
for (let rec of myrecs) {
|
||||||
//console.log('syncing', table, '', rec.descr)
|
//console.log('syncing', table, '', rec.descr)
|
||||||
@@ -304,18 +302,10 @@ self.addEventListener('sync', function (event) {
|
|||||||
mode: 'cors', // 'no-cors',
|
mode: 'cors', // 'no-cors',
|
||||||
body: JSON.stringify(rec)
|
body: JSON.stringify(rec)
|
||||||
})
|
})
|
||||||
.then(function (resData) {
|
.then(resData => deleteItemFromData(table, rec._id))
|
||||||
// console.log('Result CALL ', method, ' OK? =', resData.ok);
|
.then(() => {
|
||||||
|
|
||||||
// Anyway Delete this, otherwise in some cases will return error, but it's not a problem.
|
|
||||||
// for example if I change a record and then I deleted ...
|
|
||||||
// if (resData.ok) {
|
|
||||||
deleteItemFromData(table, rec._id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
console.log('DELETE: ', mystrparam)
|
console.log('DELETE: ', mystrparam)
|
||||||
deleteItemFromData('swmsg', mystrparam)
|
deleteItemFromData('swmsg', mystrparam)
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
console.log('!!!!!!!!!!!!!!! Error while sending data', err);
|
console.log('!!!!!!!!!!!!!!! Error while sending data', err);
|
||||||
@@ -360,7 +350,7 @@ self.addEventListener('sync', event => {
|
|||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
self.addEventListener('notificationclick', function(event) {
|
self.addEventListener('notificationclick', function (event) {
|
||||||
var notification = event.notification;
|
var notification = event.notification;
|
||||||
var action = event.action;
|
var action = event.action;
|
||||||
|
|
||||||
@@ -373,8 +363,8 @@ self.addEventListener('notificationclick', function(event) {
|
|||||||
console.log(action);
|
console.log(action);
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
clients.matchAll()
|
clients.matchAll()
|
||||||
.then(function(clis) {
|
.then(function (clis) {
|
||||||
var client = clis.find(function(c) {
|
var client = clis.find(function (c) {
|
||||||
return c.visibilityState === 'visible';
|
return c.visibilityState === 'visible';
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -390,14 +380,14 @@ self.addEventListener('notificationclick', function(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('notificationclose', function(event) {
|
self.addEventListener('notificationclose', function (event) {
|
||||||
console.log('Notification was closed', event);
|
console.log('Notification was closed', event);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('push', function(event) {
|
self.addEventListener('push', function (event) {
|
||||||
console.log('Push Notification received', event);
|
console.log('Push Notification received', event);
|
||||||
|
|
||||||
var data = {title: 'New!', content: 'Something new happened!', openUrl: '/'};
|
var data = { title: 'New!', content: 'Something new happened!', openUrl: '/' };
|
||||||
|
|
||||||
if (event.data) {
|
if (event.data) {
|
||||||
data = JSON.parse(event.data.text());
|
data = JSON.parse(event.data.text());
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ export default class App extends Vue {
|
|||||||
// console.info(process.env)
|
// console.info(process.env)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserStore.actions.autologin()
|
UserStore.actions.autologin_FromLocalStorage()
|
||||||
.then((loginEseguito) => {
|
.then((loadstorage) => {
|
||||||
if (loginEseguito) {
|
if (loadstorage) {
|
||||||
globalroutines(this, 'loadapp', '')
|
globalroutines(this, 'loadapp', '')
|
||||||
// this.$router.replace('/')
|
// this.$router.replace('/')
|
||||||
|
|
||||||
@@ -48,6 +48,9 @@ export default class App extends Vue {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Calling the Server for updates ?
|
||||||
|
// Check the verified_email
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
AxiosResponse
|
AxiosResponse
|
||||||
} from 'axios'
|
} from 'axios'
|
||||||
import { default as VueRouter } from 'vue-router'
|
import { default as VueRouter } from 'vue-router'
|
||||||
|
import { serv_constants } from "@src/store/Modules/serv_constants"
|
||||||
// import { TokenHelper } from "./token-helper";
|
// import { TokenHelper } from "./token-helper";
|
||||||
|
|
||||||
let initialized: boolean = false
|
let initialized: boolean = false
|
||||||
@@ -54,7 +55,7 @@ export function UseAxios(router: VueRouter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 403 && handle(response.status, exclude)) {
|
if (response.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN && handle(response.status, exclude)) {
|
||||||
window.setTimeout(() => router.replace('/forbidden'), 200)
|
window.setTimeout(() => router.replace('/forbidden'), 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,17 @@
|
|||||||
<div slot="subtitle">{{$t('msg.myDescriz')}} {{ getAppVersion() }}</div>
|
<div slot="subtitle">{{$t('msg.myDescriz')}} {{ getAppVersion() }}</div>
|
||||||
</q-toolbar-title>
|
</q-toolbar-title>
|
||||||
|
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
round
|
||||||
|
@click=""
|
||||||
|
aria-label="Connection"
|
||||||
|
>
|
||||||
|
<q-icon :name="iconConn" :class="clIconConn"></q-icon>
|
||||||
|
<q-icon v-if="isUserNotAuth" name="device_unknown"></q-icon>
|
||||||
|
</q-btn>
|
||||||
|
|
||||||
<q-select class="sel_lang" v-model="lang" stack-label="" :options="selectOpLang"/>
|
<q-select class="sel_lang" v-model="lang" stack-label="" :options="selectOpLang"/>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -68,17 +79,72 @@
|
|||||||
|
|
||||||
import { GlobalStore } from '@modules'
|
import { GlobalStore } from '@modules'
|
||||||
import { rescodes } from '../store/Modules/rescodes'
|
import { rescodes } from '../store/Modules/rescodes'
|
||||||
|
import QIcon from "quasar-framework/src/components/icon/QIcon";
|
||||||
|
import { StateConnection } from "../model";
|
||||||
|
import { Watch } from "vue-property-decorator";
|
||||||
|
import QField from "quasar-framework/src/components/field/QField";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
QField,
|
||||||
|
QIcon,
|
||||||
drawer,
|
drawer,
|
||||||
messagePopover,
|
messagePopover,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default class Header extends Vue {
|
export default class Header extends Vue {
|
||||||
|
public $t
|
||||||
public $v
|
public $v
|
||||||
public $q
|
public $q
|
||||||
|
public isUserNotAuth: boolean = false
|
||||||
|
public iconConn: string = 'wifi'
|
||||||
|
public clIconConn: string = 'clIconOnline'
|
||||||
|
public strConn: string = ''
|
||||||
|
|
||||||
|
get conn_changed() {
|
||||||
|
return GlobalStore.state.stateConnection
|
||||||
|
}
|
||||||
|
|
||||||
|
@Watch('GlobalStore.state.stateConnection', { immediate: true, deep: true })
|
||||||
|
changeconn(value: string, oldValue: string) {
|
||||||
|
|
||||||
|
this.strConn = value
|
||||||
|
|
||||||
|
this.$q.notify({
|
||||||
|
color : 'primary',
|
||||||
|
icon: 'wifi',
|
||||||
|
message: "CAMBIATOO! " + value
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Watch('conn_changed', { immediate: true, deep: true })
|
||||||
|
changeconn_changed(value: string, oldValue: string) {
|
||||||
|
if (value != oldValue) {
|
||||||
|
|
||||||
|
console.log('SSSSSSSS: ', value, oldValue)
|
||||||
|
|
||||||
|
const color = (value === 'online') ? 'positive' : 'warning'
|
||||||
|
|
||||||
|
if (oldValue !== undefined) {
|
||||||
|
this.$q.notify({
|
||||||
|
color,
|
||||||
|
icon: 'wifi',
|
||||||
|
message: this.$t('connection') + ` ${value}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('Todos.state.todos_changed CHANGED!', value, oldValue)
|
||||||
|
this.changeIconConn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeIconConn() {
|
||||||
|
this.iconConn = GlobalStore.state.stateConnection === 'online' ? "wifi" : "wifi_off"
|
||||||
|
this.clIconConn = GlobalStore.state.stateConnection === 'online' ? 'clIconOnline' : 'clIconOffline'
|
||||||
|
}
|
||||||
|
|
||||||
public selectOpLang = [
|
public selectOpLang = [
|
||||||
{ label: 'English (UK)', icon: 'fa-flag-us', value: 'en-uk' },
|
{ label: 'English (UK)', icon: 'fa-flag-us', value: 'en-uk' },
|
||||||
@@ -115,6 +181,38 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
create () {
|
||||||
|
|
||||||
|
// Test this by running the code snippet below and then
|
||||||
|
// use the "Offline" checkbox in DevTools Network panel
|
||||||
|
|
||||||
|
let mythis = this
|
||||||
|
console.log('Event LOAD')
|
||||||
|
if (window) {
|
||||||
|
window.addEventListener('load', function () {
|
||||||
|
console.log('2) ENTERING Event LOAD')
|
||||||
|
|
||||||
|
function updateOnlineStatus(event) {
|
||||||
|
if (navigator.onLine) {
|
||||||
|
console.log('ONLINE!')
|
||||||
|
// handle online status
|
||||||
|
GlobalStore.mutations.setStateConnection('online')
|
||||||
|
mythis.changeIconConn()
|
||||||
|
} else {
|
||||||
|
console.log('OFFLINE!')
|
||||||
|
// handle offline status
|
||||||
|
GlobalStore.mutations.setStateConnection('offline')
|
||||||
|
mythis.changeIconConn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('online', updateOnlineStatus);
|
||||||
|
window.addEventListener('offline', updateOnlineStatus);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public snakeToCamel(str) {
|
public snakeToCamel(str) {
|
||||||
return str.replace(/(-\w)/g, m => {
|
return str.replace(/(-\w)/g, m => {
|
||||||
return m[1].toUpperCase()
|
return m[1].toUpperCase()
|
||||||
@@ -359,5 +457,13 @@
|
|||||||
content: url('../statics/icons/flag_it.svg');
|
content: url('../statics/icons/flag_it.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clIconOnline {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clIconOffline {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export default class Todo extends Vue {
|
|||||||
@Watch('todos_changed', { immediate: true, deep: true })
|
@Watch('todos_changed', { immediate: true, deep: true })
|
||||||
changetodos_changed(value: string, oldValue: string) {
|
changetodos_changed(value: string, oldValue: string) {
|
||||||
|
|
||||||
this.$q.notify('Changed...')
|
// this.$q.notify('Changed...')
|
||||||
|
|
||||||
// console.log('Todos.state.todos_changed CHANGED!', value, oldValue)
|
// console.log('Todos.state.todos_changed CHANGED!', value, oldValue)
|
||||||
this.updatetable(true)
|
this.updatetable(true)
|
||||||
@@ -287,7 +287,7 @@ export default class Todo extends Vue {
|
|||||||
let update = false
|
let update = false
|
||||||
await this.todos_arr.forEach((elem: ITodo) => {
|
await this.todos_arr.forEach((elem: ITodo) => {
|
||||||
if (elem.modified) {
|
if (elem.modified) {
|
||||||
console.log('calling MODIFY 3')
|
// console.log('calling MODIFY 3')
|
||||||
this.modify(elem, false)
|
this.modify(elem, false)
|
||||||
update = true
|
update = true
|
||||||
elem.modified = false
|
elem.modified = false
|
||||||
@@ -367,7 +367,7 @@ export default class Todo extends Vue {
|
|||||||
let mydatenow = new Date().getDate()
|
let mydatenow = new Date().getDate()
|
||||||
let mydateexp = new Date().getDate() + 10
|
let mydateexp = new Date().getDate() + 10
|
||||||
|
|
||||||
console.log('User:' + UserStore.state.userId)
|
// console.log('User:' + UserStore.state.userId)
|
||||||
|
|
||||||
const objtodo: ITodo = {
|
const objtodo: ITodo = {
|
||||||
// _id: new Date().toISOString(), // Create NEW
|
// _id: new Date().toISOString(), // Create NEW
|
||||||
@@ -432,30 +432,18 @@ export default class Todo extends Vue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await globalroutines(this, 'write', 'todos', objtodo)
|
const id = await globalroutines(this, 'write', 'todos', objtodo)
|
||||||
.then((id) => {
|
// update also the last elem
|
||||||
console.log('*** IDNEW (3) = ', id)
|
if (lastelem !== null) {
|
||||||
|
lastelem.id_next = id
|
||||||
|
// lastelem.modified = true
|
||||||
|
// console.log('calling MODIFY 4', lastelem)
|
||||||
|
}
|
||||||
|
|
||||||
// update also the last elem
|
const rismod = await this.modify(lastelem, false)
|
||||||
if (lastelem !== null) {
|
|
||||||
lastelem.id_next = id
|
|
||||||
// lastelem.modified = true
|
|
||||||
console.log('calling MODIFY 4', lastelem)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modify(lastelem, false)
|
this.saveItemToSyncAndDb(rescodes.DB.TABLE_SYNC_TODOS, 'POST', objtodo, true)
|
||||||
.then(ris => {
|
this.updatetable(false)
|
||||||
console.log('END calling MODIFY 4')
|
|
||||||
|
|
||||||
this.saveItemToSyncAndDb(rescodes.DB.TABLE_SYNC_TODOS, 'POST', objtodo, true)
|
|
||||||
this.updatetable(false)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
}).catch(err => {
|
|
||||||
console.log('Errore: ' + err.message)
|
|
||||||
})
|
|
||||||
|
|
||||||
// console.log('ESCO.........')
|
// console.log('ESCO.........')
|
||||||
|
|
||||||
@@ -587,14 +575,14 @@ export default class Todo extends Vue {
|
|||||||
if (myobjprev !== null) {
|
if (myobjprev !== null) {
|
||||||
myobjprev.id_next = myobjtrov.id_next
|
myobjprev.id_next = myobjtrov.id_next
|
||||||
myobjprev.modified = true
|
myobjprev.modified = true
|
||||||
console.log('calling MODIFY 2')
|
// console.log('calling MODIFY 2')
|
||||||
this.modify(myobjprev, false)
|
this.modify(myobjprev, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myobjnext !== null) {
|
if (myobjnext !== null) {
|
||||||
myobjnext.id_prev = myobjtrov.id_prev
|
myobjnext.id_prev = myobjtrov.id_prev
|
||||||
myobjnext.modified = true
|
myobjnext.modified = true
|
||||||
console.log('calling MODIFY 1')
|
// console.log('calling MODIFY 1')
|
||||||
this.modify(myobjnext, false)
|
this.modify(myobjnext, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,7 +598,7 @@ export default class Todo extends Vue {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('FINE deleteitem')
|
// console.log('FINE deleteitem')
|
||||||
}
|
}
|
||||||
|
|
||||||
getElem(myarray: ITodo[], id) {
|
getElem(myarray: ITodo[], id) {
|
||||||
@@ -729,7 +717,7 @@ export default class Todo extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateitem(myobj) {
|
updateitem(myobj) {
|
||||||
console.log('updateitem')
|
// console.log('updateitem')
|
||||||
this.modify(myobj, true)
|
this.modify(myobj, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,7 +766,7 @@ export default class Todo extends Vue {
|
|||||||
|
|
||||||
modifyField(recOut, recIn, field) {
|
modifyField(recOut, recIn, field) {
|
||||||
if (recOut[field] !== recIn[field]) {
|
if (recOut[field] !== recIn[field]) {
|
||||||
console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
// console.log('*************** CAMPO ', field, 'MODIFICATO!', recOut[field], recIn[field])
|
||||||
recOut.modified = true
|
recOut.modified = true
|
||||||
recOut[field] = recIn[field]
|
recOut[field] = recIn[field]
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ export default async (context, cmd, table, datakey = null, id = '') => {
|
|||||||
return await storage.getdata(table, id)
|
return await storage.getdata(table, id)
|
||||||
} else if (cmd === 'delete') {
|
} else if (cmd === 'delete') {
|
||||||
return await storage.deletedata(table, id)
|
return await storage.deletedata(table, id)
|
||||||
|
} else if (cmd === 'clearalldata') {
|
||||||
|
return await storage.clearalldata(table)
|
||||||
} else if (cmd === 'log') {
|
} else if (cmd === 'log') {
|
||||||
consolelogpao(table)
|
consolelogpao(table)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export let idbKeyval = (() => {
|
|||||||
},
|
},
|
||||||
async setdata(table, value) {
|
async setdata(table, value) {
|
||||||
let req;
|
let req;
|
||||||
console.log('setdata', table, value)
|
// console.log('setdata', table, value)
|
||||||
|
|
||||||
await withStore('readwrite', table, store => {
|
await withStore('readwrite', table, store => {
|
||||||
req = store.put(value);
|
req = store.put(value);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
get Verificato() {
|
get Verificato() {
|
||||||
return UserStore.state.verifiedEmail
|
return UserStore.state.verified_email
|
||||||
}
|
}
|
||||||
|
|
||||||
get Email() {
|
get Email() {
|
||||||
@@ -111,6 +111,7 @@
|
|||||||
|
|
||||||
logoutHandler() {
|
logoutHandler() {
|
||||||
UserStore.actions.logout()
|
UserStore.actions.logout()
|
||||||
|
this.$router.push('/signin')
|
||||||
this.$q.notify(this.$t('logout.uscito'))
|
this.$q.notify(this.$t('logout.uscito'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ export interface IPost {
|
|||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type StateConnection = 'online' | 'offline'
|
||||||
|
|
||||||
export interface IGlobalState {
|
export interface IGlobalState {
|
||||||
conta: number
|
conta: number
|
||||||
isSubscribed: boolean
|
isSubscribed: boolean
|
||||||
@@ -11,6 +13,7 @@ export interface IGlobalState {
|
|||||||
menuCollapse: boolean
|
menuCollapse: boolean
|
||||||
leftDrawerOpen: boolean
|
leftDrawerOpen: boolean
|
||||||
category: string
|
category: string
|
||||||
|
stateConnection: StateConnection
|
||||||
posts: IPost[]
|
posts: IPost[]
|
||||||
listatodo: ITodoList[]
|
listatodo: ITodoList[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface IUserState {
|
|||||||
tokenforgot?: string
|
tokenforgot?: string
|
||||||
|
|
||||||
servercode?: number
|
servercode?: number
|
||||||
|
resStatus?: number
|
||||||
x_auth_token?: string
|
x_auth_token?: string
|
||||||
isLogged?: boolean
|
isLogged?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const messages = {
|
|||||||
fetch: {
|
fetch: {
|
||||||
errore_generico: 'Errore Generico',
|
errore_generico: 'Errore Generico',
|
||||||
errore_server: 'Impossibile accedere al Server. Riprovare Grazie',
|
errore_server: 'Impossibile accedere al Server. Riprovare Grazie',
|
||||||
|
error_doppiologin: 'Rieseguire il Login. Accesso aperto da un altro dispositivo.',
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
notregistered: 'Devi registrarti al servizio prima di porter memorizzare i dati'
|
notregistered: 'Devi registrarti al servizio prima di porter memorizzare i dati'
|
||||||
@@ -121,7 +122,8 @@ const messages = {
|
|||||||
titledenied: 'Permesso Notifiche Disabilitato!',
|
titledenied: 'Permesso Notifiche Disabilitato!',
|
||||||
title_subscribed: 'Sottoscrizione a FreePlanet.app!',
|
title_subscribed: 'Sottoscrizione a FreePlanet.app!',
|
||||||
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.'
|
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.'
|
||||||
}
|
},
|
||||||
|
connection: 'Connessione',
|
||||||
},
|
},
|
||||||
es: {
|
es: {
|
||||||
dialog: {
|
dialog: {
|
||||||
@@ -175,6 +177,7 @@ const messages = {
|
|||||||
fetch: {
|
fetch: {
|
||||||
errore_generico: 'Error genérico',
|
errore_generico: 'Error genérico',
|
||||||
errore_server: 'No se puede acceder al Servidor. Inténtalo de nuevo, Gracias',
|
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: {
|
user: {
|
||||||
notregistered: 'Debe registrarse en el servicio antes de poder almacenar los datos'
|
notregistered: 'Debe registrarse en el servicio antes de poder almacenar los datos'
|
||||||
@@ -245,7 +248,8 @@ const messages = {
|
|||||||
titledenied: 'Notificaciones permitidas deshabilitadas!',
|
titledenied: 'Notificaciones permitidas deshabilitadas!',
|
||||||
title_subscribed: 'Suscripción a FreePlanet.app!',
|
title_subscribed: 'Suscripción a FreePlanet.app!',
|
||||||
subscribed: 'Ahora puedes recibir mensajes y notificaciones.'
|
subscribed: 'Ahora puedes recibir mensajes y notificaciones.'
|
||||||
}
|
},
|
||||||
|
connection: 'Connection',
|
||||||
},
|
},
|
||||||
enUk: {
|
enUk: {
|
||||||
dialog: {
|
dialog: {
|
||||||
@@ -299,6 +303,7 @@ const messages = {
|
|||||||
fetch: {
|
fetch: {
|
||||||
errore_generico: 'Generic Error',
|
errore_generico: 'Generic Error',
|
||||||
errore_server: 'Unable to access to the Server. Retry. Thank you.',
|
errore_server: 'Unable to access to the Server. Retry. Thank you.',
|
||||||
|
error_doppiologin: 'Signup again. Another access was made with another device.',
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
notregistered: 'You need first to SignUp before storing data'
|
notregistered: 'You need first to SignUp before storing data'
|
||||||
@@ -369,7 +374,8 @@ const messages = {
|
|||||||
titledenied: 'Notification Permission Denied!',
|
titledenied: 'Notification Permission Denied!',
|
||||||
title_subscribed: 'Subscribed to FreePlanet.app!',
|
title_subscribed: 'Subscribed to FreePlanet.app!',
|
||||||
subscribed: 'You can now receive Notification and Messages.'
|
subscribed: 'You can now receive Notification and Messages.'
|
||||||
}
|
},
|
||||||
|
connection: 'Conexión',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,18 +16,21 @@ async function sendRequest(url: string, lang: string, mytok: string, method: str
|
|||||||
configInit = {
|
configInit = {
|
||||||
method: method,
|
method: method,
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
|
mode: 'cors',
|
||||||
headers: authHeader
|
headers: authHeader
|
||||||
}
|
}
|
||||||
} else if (method === 'DELETE') {
|
} else if (method === 'DELETE') {
|
||||||
configInit = {
|
configInit = {
|
||||||
method: method,
|
method: method,
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
|
mode: 'cors',
|
||||||
headers: authHeader
|
headers: authHeader
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
configInit = {
|
configInit = {
|
||||||
method: method,
|
method: method,
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
|
mode: 'cors',
|
||||||
body: JSON.stringify(mydata),
|
body: JSON.stringify(mydata),
|
||||||
headers: authHeader
|
headers: authHeader
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ export { addAuthHeaders, removeAuthHeaders, API_URL } from './Instance'
|
|||||||
import Paths from '@paths'
|
import Paths from '@paths'
|
||||||
import { rescodes } from '@src/store/Modules/rescodes'
|
import { rescodes } from '@src/store/Modules/rescodes'
|
||||||
|
|
||||||
import { 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 router from '@router'
|
||||||
|
|
||||||
|
|
||||||
// const algoliaApi = new AlgoliaSearch()
|
// const algoliaApi = new AlgoliaSearch()
|
||||||
@@ -45,53 +47,68 @@ export namespace ApiTool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function SendReq(url: string, lang: string, mytok: string, method: string, mydata: any, noAuth: boolean = false) {
|
export async function SendReq(url: string, lang: string, mytok: string, method: string, mydata: any, setAuthToken: boolean = false) {
|
||||||
UserStore.mutations.setServerCode(rescodes.EMPTY)
|
UserStore.mutations.setServerCode(rescodes.EMPTY)
|
||||||
|
UserStore.mutations.setResStatus(0)
|
||||||
UserStore.mutations.setAuth('')
|
UserStore.mutations.setAuth('')
|
||||||
return await new Promise(function (resolve, reject) {
|
return await new Promise(function (resolve, reject) {
|
||||||
let ricevuto = false
|
let ricevuto = false
|
||||||
sendRequest(url, lang, mytok, method, mydata)
|
|
||||||
|
return sendRequest(url, lang, mytok, method, mydata)
|
||||||
.then(resreceived => {
|
.then(resreceived => {
|
||||||
|
console.log('resreceived', resreceived)
|
||||||
ricevuto = true
|
ricevuto = true
|
||||||
let res = resreceived.clone()
|
let res = resreceived.clone()
|
||||||
if (process.env.DEV) {
|
if (process.env.DEV) {
|
||||||
console.log('SendReq RES [', res.status, ']', res)
|
console.log('SendReq RES [', res.status, ']', res)
|
||||||
}
|
}
|
||||||
|
|
||||||
let x_auth_token = ''
|
UserStore.mutations.setResStatus(res.status)
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
let x_auth_token = ''
|
||||||
try {
|
try {
|
||||||
if (!noAuth) {
|
if (setAuthToken) {
|
||||||
x_auth_token = String(res.headers.get('x-auth'))
|
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') {
|
if (url === process.env.MONGODB_HOST + '/updatepwd') {
|
||||||
UserStore.mutations.UpdatePwd({ idToken: x_auth_token })
|
UserStore.mutations.UpdatePwd({ idToken: x_auth_token })
|
||||||
localStorage.setItem(rescodes.localStorage.token, x_auth_token)
|
localStorage.setItem(rescodes.localStorage.token, x_auth_token)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_auth_token === '') {
|
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UserStore.mutations.setServerCode(rescodes.OK)
|
UserStore.mutations.setServerCode(rescodes.OK)
|
||||||
UserStore.mutations.setAuth(x_auth_token)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!noAuth) {
|
if (setAuthToken) {
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
||||||
UserStore.mutations.setAuth(x_auth_token)
|
UserStore.mutations.setAuth('')
|
||||||
}
|
}
|
||||||
return reject(e)
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
return reject({ code: rescodes.ERR_AUTHENTICATION, status: res.status })
|
||||||
}
|
}
|
||||||
|
} else if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
|
// Forbidden
|
||||||
|
// You probably is connectiong with other page...
|
||||||
|
UserStore.mutations.setServerCode(rescodes.ERR_AUTHENTICATION)
|
||||||
|
UserStore.mutations.setAuth('')
|
||||||
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
router.push('/signin')
|
||||||
|
return reject({ code: rescodes.ERR_AUTHENTICATION, status: res.status })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
|
||||||
return res.json()
|
return res.json()
|
||||||
.then((body) => {
|
.then((body) => {
|
||||||
return resolve({ res, body })
|
return resolve({ res, body })
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
||||||
return reject(e)
|
return reject({ code: rescodes.ERR_GENERICO, status: res.status })
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -104,7 +121,10 @@ export namespace ApiTool {
|
|||||||
} else {
|
} else {
|
||||||
UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
UserStore.mutations.setServerCode(rescodes.ERR_GENERICO)
|
||||||
}
|
}
|
||||||
return reject(error)
|
|
||||||
|
GlobalStore.mutations.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||||
|
|
||||||
|
return reject({ code: error, status: 0 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -129,50 +149,56 @@ export namespace ApiTool {
|
|||||||
headers.append('Accept', 'application/json')
|
headers.append('Accept', 'application/json')
|
||||||
headers.append('x-auth', token)
|
headers.append('x-auth', token)
|
||||||
|
|
||||||
console.log('A1) INIZIO.............................................................')
|
// console.log('A1) INIZIO.............................................................')
|
||||||
|
|
||||||
await globalroutines(null, 'readall', table, null)
|
await globalroutines(null, 'readall', table, null)
|
||||||
.then(function (alldata) {
|
.then(function (alldata) {
|
||||||
const myrecs = [...alldata]
|
const myrecs = [...alldata]
|
||||||
console.log('----------------------- LEGGO QUALCOSA ')
|
// console.log('----------------------- LEGGO QUALCOSA ')
|
||||||
if (myrecs) {
|
if (myrecs) {
|
||||||
for (let rec of myrecs) {
|
for (let rec of myrecs) {
|
||||||
// console.log('syncing', table, '', rec.descr)
|
// console.log('syncing', table, '', rec.descr)
|
||||||
let link = process.env.MONGODB_HOST + '/todos'
|
let link = process.env.MONGODB_HOST + '/todos'
|
||||||
|
|
||||||
if (method !== 'POST')
|
if (method !== 'POST')
|
||||||
link += '/' + rec._id
|
link += '/' + rec._id
|
||||||
|
|
||||||
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
|
let lettoqualcosa = false
|
||||||
fetch(link, {
|
|
||||||
method: method,
|
|
||||||
headers: headers,
|
|
||||||
mode: 'cors', // 'no-cors',
|
|
||||||
body: JSON.stringify(rec)
|
|
||||||
})
|
|
||||||
.then(function (resData) {
|
|
||||||
// console.log('Result CALL ', method, ' OK? =', resData.ok);
|
|
||||||
|
|
||||||
// Anyway Delete this, otherwise in some cases will return error, but it's not a problem.
|
// Insert/Delete/Update table to the server
|
||||||
// for example if I change a record and then I deleted ...
|
return fetch(link, {
|
||||||
// if (resData.ok) {
|
method: method,
|
||||||
// deleteItemFromData(table, rec._id);
|
headers: headers,
|
||||||
globalroutines(null, 'delete', table, null, rec._id)
|
cache: 'no-cache',
|
||||||
|
mode: 'cors', // 'no-cors',
|
||||||
console.log('DELETE: ', mystrparam)
|
body: JSON.stringify(rec)
|
||||||
// deleteItemFromData('swmsg', mystrparam)
|
}).then(resData => {
|
||||||
globalroutines(null, 'delete', 'swmsg', null, mystrparam)
|
lettoqualcosa = true
|
||||||
|
|
||||||
|
console.log('Clear', table, rec._id)
|
||||||
|
return globalroutines(null, 'delete', table, null, rec._id)
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.then((ris) => {
|
||||||
console.log(' [Alternative] !!!!!!!!!!!!!!! Error while sending data', err)
|
console.log('Clear', 'swmsg', method)
|
||||||
})
|
GlobalStore.mutations.setStateConnection(lettoqualcosa ? 'online' : 'offline')
|
||||||
|
// deleteItemFromData('swmsg', mystrparam)
|
||||||
|
return globalroutines(null, 'delete', 'swmsg', null, mystrparam)
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(' [Alternative] !!!!!!!!!!!!!!! Error while sending data', err)
|
||||||
|
GlobalStore.mutations.setStateConnection(lettoqualcosa ? 'online' : 'offline')
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
).catch(e => {
|
||||||
|
console.log('ERROR:', e)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!! err=')
|
console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!! err=')
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IGlobalState } from 'model'
|
import { IGlobalState, StateConnection } from 'model'
|
||||||
import { storeBuilder } from './Store/Store'
|
import { storeBuilder } from './Store/Store'
|
||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
@@ -8,7 +8,10 @@ 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 { UserStore } from "@store"
|
import { UserStore } from '@store'
|
||||||
|
import globalroutines from './../../globalroutines/index'
|
||||||
|
|
||||||
|
const allTables = ['todos', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg']
|
||||||
|
|
||||||
const state: IGlobalState = {
|
const state: IGlobalState = {
|
||||||
conta: 0,
|
conta: 0,
|
||||||
@@ -18,6 +21,7 @@ const state: IGlobalState = {
|
|||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
menuCollapse: true,
|
menuCollapse: true,
|
||||||
leftDrawerOpen: true,
|
leftDrawerOpen: true,
|
||||||
|
stateConnection: 'online',
|
||||||
category: 'personal',
|
category: 'personal',
|
||||||
posts: [],
|
posts: [],
|
||||||
listatodo: [
|
listatodo: [
|
||||||
@@ -65,11 +69,18 @@ namespace Mutations {
|
|||||||
state.category = cat
|
state.category = cat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setStateConnection(state: IGlobalState, stateconn: StateConnection) {
|
||||||
|
if (state.stateConnection !== stateconn) {
|
||||||
|
console.log('INTERNET ', stateconn)
|
||||||
|
state.stateConnection = stateconn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -109,9 +120,10 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(function (newSub) {
|
.then(function (newSub) {
|
||||||
|
// console.log('newSub', newSub)
|
||||||
if (newSub) {
|
if (newSub) {
|
||||||
saveNewSubscriptionToServer(context, newSub)
|
saveNewSubscriptionToServer(context, newSub)
|
||||||
mystate.isSubscribed = true;
|
mystate.isSubscribed = true
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@@ -174,8 +186,17 @@ namespace Actions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAfterLogin (context) {
|
async function clearDataAfterLogout (context) {
|
||||||
|
|
||||||
|
// Clear all data from the IndexedDB
|
||||||
|
allTables.forEach(table => {
|
||||||
|
globalroutines(null, 'clearalldata', table, null)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadAfterLogin (context) {
|
||||||
|
actions.clearDataAfterLogout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,6 +204,7 @@ namespace Actions {
|
|||||||
setConta: b.dispatch(setConta),
|
setConta: b.dispatch(setConta),
|
||||||
createPushSubscription: b.dispatch(createPushSubscription),
|
createPushSubscription: b.dispatch(createPushSubscription),
|
||||||
loadAfterLogin: b.dispatch(loadAfterLogin),
|
loadAfterLogin: b.dispatch(loadAfterLogin),
|
||||||
|
clearDataAfterLogout: b.dispatch(clearDataAfterLogout),
|
||||||
prova: b.dispatch(prova)
|
prova: b.dispatch(prova)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,4 +224,3 @@ const GlobalModule = {
|
|||||||
|
|
||||||
|
|
||||||
export default GlobalModule
|
export default GlobalModule
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { rescodes } from './rescodes'
|
|||||||
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"
|
||||||
|
|
||||||
|
|
||||||
const state: ITodosState = {
|
const state: ITodosState = {
|
||||||
@@ -73,7 +74,7 @@ namespace Actions {
|
|||||||
let something = false
|
let something = false
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
console.log(' -------- sendSwMsgIfAvailable')
|
// console.log(' -------- sendSwMsgIfAvailable')
|
||||||
|
|
||||||
let count = await checkPendingMsg(null)
|
let count = await checkPendingMsg(null)
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
@@ -135,7 +136,7 @@ namespace Actions {
|
|||||||
async function waitAndRefreshData(context) {
|
async function waitAndRefreshData(context) {
|
||||||
await aspettansec(3000)
|
await aspettansec(3000)
|
||||||
|
|
||||||
console.log('waitAndRefreshData')
|
// console.log('waitAndRefreshData')
|
||||||
|
|
||||||
return await dbLoadTodo(context, false)
|
return await dbLoadTodo(context, false)
|
||||||
}
|
}
|
||||||
@@ -186,33 +187,38 @@ namespace Actions {
|
|||||||
state.todos = [...body.todos]
|
state.todos = [...body.todos]
|
||||||
Todos.mutations.setTodos_changed()
|
Todos.mutations.setTodos_changed()
|
||||||
|
|
||||||
console.log('state.todos', state.todos, 'checkPending', checkPending)
|
console.log('********** resData', resData, 'state.todos', state.todos, 'checkPending', checkPending)
|
||||||
|
|
||||||
// After Login will store into the indexedDb...
|
// After Login will store into the indexedDb...
|
||||||
|
|
||||||
return rescodes.OK
|
return rescodes.OK
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
console.log('error=', error)
|
||||||
UserStore.mutations.setErrorCatch(error)
|
UserStore.mutations.setErrorCatch(error)
|
||||||
return UserStore.getters.getServerCode
|
return UserStore.getters.getServerCode
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('fine della funz...')
|
console.log('ris FUNZ: ', ris.code, 'status', ris.status)
|
||||||
|
|
||||||
if (!Todos.state.networkDataReceived) {
|
if (!Todos.state.networkDataReceived) {
|
||||||
console.log('NETWORK UNREACHABLE ! (Error in fetch)')
|
|
||||||
consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)')
|
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
|
consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||||
|
} else {
|
||||||
|
consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.code)
|
||||||
|
}
|
||||||
// Read all data from IndexedDB Store into Memory
|
// Read all data from IndexedDB Store into Memory
|
||||||
await updateArrayInMemory(context)
|
await updateArrayInMemory(context)
|
||||||
} else {
|
} else {
|
||||||
if (ris === rescodes.OK && checkPending) {
|
if (ris.code === rescodes.OK && checkPending) {
|
||||||
waitAndcheckPendingMsg(context)
|
waitAndcheckPendingMsg(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateArrayInMemory(context) {
|
async function updateArrayInMemory(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, 'updateinMemory', 'todos', null)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// console.log('updateArrayInMemory! ')
|
// console.log('updateArrayInMemory! ')
|
||||||
@@ -246,8 +252,8 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function UpdateNewIdFromDB(oldItem, newItem, method) {
|
function UpdateNewIdFromDB(oldItem, newItem, method) {
|
||||||
console.log('PRIMA state.todos', state.todos)
|
// console.log('PRIMA state.todos', state.todos)
|
||||||
console.log('ITEM', newItem)
|
// console.log('ITEM', newItem)
|
||||||
if (method === 'POST') {
|
if (method === 'POST') {
|
||||||
state.todos.push(newItem)
|
state.todos.push(newItem)
|
||||||
Todos.mutations.setTodos_changed()
|
Todos.mutations.setTodos_changed()
|
||||||
@@ -260,7 +266,7 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log('DOPO state.todos', state.todos)
|
// console.log('DOPO state.todos', state.todos)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
|
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
|
||||||
@@ -290,7 +296,7 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function dbDeleteTodo(context, item: ITodo) {
|
async function dbDeleteTodo(context, item: ITodo) {
|
||||||
console.log('dbDeleteTodo', item)
|
// console.log('dbDeleteTodo', item)
|
||||||
let call = process.env.MONGODB_HOST + '/todos/' + item._id
|
let call = process.env.MONGODB_HOST + '/todos/' + item._id
|
||||||
|
|
||||||
const token = UserStore.state.idToken
|
const token = UserStore.state.idToken
|
||||||
|
|||||||
@@ -121,6 +121,10 @@ namespace Mutations {
|
|||||||
state.servercode = num
|
state.servercode = num
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setResStatus(state: IUserState, status: number) {
|
||||||
|
state.resStatus = status
|
||||||
|
}
|
||||||
|
|
||||||
function setAuth(state: IUserState, x_auth_token: string) {
|
function setAuth(state: IUserState, x_auth_token: string) {
|
||||||
state.x_auth_token = x_auth_token
|
state.x_auth_token = x_auth_token
|
||||||
}
|
}
|
||||||
@@ -168,6 +172,7 @@ namespace Mutations {
|
|||||||
setlang: b.commit(setlang),
|
setlang: b.commit(setlang),
|
||||||
UpdatePwd: b.commit(UpdatePwd),
|
UpdatePwd: b.commit(UpdatePwd),
|
||||||
setServerCode: b.commit(setServerCode),
|
setServerCode: b.commit(setServerCode),
|
||||||
|
setResStatus: b.commit(setResStatus),
|
||||||
setAuth: b.commit(setAuth),
|
setAuth: b.commit(setAuth),
|
||||||
clearAuthData: b.commit(clearAuthData),
|
clearAuthData: b.commit(clearAuthData),
|
||||||
setErrorCatch: b.commit(setErrorCatch),
|
setErrorCatch: b.commit(setErrorCatch),
|
||||||
@@ -205,7 +210,7 @@ namespace Actions {
|
|||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(rescodes.CALLING)
|
||||||
|
|
||||||
return await Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend)
|
return await Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend, true)
|
||||||
.then(({ res, body }) => {
|
.then(({ res, body }) => {
|
||||||
return { code: body.code, msg: body.msg }
|
return { code: body.code, msg: body.msg }
|
||||||
})
|
})
|
||||||
@@ -259,7 +264,7 @@ namespace Actions {
|
|||||||
// mutations.setServerCode(myres);
|
// mutations.setServerCode(myres);
|
||||||
if (body.code === serv_constants.RIS_CODE_EMAIL_VERIFIED) {
|
if (body.code === serv_constants.RIS_CODE_EMAIL_VERIFIED) {
|
||||||
console.log('VERIFICATO !!')
|
console.log('VERIFICATO !!')
|
||||||
localStorage.setItem(rescodes.localStorage.verifiedEmail, '1')
|
localStorage.setItem(rescodes.localStorage.verified_email, String(true))
|
||||||
} else {
|
} else {
|
||||||
console.log('Risultato di vreg: ', body.code)
|
console.log('Risultato di vreg: ', body.code)
|
||||||
}
|
}
|
||||||
@@ -326,7 +331,7 @@ namespace Actions {
|
|||||||
localStorage.setItem(rescodes.localStorage.username, username)
|
localStorage.setItem(rescodes.localStorage.username, username)
|
||||||
localStorage.setItem(rescodes.localStorage.token, x_auth_token)
|
localStorage.setItem(rescodes.localStorage.token, x_auth_token)
|
||||||
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
||||||
localStorage.setItem(rescodes.localStorage.verifiedEmail, '0')
|
localStorage.setItem(rescodes.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);
|
||||||
@@ -363,7 +368,7 @@ namespace Actions {
|
|||||||
|
|
||||||
Mutations.mutations.setServerCode(rescodes.CALLING)
|
Mutations.mutations.setServerCode(rescodes.CALLING)
|
||||||
|
|
||||||
return await Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend)
|
return await Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend, true)
|
||||||
.then(({ res, body }) => {
|
.then(({ res, body }) => {
|
||||||
myres = res
|
myres = res
|
||||||
if (res.code === serv_constants.RIS_CODE_LOGIN_ERR) {
|
if (res.code === serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||||
@@ -375,36 +380,41 @@ namespace Actions {
|
|||||||
|
|
||||||
if (myres.status === 200) {
|
if (myres.status === 200) {
|
||||||
let myuser: IUserState = body.usertosend
|
let myuser: IUserState = body.usertosend
|
||||||
let userId = myuser.userId
|
if (myuser) {
|
||||||
let username = authData.username
|
let userId = myuser.userId
|
||||||
let verifiedEmail = myuser.verified_email === true
|
let username = authData.username
|
||||||
if (process.env.DEV) {
|
let verified_email = myuser.verified_email
|
||||||
console.log('USERNAME = ' + username)
|
if (process.env.DEV) {
|
||||||
console.log('IDUSER= ' + userId)
|
console.log('USERNAME = ' + username)
|
||||||
Mutations.mutations.authUser({
|
console.log('IDUSER= ' + userId)
|
||||||
userId: userId,
|
console.log('state.x_auth_token= ' + state.x_auth_token)
|
||||||
username: username,
|
Mutations.mutations.authUser({
|
||||||
idToken: state.x_auth_token,
|
userId,
|
||||||
verified_email: verifiedEmail
|
username,
|
||||||
})
|
idToken: state.x_auth_token,
|
||||||
|
verified_email
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||||
|
const expirationDate = new Date(now.getTime() * 1000)
|
||||||
|
localStorage.setItem(rescodes.localStorage.userId, userId)
|
||||||
|
localStorage.setItem(rescodes.localStorage.username, username)
|
||||||
|
localStorage.setItem(rescodes.localStorage.token, state.x_auth_token)
|
||||||
|
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
||||||
|
localStorage.setItem(rescodes.localStorage.isLogged, String(true))
|
||||||
|
localStorage.setItem(rescodes.localStorage.verified_email, String(verified_email))
|
||||||
|
|
||||||
|
setGlobal()
|
||||||
|
|
||||||
|
// dispatch('storeUser', authData);
|
||||||
|
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
||||||
|
return rescodes.OK
|
||||||
|
} else {
|
||||||
|
return rescodes.ERR_GENERICO
|
||||||
}
|
}
|
||||||
|
} else if (myres.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
const now = new Date()
|
|
||||||
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
|
||||||
const expirationDate = new Date(now.getTime() * 1000)
|
|
||||||
localStorage.setItem(rescodes.localStorage.userId, userId)
|
|
||||||
localStorage.setItem(rescodes.localStorage.username, username)
|
|
||||||
localStorage.setItem(rescodes.localStorage.token, state.x_auth_token)
|
|
||||||
localStorage.setItem(rescodes.localStorage.expirationDate, expirationDate.toString())
|
|
||||||
localStorage.setItem(rescodes.localStorage.isLogged, String(true))
|
|
||||||
localStorage.setItem(rescodes.localStorage.verifiedEmail, Number(verifiedEmail).toString())
|
|
||||||
|
|
||||||
setGlobal()
|
|
||||||
|
|
||||||
// dispatch('storeUser', authData);
|
|
||||||
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
|
||||||
return rescodes.OK
|
|
||||||
} else if (myres.status === 404) {
|
|
||||||
if (process.env.DEV) {
|
if (process.env.DEV) {
|
||||||
console.log('CODE = ' + body.code)
|
console.log('CODE = ' + body.code)
|
||||||
}
|
}
|
||||||
@@ -449,31 +459,35 @@ namespace Actions {
|
|||||||
localStorage.removeItem(rescodes.localStorage.username)
|
localStorage.removeItem(rescodes.localStorage.username)
|
||||||
localStorage.removeItem(rescodes.localStorage.isLogged)
|
localStorage.removeItem(rescodes.localStorage.isLogged)
|
||||||
// localStorage.removeItem(rescodes.localStorage.leftDrawerOpen)
|
// localStorage.removeItem(rescodes.localStorage.leftDrawerOpen)
|
||||||
localStorage.removeItem(rescodes.localStorage.verifiedEmail)
|
localStorage.removeItem(rescodes.localStorage.verified_email)
|
||||||
localStorage.removeItem(rescodes.localStorage.categorySel)
|
localStorage.removeItem(rescodes.localStorage.categorySel)
|
||||||
|
|
||||||
router.push('/signin')
|
GlobalStore.actions.clearDataAfterLogout()
|
||||||
|
|
||||||
|
// this.$router.push('/signin')
|
||||||
}
|
}
|
||||||
|
|
||||||
function setGlobal() {
|
async function setGlobal() {
|
||||||
state.isLogged = true
|
state.isLogged = true
|
||||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(rescodes.localStorage.leftDrawerOpen) === 'true')
|
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(rescodes.localStorage.leftDrawerOpen) === 'true')
|
||||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(rescodes.localStorage.categorySel))
|
GlobalStore.mutations.setCategorySel(localStorage.getItem(rescodes.localStorage.categorySel))
|
||||||
|
|
||||||
GlobalStore.actions.loadAfterLogin()
|
|
||||||
|
|
||||||
Todos.actions.dbLoadTodo(true)
|
|
||||||
|
|
||||||
|
|
||||||
|
await GlobalStore.actions.loadAfterLogin()
|
||||||
|
.then(() => {
|
||||||
|
Todos.actions.dbLoadTodo(true)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function autologin(context) {
|
async function autologin_FromLocalStorage(context) {
|
||||||
try {
|
try {
|
||||||
console.log('*** Autologin ***')
|
console.log('*** autologin_FromLocalStorage ***')
|
||||||
// INIT
|
// INIT
|
||||||
|
|
||||||
UserStore.mutations.setlang(process.env.LANG_DEFAULT)
|
UserStore.mutations.setlang(process.env.LANG_DEFAULT)
|
||||||
// ++Todo: Estrai la Lang dal Localstorage
|
// Estrai la Lang dal Localstorage
|
||||||
const lang = localStorage.getItem('lang')
|
const lang = localStorage.getItem('lang')
|
||||||
if (lang) {
|
if (lang) {
|
||||||
UserStore.mutations.setlang(lang)
|
UserStore.mutations.setlang(lang)
|
||||||
@@ -492,7 +506,7 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
const userId = String(localStorage.getItem(rescodes.localStorage.userId))
|
const userId = String(localStorage.getItem(rescodes.localStorage.userId))
|
||||||
const username = String(localStorage.getItem(rescodes.localStorage.username))
|
const username = String(localStorage.getItem(rescodes.localStorage.username))
|
||||||
const verifiedEmail = localStorage.getItem(rescodes.localStorage.verifiedEmail) === '1'
|
const verified_email = localStorage.getItem(rescodes.localStorage.verified_email) === 'true'
|
||||||
|
|
||||||
console.log('autologin userId', userId)
|
console.log('autologin userId', userId)
|
||||||
|
|
||||||
@@ -500,10 +514,10 @@ namespace Actions {
|
|||||||
userId: userId,
|
userId: userId,
|
||||||
username: username,
|
username: username,
|
||||||
idToken: token,
|
idToken: token,
|
||||||
verified_email: verifiedEmail
|
verified_email: verified_email
|
||||||
})
|
})
|
||||||
|
|
||||||
setGlobal()
|
await setGlobal()
|
||||||
|
|
||||||
console.log('autologin userId STATE ', state.userId)
|
console.log('autologin userId STATE ', state.userId)
|
||||||
|
|
||||||
@@ -522,7 +536,7 @@ namespace Actions {
|
|||||||
signup: b.dispatch(signup),
|
signup: b.dispatch(signup),
|
||||||
signin: b.dispatch(signin),
|
signin: b.dispatch(signin),
|
||||||
logout: b.dispatch(logout),
|
logout: b.dispatch(logout),
|
||||||
autologin: b.dispatch(autologin)
|
autologin_FromLocalStorage: b.dispatch(autologin_FromLocalStorage)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const rescodes = {
|
|||||||
LIST_START: '0',
|
LIST_START: '0',
|
||||||
|
|
||||||
localStorage: {
|
localStorage: {
|
||||||
verifiedEmail: 'vf',
|
verified_email: 'vf',
|
||||||
categorySel: 'cs',
|
categorySel: 'cs',
|
||||||
isLogged: 'ilog',
|
isLogged: 'ilog',
|
||||||
expirationDate: 'expdate',
|
expirationDate: 'expdate',
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ export const serv_constants = {
|
|||||||
RIS_CODE_EMAIL_VERIFIED: 1,
|
RIS_CODE_EMAIL_VERIFIED: 1,
|
||||||
|
|
||||||
RIS_CODE_LOGIN_ERR_GENERIC: -20,
|
RIS_CODE_LOGIN_ERR_GENERIC: -20,
|
||||||
|
|
||||||
RIS_CODE_LOGIN_ERR: -10,
|
RIS_CODE_LOGIN_ERR: -10,
|
||||||
RIS_CODE_OK: 1,
|
RIS_CODE_OK: 1,
|
||||||
|
RIS_CODE_LOGIN_OK: 1,
|
||||||
|
|
||||||
RIS_CODE_LOGIN_OK: 1
|
RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN: 403
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ export default class Signin extends Vue {
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.$v.$reset()
|
this.$v.$reset()
|
||||||
|
|
||||||
|
if (UserStore.state.resStatus === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||||
|
this.showNotif(this.$t('fetch.error_doppiologin'))
|
||||||
|
}
|
||||||
|
|
||||||
// this.$myconfig.socialLogin.facebook = true
|
// this.$myconfig.socialLogin.facebook = true
|
||||||
// console.log('PROVA fb:', this.$myconfig.socialLogin.facebook)
|
// console.log('PROVA fb:', this.$myconfig.socialLogin.facebook)
|
||||||
}
|
}
|
||||||
@@ -125,18 +130,25 @@ export default class Signin extends Vue {
|
|||||||
console.log('riscode=', riscode)
|
console.log('riscode=', riscode)
|
||||||
if (riscode === rescodes.OK) {
|
if (riscode === rescodes.OK) {
|
||||||
router.push('/signin')
|
router.push('/signin')
|
||||||
globalroutines(this, 'loadapp', '')
|
}
|
||||||
|
return riscode
|
||||||
|
}).then((riscode) => {
|
||||||
|
globalroutines(this, 'loadapp', '')
|
||||||
|
return riscode
|
||||||
|
})
|
||||||
|
.then((riscode) => {
|
||||||
|
if (riscode === rescodes.OK) {
|
||||||
GlobalStore.actions.createPushSubscription()
|
GlobalStore.actions.createPushSubscription()
|
||||||
}
|
}
|
||||||
this.checkErrors(riscode)
|
this.checkErrors(riscode)
|
||||||
this.$q.loading.hide()
|
this.$q.loading.hide()
|
||||||
}).catch(error => {
|
})
|
||||||
console.log('ERROR = ' + error)
|
.catch(error => {
|
||||||
|
console.log('ERROR = ' + error)
|
||||||
|
|
||||||
this.checkErrors(error)
|
this.checkErrors(error)
|
||||||
this.$q.loading.hide()
|
this.$q.loading.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user