Skip to content

Modular logistics and supply chain operating system (LSOS)

Refactor widget configurations in initialize widgets

Turtuvshin13db00c39f61
diff --git a/console/app/instance-initializers/initialize-widgets.js b/console/app/instance-initializers/initialize-widgets.js
index 7dba3e9d..10e0c13a 100644
--- a/console/app/instance-initializers/initialize-widgets.js
+++ b/console/app/instance-initializers/initialize-widgets.js
@@ -1,50 +1,50 @@
export function initialize(application) {
const universe = application.lookup('service:universe');
- const fleetOpsWidgets = [
- {
- name: 'Open Issues',
- component: 'dashboard/count',
- grid_options: { w: 2, h: 2 },
- options: {
- title: 'Open Issues',
- value: 0,
- },
- },
+ const fleetOpsWidgetConfigs = [
+ { name: 'Earnings', format: 'money', currency: 'USD' },
+ { name: 'Fuel costs', format: 'money', currency: 'USD' },
+ { name: 'Total distance traveled', format: 'meters' },
+ { name: 'Orders canceled' },
+ { name: 'Orders completed' },
+ { name: 'Orders in progress' },
+ { name: 'Orders scheduled' },
+ { name: 'Drivers online' },
+ { name: 'Total drivers' },
+ { name: 'Open Issues' },
+ { name: 'Total customers' },
+ { name: 'Open Issues' },
+ { name: 'Resolved Issues' },
];
- const storefrontWidgets = [
- {
- name: 'Total Products',
- component: 'dashboard/count',
- grid_options: { w: 2, h: 2 },
- options: {
- title: 'Total Products',
- value: 0,
- },
- },
+ const storefrontWidgetConfigs = [
+ { name: 'Total Products' },
+ { name: 'Total Stores' },
+ { name: 'Total Networks' },
+ { name: 'Ordser in progress' },
+ { name: 'Orders completed' },
+ { name: 'Orders canceled' },
];
- const iamWidgets = [
- {
- name: 'User count',
- component: 'dashboard/count',
- grid_options: { w: 2, h: 2 },
- options: {
- title: 'User count',
- value: 0,
- },
- },
- {
- name: 'Group count',
- component: 'dashboard/count',
- grid_options: { w: 2, h: 2 },
- options: {
- title: 'Group count',
- value: 0,
- },
+ const iamWidgetConfigs = [{ name: 'User count' }, { name: 'Group count' }, { name: 'Policy count' }, { name: 'Role count' }];
+
+ const createWidgets = (configs) => configs.map(({ name, format, currency }) => createWidget(name, format, currency));
+
+ const createWidget = (name, format, currency) => ({
+ name,
+ component: 'dashboard/count',
+ grid_options: { w: 2, h: 2 },
+ options: {
+ title: name,
+ value: 0,
+ ...(format && { format }),
+ ...(currency && { currency }),
},
- ];
+ });
+
+ const fleetOpsWidgets = createWidgets(fleetOpsWidgetConfigs);
+ const storefrontWidgets = createWidgets(storefrontWidgetConfigs);
+ const iamWidgets = createWidgets(iamWidgetConfigs);
const availableWidgets = [
{