mirror of
https://github.com/fleetbase/fleetbase.git
synced 2025-12-19 14:18:57 +00:00
Revert "refactor: Migrate FleetbaseConsole to new Universe architecture"
Some checks failed
Fleetbase CI / Build and Start Docker Services (push) Has been cancelled
Some checks failed
Fleetbase CI / Build and Start Docker Services (push) Has been cancelled
This reverts commit 4b12efef41.
This commit is contained in:
@@ -4,11 +4,11 @@ import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class DashboardWidgetPanelComponent extends Component {
|
||||
@service('universe/widget-service') widgetService;
|
||||
@service notifications;
|
||||
@service universe;
|
||||
@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.widgetService.getWidgets('dashboard');
|
||||
this.availableWidgets = this.universe.getDashboardWidgets();
|
||||
this.dashboard = dashboard;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
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
|
||||
};
|
||||
36
console/app/instance-initializers/initialize-widgets.js
Normal file
36
console/app/instance-initializers/initialize-widgets.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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,
|
||||
};
|
||||
11
console/app/instance-initializers/load-extensions.js
Normal file
11
console/app/instance-initializers/load-extensions.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export function initialize(application) {
|
||||
const universe = application.lookup('service:universe');
|
||||
if (universe) {
|
||||
universe.createRegistries(['@fleetbase/console', 'auth:login']);
|
||||
universe.bootEngines(application);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
initialize,
|
||||
};
|
||||
@@ -90,9 +90,9 @@ export default class DashboardModel extends Model {
|
||||
|
||||
getRegistry() {
|
||||
const owner = getOwner(this);
|
||||
const widgetService = owner.lookup('service:universe/widget-service');
|
||||
if (widgetService) {
|
||||
return widgetService.getRegistry(this.id);
|
||||
const universe = owner.lookup('service:universe');
|
||||
if (universe) {
|
||||
return universe.getDashboardRegistry(this.id);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@@ -15,8 +15,7 @@ export default class ApplicationRoute extends Route {
|
||||
@service intl;
|
||||
@service currentUser;
|
||||
@service router;
|
||||
@service('universe/hook-service') hookService;
|
||||
@service('universe/extension-manager') extensionManager;
|
||||
@service universe;
|
||||
@tracked defaultTheme;
|
||||
|
||||
/**
|
||||
@@ -25,7 +24,7 @@ export default class ApplicationRoute extends Route {
|
||||
* @memberof ApplicationRoute
|
||||
*/
|
||||
@action willTransition(transition) {
|
||||
this.hookService.execute('application:will-transition', this.session, this.router, transition);
|
||||
this.universe.callHooks('application:will-transition', this.session, this.router, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ export default class ApplicationRoute extends Route {
|
||||
* @memberof ApplicationRoute
|
||||
*/
|
||||
@action loading(transition) {
|
||||
this.hookService.execute('application:loading', this.session, this.router, transition);
|
||||
this.universe.callHooks('application:loading', this.session, this.router, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,9 +79,9 @@ export default class ApplicationRoute extends Route {
|
||||
*/
|
||||
async beforeModel(transition) {
|
||||
await this.session.setup();
|
||||
await this.extensionManager.waitForBoot();
|
||||
await this.universe.booting();
|
||||
|
||||
this.hookService.execute('application:before-model', this.session, this.router, transition);
|
||||
this.universe.callHooks('application:before-model', this.session, this.router, transition);
|
||||
|
||||
const shift = this.urlSearchParams.get('shift');
|
||||
if (this.session.isAuthenticated && shift) {
|
||||
|
||||
Reference in New Issue
Block a user