forked from Techsystech/web
[IMP] web_pwa_oca: black, isort, prettier
parent
fc3ab59acb
commit
7bf6e89d9a
|
@ -68,7 +68,10 @@ class ResConfigSettings(models.TransientModel):
|
||||||
resized_image.save(icon_bytes_output, format=extension.lstrip(".").upper())
|
resized_image.save(icon_bytes_output, format=extension.lstrip(".").upper())
|
||||||
icon = base64.b64encode(icon_bytes_output.getvalue())
|
icon = base64.b64encode(icon_bytes_output.getvalue())
|
||||||
url = "{}{}x{}{}".format(
|
url = "{}{}x{}{}".format(
|
||||||
self._pwa_icon_url_base, str(size[0]), str(size[1]), extension,
|
self._pwa_icon_url_base,
|
||||||
|
str(size[0]),
|
||||||
|
str(size[1]),
|
||||||
|
extension,
|
||||||
)
|
)
|
||||||
# Retreive existing attachment
|
# Retreive existing attachment
|
||||||
existing_attachment = (
|
existing_attachment = (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
odoo.define("web_pwa_oca.PWAManager", function(require) {
|
odoo.define("web_pwa_oca.PWAManager", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var core = require("web.core");
|
var core = require("web.core");
|
||||||
|
@ -13,7 +13,7 @@ odoo.define("web_pwa_oca.PWAManager", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
init: function() {
|
init: function () {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
if (!("serviceWorker" in navigator)) {
|
if (!("serviceWorker" in navigator)) {
|
||||||
console.error(
|
console.error(
|
||||||
|
@ -31,11 +31,11 @@ odoo.define("web_pwa_oca.PWAManager", function(require) {
|
||||||
* @param {String} sw_script
|
* @param {String} sw_script
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
registerServiceWorker: function(sw_script) {
|
registerServiceWorker: function (sw_script) {
|
||||||
return this._service_worker
|
return this._service_worker
|
||||||
.register(sw_script)
|
.register(sw_script)
|
||||||
.then(this._onRegisterServiceWorker)
|
.then(this._onRegisterServiceWorker)
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(_t("[ServiceWorker] Registration failed: "), error);
|
console.log(_t("[ServiceWorker] Registration failed: "), error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -46,7 +46,7 @@ odoo.define("web_pwa_oca.PWAManager", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @param {ServiceWorkerRegistration} registration
|
* @param {ServiceWorkerRegistration} registration
|
||||||
*/
|
*/
|
||||||
_onRegisterServiceWorker: function(registration) {
|
_onRegisterServiceWorker: function (registration) {
|
||||||
console.log(_t("[ServiceWorker] Registered:"), registration);
|
console.log(_t("[ServiceWorker] Registered:"), registration);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
/* Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
odoo.define("web_pwa_oca.webclient", function(require) {
|
odoo.define("web_pwa_oca.webclient", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WebClient = require("web.WebClient");
|
var WebClient = require("web.WebClient");
|
||||||
|
@ -11,7 +11,7 @@ odoo.define("web_pwa_oca.webclient", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
show_application: function() {
|
show_application: function () {
|
||||||
this.pwa_manager = new PWAManager(this);
|
this.pwa_manager = new PWAManager(this);
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
// This is a hack, not a complete implementation!
|
// This is a hack, not a complete implementation!
|
||||||
// only expected to be used by boot.js
|
// only expected to be used by boot.js
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
function JQuery(selector, context) {
|
function JQuery(selector, context) {
|
||||||
return new JQuery.prototype.init(selector, context);
|
return new JQuery.prototype.init(selector, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
JQuery.prototype = {
|
JQuery.prototype = {
|
||||||
init: function(selector) {
|
init: function (selector) {
|
||||||
if (typeof selector === "function") {
|
if (typeof selector === "function") {
|
||||||
selector();
|
selector();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deparam: function(data) {
|
deparam: function (data) {
|
||||||
const params = data.split(",");
|
const params = data.split(",");
|
||||||
const res = [];
|
const res = [];
|
||||||
for (const param of params) {
|
for (const param of params) {
|
||||||
|
@ -28,14 +28,14 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
param: {
|
param: {
|
||||||
querystring: function() {
|
querystring: function () {
|
||||||
return "debug=1";
|
return "debug=1";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
when: function(tasks) {
|
when: function (tasks) {
|
||||||
return Promise.all(tasks instanceof Array ? tasks : [tasks]).then(
|
return Promise.all(tasks instanceof Array ? tasks : [tasks]).then(
|
||||||
results => {
|
(results) => {
|
||||||
return results.length === 1 ? results[0] : results;
|
return results.length === 1 ? results[0] : results;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,21 +8,21 @@
|
||||||
* this class is instantiated.
|
* this class is instantiated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
odoo.define("web_pwa_oca.PWA", function(require) {
|
odoo.define("web_pwa_oca.PWA", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const OdooClass = require("web.Class");
|
const OdooClass = require("web.Class");
|
||||||
|
|
||||||
const PWA = OdooClass.extend({
|
const PWA = OdooClass.extend({
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
init: function(params) {
|
init: function (params) {
|
||||||
// To be overridden
|
// To be overridden
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
installWorker: function() {
|
installWorker: function () {
|
||||||
// To be overridden
|
// To be overridden
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@ odoo.define("web_pwa_oca.PWA", function(require) {
|
||||||
/**
|
/**
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
activateWorker: function() {
|
activateWorker: function () {
|
||||||
// To be overridden
|
// To be overridden
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue