From 5a1662500f12136268e21abe7ff0c9c7cecfcac8 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 15 Sep 2015 14:35:07 +0530 Subject: [PATCH] metrics: add view metrics button across resources resouces: zones, clusters, hosts, primary storage, vms and volumes Signed-off-by: Rohit Yadav --- ui/css/cloudstack3.css | 8 ++++++ ui/scripts/instances.js | 15 ++++++++++- ui/scripts/storage.js | 14 ++++++++++ ui/scripts/system.js | 42 +++++++++++++++++++++++++++-- ui/scripts/ui-custom/metricsView.js | 38 ++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 ui/scripts/ui-custom/metricsView.js diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 06abbb8b15e..daa6398af4c 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -12420,6 +12420,14 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: 0px -707px; } +.viewMetrics .icon { + background-position: -40px -32px; +} + +.viewMetrics:hover .icon { + background-position: -40px -32px; +} + .attach .icon, .attachISO .icon, .attachDisk .icon, diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index b8d1299f74d..c19e7d46241 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -288,7 +288,20 @@ poll: pollAsyncJobResult } }, - snapshot: vmSnapshotAction({ listView: true }) + snapshot: vmSnapshotAction({ listView: true }), + viewMetrics: { + label: 'label.view.metrics', + isHeader: true, + addRow: false, + action: { + custom: cloudStack.uiCustom.metricsView({resource: 'vms'}) + }, + messages: { + notification: function (args) { + return 'label.view.metrics'; + } + } + }, }, dataProvider: function(args) { diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index d56835cd7e0..b4242b93da8 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -253,6 +253,20 @@ } }, + viewMetrics: { + label: 'label.view.metrics', + isHeader: true, + addRow: false, + action: { + custom: cloudStack.uiCustom.metricsView({resource: 'volumes'}) + }, + messages: { + notification: function (args) { + return 'label.view.metrics'; + } + } + }, + uploadVolume: { isHeader: true, label: 'label.upload.volume', diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 6363e3a7864..32331e9acb9 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -7711,8 +7711,7 @@ isHeader: true, addRow: false, action: { - custom: cloudStack.uiCustom.zoneWizard( - cloudStack.zoneWizard) + custom: cloudStack.uiCustom.metricsView({resource: 'zones'}) }, messages: { notification: function (args) { @@ -14385,6 +14384,19 @@ } }); } + }, + viewMetrics: { + label: 'label.view.metrics', + isHeader: true, + addRow: false, + action: { + custom: cloudStack.uiCustom.metricsView({resource: 'clusters'}) + }, + messages: { + notification: function (args) { + return 'label.view.metrics'; + } + } } }, @@ -15622,6 +15634,19 @@ return 'label.add.host'; } } + }, + viewMetrics: { + label: 'label.view.metrics', + isHeader: true, + addRow: false, + action: { + custom: cloudStack.uiCustom.metricsView({resource: 'hosts'}) + }, + messages: { + notification: function (args) { + return 'label.view.metrics'; + } + } } }, detailView: { @@ -17428,6 +17453,19 @@ return 'label.add.primary.storage'; } } + }, + viewMetrics: { + label: 'label.view.metrics', + isHeader: true, + addRow: false, + action: { + custom: cloudStack.uiCustom.metricsView({resource: 'primarystorage'}) + }, + messages: { + notification: function (args) { + return 'label.view.metrics'; + } + } } }, diff --git a/ui/scripts/ui-custom/metricsView.js b/ui/scripts/ui-custom/metricsView.js new file mode 100644 index 00000000000..40eeefd50f5 --- /dev/null +++ b/ui/scripts/ui-custom/metricsView.js @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +(function($, cloudStack) { + + cloudStack.uiCustom.metricsView = function(args) { + return function() { + // TODO: implement switch/case to select metrics view: zone, cluster, host etc. + var metricsListView = cloudStack.sections.metrics.listView; + + var $browser = $('#browser .container'); + return $browser.cloudBrowser('addPanel', { + title: 'Metrics', + maximizeIfSelected: true, + complete: function($newPanel) { + $newPanel.listView({ + $browser: $browser, + context: cloudStack.context, + listView: metricsListView + }); + } + }); + }; + }; +})(jQuery, cloudStack);