2018-11-08 01:09:33 +01:00
|
|
|
import Vue from 'vue'
|
2018-11-17 20:32:28 +01:00
|
|
|
import { Component } from 'vue-property-decorator'
|
|
|
|
|
import { GlobalStore } from '@store'
|
2018-11-08 01:09:33 +01:00
|
|
|
|
2019-01-30 01:05:31 +01:00
|
|
|
import { Logo } from '../../components/logo'
|
2019-01-08 01:22:09 +01:00
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
@Component({
|
2019-01-08 01:22:09 +01:00
|
|
|
components: { Logo }
|
2018-11-08 01:09:33 +01:00
|
|
|
})
|
|
|
|
|
export default class Home extends Vue {
|
|
|
|
|
text: string = ''
|
|
|
|
|
visibile: boolean = false
|
|
|
|
|
cardvisible: string = 'hidden'
|
|
|
|
|
displaycard: string = 'block'
|
2019-01-08 01:22:09 +01:00
|
|
|
svgclass: string = 'svgclass'
|
2019-01-02 01:58:47 +01:00
|
|
|
$t: any
|
2018-11-08 01:09:33 +01:00
|
|
|
|
2018-11-11 19:27:04 +01:00
|
|
|
public $q
|
|
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
constructor() {
|
|
|
|
|
super()
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('Home constructor...')
|
2018-11-08 01:09:33 +01:00
|
|
|
this.initprompt()
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 21:02:16 +01:00
|
|
|
created() {
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('Home created...')
|
2018-12-26 21:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
mystilecard() {
|
|
|
|
|
return {
|
|
|
|
|
visibility: this.cardvisible,
|
|
|
|
|
display: this.displaycard
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get conta() {
|
2018-12-26 21:02:16 +01:00
|
|
|
return GlobalStore.state.conta
|
2018-11-08 01:09:33 +01:00
|
|
|
}
|
|
|
|
|
set conta(valore) {
|
2018-11-17 20:32:28 +01:00
|
|
|
GlobalStore.actions.setConta(valore)
|
|
|
|
|
let my = this.$q.i18n.lang
|
2018-11-08 01:09:33 +01:00
|
|
|
this.showNotification(String(my))
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 16:47:15 +01:00
|
|
|
showNotification(message: string, color = 'primary', icon = '') {
|
|
|
|
|
this.$q.notify({
|
|
|
|
|
color,
|
|
|
|
|
icon,
|
|
|
|
|
message
|
|
|
|
|
})
|
|
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initprompt() {
|
|
|
|
|
window.addEventListener('beforeinstallprompt', function (event) {
|
|
|
|
|
console.log('******************************** beforeinstallprompt fired')
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
console.log('§§§§§§§§§§§§§§§§§§§§ IMPOSTA DEFERRED PROMPT !!!!!!!!!!!!!!!!! ')
|
|
|
|
|
return false
|
|
|
|
|
})
|
2019-02-01 04:10:31 +01:00
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 16:47:15 +01:00
|
|
|
getPermission () {
|
|
|
|
|
return Notification.permission
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
displayConfirmNotification() {
|
|
|
|
|
let options = null
|
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
|
options = {
|
|
|
|
|
body: 'You successfully subscribed to our Notification service!',
|
|
|
|
|
icon: '/src/images/icons/app-icon-96x96.png',
|
|
|
|
|
image: '/src/images/sf-boat.jpg',
|
|
|
|
|
dir: 'ltr',
|
|
|
|
|
lang: 'en-US', // BCP 47,
|
|
|
|
|
vibrate: [100, 50, 200],
|
|
|
|
|
badge: '/src/images/icons/app-icon-96x96.png',
|
|
|
|
|
tag: 'confirm-notification',
|
|
|
|
|
renotify: true, // if it's already sent, will Vibrate anyway
|
|
|
|
|
actions: [
|
|
|
|
|
{ action: 'confirm', title: 'Okay', icon: '/src/images/icons/app-icon-96x96.png' },
|
|
|
|
|
{ action: 'cancel', title: 'Cancel', icon: '/src/images/icons/app-icon-96x96.png' }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navigator.serviceWorker.ready
|
|
|
|
|
.then(function(swreg) {
|
|
|
|
|
swreg.showNotification('Successfully subscribed!', options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showNotificationExample() {
|
|
|
|
|
let options = null
|
|
|
|
|
let mythis = this
|
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
|
options = {
|
|
|
|
|
body: mythis.$t('notification.subscribed'),
|
|
|
|
|
icon: '/statics/icons/android-chrome-192x192.png',
|
|
|
|
|
image: '/statics/images/freeplanet.png',
|
|
|
|
|
dir: 'ltr',
|
|
|
|
|
lang: 'en-US', // 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(mythis.$t('notification.title_subscribed'), options)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
askfornotification () {
|
|
|
|
|
this.showNotification(this.$t('notification.waitingconfirm'), 'positive', 'notifications')
|
|
|
|
|
|
|
|
|
|
let mythis = this
|
|
|
|
|
Notification.requestPermission(function(result) {
|
|
|
|
|
console.log('User Choice', result)
|
|
|
|
|
if (result === 'granted') {
|
|
|
|
|
mythis.showNotification(mythis.$t('notification.confirmed'), 'positive', 'notifications')
|
|
|
|
|
} else {
|
|
|
|
|
mythis.showNotification(mythis.$t('notification.denied'), 'negative', 'notifications')
|
|
|
|
|
|
|
|
|
|
// displayConfirmNotification();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 01:09:33 +01:00
|
|
|
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)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openCreatePostModal() {
|
|
|
|
|
console.log('APERTO ! openCreatePostModal')
|
|
|
|
|
|
|
|
|
|
this.conta = this.conta + 1
|
|
|
|
|
|
|
|
|
|
this.visibile = !this.visibile
|
|
|
|
|
|
|
|
|
|
if (this.visibile) {
|
|
|
|
|
this.displaycard = 'block'
|
|
|
|
|
this.cardvisible = 'visible'
|
|
|
|
|
} else {
|
|
|
|
|
this.displaycard = 'block'
|
|
|
|
|
this.cardvisible = 'hidden'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|