Created Project for WebSite...

Basic Structure
This commit is contained in:
Paolo Arena
2019-05-03 20:31:47 +02:00
parent cd73305d8d
commit 3d8cb00839
16 changed files with 829 additions and 797 deletions

View File

@@ -16,7 +16,7 @@ import { GlobalStore, Projects, Todos, UserStore } from '@store'
import messages from '../../statics/i18n'
import globalroutines from './../../globalroutines/index'
import { cfgrouter } from '../../../cfg_locale/index'
import { cfgrouter } from '../../router/route-config'
let stateConnDefault = 'online'
@@ -114,7 +114,7 @@ namespace Getters {
}, 'showtype')
const getmenu = b.read((state) => {
console.log('getmenu', cfgrouter.getmenu())
// console.log('getmenu', cfgrouter.getmenu())
state.menulinks = {
Dashboard: {

View File

@@ -11,6 +11,8 @@ import globalroutines from './../../globalroutines/index'
import objectId from '@src/js/objectId'
import { costanti } from '@src/store/Modules/costanti'
import { RouteNames } from '@src/router/route-names'
import * as Types from '@src/store/Api/ApiTypes'
import { serv_constants } from '@src/store/Modules/serv_constants'
const nametable = 'projects'
@@ -272,7 +274,7 @@ namespace Actions {
if (onlyiffirsttime) {
if (stateglob.projects.length > 0) {
// if already set, then exit.
return false
return new Types.AxiosError(0, null, 0, '')
}
}
@@ -304,7 +306,7 @@ namespace Actions {
.catch((error) => {
console.log('error dbLoad', error)
UserStore.mutations.setErrorCatch(error)
return error
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error)
})
ApiTables.aftercalling(ris, checkPending, nametable)

View File

@@ -13,6 +13,7 @@ import { GetterTree } from 'vuex'
import objectId from '@src/js/objectId'
import { costanti } from '@src/store/Modules/costanti'
import { IAction } from '@src/model'
import * as Types from '@src/store/Api/ApiTypes'
const nametable = 'todos'
@@ -240,9 +241,9 @@ namespace Actions {
async function dbLoad(context, { checkPending }) {
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
if (UserStore.state.userId === '') {
return false // Login not made
}
// if (UserStore.state.userId === '') {
// return new Types.AxiosError(0, null, 0, '')
// }
const ris = await Api.SendReq('/todos/' + UserStore.state.userId, 'GET', null)
.then((res) => {
@@ -268,10 +269,12 @@ namespace Actions {
.catch((error) => {
console.log('error dbLoad', error)
UserStore.mutations.setErrorCatch(error)
return error
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error)
})
ApiTables.aftercalling(ris, checkPending, 'categories')
return ris
}
async function deleteItemtodo(context, { cat, idobj }) {

View File

@@ -520,10 +520,11 @@ namespace Actions {
GlobalStore.actions.checkUpdates()
}
await GlobalStore.actions.loadAfterLogin()
return await GlobalStore.actions.loadAfterLogin()
.then(() => {
Todos.actions.dbLoad({ checkPending: true })
Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
return Todos.actions.dbLoad({ checkPending: true })
}).then(() => {
return Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
})
}

View File

@@ -1572,5 +1572,86 @@ export const tools = {
addRoute(myarr, values) {
myarr.push(values)
},
displayConfirmNotification() {
let options = null
if ('serviceWorker' in navigator) {
options = {
body: 'You successfully subscribed to our Notification service!',
icon: '/statics/icons/app-icon-96x96.png',
image: '/statics/images/sf-boat.jpg',
dir: 'ltr',
lang: 'enUs', // BCP 47,
vibrate: [100, 50, 200],
badge: '/statics/icons/app-icon-96x96.png',
tag: 'confirm-notification',
renotify: true, // if it's already sent, will Vibrate anyway
actions: [
{ action: 'confirm', title: 'Okay', icon: '/statics/icons/app-icon-96x96.png' },
{ action: 'cancel', title: 'Cancel', icon: '/statics/icons/app-icon-96x96.png' }
]
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(function (swreg) {
swreg.showNotification('Successfully subscribed!', options)
})
}
}
},
dataURItoBlob(dataURI) {
const byteString = atob(dataURI.split(',')[1])
const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
const ab = new ArrayBuffer(byteString.length)
const ia = new Uint8Array(ab)
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i)
}
const blob = new Blob([ab], { type: mimeString })
return blob
},
showNotificationExample() {
let options = null
const mythis = this
if ('serviceWorker' in navigator) {
options = {
body: mythis.$t('notification.subscribed'),
icon: '/statics/icons/android-chrome-192x192.png',
image: '/statics/images/imglogonotif.png',
dir: 'ltr',
lang: 'enUs', // BCP 47,
vibrate: [100, 50, 200],
badge: '/statics/icons/android-chrome-192x192.png',
tag: 'confirm-notification',
renotify: true, // if it's already sent, will Vibrate anyway
actions: [
{ action: 'confirm', title: mythis.$t('dialog.ok'), icon: '/statics/icons/android-chrome-192x192.png' }
// { action: 'cancel', title: 'Cancel', icon: '/statics/icons/android-chrome-192x192.png', }
]
}
navigator.serviceWorker.ready
.then(function (swreg) {
swreg.showNotification('aaa', options)
})
}
},
askfornotification() {
tools.showNotif(this.$q, this.$t('notification.waitingconfirm'), { color: 'positive', icon: 'notifications' })
Notification.requestPermission((result) => {
console.log('User Choice', result)
if (result === 'granted') {
tools.showNotif(this.$q, this.$t('notification.confirmed'), { color: 'positive', icon: 'notifications' })
} else {
tools.showNotif(this.$q, this.$t('notification.denied'), { color: 'negative', icon: 'notifications' })
// displayConfirmNotification();
}
})
}
}