Rename web_pwa -> web_pwa_oca

This commit is contained in:
eLBati
2020-06-05 08:12:22 +02:00
committed by sergio-teruel
parent 7d9053cb69
commit 4ec8d1ab8b
23 changed files with 1074 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="web_layout_pwa" name="Web layout PWA" inherit_id="web.layout">
<xpath expr="//meta[@name='viewport']" position="after">
<!-- Add link rel manifest -->
<link rel="manifest" href="/web_pwa_oca/manifest.json"/>
<!-- Add iOS meta tags and icons -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="apple-mobile-web-app-title" content="Odoo PWA"/>
<link rel="apple-touch-icon" href="/web_pwa_oca/static/img/icons/icon-152x152.png"/>
<!-- Add meta theme-color -->
<meta name="theme-color" content="#2E69B5" />
</xpath>
</template>
<template id="assets_backend" name="PWA assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_pwa_oca/static/src/js/pwa_install.js"/>
</xpath>
</template>
<template id="service_worker" name="PWA service worker">
'use strict';
const CACHE_NAME = '<t t-esc="pwa_cache_name"/>';
const FILES_TO_CACHE = [
<t t-foreach="pwa_files_to_cache" t-as="file_to_cache">
'<t t-esc="file_to_cache"/>',
</t>
];
self.addEventListener('install', function (evt) {
console.log('[ServiceWorker] Install');
evt.waitUntil(
caches.open(CACHE_NAME).then(function (cache) {
console.log('[ServiceWorker] Pre-caching offline page');
return cache.addAll(FILES_TO_CACHE);
})
);
self.skipWaiting();
});
self.addEventListener('activate', function(evt) {
console.log('[ServiceWorker] Activate');
evt.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (key !== CACHE_NAME) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
})
);
self.clients.claim();
});
self.addEventListener('fetch', function(evt) {
if (evt.request.cache === 'only-if-cached' &amp;&amp; evt.request.mode !== 'same-origin') {
return;
}
console.log('[ServiceWorker] Fetch', evt.request.url);
evt.respondWith(
caches.open(CACHE_NAME).then(function(cache) {
return cache.match(evt.request)
.then(function(response) {
return response || fetch(evt.request);
});
})
);
});
</template>
<template id="manifest" name="PWA manifest">
{
"name": "<t t-esc="pwa_name"/>",
"short_name": "<t t-esc="pwa_short_name"/>",
"icons": [{
"src": "<t t-esc="icon128x128"/>",
"sizes": "128x128",
"type": "image/png"
}, {
"src": "<t t-esc="icon144x144"/>",
"sizes": "144x144",
"type": "image/png"
}, {
"src": "<t t-esc="icon152x152"/>",
"sizes": "152x152",
"type": "image/png"
}, {
"src": "<t t-esc="icon192x192"/>",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "<t t-esc="icon256x256"/>",
"sizes": "256x256",
"type": "image/png"
}, {
"src": "<t t-esc="icon512x512"/>",
"sizes": "512x512",
"type": "image/png"
}],
"start_url": "/web",
"display": "standalone",
"background_color": "<t t-esc="background_color"/>",
"theme_color": "<t t-esc="theme_color"/>"
}
</template>
</odoo>