Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Refactor Sidebar to Subtab to better reflect its purpose.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtho11 committed Sep 29, 2015
1 parent be6aabb commit 09e76a3
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 126 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- <div class="col-sm-3 col-md-2 sidebar-pf sidebar-pf-left sidebar-pf-dark sidebar-pf-big-icons sidebar-pf-fixed">
<!-- <div class="col-sm-3 col-md-2 subtab-pf subtab-pf-left subtab-pf-dark subtab-pf-big-icons subtab-pf-fixed">
<nav>
<ul class="nav nav-pills nav-stacked nav-dark nav-big-icons" ng-hide="isSinglePage()">
<li ng-class="getClass('/metrics/availability')"><a ng-href="/metrics/availability/{{hkParams.resourceId}}/{{hkParams.timeOffset}}/{{hkEndTimestamp}}"><i class="fa fa-arrow-up"></i>Availability</a></li>
Expand Down
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;
};

}]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
///

/// <reference path='../../includes.ts'/>
module Sidebar {
module Subtab {

export var pluginName = 'sidebar';
export var pluginName = 'subdtab';

export var log:Logging.Logger = Logger.get(pluginName);

export var templatePath = 'plugins/directives/sidebar/html/sidebar.html';
export var templatePath = 'plugins/directives/subtab/html/subtab.html';

export var globalEnvironmentId = 'test';
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
///

/// <reference path="../../includes.ts"/>
/// <reference path="sidebarGlobals.ts"/>
/// <reference path="sidebarDirective.ts"/>
module Sidebar {
/// <reference path="subtabGlobals.ts"/>
/// <reference path="subtabDirective.ts"/>
module Subtab {

export var _module = angular.module(pluginName, ['duScroll']);

_module.directive('hawkularSidebar', function () {
return new Sidebar.SidebarDirective();
_module.directive('hawkularSubtab', function () {
return new Subtab.SubtabDirective();
});

hawtioPluginLoader.addModule(pluginName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="hk-screen-content" ng-controller="AppServerDetailsController as tabs">

<hawkular-sidebar ng-controller="Sidebar.SidebarController">
<hawkular-subtab ng-controller="Subtab.SubtabController">
<div class="hk-nav-tabs-container">
<ul class="nav nav-tabs nav-tabs-pf" ng-init="tabs.activeTab = tabs.activeTab || 'jvm'">
<li ng-repeat="tab in tabs.availableTabs" ng-class="tabs.activeTab === tab.id ? 'active' : ''" ng-show="tab.enabled">
Expand All @@ -9,7 +9,7 @@
</ul>
</div>

</hawkular-sidebar>
</hawkular-subtab>

<div ng-repeat="tab in tabs.availableTabs">{{tab.controller}}</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="hk-screen-content" ng-controller="MetricsAlertController as mac">
<hawkular-sidebar ng-controller="Sidebar.SidebarController">
<hawkular-sidebar ng-controller="Subtab.SubtabController">
<div class="hk-nav-tabs-container">
<ul class="nav nav-tabs nav-tabs-pf">
<li class="active"><a href="/hawkular-ui/url/alerts/{{mac.$routeParams.resourceId}}/{{mac.$routeParams.timeOffset}}" class="hk-alerts">All Alerts</a></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="hk-screen-content" ng-controller="MetricsAvailabilityController as vm">
<hawkular-sidebar ng-controller="Sidebar.SidebarController">
<hawkular-sidebar ng-controller="Subtab.SubtabController">
<div class="hk-nav-tabs-container">
<ul class="nav nav-tabs nav-tabs-pf">
<li><a href="/hawkular-ui/url/alerts/{{vm.$routeParams.resourceId}}/{{vm.$routeParams.timeOffset}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="hk-screen-content" ng-controller="MetricsViewController as vm">

<hawkular-sidebar ng-controller="Sidebar.SidebarController">
<hawkular-sidebar ng-controller="Subtab.SubtabController">
<div class="hk-nav-tabs-container">
<ul class="nav nav-tabs nav-tabs-pf">
<li><a href="/hawkular-ui/url/alerts/{{vm.$routeParams.resourceId}}/{{vm.$routeParams.timeOffset}}" class="hk-alerts">All Alerts</a></li>
Expand Down

0 comments on commit 09e76a3

Please sign in to comment.