Fixed WebPush Notification error subscription

This commit is contained in:
Paolo Arena
2021-10-05 15:39:33 +02:00
parent 9121569809
commit eb4156fc89
9 changed files with 161 additions and 130 deletions

View File

@@ -116,13 +116,8 @@ export default defineComponent({
emit('loginOk')
// GlobalStore.actions.createPushSubscription()
// .then((rissub) => {
// // ...
// })
// .catch((e) => {
// console.log('ERROR Subscription = ' + e)
// })
globalStore.createPushSubscription()
} else {
emit('checkErrors', riscode)
}

View File

@@ -1,58 +1,17 @@
import { LMap, LIcon, LTileLayer, LMarker, LControlLayers, LTooltip, LPopup, LPolyline, LPolygon, LRectangle, } from '@vue-leaflet/vue-leaflet'
import 'leaflet/dist/leaflet.css'
import {
defineComponent, ref, computed,
} from 'vue'
import { tools } from '@src/store/Modules/tools'
export default defineComponent({
name: 'Home',
components: {
LMap,
LIcon,
LTileLayer,
LMarker,
LControlLayers,
LTooltip,
LPopup,
LPolyline,
LPolygon,
LRectangle,
},
setup() {
const zoom = ref(2)
const iconWidth = ref(25)
const iconHeight = ref(40)
const iconUrl = computed(() => `https://placekitten.com/${iconWidth.value}/${iconHeight.value}`)
const iconSize = computed(() => [iconWidth.value, iconHeight.value])
function log(a: any) {
console.log(a)
}
function changeIcon() {
iconWidth.value += 2
if (iconWidth.value > iconHeight.value) {
iconWidth.value = Math.floor(iconHeight.value / 2)
}
}
return {
tools,
zoom,
iconWidth,
iconHeight,
iconUrl,
iconSize,
changeIcon,
log,
}
},
})

View File

@@ -2,79 +2,7 @@
<q-page class="">
<h1>Inizio:</h1>
<template>
<div style="height: 75vh; width: 50vw;">
<l-map
v-model="zoom"
v-model:zoom="zoom"
:center="[47.41322, -1.219482]"
@move="log('move')"
>
<l-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
></l-tile-layer>
<l-control-layers />
<l-marker :lat-lng="[0, 0]" draggable @moveend="log('moveend')">
<l-tooltip>
lol
</l-tooltip>
</l-marker>
<l-marker :lat-lng="[47.41322, -1.219482]">
<l-icon :icon-url="iconUrl" :icon-size="iconSize" />
</l-marker>
<l-marker :lat-lng="[50, 50]" draggable @moveend="log('moveend')">
<l-popup>
lol
</l-popup>
</l-marker>
<l-polyline
:lat-lngs="[
[47.334852, -1.509485],
[47.342596, -1.328731],
[47.241487, -1.190568],
[47.234787, -1.358337],
]"
color="green"
></l-polyline>
<l-polygon
:lat-lngs="[
[46.334852, -1.509485],
[46.342596, -1.328731],
[46.241487, -1.190568],
[46.234787, -1.358337],
]"
color="#41b782"
:fill="true"
:fillOpacity="0.5"
fillColor="#41b782"
/>
<l-rectangle
:lat-lngs="[
[46.334852, -1.509485],
[46.342596, -1.328731],
[46.241487, -1.190568],
[46.234787, -1.358337],
]"
:fill="true"
color="#35495d"
/>
<l-rectangle
:bounds="[
[46.334852, -1.190568],
[46.241487, -1.090357],
]"
>
<l-popup>
lol
</l-popup>
</l-rectangle>
</l-map>
<button @click="changeIcon">New kitten icon</button>
</div>
</template>
</q-page>
</template>

0
src/root/maps/maps.scss Executable file
View File

73
src/root/maps/maps.ts.off Executable file
View File

@@ -0,0 +1,73 @@
// @ts-ignore
import { LMap, LIcon, LTileLayer, LMarker, LControlLayers, LTooltip, LPopup, LPolyline, LPolygon, LRectangle, } from '@vue-leaflet/vue-leaflet'
import 'leaflet/dist/leaflet.css'
import {
defineComponent, ref, computed,
} from 'vue'
import { tools } from '@src/store/Modules/tools'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const leaflet = require('leaflet');
delete leaflet.Icon.Default.prototype._getIconUrl;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const iconRetinaUrl = require('leaflet/dist/images/marker-icon-2x.png');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const iconUrl = require('leaflet/dist/images/marker-icon.png');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const shadowUrl = require('leaflet/dist/images/marker-shadow.png');
leaflet.Icon.Default.mergeOptions({ iconRetinaUrl, iconUrl, shadowUrl })
export default defineComponent({
name: 'Home',
components: {
LMap,
LIcon,
LTileLayer,
LMarker,
LControlLayers,
LTooltip,
LPopup,
LPolyline,
LPolygon,
LRectangle,
},
setup() {
const zoom = ref(2)
const iconWidth = ref(25)
const iconHeight = ref(40)
const iconUrl = computed(() => `https://placekitten.com/${iconWidth.value}/${iconHeight.value}`)
const iconSize = computed(() => [iconWidth.value, iconHeight.value])
function log(a: any) {
console.log(a)
}
function changeIcon() {
iconWidth.value += 2
if (iconWidth.value > iconHeight.value) {
iconWidth.value = Math.floor(iconHeight.value / 2)
}
}
return {
tools,
zoom,
iconWidth,
iconHeight,
iconUrl,
iconSize,
changeIcon,
log,
}
},
})

85
src/root/maps/maps.vue.off Executable file
View File

@@ -0,0 +1,85 @@
<template>
<q-page class="">
<h1>Inizio:</h1>
<template>
<div style="height: 75vh; width: 50vw;">
<l-map
v-model="zoom"
v-model:zoom="zoom"
:center="[47.41322, -1.219482]"
@move="log('move')"
>
<l-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
></l-tile-layer>
<l-control-layers />
<l-marker :lat-lng="[0, 0]" draggable @moveend="log('moveend')">
<l-tooltip>
lol
</l-tooltip>
</l-marker>
<l-marker :lat-lng="[47.41322, -1.219482]">
<l-icon :icon-url="iconUrl" :icon-size="iconSize" />
</l-marker>
<l-marker :lat-lng="[50, 50]" draggable @moveend="log('moveend')">
<l-popup>
lol
</l-popup>
</l-marker>
<l-polyline
:lat-lngs="[
[47.334852, -1.509485],
[47.342596, -1.328731],
[47.241487, -1.190568],
[47.234787, -1.358337],
]"
color="green"
></l-polyline>
<l-polygon
:lat-lngs="[
[46.334852, -1.509485],
[46.342596, -1.328731],
[46.241487, -1.190568],
[46.234787, -1.358337],
]"
color="#41b782"
:fill="true"
:fillOpacity="0.5"
fillColor="#41b782"
/>
<l-rectangle
:lat-lngs="[
[46.334852, -1.509485],
[46.342596, -1.328731],
[46.241487, -1.190568],
[46.234787, -1.358337],
]"
:fill="true"
color="#35495d"
/>
<l-rectangle
:bounds="[
[46.334852, -1.190568],
[46.241487, -1.090357],
]"
>
<l-popup>
lol
</l-popup>
</l-rectangle>
</l-map>
<button @click="changeIcon">New kitten icon</button>
</div>
</template>
</q-page>
</template>
<script lang="ts" src="./maps.ts">
</script>
<style lang="scss" scoped>
@import './maps.scss';
</style>

View File

@@ -1,3 +0,0 @@
// This is required to use Webpack loaders, cf https://stackoverflow.com/a/36151803/257169
declare function require(string): any;