Tower: upload havari_license_client 16.0.1.0.0 (was 16.0.1.0.0, via marketplace)
This commit is contained in:
45
addons/havari_license_client/static/src/js/license_bus.js
Normal file
45
addons/havari_license_client/static/src/js/license_bus.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
/**
|
||||
* License Bus Service
|
||||
* Listens for license status updates from the server and reloads the page when needed.
|
||||
*/
|
||||
export const licenseBusService = {
|
||||
dependencies: ["bus_service", "notification"],
|
||||
|
||||
start(env, { bus_service, notification }) {
|
||||
// Subscribe to license status updates
|
||||
bus_service.subscribe("license/status_update", (payload) => {
|
||||
console.log("License status update received:", payload);
|
||||
|
||||
const { module_name, action, state, message, requires_reload } = payload;
|
||||
|
||||
// Show notification to user
|
||||
if (action === "suspend" || action === "revoke") {
|
||||
notification.add(message || `License for ${module_name} has been ${state}`, {
|
||||
title: "License Status Changed",
|
||||
type: "danger",
|
||||
sticky: true,
|
||||
});
|
||||
|
||||
// Reload page after 3 seconds to apply changes
|
||||
if (requires_reload) {
|
||||
setTimeout(() => {
|
||||
browser.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
} else if (action === "activate") {
|
||||
notification.add(message || `License for ${module_name} has been activated`, {
|
||||
title: "License Activated",
|
||||
type: "success",
|
||||
sticky: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
registry.category("services").add("license_bus", licenseBusService);
|
||||
Reference in New Issue
Block a user