forked from openshift/origin-web-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildClose.js
39 lines (36 loc) · 1.13 KB
/
buildClose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
/* jshint unused: false */
angular.module('openshiftConsole')
.directive('buildClose', function($window) {
// so that builds can be dismissed on overview
var hideBuildKey = function(build) {
return 'hide/build/' + build.metadata.uid;
};
var isBuildHidden = function(build) {
var key = hideBuildKey(build);
return sessionStorage.getItem(key) === 'true';
};
return {
restrict: 'AE',
scope: {
build: '=',
hideBuild: '=' // for ng-show or ng-hide, not ng-if!
},
controller: function($scope) {
$scope.onHideBuild = function() {
var key = hideBuildKey($scope.build);
$scope.hideBuild = true;
sessionStorage.setItem(key, 'true');
};
},
link: function($scope, $elem, $attrs, ctrl) {
// initialize
$scope.hideBuild = false;
// if the build changes, check storage to see if its a hidden build
$scope.$watch('build', function(newVal) {
$scope.hideBuild = isBuildHidden(newVal);
});
},
templateUrl: 'views/directives/_build-close.html'
};
});