-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to specify alternate infra dashboard for OpenStack provider #423
Comments
@martinpovolny @himdel I think you guys expressed an opinion on this subject, so please feel free to comment! |
We can use the class decorators on a Ems subclass to return the correct dashboard service. Then you can reuse the existing controller. See: #237 (will get hopefully merged asap) |
The JS (angular) controlers are cut-n-pasted at this point and we need to stop doing that. @himdel: can you provide some guidance on how to reuse the angular controller code, please? |
Well, Seems like we could use a .DashboardService (as in, an angular service), with all the common functions there... right now, if we undo the infra/container and node/cluster naming differences, the difference between the two is just this... --- app/assets/javascripts/controllers/ems_infra_dashboard/ems_infra_dashboard_controller.js 2017-02-24 21:57:09.310581328 +0000
+++ app/assets/javascripts/controllers/container_dashboard/container_dashboard_controller.js 2017-02-24 21:57:10.530563058 +0000
@@ -6,12 +6,15 @@
// Obj-status cards init
$scope.objectStatus = {
- providers: dashboardUtilsFactory.createProvidersIcon(),
- ems_clusters: dashboardUtilsFactory.createClustersStatus(),
- hosts: dashboardUtilsFactory.createHostsStatus(),
- datastores: dashboardUtilsFactory.createDatastoresStatus(),
- vms: dashboardUtilsFactory.createVmsStatus(),
- miq_templates: dashboardUtilsFactory.createMiqTemplatesStatus(),
+ providers: dashboardUtilsFactory.createProvidersStatus(),
+ nodes: dashboardUtilsFactory.createNodesStatus(),
+ containers: dashboardUtilsFactory.createContainersStatus(),
+ registries: dashboardUtilsFactory.createRegistriesStatus(),
+ projects: dashboardUtilsFactory.createProjectsStatus(),
+ pods: dashboardUtilsFactory.createPodsStatus(),
+ services: dashboardUtilsFactory.createServicesStatus(),
+ images: dashboardUtilsFactory.createImagesStatus(),
+ routes: dashboardUtilsFactory.createRoutesStatus()
};
$scope.loadingDone = false;
@@ -63,7 +66,7 @@
$scope.id = '/' + (/^\/[^\/]+\/(\d+)$/.exec(pathname)[1]);
}
- var url = '/ems_infra_dashboard/data' + $scope.id;
+ var url = '/container_dashboard/data' + $scope.id;
$http.get(url)
.then(getDashboardData)
.catch(miqService.handleFailure);
@@ -104,11 +107,14 @@
}
}
- dashboardUtilsFactory.updateStatus($scope.objectStatus.ems_clusters, data.status.ems_clusters);
- dashboardUtilsFactory.updateStatus($scope.objectStatus.hosts, data.status.hosts);
- dashboardUtilsFactory.updateStatus($scope.objectStatus.datastores, data.status.datastores);
- dashboardUtilsFactory.updateStatus($scope.objectStatus.vms, data.status.vms);
- dashboardUtilsFactory.updateStatus($scope.objectStatus.miq_templates, data.status.miq_templates);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.nodes, data.status.nodes);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.containers, data.status.containers);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.registries, data.status.registries);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.projects, data.status.projects);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.pods, data.status.pods);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.services, data.status.services);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.images, data.status.images);
+ dashboardUtilsFactory.updateStatus($scope.objectStatus.routes, data.status.routes);
// Node utilization donut
$scope.cpuUsageData = chartsMixin.processUtilizationData(data.ems_utilization.cpu, Also, it looks like we pretty much just iterate over all (or some of?) the entities and do the same block all over again... // Recent Hosts
$scope.recentHostsConfig = chartsMixin.chartConfig.recentHostsConfig;
// recent Hosts chart
$scope.recentHostsData = chartsMixin.processRecentHostsData(data.recentHosts,
'dates',
$scope.recentHostsConfig.label); is repeated for multiple entities .. so this could be something like... ['recentHosts', 'others'].forEach(function(entity) {
vm.config[entity] = chartsMixin.chartConfig[entity];
vm.data[entity] = chartsMixin.process[entity](data[entity], 'dates', vm.config[entity].label);
}); so the controllers could almost share all of the methods except for a lists of entities, and the right url. |
..and looks like the exact same method could be applied to the files living under |
About the exact mechanism of code sharing, I think at this point, just moving the methods to a common service and passing in the relevant configs seems like the most straightforward way. (It's always possible to |
This issue has been automatically marked as stale because it has not been updated for at least 6 months. If you can still reproduce this issue on the current release or on Thank you for all your contributions! |
@tzumainn is this still a valid issue? If yes, lease remove the stale label. If not can you close. |
Closing issue. If you feel the issue needs to remain open, please either reopen or let me know and it will be reopened. |
The OpenStack infrastructure provider needs an alternate dashboard. I've played around with the code a bit, and I think I need to do the following:
Then app/controllers/ems_infra_controller.rb needs to know to use the correct service depending on the ems, and app/views/ems_infra/show_dashboard.html.haml needs to know which view to render.
So here are some initial questions:
The text was updated successfully, but these errors were encountered: