bastion 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDM5ZTg3NDNkNDIzNmQwMjk5Yjg1MDY4ZTFkN2IwZDRiNTMyZjU4Mg==
5
- data.tar.gz: !binary |-
6
- OGUyMzQ1ZWQxODI1NTE0MmQ2YWY0N2Q3YmJiM2E3OWI5MjcyMmRhYQ==
2
+ SHA1:
3
+ metadata.gz: 2b5c8f13cfb5327ac09ecd123a93eafd564affa1
4
+ data.tar.gz: 1e385621752b7030f54cc6883237c9b891c5e1cc
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWQ3YWM5N2FmOTAyMmQ1YTU3MDA1NmYxNTJmMzUxYjkxNmEyODAxMzgxZjNm
10
- NTNhODE3MGY1ZDJiOTUxYWQ1YTY5MWQxMGM3NDU0YWY3NTg1YjgyYzk4Zjc0
11
- MTQyNzYzNTk3ZDFhMmRiMTcwZDU3MjQ2YTE2OGFhMWU3MDIzNTY=
12
- data.tar.gz: !binary |-
13
- NjlkZDg2Y2IwMzM4YmQ1N2IwMTI4MzJhNmVhOGJhYzVjNzEzYzQ5M2JmYjc1
14
- ODUxNDY4MTVjMjVlNThhOWEyYmVjNzViMjQ1NTViNjkxN2ZiOTQ4YjQyMjg0
15
- YzA2MDFlY2IzNTY4YWY2ZjI2YmU1YTJjMmVlZjMxYTBkMjAzZGY=
6
+ metadata.gz: d45c125536689e914b9669634864ecf76b610adbea30f68a93c24856dd3e179ee590fad0edd58167d786734391b64e122b9e40ba9917a715270e141326b20a4e
7
+ data.tar.gz: 39f6aaec0260871e53a94350f22cb0097e7fd0b6a9cbed0831283b1a4e13839985cc09cab5db0a436ff9fc8341bdf651b2d8236e35207d7ac0705cb2434bddfe
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @ngdoc directive
3
+ * @name Bastion.components.directive:bookmark
4
+ *
5
+ * @requires BstBookmark
6
+ *
7
+ * @description
8
+ * Provides the bookmarked items for a dropdown menu
9
+ */
10
+ angular.module('Bastion.components').directive('bstBookmark', ['BstBookmark', function (BstBookmark) {
11
+ return {
12
+ scope: {
13
+ controllerName: '=',
14
+ query: '='
15
+ },
16
+ templateUrl: 'components/views/bst-bookmark.html',
17
+ controller: ['$scope', 'translate', function ($scope, translate) {
18
+ $scope.newBookmark = {};
19
+
20
+ $scope.load = function () {
21
+ BstBookmark.queryPaged({search: 'controller=' + $scope.controllerName}, function (response) {
22
+ $scope.bookmarks = response.results;
23
+ });
24
+ };
25
+
26
+ $scope.add = function () {
27
+ if (angular.isDefined($scope.query)) {
28
+ $scope.newBookmark.query = $scope.query.trim();
29
+ }
30
+ $scope.openModal();
31
+ };
32
+
33
+ $scope.save = function () {
34
+ var params, success, error;
35
+
36
+ params = {
37
+ name: $scope.newBookmark.name,
38
+ query: $scope.newBookmark.query,
39
+ public: $scope.newBookmark.public,
40
+ controller: $scope.controllerName
41
+ };
42
+
43
+ success = function () {
44
+ $scope.bookmarks = $scope.load();
45
+ $scope.$parent.successMessages = [translate('Bookmark was successfully created.')];
46
+ };
47
+
48
+ error = function (response) {
49
+ $scope.$parent.errorMessages = [response.data.error.full_messages];
50
+ };
51
+
52
+ BstBookmark.create(params, success, error);
53
+ };
54
+
55
+ $scope.setQuery = function (bookmark) {
56
+ $scope.query = bookmark.query;
57
+ };
58
+
59
+ $scope.load();
60
+ }]
61
+ };
62
+ }]);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @ngdoc service
3
+ * @name Bastion.components.service:BstBookmark
4
+ *
5
+ * @requires BastionResource
6
+ *
7
+ * @description
8
+ * Provides a BastionResource for bst-bookmarks.
9
+ */
10
+ angular.module('Bastion.components').factory('BstBookmark',
11
+ ['BastionResource', function (BastionResource) {
12
+
13
+ return BastionResource('/api/v2/bookmarks', {id: '@id'},
14
+ {
15
+ create: { method: 'POST' }
16
+ }
17
+ );
18
+ }]
19
+ );
@@ -12,52 +12,54 @@
12
12
  angular.module('Bastion.components').directive('bstModal',
13
13
  ['$templateCache', '$modal', function ($templateCache, $modal) {
14
14
  return {
15
- transclude: true,
16
15
  scope: {
17
16
  action: '&bstModal',
18
17
  modelName: '@model',
19
18
  model: '='
20
19
  },
21
- link: function (scope, iElement, iAttrs, nullCtrl, transclude) {
22
- var modalInstance, modalController, modalId;
20
+ compile: function(tElement) {
21
+ var template = angular.element('<div extend-template="components/views/bst-modal.html"></div>'), modalId;
22
+
23
+ template.append(tElement.children());
24
+ tElement.html('');
25
+ tElement = angular.element(template);
23
26
 
24
27
  modalId = 'bstModal%d.html'.replace('%d', Math.random().toString());
28
+ $templateCache.put(modalId, tElement);
25
29
 
26
- modalController = ['$scope', '$modalInstance', 'model', function ($scope, $modalInstance, model) {
27
- $scope[scope.modelName] = model;
30
+ return function (scope) {
31
+ var modalInstance, modalController;
28
32
 
29
- $scope.ok = function () {
30
- $modalInstance.close();
31
- };
33
+ modalController = ['$scope', '$modalInstance', 'model', function ($scope, $modalInstance, model) {
34
+ $scope[scope.modelName] = model;
32
35
 
33
- $scope.cancel = function () {
34
- $modalInstance.dismiss('cancel');
35
- };
36
- }];
37
-
38
- scope.openModal = function () {
39
- modalInstance = $modal.open({
40
- templateUrl: modalId,
41
- controller: modalController,
42
- resolve: {
43
- model: function () {
44
- return scope[scope.modelName];
45
- }
46
- }
47
- });
36
+ $scope.ok = function () {
37
+ $modalInstance.close();
38
+ };
48
39
 
49
- modalInstance.result.then(function () {
50
- scope.action();
51
- });
52
- };
40
+ $scope.cancel = function () {
41
+ $modalInstance.dismiss('cancel');
42
+ };
43
+ }];
53
44
 
54
- scope.$parent.openModal = scope.openModal;
45
+ scope.openModal = function () {
46
+ modalInstance = $modal.open({
47
+ templateUrl: modalId,
48
+ controller: modalController,
49
+ resolve: {
50
+ model: function () {
51
+ return scope.model;
52
+ }
53
+ }
54
+ });
55
+
56
+ modalInstance.result.then(function () {
57
+ scope.action();
58
+ });
59
+ };
55
60
 
56
- transclude(function (clone) {
57
- var template = angular.element('<div extend-template="components/views/bst-modal.html"></div>');
58
- template.append(clone);
59
- $templateCache.put(modalId, template);
60
- });
61
+ scope.$parent.openModal = scope.openModal;
62
+ };
61
63
  }
62
64
  };
63
65
  }]);
@@ -0,0 +1,46 @@
1
+ <li ng-show="bookmarks.length === 0">
2
+ <a translate>No Bookmarks</a>
3
+ </li>
4
+ <li ng-repeat="bookmark in bookmarks">
5
+ <a ng-click="setQuery(bookmark)" class="ng-scope">{{ bookmark.name }}</a>
6
+ </li>
7
+ <li class="divider"></li>
8
+ <li>
9
+ <a ng-click="add()" translate class="ng-scope">Bookmark this search</a>
10
+ </li>
11
+
12
+ <div bst-modal="save()" model="newBookmark">
13
+ <span>{{ bookmark.query }}</span>
14
+ <div data-block="modal-header" translate>Add Bookmark</div>
15
+ <div data-block="modal-body">
16
+ <form name="bookmarkForm" class="form-horizontal" novalidate role="form">
17
+ <div bst-form-group label="{{ 'Name' | translate }}">
18
+ <input id="name"
19
+ name="name"
20
+ ng-model="newBookmark.name"
21
+ type="text"
22
+ tabindex="1"
23
+ autofocus
24
+ required/>
25
+ </div>
26
+ <div bst-form-group label="{{ 'Search query' | translate }}">
27
+ <input id="query"
28
+ name="query"
29
+ ng-model="newBookmark.query"
30
+ type="text"
31
+ tabindex="1"
32
+ autofocus
33
+ required/>
34
+ </div>
35
+ <div bst-form-group label="{{ 'Public' | translate }}">
36
+ <input id="public"
37
+ name="public"
38
+ ng-model="newBookmark.public"
39
+ type="checkbox"
40
+ tabindex="1"
41
+ autofocus/>
42
+ </div>
43
+ </form>
44
+ </div>
45
+ <div data-block="modal-confirm-button" translate>Save</div>
46
+ </div>
@@ -23,7 +23,7 @@
23
23
  <div class="input-group input-group">
24
24
  <input type="text"
25
25
  class="form-control"
26
- placeholder="{{ 'Search...' | translate }}"
26
+ placeholder="{{ 'Filter...' | translate }}"
27
27
  bst-on-enter="table.search(table.searchTerm)"
28
28
  ng-model="table.searchTerm"
29
29
  ng-trim="false"
@@ -31,7 +31,14 @@
31
31
  typeahead-empty
32
32
  typeahead-template-url="components/views/autocomplete-scoped-search.html"/>
33
33
  <span class="input-group-btn">
34
- <button ng-click="table.search(table.searchTerm)" class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
34
+ <button ng-click="table.search(table.searchTerm)" class="btn btn-default" type="button">
35
+ <i class="fa fa-search"></i>
36
+ <span translate>Search</span>
37
+ </button>
38
+ <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
39
+ <i class="fa fa-caret-down"></i>
40
+ </button>
41
+ <ul bst-bookmark controller-name="controllerName" query="table.searchTerm" class="dropdown-menu pull-right"></ul>
35
42
  </span>
36
43
  </div>
37
44
  </div>
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "2.0.4"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -0,0 +1,145 @@
1
+ describe('Directive: bstBookmark', function() {
2
+ var scope,
3
+ compile,
4
+ compileDirective,
5
+ element,
6
+ elementScope,
7
+ BstBookmark,
8
+ bookmarks,
9
+ $modal;
10
+
11
+ compileDirective = function () {
12
+ compile(element)(scope);
13
+ scope.$digest();
14
+ };
15
+
16
+ beforeEach(module('Bastion.test-mocks', 'Bastion.components', 'components/views/bst-bookmark.html'));
17
+
18
+ beforeEach(module(function($provide) {
19
+ var translate = function() {
20
+ this.$get = function() {
21
+ return function() {};
22
+ };
23
+
24
+ return this;
25
+ };
26
+
27
+ $modal = {
28
+ $get: function() {
29
+ return this;
30
+ }
31
+ };
32
+
33
+ bookmarks = ['bookmark'];
34
+
35
+ BstBookmark = {
36
+ failed: false,
37
+
38
+ $get: function() {
39
+ return this;
40
+ },
41
+
42
+ queryPaged: function (params, callback) {
43
+ callback({results: bookmarks});
44
+ },
45
+
46
+ create: function (params, success, error) {
47
+ if (this.failed) {
48
+ var response = {
49
+ data: {
50
+ error: {
51
+ full_message: ''
52
+ }
53
+ }
54
+ };
55
+ error(response);
56
+ } else {
57
+ success();
58
+ }
59
+ }
60
+ };
61
+
62
+ $provide.provider('$modal', $modal);
63
+ $provide.provider('translate', translate);
64
+ $provide.provider('BstBookmark', BstBookmark);
65
+ }));
66
+
67
+ beforeEach(inject(function(_$compile_, _$rootScope_) {
68
+ compile = _$compile_;
69
+ scope = _$rootScope_;
70
+ }));
71
+
72
+ beforeEach(function() {
73
+ scope.controllerName = 'controller';
74
+ element = angular.element('<ul bst-bookmark controller-name="controllerName"></ul>');
75
+ compileDirective();
76
+ elementScope = element.isolateScope();
77
+ });
78
+
79
+ it("should set bookmarks on the scope", function () {
80
+ spyOn(BstBookmark, 'queryPaged').andCallThrough();
81
+ compileDirective();
82
+ expect(BstBookmark.queryPaged).toHaveBeenCalled();
83
+ expect(elementScope.bookmarks).toEqual(['bookmark']);
84
+ });
85
+
86
+ it("should display a <li>", function() {
87
+ expect(element.find('li').length).toBe(4);
88
+ });
89
+
90
+ it("should open a modal upon triggering", function() {
91
+ spyOn(elementScope, 'openModal');
92
+ elementScope.add();
93
+ expect(elementScope.openModal).toHaveBeenCalled();
94
+ });
95
+
96
+ describe("should save the bookmark", function () {
97
+ var expectedParams;
98
+
99
+ beforeEach(function () {
100
+ var bookmark = {
101
+ name: 'a bookmark',
102
+ query: 'query',
103
+ public: true
104
+ };
105
+
106
+ elementScope.newBookmark = bookmark;
107
+
108
+ expectedParams = {
109
+ name: bookmark.name,
110
+ query: bookmark.query,
111
+ public: bookmark.public,
112
+ controller: scope.controllerName
113
+ };
114
+
115
+ spyOn(BstBookmark, 'create').andCallThrough();
116
+ spyOn(BstBookmark, 'queryPaged');
117
+ });
118
+
119
+ afterEach(function () {
120
+ expect(BstBookmark.create).toHaveBeenCalledWith(expectedParams, jasmine.any(Function), jasmine.any(Function));
121
+ });
122
+
123
+ it("and succeed", function () {
124
+ elementScope.save();
125
+
126
+ expect(BstBookmark.queryPaged).toHaveBeenCalled();
127
+ expect(elementScope.$parent.successMessages.length).toBe(1);
128
+ });
129
+
130
+ it("and fail", function () {
131
+ BstBookmark.failed = true;
132
+
133
+ elementScope.save();
134
+
135
+ expect(BstBookmark.queryPaged).not.toHaveBeenCalled();
136
+ expect(elementScope.$parent.errorMessages.length).toBe(1);
137
+ });
138
+ });
139
+
140
+ it("sets the query on bookmark selection", function () {
141
+ var bookmark = {query: 'blah'};
142
+ elementScope.setQuery(bookmark);
143
+ expect(elementScope.query).toBe(bookmark.query);
144
+ });
145
+ });
@@ -0,0 +1,31 @@
1
+ describe('Factory: BstBookmark', function() {
2
+ var $httpBackend,
3
+ bookmarks,
4
+ BstBookmark;
5
+
6
+ beforeEach(module('Bastion', 'Bastion.components'));
7
+
8
+ beforeEach(module(function() {
9
+ bookmarks = {
10
+ results: [{name:"search1",
11
+ controller:"controller1",
12
+ query:"name = ak1",
13
+ public:null}],
14
+ total: 1,
15
+ subtotal: 1
16
+ };
17
+ }));
18
+
19
+ beforeEach(inject(function($injector) {
20
+ $httpBackend = $injector.get('$httpBackend');
21
+ BstBookmark = $injector.get('BstBookmark');
22
+ }));
23
+
24
+ it('provides a way to create a bookmark', function() {
25
+ $httpBackend.expectPOST('/api/v2/bookmarks').respond(bookmarks.results[0]);
26
+
27
+ BstBookmark.create(function(bookmarks) {
28
+ expect(response).toBeDefined();
29
+ });
30
+ });
31
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms
@@ -29,28 +29,28 @@ dependencies:
29
29
  name: uglifier
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ! '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ! '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: less-rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 2.5.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 2.5.0
56
56
  description: Bastion provides a UI library of AngularJS based components designed
@@ -62,8 +62,8 @@ executables: []
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - .eslintignore
66
- - .jshintrc
65
+ - ".eslintignore"
66
+ - ".jshintrc"
67
67
  - Gruntfile.js
68
68
  - LICENSE
69
69
  - README.md
@@ -76,6 +76,8 @@ files:
76
76
  - app/assets/javascripts/bastion/bastion.module.js
77
77
  - app/assets/javascripts/bastion/components/bst-alert.directive.js
78
78
  - app/assets/javascripts/bastion/components/bst-alerts.directive.js
79
+ - app/assets/javascripts/bastion/components/bst-bookmark.directive.js
80
+ - app/assets/javascripts/bastion/components/bst-bookmark.factory.js
79
81
  - app/assets/javascripts/bastion/components/bst-container-scroll.directive.js
80
82
  - app/assets/javascripts/bastion/components/bst-dropdown.directive.js
81
83
  - app/assets/javascripts/bastion/components/bst-edit.directive.js
@@ -104,6 +106,7 @@ files:
104
106
  - app/assets/javascripts/bastion/components/views/autocomplete-scoped-search.html
105
107
  - app/assets/javascripts/bastion/components/views/bst-alert.html
106
108
  - app/assets/javascripts/bastion/components/views/bst-alerts.html
109
+ - app/assets/javascripts/bastion/components/views/bst-bookmark.html
107
110
  - app/assets/javascripts/bastion/components/views/bst-dropdown.html
108
111
  - app/assets/javascripts/bastion/components/views/bst-edit-add-item.html
109
112
  - app/assets/javascripts/bastion/components/views/bst-edit-add-remove-cancel.html
@@ -186,6 +189,8 @@ files:
186
189
  - test/bastion/test-constants.js
187
190
  - test/components/bst-alert.directive.test.js
188
191
  - test/components/bst-alerts.directive.test.js
192
+ - test/components/bst-bookmark.directive.test.js
193
+ - test/components/bst-bookmark.factory.test.js
189
194
  - test/components/bst-container-scroll.directive.test.js
190
195
  - test/components/bst-dropdown.directive.test.js
191
196
  - test/components/bst-edit.directive.test.js
@@ -1146,50 +1151,53 @@ require_paths:
1146
1151
  - lib
1147
1152
  required_ruby_version: !ruby/object:Gem::Requirement
1148
1153
  requirements:
1149
- - - ! '>='
1154
+ - - ">="
1150
1155
  - !ruby/object:Gem::Version
1151
1156
  version: '0'
1152
1157
  required_rubygems_version: !ruby/object:Gem::Requirement
1153
1158
  requirements:
1154
- - - ! '>='
1159
+ - - ">="
1155
1160
  - !ruby/object:Gem::Version
1156
1161
  version: '0'
1157
1162
  requirements: []
1158
1163
  rubyforge_project:
1159
- rubygems_version: 2.4.7
1164
+ rubygems_version: 2.4.6
1160
1165
  signing_key:
1161
1166
  specification_version: 4
1162
1167
  summary: UI library of AngularJS based components for Foreman
1163
1168
  test_files:
1164
- - test/bastion/bastion-resource.factory.test.js
1165
- - test/bastion/test-constants.js
1166
1169
  - test/features/bst-feature-flag.directive.test.js
1167
1170
  - test/features/feature-flag.service.test.js
1168
1171
  - test/auth/authorization.service.test.js
1169
- - test/i18n/translate.service.test.js
1172
+ - test/components/bst-form-group.directive.test.js
1173
+ - test/components/bst-table.directive.test.js
1174
+ - test/components/page-title.directive.test.js
1170
1175
  - test/components/bst-nutupane-table.directive.test.js
1171
- - test/components/bst-dropdown.directive.test.js
1172
- - test/components/bst-form-buttons.directive.test.js
1173
- - test/components/typeahead-empty.directive.test.js
1176
+ - test/components/bst-menu.directive.test.js
1174
1177
  - test/components/bst-alerts.directive.test.js
1175
1178
  - test/components/nutupane.factory.test.js
1176
- - test/components/page-title.directive.test.js
1177
- - test/components/bst-table.directive.test.js
1178
- - test/components/bst-container-scroll.directive.test.js
1179
- - test/components/formatters/capitalize.filter.test.js
1179
+ - test/components/path-selector.directive.test.js
1180
1180
  - test/components/formatters/array-to-string.filter.test.js
1181
- - test/components/formatters/boolean-to-yes-no.filter.test.js
1182
1181
  - test/components/formatters/unlimited-filter.filter.test.js
1182
+ - test/components/formatters/capitalize.filter.test.js
1183
1183
  - test/components/formatters/key-value-to-string.filter.test.js
1184
- - test/components/bst-menu.directive.test.js
1185
- - test/components/bst-edit.directive.test.js
1186
- - test/components/bst-modal.directive.test.js
1187
- - test/components/bst-form-group.directive.test.js
1188
- - test/components/bst-flyout.directive.test.js
1184
+ - test/components/formatters/boolean-to-yes-no.filter.test.js
1189
1185
  - test/components/page-title.service.test.js
1186
+ - test/components/bst-bookmark.factory.test.js
1190
1187
  - test/components/bst-alert.directive.test.js
1191
- - test/components/path-selector.directive.test.js
1192
- - test/utils/as.filter.test.js
1193
- - test/utils/form-utils.service.test.js
1188
+ - test/components/bst-container-scroll.directive.test.js
1189
+ - test/components/bst-bookmark.directive.test.js
1190
+ - test/components/bst-flyout.directive.test.js
1191
+ - test/components/bst-dropdown.directive.test.js
1192
+ - test/components/typeahead-empty.directive.test.js
1193
+ - test/components/bst-form-buttons.directive.test.js
1194
+ - test/components/bst-edit.directive.test.js
1195
+ - test/components/bst-modal.directive.test.js
1194
1196
  - test/test-mocks.module.js
1195
1197
  - test/menu/menu-expander.service.test.js
1198
+ - test/i18n/translate.service.test.js
1199
+ - test/bastion/test-constants.js
1200
+ - test/bastion/bastion-resource.factory.test.js
1201
+ - test/utils/form-utils.service.test.js
1202
+ - test/utils/as.filter.test.js
1203
+ has_rdoc: