From 88a8cff27f12081e6c042d4b8beaf6eecedcfc74 Mon Sep 17 00:00:00 2001 From: Olivier Van Goethem Date: Tue, 24 Dec 2013 14:44:42 +0000 Subject: [PATCH 01/17] Adding ability to rename Application Groups and Resource Groups in UI --- grails-app/conf/BootStrap.groovy | 4 ++++ grails-app/views/dashboard/appgroup.gsp | 6 ++++-- grails-app/views/dashboard/detail.gsp | 4 +++- grails-app/views/dashboard/editappgroup.gsp | 8 +++++--- grails-app/views/layouts/main.gsp | 8 ++++---- src/java/com/netflix/ice/common/IceOptions.java | 10 ++++++++++ src/java/com/netflix/ice/reader/ReaderConfig.java | 4 ++++ 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/grails-app/conf/BootStrap.groovy b/grails-app/conf/BootStrap.groovy index 44e978bf..79c9b59b 100644 --- a/grails-app/conf/BootStrap.groovy +++ b/grails-app/conf/BootStrap.groovy @@ -198,6 +198,10 @@ class BootStrap { properties.setProperty(IceOptions.CURRENCY_SIGN, prop.getProperty(IceOptions.CURRENCY_SIGN)); if (prop.getProperty(IceOptions.HIGHSTOCK_URL) != null) properties.setProperty(IceOptions.HIGHSTOCK_URL, prop.getProperty(IceOptions.HIGHSTOCK_URL)); + if (prop.getProperty(IceOptions.RESOURCE_GROUP) != null) + properties.setProperty(IceOptions.RESOURCE_GROUP, prop.getProperty(IceOptions.RESOURCE_GROUP)); + if (prop.getProperty(IceOptions.APPLICATION_GROUP) != null) + properties.setProperty(IceOptions.APPLICATION_GROUP, prop.getProperty(IceOptions.APPLICATION_GROUP)); ResourceService resourceService = StringUtils.isEmpty(properties.getProperty(IceOptions.CUSTOM_TAGS)) ? null : new BasicResourceService(); ApplicationGroupService applicationGroupService = new BasicS3ApplicationGroupService(); diff --git a/grails-app/views/dashboard/appgroup.gsp b/grails-app/views/dashboard/appgroup.gsp index 28efa154..76c23839 100644 --- a/grails-app/views/dashboard/appgroup.gsp +++ b/grails-app/views/dashboard/appgroup.gsp @@ -16,16 +16,18 @@ --%> +<%@ page import="com.netflix.ice.reader.ReaderConfig" %> + <%@ page contentType="text/html;charset=UTF-8" %> - Application Group {{appgroup.name}} + ${ReaderConfig.getInstance().applicationGroup} {{appgroup.name}}
-

Application Group {{appgroup.name}} +

${ReaderConfig.getInstance().applicationGroup} {{appgroup.name}} Edit Application Group

diff --git a/grails-app/views/dashboard/detail.gsp b/grails-app/views/dashboard/detail.gsp index ae02f45a..8f9b06b2 100644 --- a/grails-app/views/dashboard/detail.gsp +++ b/grails-app/views/dashboard/detail.gsp @@ -16,6 +16,8 @@ --%> +<%@ page import="com.netflix.ice.reader.ReaderConfig" %> + <%@ page contentType="text/html;charset=UTF-8" %> @@ -31,7 +33,7 @@ Account Region Product - ResourceGroup + ${ReaderConfig.getInstance().resourceGroup} Operation UsageType diff --git a/grails-app/views/dashboard/editappgroup.gsp b/grails-app/views/dashboard/editappgroup.gsp index 1ff03a8c..43f321ac 100644 --- a/grails-app/views/dashboard/editappgroup.gsp +++ b/grails-app/views/dashboard/editappgroup.gsp @@ -16,23 +16,25 @@ --%> +<%@ page import="com.netflix.ice.reader.ReaderConfig" %> + <%@ page contentType="text/html;charset=UTF-8" %> - Edit Application Group + Edit ${ReaderConfig.getInstance().applicationGroup}
{{message}}
-

CreateEdit Application Group {{appgroup.name}}

+

CreateEdit ${ReaderConfig.getInstance().applicationGroup} {{appgroup.name}}

- + diff --git a/grails-app/views/layouts/main.gsp b/grails-app/views/layouts/main.gsp index 7e1e094d..76a12dd7 100644 --- a/grails-app/views/layouts/main.gsp +++ b/grails-app/views/layouts/main.gsp @@ -47,7 +47,7 @@ @@ -62,9 +62,9 @@ diff --git a/src/java/com/netflix/ice/common/IceOptions.java b/src/java/com/netflix/ice/common/IceOptions.java index c7d9bca9..b70ca259 100644 --- a/src/java/com/netflix/ice/common/IceOptions.java +++ b/src/java/com/netflix/ice/common/IceOptions.java @@ -154,4 +154,14 @@ public class IceOptions { * from email to use when test flag is enabled. */ public static final String NUM_WEEKS_FOR_WEEKLYEMAILS = "ice.weeklyCostEmails_numWeeks"; + + /** + * Term to use instead of resource groups. + */ + public static final String RESOURCE_GROUP = "ice.resourceGroup"; + + /** + * Term to use instead of application groups. + */ + public static final String APPLICATION_GROUP = "ice.applicationGroup"; } diff --git a/src/java/com/netflix/ice/reader/ReaderConfig.java b/src/java/com/netflix/ice/reader/ReaderConfig.java index 4c08af76..64405973 100644 --- a/src/java/com/netflix/ice/reader/ReaderConfig.java +++ b/src/java/com/netflix/ice/reader/ReaderConfig.java @@ -42,6 +42,8 @@ public class ReaderConfig extends Config { public final String currencySign; public final double currencyRate; public final String highstockUrl; + public final String resourceGroup; + public final String applicationGroup; public final ApplicationGroupService applicationGroupService; public final ThroughputMetricService throughputMetricService; public final BasicWeeklyCostEmailService costEmailService; @@ -74,6 +76,8 @@ public ReaderConfig( currencySign = properties.getProperty(IceOptions.CURRENCY_SIGN, "$"); currencyRate = Double.parseDouble(properties.getProperty(IceOptions.CURRENCY_RATE, "1")); highstockUrl = properties.getProperty(IceOptions.HIGHSTOCK_URL, "http://code.highcharts.com/stock/highstock.js"); + resourceGroup = properties.getProperty(IceOptions.RESOURCE_GROUP, "Resource Group"); + applicationGroup = properties.getProperty(IceOptions.APPLICATION_GROUP, "Application Group"); this.managers = managers; this.applicationGroupService = applicationGroupService; From a8c0318da47fac0d7eb0d87c44af00189507b5f4 Mon Sep 17 00:00:00 2001 From: Olivier Van Goethem Date: Tue, 31 Dec 2013 11:07:56 +0000 Subject: [PATCH 02/17] Ability to rename resource groups and application groups in ice.js --- .../netflix/ice/DashboardController.groovy | 18 +++++++++++++++++- web-app/js/ice.js | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/grails-app/controllers/com/netflix/ice/DashboardController.groovy b/grails-app/controllers/com/netflix/ice/DashboardController.groovy index 39488d8b..51724e0f 100644 --- a/grails-app/controllers/com/netflix/ice/DashboardController.groovy +++ b/grails-app/controllers/com/netflix/ice/DashboardController.groovy @@ -391,7 +391,23 @@ class DashboardController { return [status: 200, start: 0, data: [:], stats: [:], groupBy: "None"]; } - TagType groupBy = query.getString("groupBy").equals("None") ? null : TagType.valueOf(query.getString("groupBy")); + TagType groupBy = null; + String groupByParam = query.getString("groupBy"); + switch(groupByParam) { + case getConfig().resourceGroup: + groupBy = TagType.valueOf("ResourceGroup"); + break; + case getConfig().applicationGroup: + groupBy = TagType.valueOf("ApplicationGroup"); + break; + case "None": + break; + default: + groupBy = TagType.valueOf(query.getString("groupBy")); + break; + } + + //TagType groupBy = query.getString("groupBy").equals("None") ? null : TagType.valueOf(query.getString("groupBy")); boolean isCost = query.getBoolean("isCost"); boolean breakdown = query.getBoolean("breakdown"); boolean showsps = query.getBoolean("showsps"); diff --git a/web-app/js/ice.js b/web-app/js/ice.js index f76e6011..95f705ec 100644 --- a/web-app/js/ice.js +++ b/web-app/js/ice.js @@ -278,6 +278,8 @@ ice.factory('highchart', function() { ice.factory('usage_db', function($window, $http, $filter) { var graphonly = false; + var resourcegroup = "Component"; + var applicationgroup = "Project"; var retrieveNamesIfNotAll = function(array, selected, preselected, filter) { if (!selected && !preselected) @@ -331,6 +333,15 @@ ice.factory('usage_db', function($window, $http, $filter) { graphOnly: function() { return graphonly; }, + + resourceGroup: function() { + return resourcegroup; + }, + + applicationGroup: function() { + return applicationgroup; + }, + addParams: function(params, name, array, selected, preselected, filter) { var selected = retrieveNamesIfNotAll(array, selected, preselected, filter); if (selected) @@ -462,7 +473,7 @@ ice.factory('usage_db', function($window, $http, $filter) { } if (!$scope.showResourceGroups) { for (var j in $scope.groupBys) { - if ($scope.groupBys[j].name === "ResourceGroup") { + if ($scope.groupBys[j].name === resourcegroup) { $scope.groupBys.splice(j, 1); break; } @@ -1012,7 +1023,7 @@ function detailCtrl($scope, $location, $http, usage_db, highchart) { {name: "Account"}, {name: "Region"}, {name: "Product"}, - {name: "ResourceGroup"}, + {name: usage_db.resourceGroup()}, {name: "Operation"}, {name: "UsageType"} ], @@ -1184,7 +1195,7 @@ function appgroupCtrl($scope, $location, $http, usage_db, highchart) { {name: "Account"}, {name: "Region"}, {name: "Product"}, - {name: "ResourceGroup"}, + {name: usage_db.resourceGroup()}, {name: "Operation"}, {name: "UsageType"} ], @@ -1336,7 +1347,7 @@ function breakdownCtrl($scope, $location, $http, usage_db, highchart) { $scope.showResourceGroups = true; $scope.usage_cost = "cost"; - $scope.groupBys = [{name: "ResourceGroup"}, {name: "ApplicationGroup"}]; + $scope.groupBys = [{name: usage_db.resourceGroup()}, {name: usage_db.applicationGroup()}]; $scope.groupBy = $scope.groupBys[0]; $scope.consolidate = "weekly"; $scope.end = new Date(); From 15473392c86ced89e15abd748f31da776102a3ca Mon Sep 17 00:00:00 2001 From: Olivier Van Goethem Date: Thu, 2 Jan 2014 10:02:02 +0000 Subject: [PATCH 03/17] Fix in the breakdown view to support parameterised Resource/Application groups --- grails-app/views/dashboard/breakdown.gsp | 12 +++++++----- grails-app/views/layouts/main.gsp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/grails-app/views/dashboard/breakdown.gsp b/grails-app/views/dashboard/breakdown.gsp index 6697dea3..dfbbc052 100644 --- a/grails-app/views/dashboard/breakdown.gsp +++ b/grails-app/views/dashboard/breakdown.gsp @@ -16,6 +16,8 @@ --%> +<%@ page import="com.netflix.ice.reader.ReaderConfig" %> + <%@ page contentType="text/html;charset=UTF-8" %> @@ -89,8 +91,8 @@
Group Name:Name:
- - + + @@ -100,14 +102,14 @@ - -
EditDeleteEditDelete {{groupBy.name}} {{dayFormat(period)}} {{getConsolidateName(data_consolidate)}}
+ Edit + Delete - {{row.name}} + {{row.name}} {{row.name}} diff --git a/grails-app/views/layouts/main.gsp b/grails-app/views/layouts/main.gsp index 76a12dd7..891861fb 100644 --- a/grails-app/views/layouts/main.gsp +++ b/grails-app/views/layouts/main.gsp @@ -60,9 +60,9 @@