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.
Merge pull request #401 from vrockai/AlertRedo
Console: Alerts refactoring
- Loading branch information
Showing
23 changed files
with
1,087 additions
and
778 deletions.
There are no files selected for viewing
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
25 changes: 12 additions & 13 deletions
25
console/src/main/scripts/plugins/directives/alert/html/fieldset-dampening.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
<fieldset> | ||
<legend>Alert</legend> | ||
<hk-switch ng-show="hkSwitchEnabled" | ||
hk-model="hkSwitch" | ||
id="usage-less-switch" class="pull-right-switch"></hk-switch> | ||
<legend>{{hkTitle || 'Alert'}}</legend> | ||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">Create Alert</label> | ||
<div class="col-sm-9"> | ||
<div class="radio"> | ||
<label for="every-time-heap"> | ||
<input type="radio" name="alert-heap" id="every-time-heap" ng-value="false" ng-model="durationEnabled" | ||
ng-click="durationToggle()" checked=""> | ||
Every time conditions are met. | ||
ng-click="durationToggle()" checked="" ng-disabled="hkDisabled || (hkSwitchEnabled && !hkSwitch)"> | ||
{{hkTitleMet || 'Every time conditions are met.'}} | ||
</label> | ||
</div> | ||
<div class="radio"> | ||
<label for="greater-time-heap"> | ||
<input type="radio" name="alert-heap" id="greater-time-heap" ng-value="true" ng-model="durationEnabled" | ||
ng-click="durationToggle()"> | ||
Only when conditions are met for greater than: | ||
ng-click="durationToggle()" ng-disabled="hkDisabled || (hkSwitchEnabled && !hkSwitch)"> | ||
{{hkTitleUnmet || 'Only when conditions are met for greater than:'}} | ||
</label> | ||
</div> | ||
<div class="input-group input-select indented"> | ||
<input type="number" class="form-control" placeholder="Duration" ng-model="hkConvertedDuration" | ||
ng-disabled="!durationEnabled" ng-change="durationChange()"> | ||
<select pf-select ng-model="responseUnit" id="responseUnit" | ||
ng-disabled="!durationEnabled" | ||
ng-options="item.value as item.label for item in timeUnits" | ||
ng-change="computeTimeInUnits()"></select> | ||
</div> | ||
<hk-time-input hk-duration="hkDuration" | ||
hk-disabled="hkDisabled || !durationEnabled || (hkSwitchEnabled && !hkSwitch)" | ||
hk-change="durationChange()" | ||
id="dw-duration"></hk-time-input> | ||
</div> | ||
</div> | ||
</fieldset> |
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
16 changes: 16 additions & 0 deletions
16
console/src/main/scripts/plugins/directives/components/html/hk-switch.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="onoffswitch" tabindex='0'> | ||
<input type="checkbox" | ||
class="onoffswitch-checkbox" | ||
ng-model="hkModel" | ||
ng-disabled="hkDisabled" | ||
ng-click="hkClick()" | ||
ng-change="hkChange()" | ||
id="{{id}}"> | ||
<label class="onoffswitch-label" for="{{id}}"> | ||
<span class="onoffswitch-inner"> | ||
<span class="onoffswitch-active ng-binding">{{hkOnText}}</span> | ||
<span class="onoffswitch-inactive ng-binding">{{hkOffText}}</span> | ||
</span> | ||
<span class="onoffswitch-switch"></span> | ||
</label> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
console/src/main/scripts/plugins/directives/components/html/time-input.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="input-group input-select indented"> | ||
<input type="number" class="form-control" placeholder="Duration" ng-model="hkConvertedDuration" | ||
ng-disabled="hkDisabled" ng-change="durationChange()" id="{{id}}"> | ||
<select pf-select ng-model="responseUnit" id="responseUnit" | ||
ng-disabled="hkDisabled" | ||
ng-options="item.value as item.label for item in timeUnits" | ||
ng-change="computeTimeInUnits()"></select> | ||
</div> |
126 changes: 126 additions & 0 deletions
126
console/src/main/scripts/plugins/directives/components/ts/hkComponents.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,126 @@ | ||
/// | ||
/// 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="../../includes.ts"/> | ||
module HawkularComponents { | ||
|
||
export var _module = angular.module('hawkular-components', []); | ||
|
||
export class HkSwitch { | ||
|
||
public link:(scope:any, element:any, attrs:any) => void; | ||
public restrict = 'E'; | ||
public replace = 'true'; | ||
public scope = { | ||
name: '@', | ||
id: '@', | ||
hkModel: '=', | ||
hkDisabled: '=', | ||
hkChange: '&', | ||
hkClick: '&' | ||
}; | ||
public templateUrl = 'plugins/directives/components/html/hk-switch.html'; | ||
|
||
constructor() { | ||
this.link = (scope:any, element:any, attrs:any) => { | ||
element.removeAttr('name'); | ||
element.removeAttr('id'); | ||
|
||
scope.hkOnText = attrs.onText || 'ON'; | ||
scope.hkOffText = attrs.offText || 'OFF'; | ||
|
||
element.bind('keydown', function (e) { | ||
var code = e.keyCode || e.which; | ||
if (code === 32 || code === 13) { | ||
e.stopImmediatePropagation(); | ||
e.preventDefault(); | ||
$(e.target).find('input').click(); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
public static Factory() { | ||
var directive = () => { | ||
return new HkSwitch(); | ||
}; | ||
|
||
directive['$inject'] = []; | ||
|
||
return directive; | ||
} | ||
} | ||
|
||
_module.directive('hkSwitch', HawkularComponents.HkSwitch.Factory()); | ||
|
||
export class HkTimeInput { | ||
|
||
public link:(scope:any, attrs:any, element:any) => void; | ||
public replace = 'true'; | ||
public restrict = 'E'; | ||
public scope = { | ||
id: '@', | ||
hkDuration: '=', | ||
hkDisabled: '=', | ||
hkAutoConvert: '=', | ||
hkChange: '&' | ||
}; | ||
public templateUrl = 'plugins/directives/components/html/time-input.html'; | ||
|
||
constructor(private hkTimeUnit:any) { | ||
this.link = (scope:any, element:any, attrs:any) => { | ||
element.removeAttr('id'); | ||
|
||
var localChange = false; | ||
|
||
scope.timeUnits = hkTimeUnit.timeUnits; | ||
scope.timeUnitsDict = hkTimeUnit.timeUnitDictionary; | ||
|
||
scope.durationChange = ():void => { | ||
localChange = true; | ||
scope.hkDuration = scope.hkConvertedDuration * scope.responseUnit; | ||
scope.hkChange(); | ||
}; | ||
|
||
scope.computeTimeInUnits = ():void => { | ||
scope.hkConvertedDuration = scope.hkDuration / scope.responseUnit; | ||
}; | ||
|
||
scope.$watch('hkDuration', (newDuration, oldDuration) => { | ||
scope.durationEnabled = scope.hkDuration !== 0; | ||
if (!localChange) { | ||
scope.responseUnit = hkTimeUnit.getFittestTimeUnit(scope.hkDuration); | ||
scope.computeTimeInUnits(); | ||
} | ||
localChange = false; | ||
}); | ||
}; | ||
} | ||
|
||
public static Factory() { | ||
var directive = (hkTimeUnit:any) => { | ||
return new HkTimeInput(hkTimeUnit); | ||
}; | ||
|
||
directive['$inject'] = ['hkTimeUnit']; | ||
|
||
return directive; | ||
} | ||
} | ||
|
||
_module.directive('hkTimeInput', HawkularComponents.HkTimeInput.Factory()); | ||
} |
Oops, something went wrong.