- updated SendReq
- If Server Down the login msg error corrected.
This commit is contained in:
@@ -113,10 +113,12 @@ if (workbox) {
|
|||||||
return clonedRes.json();
|
return clonedRes.json();
|
||||||
})
|
})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
|
if (data.todos) {
|
||||||
console.log('Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
|
console.log('Records TODOS Received from Server [', data.todos.length, 'record]', data.todos)
|
||||||
for (let key in data.todos) {
|
for (let key in data.todos) {
|
||||||
writeData('todos', data.todos[key])
|
writeData('todos', data.todos[key])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
@@ -278,7 +280,11 @@ self.addEventListener('sync', function (event) {
|
|||||||
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 = cfgenv.serverweb + '/todos/' + rec._id
|
let link = cfgenv.serverweb + '/todos'
|
||||||
|
|
||||||
|
if (method !== 'POST')
|
||||||
|
link += '/' + rec._id
|
||||||
|
|
||||||
console.log('++++++++++++++++++ SYNCING !!!! ', rec.descr, table, 'FETCH: ', method, link, 'data:')
|
console.log('++++++++++++++++++ SYNCING !!!! ', rec.descr, table, 'FETCH: ', method, link, 'data:')
|
||||||
|
|
||||||
// Insert/Delete/Update table to the server
|
// Insert/Delete/Update table to the server
|
||||||
@@ -289,7 +295,7 @@ self.addEventListener('sync', function (event) {
|
|||||||
body: JSON.stringify(rec)
|
body: JSON.stringify(rec)
|
||||||
})
|
})
|
||||||
.then(function (resData) {
|
.then(function (resData) {
|
||||||
console.log('Result CALL ', method, ' OK? =', resData.ok);
|
// console.log('Result CALL ', method, ' OK? =', resData.ok);
|
||||||
|
|
||||||
// Anyway Delete this, otherwise in some cases will return error, but it's not a problem.
|
// 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 ...
|
// for example if I change a record and then I deleted ...
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ export default class Todo extends Vue {
|
|||||||
@Watch('reload_fromServer', { immediate: true })
|
@Watch('reload_fromServer', { immediate: true })
|
||||||
reload_fromServer_changed(value: string, oldValue: string) {
|
reload_fromServer_changed(value: string, oldValue: string) {
|
||||||
console.log('reload_fromServer_changed!', value, oldValue)
|
console.log('reload_fromServer_changed!', value, oldValue)
|
||||||
if (value) {
|
// if (value) {
|
||||||
Todos.actions.dbLoadTodo(false)
|
Todos.actions.dbLoadTodo(false)
|
||||||
|
|
||||||
Todos.actions.updateArrayInMemory()
|
Todos.actions.updateArrayInMemory()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -397,10 +397,20 @@ export default class Todo extends Vue {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isRegistered() {
|
||||||
|
return localStorage.getItem(rescodes.localStorage.userId) !== ''
|
||||||
|
}
|
||||||
|
|
||||||
async insertTodo() {
|
async insertTodo() {
|
||||||
if (this.todo.trim() === '')
|
if (this.todo.trim() === '')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (!this.isRegistered()) {
|
||||||
|
// Not logged
|
||||||
|
this.$q.notify(this.$t('user.notregistered'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const objtodo = this.initcat()
|
const objtodo = this.initcat()
|
||||||
|
|
||||||
console.log('insertTodo ', UserStore.state.userId)
|
console.log('insertTodo ', UserStore.state.userId)
|
||||||
|
|||||||
@@ -28,4 +28,5 @@ export interface IUserState {
|
|||||||
|
|
||||||
servercode?: number
|
servercode?: number
|
||||||
x_auth_token?: string
|
x_auth_token?: string
|
||||||
|
isLogged?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ const messages = {
|
|||||||
errore_generico: 'Errore Generico',
|
errore_generico: 'Errore Generico',
|
||||||
errore_server: 'Impossibile accedere al Server. Riprovare Grazie',
|
errore_server: 'Impossibile accedere al Server. Riprovare Grazie',
|
||||||
},
|
},
|
||||||
|
user: {
|
||||||
|
notregistered: 'Devi registrarti al servizio prima di porter memorizzare i dati'
|
||||||
|
},
|
||||||
reg: {
|
reg: {
|
||||||
incorso: 'Registrazione in corso...',
|
incorso: 'Registrazione in corso...',
|
||||||
richiesto: 'Campo Richiesto',
|
richiesto: 'Campo Richiesto',
|
||||||
@@ -173,6 +176,9 @@ const messages = {
|
|||||||
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.',
|
||||||
},
|
},
|
||||||
|
user: {
|
||||||
|
notregistered: 'You need first to SignUp before storing data'
|
||||||
|
},
|
||||||
reg: {
|
reg: {
|
||||||
incorso: 'Registration please wait...',
|
incorso: 'Registration please wait...',
|
||||||
richiesto: 'Field Required',
|
richiesto: 'Field Required',
|
||||||
|
|||||||
@@ -79,19 +79,17 @@ export namespace ApiTool {
|
|||||||
}
|
}
|
||||||
return reject(e)
|
return reject(e)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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(e)
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
|
||||||
return resolve({res, body: res.body})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (process.env.DEV) {
|
if (process.env.DEV) {
|
||||||
|
|||||||
@@ -80,12 +80,12 @@ namespace Actions {
|
|||||||
|
|
||||||
globalroutines(null, 'readall', 'swmsg')
|
globalroutines(null, 'readall', 'swmsg')
|
||||||
.then(function (arr_recmsg) {
|
.then(function (arr_recmsg) {
|
||||||
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(' TROVATI MSG PENDENTI ! ORA LI MANDO: ', arr_recmsg)
|
||||||
|
|
||||||
console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
// console.log('---------------------- 2) navigator (2) .serviceWorker.ready')
|
||||||
|
|
||||||
something = true
|
something = true
|
||||||
for (let rec of arr_recmsg) {
|
for (let rec of arr_recmsg) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const state: IUserState = {
|
|||||||
verifiedEmail: false,
|
verifiedEmail: false,
|
||||||
categorySel: 'personal',
|
categorySel: 'personal',
|
||||||
servercode: 0,
|
servercode: 0,
|
||||||
x_auth_token: ''
|
x_auth_token: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,8 +76,7 @@ namespace Getters {
|
|||||||
},
|
},
|
||||||
get getServerCode() {
|
get getServerCode() {
|
||||||
return getServerCode()
|
return getServerCode()
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -334,6 +333,7 @@ namespace Actions {
|
|||||||
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.verifiedEmail, '0')
|
||||||
|
state.isLogged = true
|
||||||
// dispatch('storeUser', authData);
|
// dispatch('storeUser', authData);
|
||||||
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
||||||
|
|
||||||
@@ -476,6 +476,7 @@ namespace Actions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setGlobal() {
|
function setGlobal() {
|
||||||
|
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))
|
||||||
|
|
||||||
@@ -506,6 +507,7 @@ namespace Actions {
|
|||||||
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')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const userId = String(localStorage.getItem(rescodes.localStorage.userId))
|
const userId = String(localStorage.getItem(rescodes.localStorage.userId))
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
export const serv_constants = {
|
export const serv_constants = {
|
||||||
|
RIS_CODE_TODO_CREATING_NOTMYUSER: -1001,
|
||||||
|
|
||||||
RIS_CODE_ERR: -99,
|
RIS_CODE_ERR: -99,
|
||||||
RIS_CODE_EMAIL_ALREADY_VERIFIED: -5,
|
RIS_CODE_EMAIL_ALREADY_VERIFIED: -5,
|
||||||
RIS_CODE_EMAIL_VERIFIED: 1,
|
RIS_CODE_EMAIL_VERIFIED: 1,
|
||||||
RIS_CODE_OK: 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_LOGIN_OK: 1
|
RIS_CODE_LOGIN_OK: 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user