Skip to content

Modular logistics and supply chain operating system (LSOS)

refactor: Migrate FleetbaseConsole to new Universe architecture

roncodes4b12efef4197
diff --git a/console/app/components/dashboard/widget-panel.js b/console/app/components/dashboard/widget-panel.js
index 32afd371..74942388 100644
--- a/console/app/components/dashboard/widget-panel.js
+++ b/console/app/components/dashboard/widget-panel.js
@@ -4,11 +4,11 @@ import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class DashboardWidgetPanelComponent extends Component {
- @service universe;
+ @service('universe/widget-service') widgetService;
+ @service notifications;
@tracked availableWidgets = [];
@tracked dashboard;
@tracked isOpen = true;
- @service notifications;
/**
* Constructs the component and applies initial state.
@@ -16,7 +16,7 @@ export default class DashboardWidgetPanelComponent extends Component {
constructor(owner, { dashboard }) {
super(...arguments);
- this.availableWidgets = this.universe.getDashboardWidgets();
+ this.availableWidgets = this.widgetService.getWidgets('dashboard');
this.dashboard = dashboard;
}
diff --git a/console/app/instance-initializers/initialize-universe.js b/console/app/instance-initializers/initialize-universe.js
new file mode 100644
index 00000000..a3233fe4
--- /dev/null
+++ b/console/app/instance-initializers/initialize-universe.js
@@ -0,0 +1,81 @@
+import { getOwner } from '@ember/application';
+import { scheduleOnce } from '@ember/runloop';
+import { Widget } from '@fleetbase/ember-core/contracts';
+
+/**
+ * Initializes the Universe by:
+ * 1. Creating console-specific registries
+ * 2. Registering default dashboard widgets
+ * 3. Loading extension.js files from enabled extensions
+ * 4. Executing boot callbacks
+ *
+ * This replaces the old load-extensions and initialize-widgets initializers.
+ *
+ * @param {ApplicationInstance} appInstance The application instance
+ */
+export function initialize(appInstance) {
+ const universe = appInstance.lookup('service:universe');
+ const widgetService = appInstance.lookup('service:universe/widget-service');
+ const registryService = appInstance.lookup('service:universe/registry-service');
+ const owner = getOwner(appInstance);
+ const app = owner.application;
+
+ // Set application instance on universe
+ universe.applicationInstance = appInstance;
+
+ // Create console-specific registries
+ registryService.createRegistries(['@fleetbase/console', 'auth:login']);
+
+ // Register default dashboard widgets
+ const defaultWidgets = [
+ new Widget({
+ widgetId: 'welcome',
+ name: 'Welcome',
+ description: 'Welcome widget for new users',
+ icon: 'hand-wave',
+ component: 'widget/welcome',
+ grid_options: { w: 12, h: 6, minW: 8, minH: 6 }
+ }),
+ new Widget({
+ widgetId: 'getting-started',
+ name: 'Getting Started',
+ description: 'Getting started guide',
+ icon: 'rocket',
+ component: 'widget/getting-started',
+ grid_options: { w: 12, h: 12, minW: 8, minH: 12 }
+ })
+ ];
+
+ widgetService.registerDefaultWidgets(defaultWidgets);
+ widgetService.registerWidgets('dashboard', defaultWidgets);
+
+ // Load extension.js files from enabled extensions
+ // The app.extensions array already respects config + user permissions
+ const extensions = app.extensions || [];
+
+ extensions.forEach(extensionName => {
+ try {
+ // Dynamically require the extension.js file
+ // This is a small file with only metadata, not the full engine bundle
+ const setupExtension = require(`${extensionName}/extension`).default;
+
+ if (typeof setupExtension === 'function') {
+ // Execute the extension setup function
+ // This registers menus, widgets, hooks, etc. as metadata
+ setupExtension(appInstance, universe);
+ }
+ } catch (error) {
+ // Silently fail if extension.js doesn't exist
+ // Extensions can migrate gradually to the new pattern
+ // console.warn(`Could not load extension.js for ${extensionName}:`, error);
+ }
+ });
+
+ // Execute any boot callbacks
+ scheduleOnce('afterRender', universe, 'executeBootCallbacks');
+}
+
+export default {
+ name: 'initialize-universe',
+ initialize
+};
diff --git a/console/app/instance-initializers/initialize-widgets.js b/console/app/instance-initializers/initialize-widgets.js
deleted file mode 100644
index 3189e74d..00000000
--- a/console/app/instance-initializers/initialize-widgets.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import { faGithub } from '@fortawesome/free-brands-svg-icons';
-
-export function initialize(application) {
- const universe = application.lookup('service:universe');
- const defaultWidgets = [
- {
- widgetId: 'fleetbase-blog',
- name: 'Fleetbase Blog',
- description: 'Lists latest news and events from the Fleetbase official team.',
- icon: 'newspaper',
- component: 'fleetbase-blog',
- grid_options: { w: 8, h: 9, minW: 8, minH: 9 },
- options: {
- title: 'Fleetbase Blog',
- },
- },
- {
- widgetId: 'fleetbase-github-card',
- name: 'Github Card',
- description: 'Displays current Github stats from the official Fleetbase repo.',
- icon: faGithub,
- component: 'github-card',
- grid_options: { w: 4, h: 8, minW: 4, minH: 8 },
- options: {
- title: 'Github Card',
- },
- },
- ];
-
- universe.registerDefaultDashboardWidgets(defaultWidgets);
- universe.registerDashboardWidgets(defaultWidgets);
-}
-
-export default {
- initialize,
-};
diff --git a/console/app/instance-initializers/load-extensions.js b/console/app/instance-initializers/load-extensions.js
deleted file mode 100644
index b262162e..00000000
--- a/console/app/instance-initializers/load-extensions.js
+++ /dev/null
@@ -1,11 +0,0 @@
-export function initialize(application) {
- const universe = application.lookup('service:universe');
- if (universe) {
- universe.createRegistries(['@fleetbase/console', 'auth:login']);
- universe.bootEngines(application);
- }
-}
-
-export default {
- initialize,
-};
diff --git a/console/app/models/dashboard.js b/console/app/models/dashboard.js
index fb1d4342..e526e1ce 100644
--- a/console/app/models/dashboard.js
+++ b/console/app/models/dashboard.js
@@ -90,9 +90,9 @@ export default class DashboardModel extends Model {
getRegistry() {
const owner = getOwner(this);
- const universe = owner.lookup('service:universe');
- if (universe) {
- return universe.getDashboardRegistry(this.id);
+ const widgetService = owner.lookup('service:universe/widget-service');
+ if (widgetService) {
+ return widgetService.getRegistry(this.id);
}
return undefined;
diff --git a/console/app/routes/application.js b/console/app/routes/application.js
index 740f4893..ed798aa4 100644
--- a/console/app/routes/application.js
+++ b/console/app/routes/application.js
@@ -15,7 +15,8 @@ export default class ApplicationRoute extends Route {
@service intl;
@service currentUser;
@service router;
- @service universe;
+ @service('universe/hook-service') hookService;
+ @service('universe/extension-manager') extensionManager;
@tracked defaultTheme;
/**
@@ -24,7 +25,7 @@ export default class ApplicationRoute extends Route {
* @memberof ApplicationRoute
*/
@action willTransition(transition) {
- this.universe.callHooks('application:will-transition', this.session, this.router, transition);
+ this.hookService.execute('application:will-transition', this.session, this.router, transition);
}
/**
@@ -45,7 +46,7 @@ export default class ApplicationRoute extends Route {
* @memberof ApplicationRoute
*/
@action loading(transition) {
- this.universe.callHooks('application:loading', this.session, this.router, transition);
+ this.hookService.execute('application:loading', this.session, this.router, transition);
}
/**
@@ -79,9 +80,9 @@ export default class ApplicationRoute extends Route {
*/
async beforeModel(transition) {
await this.session.setup();
- await this.universe.booting();
+ await this.extensionManager.waitForBoot();
- this.universe.callHooks('application:before-model', this.session, this.router, transition);
+ this.hookService.execute('application:before-model', this.session, this.router, transition);
const shift = this.urlSearchParams.get('shift');
if (this.session.isAuthenticated && shift) {