Skip to content

Commit

Permalink
fixing the api (the old inventory was still on various places through…
Browse files Browse the repository at this point in the history
…out the code base)
  • Loading branch information
jkremser committed Apr 13, 2015
1 parent 4a5fc1e commit bf1e6d2
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 46 deletions.
5 changes: 3 additions & 2 deletions dist/hawkular-ui-components-directives.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/hawkular-ui-components-inventory.js

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions dist/hawkular-ui-components-metrics.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugins/directives/plugins/topbar/html/topbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
</li>
<li class="context dropdown">
<a href="#" class="additional-info" dropdown-toggle ng-hide="resources.length === 0">
{{selectedResource.parameters.url}}
{{selectedResource.properties.url}}
<b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu">
<li ng-class="{'active': hkParams.resourceId === resource.id}" ng-repeat="resource in hkResources | orderBy:'parameters.url'">
<a href="" ng-click="setSelection(resource)">{{resource.parameters.url}}</a>
<li ng-class="{'active': hkParams.resourceId === resource.id}" ng-repeat="resource in hkResources | orderBy:'properties.url'">
<a href="" ng-click="setSelection(resource)">{{resource.properties.url}}</a>
</li>
<li class="divider"></li>
<li>
Expand Down
2 changes: 2 additions & 0 deletions plugins/directives/plugins/topbar/ts/topbarGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ module Topbar {

export var globalTenantId = "test";

export var globalEnvironmentId = "test";

}
8 changes: 4 additions & 4 deletions plugins/inventory/plugins/inventory/html/inventory.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3 class="panel-title"><i class="fa fa-user"></i> Tenant</h3>
<h3 class="panel-title"><i class="fa fa-cube"></i> Resource <span class="pull-right" ng-show="tenantId && resources"><a href="#" ng-click="showTable = !showTable"><span ng-hide="showTable">Show</span><span ng-show="showTable">Hide</span> all</a></span></h3>
</div>
<div class="panel-body">
<select class="form-control" ng-options="resource.id as resource.parameters.url + ' (' +resource.id + ')' for resource in resources" ng-model="resourceId" ng-disabled="!tenantId || !resources" ng-hide="resources.length === 0" ng-change="queryMetrics()"></select>
<select class="form-control" ng-options="resource.id as resource.properties.url + ' (' +resource.id + ')' for resource in resources" ng-model="resourceId" ng-disabled="!tenantId || !resources" ng-hide="resources.length === 0" ng-change="queryMetrics()"></select>
<span ng-show="resources.length === 0"><i class="fa fa-warning"></i> No Resources Available</span>
</div>
</div>
Expand Down Expand Up @@ -62,14 +62,14 @@ <h1>Resources</h1>
<thead>
<th>Resource ID</th>
<th>Resource Type</th>
<th>Parameters</th>
<th>Properties</th>
<th>Metrics</th>
</thead>
<tr ng-repeat="resource in resources">
<td>{{resource.id}}</td>
<td>{{resource.type}}</td>
<td>{{resource.resourceTypeId}}</td>
<td>
<dl class="dl-horizontal" ng-repeat="(name, value) in resource.parameters">
<dl class="dl-horizontal" ng-repeat="(name, value) in resource.properties">
<dt>{{name}}</dt>
<dd>{{value}}</dd>
</dl>
Expand Down
6 changes: 3 additions & 3 deletions plugins/inventory/plugins/inventory/ts/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ module Inventory {

export var InventoryController = _module.controller("Inventory.InventoryController", ['$scope', '$rootScope', 'HawkularInventory', 'HawkularMetric' ,($scope, $rootScope, hkInventory, hkMetric) => {
// hard coded for now
var envId = 'prod';
var envId = 'test';

$scope.queryResources = function() {
if(this.tenantId) {
this.resources = hkInventory.Resource.query({tenantId: this.tenantId, environmentId: envId, type: 'URL'}, function(data) {
this.resources = hkInventory.ResourceOfType.query({tenantId: this.tenantId, resourceTypeId: 'URL'}, function(data) {
angular.forEach(data, function(value) {
value.metrics = hkInventory.ResourceMetric.query({tenantId: $scope.tenantId, environmentId: envId, resourceId: value.id});
});
Expand All @@ -31,7 +31,7 @@ module Inventory {
};

$scope.queryMetrics = function() {
if(this.tenantId && this.resourceId) {
if(this.tenantId && this.resourceId && envId) {
this.metrics = hkInventory.ResourceMetric.query({tenantId: this.tenantId, environmentId: envId, resourceId: this.resourceId});
}
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/metrics/plugins/metrics/html/add-url.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ <h2 ng-show="vm.resourceList.length === 0">Collect metrics from a website that y
</div>
</div>

<div class="panel panel-default summary url-info" ng-repeat="res in vm.resourceList | orderBy:'parameters.url':vm.reverse">
<div class="panel panel-default summary url-info" ng-repeat="res in vm.resourceList | orderBy:'properties.url':vm.reverse">
<div class="row row-table">
<div class="col-md-4 summary-item">
<span class="url-link"><a href="/hawkular/{{res.id}}">{{res.parameters.url}}</a><i class="fa fa-flag" tooltip="Some alert happened" tooltip-trigger tooltip-placement="top" ng-show="(vm.alertList|filter:{triggerId: (res.id + '_trigger')}).length > 0"></i></span>
<span class="url-link"><a href="/hawkular/{{res.id}}">{{res.properties.url}}</a><i class="fa fa-flag" tooltip="Some alert happened" tooltip-trigger tooltip-placement="top" ng-show="(vm.alertList|filter:{triggerId: (res.id + '_trigger')}).length > 0"></i></span>
<button class="btn btn-link delete" tooltip="Remove" tooltip-trigger tooltip-placement="top" ng-click="vm.deleteResource(res)"><i class="fa fa-trash-o"></i></button>
<button class="btn btn-link trigger" ng-show="res.responseTime.length > 0" tooltip="Expand/collapse" tooltip-trigger tooltip-placement="top" ng-click="vm.resourceList.expanded[res.id] = !vm.resourceList.expanded[res.id]"><i class="fa" ng-class="vm.resourceList.expanded[res.id] ? 'fa-minus-square-o' : 'fa-plus-square-o'"></i>Last 24 hours</button>
</div>
Expand Down
40 changes: 27 additions & 13 deletions plugins/metrics/plugins/metrics/ts/addUrlPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ module HawkularMetrics {
addUrl(url:string):void {
this.addProgress = true;

var resourceId = this.md5.createHash(url || '');
var resource = {
resourceTypeId: 'URL',
id: this.md5.createHash(url || ''),
id: resourceId,
properties: {
url: url
}
Expand All @@ -88,28 +89,41 @@ module HawkularMetrics {
this.HawkularInventory.Resource.save({tenantId: globalTenantId, environmentId: globalEnvironmentId}, resource).$promise
.then((newResource) => {
this.getResourceList();
// we now have a resourceId from this call
metricId = newResource.id;
metricId = resourceId;
console.dir(newResource);
this.$log.info('New Resource ID: ' + metricId + ' created.');

var metricsIds: string[] = [metricId + '.status.duration', metricId + '.status.code'];
var metrics = [{
name: metricId + '.status.duration',
unit: 'MILLI_SECOND',
description: 'Response Time in ms.'
name: metricsIds[0],
metricTypeId: 'status.duration.type',
properties: {
description: 'Response Time in ms.'
}
}, {
name: metricId + '.status.code',
unit: 'NONE',
description: 'Status Code'
name: metricsIds[1],
metricTypeId: 'status.code.type',
properties: {
description: 'Status Code'
}
}];


/// For right now we will just Register a couple of metrics automatically
return this.HawkularInventory.Metric.save({
tenantId: globalTenantId,
resourceId: newResource.id
}, metrics).$promise.then((newMetrics) => {
environmentId: globalEnvironmentId,
resourceId: resourceId
}, metrics[0]).$promise.then(this.HawkularInventory.Metric.save({
tenantId: globalTenantId,
environmentId: globalEnvironmentId,
resourceId: resourceId
}, metrics[1])).$promise.then(this.HawkularInventory.ResourceMetric.save({
tenantId: globalTenantId,
environmentId: globalEnvironmentId,
resourceId: resourceId
}, metricsIds)).$promise.then((newMetrics) => {
// TODO: Add availability...
});
});
}).then(()=> {
// Find if a default email exists
return this.HawkularAlertsManager.addEmailAction(defaultEmail);
Expand Down
2 changes: 1 addition & 1 deletion plugins/metrics/plugins/metrics/ts/metricsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module HawkularMetrics {
when('/metrics/response-time', {templateUrl: 'plugins/metrics/html/response-time.html',
resolve: {
hkResourceList : function($filter, $location, $q, HawkularInventory) {
var resPromise = HawkularInventory.Resource.query({tenantId: globalTenantId}).$promise;
var resPromise = HawkularInventory.Resource.query({tenantId: globalTenantId, environmentId: globalEnvironmentId}).$promise;
resPromise.then(function(hkResourceList){
$location.path('/metrics/response-time/' + hkResourceList[0].id);
}, function(){
Expand Down

0 comments on commit bf1e6d2

Please sign in to comment.