diff --git a/.env.development b/.env.development
index 71e9afb..77ae56f 100644
--- a/.env.development
+++ b/.env.development
@@ -1,11 +1,12 @@
-SERVICE_WORKER_FILE='service-worker.js${Math.random()}'
+APP_VERSION="DEV 0.0.10"
+SERVICE_WORKER_FILE='service-worker.js'
APP_ID='1'
-VUE_APP_URL='prova SVILUPPO!'
+APP_URL='https://freeplanet.app'
PROVA_PAOLO='PROVA SVILUPPO'
LANG_DEFAULT='it'
-MONGODB_HOST='http://localhost:3000'
PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF'
MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
+MONGODB_HOST='http://localhost:3000'
LOGO_REG='freeplanet-logo-full.svg'
TEST_EMAIL='paolo.arena77@gmail.com'
TEST_USERNAME='paoloar77'
diff --git a/config/envparser.js b/config/envparser.js
index a53d29e..5594197 100644
--- a/config/envparser.js
+++ b/config/envparser.js
@@ -9,7 +9,8 @@ switch (process.env.NODE_ENV) {
path = `.env.development`
break
default:
- path = `.env`
+ path = `.env.production`
+ break
}
// console.log("PATH", path)
diff --git a/package.json b/package.json
index 32143ff..4bdad00 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "freeplanet",
- "version": "0.0.2",
+ "version": "0.0.4",
"private": true,
"keywords": [
"freeplanet",
diff --git a/quasar.conf.js b/quasar.conf.js
index b19d814..3dbbc0d 100644
--- a/quasar.conf.js
+++ b/quasar.conf.js
@@ -88,6 +88,7 @@ module.exports = function (ctx) {
.alias
.set('~', __dirname)
.set('@', path.resolve(__dirname, 'src'))
+ // .set('env', path.resolve(__dirname, 'config/helpers/env.js'))
config.module
.rule('template-engine')
.test(/\.pug$/)
diff --git a/src-pwa/custom-service-worker.js b/src-pwa/custom-service-worker.js
index bd05761..c1cdaa1 100644
--- a/src-pwa/custom-service-worker.js
+++ b/src-pwa/custom-service-worker.js
@@ -1,3 +1,4 @@
+
/*
* This file (which will be your service worker)
* is picked up by the build system ONLY if
@@ -6,22 +7,26 @@
// Questo è il swSrc
-console.log('05 ___________________________ PAO: this is my custom service worker');
+console.log('SW-06 ___________________________ 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('../statics/js/idb.js');
-importScripts('js/globalenv.js');
-// importScripts('js/utility.js');
-
importScripts('../statics/js/storage.js');
+
+console.log('SW-06 1');
const cfgenv = {
- website: 'http://localhost:8080',
- serverweb: 'http://localhost:3000',
+ serverweb: self.location.protocol + "//" + self.location.hostname + ':3000',
dbname: 'mydb3',
dbversion: 11,
}
+console.log('SW-06 2');
+
+console.log('SERVERWEB=', cfgenv.serverweb)
+
+// console.log('serverweb', cfgenv.serverweb)
+
async function writeData(table, data) {
console.log('writeData', table, data);
await idbKeyval.setdata(table, data);
@@ -53,6 +58,7 @@ async function deleteItemFromData(table, id) {
if (!workbox) {
let workbox = new self.WorkboxSW();
+ console.log('SW-06 3');
}
if (workbox) {
@@ -103,24 +109,28 @@ if (workbox) {
workbox.routing.registerRoute(
new RegExp(cfgenv.serverweb + '/todos/'),
function (args) {
+ console.log('registerRoute!')
return fetch(args.event.request, args.event.headers)
.then(function (res) {
- // console.log('1° ******* registerRoute fetch: ', args.event)
+ console.log('1° ******* [[[ SERVICE-WORKER ]]] registerRoute fetch: ', args.event)
// LOAD FROM SERVER , AND SAVE INTO INDEXEDDB
- var clonedRes = res.clone();
- clearAllData('todos')
- .then(function () {
- return clonedRes.json();
- })
- .then(function (data) {
- if (data.todos) {
- console.log('Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
- for (let key in data.todos) {
- writeData('todos', data.todos[key])
+ console.log('res.status', res.status)
+ if (res.status === 200) {
+ var clonedRes = res.clone();
+ clearAllData('todos')
+ .then(function () {
+ return clonedRes.json();
+ })
+ .then(function (data) {
+ if (data.todos) {
+ console.log('Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
+ for (let key in data.todos) {
+ writeData('todos', data.todos[key])
+ }
}
- }
- });
- return res
+ });
+ return res
+ }
})
}
);
diff --git a/src/App.ts b/src/App.ts
index 3104915..3fa8cf6 100644
--- a/src/App.ts
+++ b/src/App.ts
@@ -9,7 +9,7 @@ import $ from 'jquery'
import Header from './components/Header.vue'
import globalroutines from './globalroutines/index'
-import { GlobalStore } from "./store/Modules"
+import { GlobalStore } from './store/Modules'
@@ -34,7 +34,7 @@ export default class App extends Vue {
}
if (process.env.PROD) {
console.info('SESSIONE IN PRODUZIONE!')
- console.info(process.env)
+ // console.info(process.env)
}
UserStore.actions.autologin()
diff --git a/src/components/Header.vue b/src/components/Header.vue
index e859de8..7d2557b 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -29,7 +29,7 @@
{{$t('msg.myAppName')}}
- {{$t('msg.myDescriz')}}
+ {{$t('msg.myDescriz')}} {{ getAppVersion() }}
@@ -96,6 +96,10 @@
localStorage.setItem(rescodes.localStorage.leftDrawerOpen, value.toString())
}
+ getAppVersion() {
+ // return "AA"
+ return "[" + process.env.APP_VERSION + "]"
+ }
get lang() {
return this.$q.i18n.lang
}
diff --git a/src/components/todos/todo/todo.ts b/src/components/todos/todo/todo.ts
index 3b9e4b9..cc35885 100644
--- a/src/components/todos/todo/todo.ts
+++ b/src/components/todos/todo/todo.ts
@@ -20,6 +20,7 @@ import VueIdb from 'vue-idb'
import globalroutines from '../../../globalroutines/index'
import $ from 'jquery'
+import Api from "@api"
@Component({
@@ -76,8 +77,11 @@ export default class Todo extends Vue {
}
- @Watch('todos_changed', { immediate: true })
+ @Watch('todos_changed', { immediate: true, deep: true })
changetodos_changed(value: string, oldValue: string) {
+
+ this.$q.notify('Changed...')
+
// console.log('Todos.state.todos_changed CHANGED!', value, oldValue)
this.updatetable(true)
}
@@ -86,9 +90,9 @@ export default class Todo extends Vue {
reload_fromServer_changed(value: string, oldValue: string) {
console.log('reload_fromServer_changed!', value, oldValue)
// if (value) {
- Todos.actions.dbLoadTodo(false)
+ Todos.actions.dbLoadTodo(false)
- Todos.actions.updateArrayInMemory()
+ Todos.actions.updateArrayInMemory()
// }
}
@@ -343,7 +347,7 @@ export default class Todo extends Vue {
checkUpdate_everytime() {
this.polling = setInterval(() => {
this.checkUpdate()
- }, 10000)
+ }, 10000)
}
copy(o) {
@@ -470,8 +474,13 @@ export default class Todo extends Vue {
cmdSw = rescodes.DB.CMD_SYNC_TODOS
}
+ if (process.env.DEV) {
+ console.log('serviceWorker ', ('serviceWorker' in navigator) ? 'PRESENT!' : 'DOESN\'T EXIST!')
+ console.log('SyncManager ', ('SyncManager' in window) ? 'PRESENT!' : 'DOESN\'T EXIST!')
+ }
+
const mythis = this
- if (('serviceWorker' in navigator && 'SyncManager' in window)) {
+ if ('serviceWorker' in navigator) {
await navigator.serviceWorker.ready
.then(function (sw) {
// _id: new Date().toISOString(),
@@ -482,18 +491,24 @@ export default class Todo extends Vue {
globalroutines(mythis, 'write', table, item, id)
.then(function (id) {
// console.log('id', id)
- const sep = '|'
- let multiparams = cmdSw + sep + table + sep + method + sep + UserStore.state.idToken + sep + UserStore.state.lang
- console.log(' SENDING... sw.sync.register', multiparams)
- let mymsgkey = {
- _id: multiparams,
- value: multiparams
+ })
+ const sep = '|'
+
+ let multiparams = cmdSw + sep + table + sep + method + sep + UserStore.state.idToken + sep + UserStore.state.lang
+ let mymsgkey = {
+ _id: multiparams,
+ value: multiparams
+ }
+ globalroutines(mythis, '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
+ Api.syncAlternative(multiparams)
}
- globalroutines(mythis, 'write', 'swmsg', mymsgkey, multiparams)
- .then(ris => {
- return sw.sync.register(multiparams)
- })
})
.then(function () {
@@ -822,6 +837,7 @@ export default class Todo extends Vue {
objtodo.descr = 'PROVA'
objtodo.category = this.getCategory()
Todos.state.todos.push(objtodo)
+ Todos.mutations.setTodos_changed()
console.log('Todos.state.todos', Todos.state.todos)
}
@@ -831,7 +847,7 @@ export default class Todo extends Vue {
console.log('Todos.state.todos', Todos.state.todos)
}
- checkUpdate () {
+ checkUpdate() {
Todos.actions.waitAndcheckPendingMsg()
}
diff --git a/src/components/todos/todo/todo.vue b/src/components/todos/todo/todo.vue
index e82900c..eb221c3 100644
--- a/src/components/todos/todo/todo.vue
+++ b/src/components/todos/todo/todo.vue
@@ -35,8 +35,8 @@
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="insertTodo"/>
-
-
+
+
diff --git a/src/globalroutines/indexdb.js b/src/globalroutines/indexdb.js
index d4b77a4..00e7d3b 100644
--- a/src/globalroutines/indexdb.js
+++ b/src/globalroutines/indexdb.js
@@ -34,7 +34,7 @@ async function readfromIndexDbToStateTodos(context, table) {
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
if (table === 'todos') {
Todos.state.todos = [...records]
- Todos.state.todos_changed++
+ Todos.mutations.setTodos_changed()
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
// setTimeout(testfunc2, 3000)
}
@@ -52,7 +52,7 @@ function consolelogpao(str, str2 = '', str3 = '') {
function testfunc2 () {
consolelogpao('testfunc2')
Todos.mutations.setTodos_changed()
- Todos.mutations.setTestpao(Todos.state.todos_changed)
+
consolelogpao('testfunc2: Todos.state.todos_changed:', Todos.state.todos_changed)
}
diff --git a/src/js/globalenv.js b/src/js/globalenv.js
deleted file mode 100644
index 745dd1a..0000000
--- a/src/js/globalenv.js
+++ /dev/null
@@ -1,24 +0,0 @@
-
-// importScripts('/statics/js/immortal-db.min.js');
-
-// const cfgenv = {
-// website: 'http://localhost:8080',
-// serverweb: 'http://localhost:3000',
-// dbname: 'mydb3',
-// dbversion: 10,
-// }
-
-/*
-async function clearAllDataImmortal(table) {
- console.log('clearAllDataImmortal', table)
- const db = ImmortalDB.ImmortalDB
- await db.remove(table)
-}
-
-async function writeDataImmortal(table, datavalue) {
- console.log('writeDataImmortal', table, datavalue)
- const db = ImmortalDB.ImmortalDB
- await db.set(table, datavalue)
-}
-
-*/
diff --git a/src/js/utility.js b/src/js/utility.js
index 79ceb41..c629c4e 100644
--- a/src/js/utility.js
+++ b/src/js/utility.js
@@ -1,60 +1,3 @@
-import objectId from "./objectId";
-
-console.log('utility.js')
-
-// var dbPromise = idb.open('mydb1', 1, function (db) {
-// console.log('OPEN MYDB')
-// if (!db.objectStoreNames.contains('todos')) {
-// db.createObjectStore('todos', { keyPath: '_id' });
-// }
-// if (!db.objectStoreNames.contains('config')) {
-// db.createObjectStore('config', { keyPath: '_id' });
-// }
-// });
-
-
-// function readAllData(st) {
-// console.log('readAllData', st);
-// return dbPromise
-// .then(function (db) {
-// var tx = db.transaction(st, 'readonly');
-// var store = tx.objectStore(st);
-// return store.getAll();
-// });
-// }
-
-// function clearAllData(st) {
-// console.log('clearAllData', st);
-// return dbPromise
-// .then(function (db) {
-// var tx = db.transaction(st, 'readwrite');
-// var store = tx.objectStore(st);
-// store.clear();
-// return tx.complete;
-// });
-// }
-
-// function deleteItemFromData(st, id) {
-// console.log('deleteItemFromData', st, 'ID:', id);
-// dbPromise
-// .then(function (db) {
-//
-// var tx = db.transaction(st, 'readwrite');
-// var store = tx.objectStore(st);
-//
-// try {
-// store.delete(id);
-// return tx.complete;
-// } catch (e) {
-// return false;
-// }
-// })
-// .then(function (res) {
-// if (res)
-// console.log('Item deleted!');
-// });
-// }
-
function urlBase64ToUint8Array(base64String) {
var padding = '='.repeat((4 - base64String.length % 4) % 4);
var base64 = (base64String + padding)
diff --git a/src/model/UserStore.ts b/src/model/UserStore.ts
index d859a11..94c7c12 100644
--- a/src/model/UserStore.ts
+++ b/src/model/UserStore.ts
@@ -21,7 +21,7 @@ export interface IUserState {
tokens?: IToken[]
- verifiedEmail?: boolean
+ verified_email?: boolean
categorySel?: string
tokenforgot?: string
diff --git a/src/statics/i18n.js b/src/statics/i18n.js
index 19c9d03..129ff64 100644
--- a/src/statics/i18n.js
+++ b/src/statics/i18n.js
@@ -123,6 +123,130 @@ const messages = {
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.'
}
},
+ 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: 'La primera App Libera'
+ },
+ 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',
+ },
+ 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.'
+ }
+ },
enUk: {
dialog: {
ok: 'Ok',
diff --git a/src/store/Api/index.ts b/src/store/Api/index.ts
index 4998894..d8bec7f 100644
--- a/src/store/Api/index.ts
+++ b/src/store/Api/index.ts
@@ -10,6 +10,7 @@ import Paths from '@paths'
import { rescodes } from '@src/store/Modules/rescodes'
import { UserStore } from '@modules'
+import globalroutines from './../../globalroutines/index'
// const algoliaApi = new AlgoliaSearch()
@@ -52,8 +53,11 @@ export namespace ApiTool {
sendRequest(url, lang, mytok, method, mydata)
.then(resreceived => {
ricevuto = true
- let res = resreceived
- console.log('SendReq RES=', res)
+ let res = resreceived.clone()
+ if (process.env.DEV) {
+ console.log('SendReq RES [', res.status, ']', res)
+ }
+
let x_auth_token = ''
if (res.status === 200) {
try {
@@ -105,6 +109,75 @@ export namespace ApiTool {
})
}
+ export async function syncAlternative(mystrparam) {
+ console.log('[ALTERNATIVE Background syncing', mystrparam)
+
+ let multiparams = mystrparam.split('|')
+ if (multiparams) {
+ if (multiparams.length > 3) {
+ let cmd = multiparams[0]
+ let table = multiparams[1]
+ let method = multiparams[2]
+ let token = multiparams[3]
+ // let lang = multiparams[3]
+
+ if (cmd === 'sync-todos') {
+ console.log('[Alternative] Syncing', cmd, table, method)
+
+ const headers = new Headers()
+ headers.append('content-Type', 'application/json')
+ headers.append('Accept', 'application/json')
+ headers.append('x-auth', token)
+
+ console.log('A1) INIZIO.............................................................')
+
+ await globalroutines(null, 'readall', table, null)
+ .then(function (alldata) {
+ const myrecs = [...alldata]
+ console.log('----------------------- LEGGO QUALCOSA ')
+ if (myrecs) {
+ for (let rec of myrecs) {
+ // console.log('syncing', table, '', rec.descr)
+ let link = process.env.MONGODB_HOST + '/todos'
+
+ if (method !== 'POST')
+ link += '/' + rec._id
+
+ console.log(' [Alternative] ++++++++++++++++++ SYNCING !!!! ', rec.descr, table, 'FETCH: ', method, link, 'data:')
+
+ // Insert/Delete/Update table to the server
+ 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.
+ // for example if I change a record and then I deleted ...
+ // if (resData.ok) {
+ // deleteItemFromData(table, rec._id);
+ globalroutines(null, 'delete', table, null, rec._id)
+
+ console.log('DELETE: ', mystrparam)
+ // deleteItemFromData('swmsg', mystrparam)
+ globalroutines(null, 'delete', 'swmsg', null, mystrparam)
+
+ })
+ .catch(function (err) {
+ console.log(' [Alternative] !!!!!!!!!!!!!!! Error while sending data', err)
+ })
+ }
+ }
+ })
+ console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!! err=')
+ }
+ }
+ }
+ }
+
}
export default ApiTool
diff --git a/src/store/Modules/Todos.ts b/src/store/Modules/Todos.ts
index 97ec034..55ac0ee 100644
--- a/src/store/Modules/Todos.ts
+++ b/src/store/Modules/Todos.ts
@@ -3,8 +3,9 @@ import { storeBuilder } from './Store/Store'
import Api from '@api'
import { rescodes } from './rescodes'
-import { Todos, UserStore } from '@store'
+import { GlobalStore, Todos, UserStore } from '@store'
import globalroutines from './../../globalroutines/index'
+import { Mutation } from "vuex-module-decorators"
const state: ITodosState = {
@@ -40,6 +41,8 @@ namespace Mutations {
function setTodos_changed(state: ITodosState) {
state.todos_changed++
+ mutations.setTestpao('Cambiato : ' + String(state.todos_changed))
+ console.log('******************************* state.todos_changed', state.todos_changed)
}
export const mutations = {
@@ -67,14 +70,13 @@ namespace Actions {
// If something in the call of Service Worker went wrong (Network or Server Down), then retry !
async function sendSwMsgIfAvailable() {
-
- console.log(' -------- sendSwMsgIfAvailable')
-
let something = false
- let count = await checkPendingMsg(null)
- if (count > 0) {
- if (('serviceWorker' in navigator && 'SyncManager' in window)) {
+ if ('serviceWorker' in navigator) {
+ console.log(' -------- sendSwMsgIfAvailable')
+
+ let count = await checkPendingMsg(null)
+ if (count > 0) {
return navigator.serviceWorker.ready
.then(function (sw) {
@@ -90,14 +92,21 @@ namespace Actions {
something = true
for (let rec of arr_recmsg) {
console.log(' .... sw.sync.register ( ', rec._id)
- sw.sync.register(rec._id)
+ if ('SyncManager' in window) {
+ sw.sync.register(rec._id)
+ } else {
+ // #Todo ++ Alternative to SyncManager
+ Api.syncAlternative(rec._id)
+ }
}
+ return something
}
- return something
})
+
})
}
}
+
return something
}
@@ -170,12 +179,12 @@ namespace Actions {
state.networkDataReceived = false
let ris = await Api.SendReq(call, UserStore.state.lang, token, 'GET', null)
- .then(({resData, body}) => {
+ .then(({ resData, body }) => {
state.networkDataReceived = true
// console.log('******* UPDATE TODOS.STATE.TODOS !:', resData.todos)
state.todos = [...body.todos]
- Todos.state.todos_changed++
+ Todos.mutations.setTodos_changed()
console.log('state.todos', state.todos, 'checkPending', checkPending)
@@ -222,7 +231,7 @@ namespace Actions {
async function testfunc() {
while (true) {
consolelogpao('testfunc')
- Todos.state.todos_changed++
+ Todos.mutations.setTodos_changed()
// console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
await aspettansec(5000)
}
@@ -241,6 +250,7 @@ namespace Actions {
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) {
@@ -255,22 +265,20 @@ namespace Actions {
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
console.log('dbInsertSaveTodo', itemtodo, method)
- let call = process.env.MONGODB_HOST + '/todos/' + itemtodo._id
+ let call = process.env.MONGODB_HOST + '/todos'
+
+ if (method !== 'POST')
+ call += '/' + itemtodo._id
const token = UserStore.state.idToken
let res = await Api.SendReq(call, UserStore.state.lang, token, method, itemtodo)
- .then(({res, body}) => {
- console.log('RESDATA =', body)
- if (body.newItem) {
- const newId = body.newItem._id
-
- // if (method === 'PATCH') {
- // newItem = newItem.todo
- // }
+ .then(({ res, newItem }) => {
+ console.log('dbInsertSaveTodo RIS =', newItem)
+ if (newItem) {
// Update ID on local
- UpdateNewIdFromDB(itemtodo, body.newItem, method)
+ UpdateNewIdFromDB(itemtodo, newItem, method)
}
})
.catch((error) => {
@@ -288,10 +296,14 @@ namespace Actions {
const token = UserStore.state.idToken
let res = await Api.SendReq(call, UserStore.state.lang, token, 'DELETE', item)
- .then(function ({res, body}) {
+ .then(function ({ res, itemris }) {
- // Delete Item in to Array
- state.todos.splice(state.todos.indexOf(item), 1)
+ if (res.status === 200) {
+ // Delete Item in to Array
+ state.todos.splice(state.todos.indexOf(item), 1)
+
+ Todos.mutations.setTodos_changed()
+ }
return rescodes.OK
})
diff --git a/src/store/Modules/UserStore.ts b/src/store/Modules/UserStore.ts
index 8181863..a9794c7 100644
--- a/src/store/Modules/UserStore.ts
+++ b/src/store/Modules/UserStore.ts
@@ -24,10 +24,10 @@ const state: IUserState = {
repeatPassword: '',
idToken: '',
tokens: [],
- verifiedEmail: false,
+ verified_email: false,
categorySel: 'personal',
servercode: 0,
- x_auth_token: '',
+ x_auth_token: ''
}
@@ -76,7 +76,7 @@ namespace Getters {
},
get getServerCode() {
return getServerCode()
- },
+ }
}
@@ -88,7 +88,7 @@ namespace Mutations {
state.userId = data.userId
state.username = data.username
state.idToken = data.idToken
- state.verifiedEmail = data.verifiedEmail
+ state.verified_email = data.verified_email
state.category = data.categorySel
// @ts-ignore
state.tokens = [
@@ -130,7 +130,7 @@ namespace Mutations {
state.username = ''
state.tokens = []
state.idToken = ''
- state.verifiedEmail = false
+ state.verified_email = false
state.categorySel = 'personal'
}
@@ -299,19 +299,13 @@ namespace Actions {
let x_auth_token: string = ''
return Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend)
- .then(({ res, body }) => {
+ .then(({ res, newuser }) => {
myres = res
- if (process.env.DEV) {
- console.log('RISULTATO ')
- console.log('STATUS ' + myres.status + ' ' + (myres.statusText))
- console.log('BODY:')
- console.log(body)
- }
Mutations.mutations.setServerCode(myres.status)
if (myres.status === 200) {
- let userId = body.userId
+ let userId = newuser.userId
let username = authData.username
if (process.env.DEV) {
console.log('USERNAME = ' + username)
@@ -322,7 +316,7 @@ namespace Actions {
userId: userId,
username: username,
idToken: x_auth_token,
- verifiedEmail: false
+ verified_email: false
})
const now = new Date()
@@ -338,16 +332,8 @@ namespace Actions {
// dispatch('setLogoutTimer', myres.data.expiresIn);
return rescodes.OK
- } else if (myres.status === 404) {
- if (process.env.DEV) {
- console.log('CODE = ' + body.code)
- }
- return body.code
} else {
- if (process.env.DEV) {
- console.log('CODE = ' + body.code)
- }
- return body.code
+ return rescodes.ERR_GENERICO
}
})
.catch((error) => {
@@ -380,14 +366,7 @@ namespace Actions {
return await Api.SendReq(call, state.lang, Getters.getters.tok, 'POST', usertosend)
.then(({ res, body }) => {
myres = res
- if (process.env.DEV) {
- console.log('RISULTATO ')
- console.log('STATUS ' + res.status + ' ' + (res.statusText))
- console.log('BODY:')
- console.log(body)
- }
-
- if (body.code === serv_constants.RIS_CODE_LOGIN_ERR) {
+ if (res.code === serv_constants.RIS_CODE_LOGIN_ERR) {
Mutations.mutations.setServerCode(body.code)
return body.code
}
@@ -395,9 +374,10 @@ namespace Actions {
Mutations.mutations.setServerCode(myres.status)
if (myres.status === 200) {
- let userId = body.userId
+ let myuser: IUserState = body.usertosend
+ let userId = myuser.userId
let username = authData.username
- let verifiedEmail = body.verified_email === 'true' || body.verified_email === true
+ let verifiedEmail = myuser.verified_email === true
if (process.env.DEV) {
console.log('USERNAME = ' + username)
console.log('IDUSER= ' + userId)
@@ -405,7 +385,7 @@ namespace Actions {
userId: userId,
username: username,
idToken: state.x_auth_token,
- verifiedEmail: verifiedEmail
+ verified_email: verifiedEmail
})
}
@@ -520,7 +500,7 @@ namespace Actions {
userId: userId,
username: username,
idToken: token,
- verifiedEmail: verifiedEmail
+ verified_email: verifiedEmail
})
setGlobal()
diff --git a/src/utils/config.ts b/src/utils/config.ts
index 6c669bc..ed2b339 100644
--- a/src/utils/config.ts
+++ b/src/utils/config.ts
@@ -6,13 +6,17 @@ switch (process.env.NODE_ENV) {
case 'test':
path = `${__dirname}/../../.env.test`
break
- case 'production':
- path = `${__dirname}/../../.env.production`
+ case 'development':
+ path = `${__dirname}/../../.env.development`
break
default:
- path = `${__dirname}/../../.env.development`
+ path = `${__dirname}/../../.env.production`
}
dotenv.config({ path })
+console.log('path', path)
+console.log('process.env.APP_ID', process.env.APP_ID)
+
+
export const APP_ID = process.env.APP_ID
export const LOG_LEVEL = process.env.LOG_LEVEL