This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Sidebar to Subtab to better reflect its purpose.
- Loading branch information
Showing
10 changed files
with
114 additions
and
126 deletions.
There are no files selected for viewing
112 changes: 0 additions & 112 deletions
112
console/src/main/scripts/plugins/directives/sidebar/ts/sidebarDirective.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...gins/directives/sidebar/html/sidebar.html → ...lugins/directives/subtab/html/subtab.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
100 changes: 100 additions & 0 deletions
100
console/src/main/scripts/plugins/directives/subtab/ts/subtabDirective.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/// | ||
/// Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed 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. | ||
/// | ||
|
||
/// <reference path='subtabPlugin.ts'/> | ||
module Subtab { | ||
|
||
export class SubtabDirective { | ||
|
||
public restrict = 'E'; | ||
public transclude = true; | ||
public replace = false; | ||
|
||
public templateUrl = templatePath; | ||
} | ||
|
||
export var SubtabController = _module.controller('Subtab.SubtabController', | ||
['$scope', '$rootScope', '$location', 'HawkularNav', 'HawkularInventory', ($scope, $rootScope, $location, | ||
HawkularNav, HawkularInventory) => { | ||
|
||
$scope.isSinglePage = function () { | ||
return $location.path().indexOf('/metrics') !== 0; | ||
}; | ||
|
||
$scope.isAlertsPage = function () { | ||
return $location.path().indexOf('/hawkular/ui/alert-center') !== 0; | ||
}; | ||
|
||
$scope.isAppServerPage = function () { | ||
return $location.path().indexOf('/hawkular-ui/app/') === 0; | ||
}; | ||
|
||
$scope.getClass = function (path) { | ||
return $location.path().indexOf(path) === 0 ? 'active' : ''; | ||
}; | ||
|
||
$scope.rangeNames = { | ||
'3600000': 'Last Hour', | ||
'43200000': 'Last 12 Hours', | ||
'86400000': 'Last Day', | ||
'604800000': 'Last Week', | ||
'2592000000': 'Last Month', | ||
'31536000000': 'Last Year' | ||
}; | ||
|
||
$scope.getFormattedDate = function () { | ||
var diff = $scope.hkParams.timeOffset; | ||
|
||
// FIXME: Use moment ? | ||
$scope.offsetName = $scope.rangeNames[$scope.hkParams.timeOffset] || 'Custom'; | ||
|
||
// TODO: Use this for custom | ||
// var momStart = moment($scope.hkStartTimestamp); | ||
// var momEnd = moment($scope.hkEndTimestamp); | ||
|
||
var momStart = moment().subtract($scope.hkParams.timeOffset, 'milliseconds'); | ||
var momEnd = moment(); | ||
|
||
if (diff < 24 * 60 * 60 * 1000) { | ||
return momStart.format('D MMM YYYY') + ' ' + momStart.format('HH:mm') + ' - ' + | ||
(momStart.day() !== momEnd.day() ? momEnd.format('D MMM YYYY ') : '') + momEnd.format('HH:mm'); | ||
} else { | ||
return momStart.format('D MMM YYYY') + ' - ' + momEnd.format('D MMM YYYY'); | ||
} | ||
}; | ||
|
||
$scope.setRange = function (range) { | ||
HawkularNav.setTimestamp(moment.duration(range).valueOf()); | ||
}; | ||
|
||
$scope.getUrlFromId = function (id) { | ||
if (!$scope.resource) { | ||
$scope.resource = HawkularInventory.Resource.get({environmentId: globalEnvironmentId, resourcePath: id}, | ||
function (data) { | ||
$scope.resourceName = data.properties.url; | ||
}); | ||
} | ||
return $scope.resource; | ||
}; | ||
|
||
// FIXME: Mock data.. remove when we have real app servers | ||
$scope.getAppServerFromId = function (id) { | ||
$scope.resourceName = id; | ||
}; | ||
|
||
}]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
console/src/main/scripts/plugins/metrics/html/url-availability.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
console/src/main/scripts/plugins/metrics/html/url-response-time.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters