- fixed quantità

- creazione mappa numero utenti per provincia !
This commit is contained in:
Surya Paolo
2024-03-19 00:22:01 +01:00
parent 9f78ab61d9
commit 61db6cee36
90 changed files with 450 additions and 271 deletions

View File

@@ -17,6 +17,16 @@ import { CacheableResponsePlugin } from 'workbox-cacheable-response'
// Used to limit entries in cache, remove entries after a certain period of time
import { ExpirationPlugin } from 'workbox-expiration'
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
self.addEventListener('install', () => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(self.clients.claim());
});
console.log(
' [ VER-0.5.4 ] _---------________------ PAO: this is my custom service worker')
@@ -36,7 +46,7 @@ let port = 3000
if (self.location.hostname.startsWith('test')) {
port = 3001
}
console.log('SW- app ver 0.5.4')
console.log('SW- app ver 1.0.21')
const cfgenv = {
serverweb: `${self.location.protocol}//${self.location.hostname}:${port}`,
@@ -46,22 +56,22 @@ const cfgenv = {
// console.log('serverweb', cfgenv.serverweb)
async function writeData (table, data) {
async function writeData(table, data) {
console.log('writeData', table, data);
await idbKeyval.setdata(table, data)
}
async function readAllData (table) {
async function readAllData(table) {
// console.log('readAllData', table);
return idbKeyval.getalldata(table)
}
async function clearAllData (table) {
async function clearAllData(table) {
// console.log('clearAllData', table);
await idbKeyval.clearalldata(table)
}
async function deleteItemFromData (table, id) {
async function deleteItemFromData(table, id) {
// console.log('deleteItemFromData', table, 'ID:', id);
await idbKeyval.deletedata(table, id)
@@ -165,7 +175,7 @@ if (workbox) {
// console.log(' routing.registerRoute function declaration:')
function Execute_Fetch (table, args) {
function Execute_Fetch(table, args) {
console.log('Execute_Fetch registerRoute! ',
`${cfgenv.serverweb}/${table}/`)
// console.log('DATABODY:', args.event.request.body)
@@ -255,21 +265,21 @@ if (workbox) {
registerRoute(
(routeData) => (routeData.event.request.headers.get('accept')
.includes('text/html')), (args) => caches.match(args.event.request)
.then((response) => {
if (response) {
return response
}
return fetch(args.event.request)
.then((res) => caches.open('dynamic')
.then((cache) => {
console.log('fetch cache')
console.log('cache', args.event.request.url)
cache.put(args.event.request.url, res.clone())
return res
}))
.catch((err) => caches.match('/offline')
.then((res) => res))
}),
.then((response) => {
if (response) {
return response
}
return fetch(args.event.request)
.then((res) => caches.open('dynamic')
.then((cache) => {
console.log('fetch cache')
console.log('cache', args.event.request.url)
cache.put(args.event.request.url, res.clone())
return res
}))
.catch((err) => caches.match('/offline')
.then((res) => res))
}),
)
registerRoute(
@@ -420,7 +430,7 @@ self.addEventListener('message', event => {
addEventListener('fetch', event => {
// Prevent the default, and handle the request ourselves.
event.respondWith(async function() {
event.respondWith(async function () {
// Try to get the response from a cache.
const cachedResponse = await caches.match(event.request);
// Return it if we found one.
@@ -439,7 +449,7 @@ self.addEventListener('fetch', function (event) {
fetch(event.request, event.headers)
.catch(err => {
console.log('_______________________ ERRORE FETCH SW: ', event.request, err)
writeData('config', {_id: 2, stateconn: 'offline'})
writeData('config', { _id: 2, stateconn: 'offline' })
return caches.match(event.request);
})
);
@@ -523,7 +533,7 @@ self.addEventListener('sync', function (event) {
}
}
})
;
;
/*