Created Project for WebSite...
Basic Structure
This commit is contained in:
@@ -69,6 +69,10 @@ export default class Home extends Vue {
|
||||
GlobalStore.actions.prova()
|
||||
}
|
||||
|
||||
get tools() {
|
||||
return tools
|
||||
}
|
||||
|
||||
get isLogged() {
|
||||
return UserStore.state.isLogged
|
||||
}
|
||||
@@ -116,7 +120,7 @@ export default class Home extends Vue {
|
||||
}
|
||||
|
||||
public initprompt() {
|
||||
window.addEventListener('beforeinstallprompt', function(event) {
|
||||
window.addEventListener('beforeinstallprompt', (event) => {
|
||||
// console.log('******************************** beforeinstallprompt fired')
|
||||
event.preventDefault()
|
||||
// console.log('§§§§§§§§§§§§§§§§§§§§ IMPOSTA DEFERRED PROMPT !!!!!!!!!!!!!!!!! ')
|
||||
@@ -146,128 +150,31 @@ export default class Home extends Vue {
|
||||
this.$router.replace('/signup')
|
||||
}
|
||||
|
||||
public 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public urlBase64ToUint8Array(base64String) {
|
||||
const padding = '='.repeat((4 - base64String.length % 4) % 4)
|
||||
const base64 = (base64String + padding)
|
||||
.replace(/\-/g, '+')
|
||||
.replace(/_/g, '/')
|
||||
|
||||
const rawData = window.atob(base64)
|
||||
const outputArray = new Uint8Array(rawData.length)
|
||||
|
||||
for (let i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i)
|
||||
}
|
||||
return outputArray
|
||||
}
|
||||
|
||||
public 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
|
||||
}
|
||||
|
||||
public 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public 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();
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
public test_fetch() {
|
||||
fetch('https:/httpbin.org/post', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
// mode: 'no-cors',
|
||||
mode: 'cors',
|
||||
body: JSON.stringify({ message: 'Does this work?' })
|
||||
}).then(function(response) {
|
||||
console.log(response)
|
||||
if (response) {
|
||||
return response.json()
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}).then(function(data) {
|
||||
console.log(data)
|
||||
}).catch(function(err) {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
// public test_fetch() {
|
||||
// fetch('https:/httpbin.org/post', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Accept': 'application/json'
|
||||
// },
|
||||
// // mode: 'no-cors',
|
||||
// mode: 'cors',
|
||||
// body: JSON.stringify({ message: 'Does this work?' })
|
||||
// }).then(function(response) {
|
||||
// console.log(response)
|
||||
// if (response) {
|
||||
// return response.json()
|
||||
// }
|
||||
// else {
|
||||
// return null
|
||||
// }
|
||||
// }).then(function(data) {
|
||||
// console.log(data)
|
||||
// }).catch(function(err) {
|
||||
// console.log(err)
|
||||
// })
|
||||
// }
|
||||
//
|
||||
|
||||
public openCreatePostModal() {
|
||||
console.log('APERTO ! openCreatePostModal')
|
||||
|
||||
Reference in New Issue
Block a user