bastion 5.0.6 → 5.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55ce63226df9c06562642aa39364a46785888216
4
- data.tar.gz: 48c6b2e715be10035d0ba914a870e54fb75a726a
3
+ metadata.gz: 7a7c9431ed0078114c6e171f08c6235a6aee2c1a
4
+ data.tar.gz: 607f23ed40b6038579e001f4e7e42012756b0359
5
5
  SHA512:
6
- metadata.gz: d46fd5672f7ae4b25f0716db49ca56e379837794b644d3dc3d040615a889e466722b12dab2b4fb202ad8faae71a762d877cb17a0f66174b64d1f50badebdaf8a
7
- data.tar.gz: 3512a2a5f503a670e097b5d13d505a7a5ce72cf82317366016caf0546b68dc203a56394fe973f7dba8618d2eb2ad83ebfc87a780738b8b116300e5ef47b5c95d
6
+ metadata.gz: cae3c0c52a6875f8af22f7f328b66dfc81cfc08565066e808f4143906b7fe1a7c6ea6b6ad90ea92442d235a569441551e9973a03aea724d6b44a5742d90f1c56
7
+ data.tar.gz: b8fa098368c81edc55caf68cf30a97d64c3ece7dba71135ca783e0dc0e7fdcb7e9ac5fc3794dd26ad5aac90f60a8134532383e7926a7e525a35d6cf0b0c0c32f
@@ -31,7 +31,7 @@
31
31
  */
32
32
  angular.module('Bastion.components').factory('Nutupane',
33
33
  ['$location', '$q', 'entriesPerPage', 'TableCache', 'GlobalNotification', function ($location, $q, entriesPerPage, TableCache, GlobalNotification) {
34
- var Nutupane = function (resource, params, action) {
34
+ var Nutupane = function (resource, params, action, nutupaneParams) {
35
35
  var self = this;
36
36
 
37
37
  function getTableName() {
@@ -62,6 +62,8 @@ angular.module('Bastion.components').factory('Nutupane',
62
62
  params.page = $location.search().page || 1;
63
63
  params['per_page'] = $location.search()['per_page'] || entriesPerPage;
64
64
 
65
+ nutupaneParams = nutupaneParams || {};
66
+ self.disableAutoLoad = nutupaneParams.disableAutoLoad || false;
65
67
  self.searchKey = action ? action + 'Search' : 'search';
66
68
 
67
69
  self.table = {
@@ -138,6 +140,9 @@ angular.module('Bastion.components').factory('Nutupane',
138
140
  table.working = false;
139
141
  table.refreshing = false;
140
142
  table.initialLoad = false;
143
+ }).$promise.catch(function() {
144
+ table.working = false;
145
+ table.refreshing = false;
141
146
  });
142
147
 
143
148
  return deferred.promise;
@@ -341,6 +346,11 @@ angular.module('Bastion.components').factory('Nutupane',
341
346
  self.table.resource.total += 1;
342
347
  };
343
348
 
349
+ self.table.hasPagination = function () {
350
+ return self.table.resource && self.table.resource.subtotal && self.table.resource.page &&
351
+ self.table.resource.per_page && self.table.resource.offset;
352
+ };
353
+
344
354
  self.table.onFirstPage = function () {
345
355
  return self.table.resource.page === 1;
346
356
  };
@@ -464,8 +474,9 @@ angular.module('Bastion.components').factory('Nutupane',
464
474
  self.table.searchTerm = $location.search()[self.searchKey];
465
475
  };
466
476
 
467
- // Load initial set of results
468
- self.load();
477
+ if (!self.disableAutoLoad) {
478
+ self.load();
479
+ }
469
480
  };
470
481
 
471
482
  return Nutupane;
@@ -70,7 +70,7 @@
70
70
  <div data-block="table"></div>
71
71
 
72
72
  <form class="content-view-pf-pagination table-view-pf-pagination clearfix">
73
- <div class="form-group">
73
+ <div class="form-group" ng-show="table.hasPagination()">
74
74
  <div class="pagination-pf-pagesize">
75
75
  <select class="form-control" ng-model="table.params.per_page" ng-change="table.updatePageSize()"
76
76
  ng-options="value for value in table.pageSizes">
@@ -78,7 +78,7 @@
78
78
  </div>
79
79
  <span translate>per page</span>
80
80
  </div>
81
- <div class="form-group">
81
+ <div class="form-group" ng-show="table.hasPagination()">
82
82
  <span>
83
83
  <span class="pagination-pf-items-current" translate>Showing {{ table.getPageStart() }} - {{ table.getPageEnd() }}</span>
84
84
  <span translate>of </span>
@@ -1,3 +1,5 @@
1
+ @import 'patternfly/variables';
2
+
1
3
  .required {
2
4
  .control-label {
3
5
  color: inherit;
@@ -1,4 +1,9 @@
1
1
  @import "variables";
2
+ @import "bootstrap/variables";
3
+ @import "bootstrap/mixins";
4
+ @import "bootstrap/alerts";
5
+ @import "patternfly/variables";
6
+ @import "patternfly/alerts";
2
7
 
3
8
  .table {
4
9
  table-layout: fixed;
@@ -20,6 +20,7 @@ module Bastion
20
20
 
21
21
  initializer "bastion.configure_assets", :group => :all do |app|
22
22
  SETTINGS[:bastion] = {:assets => {}} if SETTINGS[:bastion].nil?
23
+ SETTINGS[:bastion][:assets] = {} if SETTINGS[:bastion][:assets].nil?
23
24
 
24
25
  SETTINGS[:bastion][:assets][:precompile] = [
25
26
  'bastion/bastion.css',
@@ -42,6 +43,12 @@ module Bastion
42
43
  app.config.angular_templates.ignore_prefix = %w([bastion]*\/+)
43
44
  end
44
45
 
46
+ initializer 'bastion.register_plugin', :before => :finisher_hook do
47
+ Foreman::Plugin.register :bastion do
48
+ requires_foreman '>= 1.16'
49
+ end
50
+ end
51
+
45
52
  rake_tasks do
46
53
  load "#{Bastion::Engine.root}/Rakefile"
47
54
  end
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "5.0.6"
2
+ VERSION = "5.0.7"
3
3
  end
@@ -2,6 +2,7 @@ describe('Factory: Nutupane', function() {
2
2
  var $timeout,
3
3
  $location,
4
4
  $rootScope,
5
+ $q,
5
6
  Resource,
6
7
  TableCache,
7
8
  entriesPerPage,
@@ -26,18 +27,32 @@ describe('Factory: Nutupane', function() {
26
27
  $provide.value('TableCache', TableCache);
27
28
  }));
28
29
 
29
- beforeEach(module(function() {
30
+ beforeEach(inject(function(_$location_, _$timeout_, _Nutupane_, _$rootScope_, _$q_) {
31
+ $location = _$location_;
32
+ $timeout = _$timeout_;
33
+ Nutupane = _Nutupane_;
34
+ $rootScope = _$rootScope_;
35
+ $q = _$q_;
36
+
30
37
  expectedResult = [{id: 2, value: "value2"}, {id:3, value: "value3"},
31
38
  {id: 4, value: "value4"}, {id:5, value: "value5"}];
32
39
  Resource = {
33
40
  queryPaged: function(params, callback) {
34
- var result = {page: 1, results: expectedResult, subtotal: 8, per_page: 2};
41
+ var result = {
42
+ page: 1,
43
+ results: expectedResult,
44
+ subtotal: 8,
45
+ per_page: 2,
46
+ $promise: $q.resolve()
47
+ };
35
48
  if (callback) {
36
49
  callback(result);
37
50
  }
38
51
  return result;
39
52
  },
40
- customAction: function() {},
53
+ customAction: function(params, callback) {
54
+ return {$promise: $q.resolve()};
55
+ },
41
56
  page: 1,
42
57
  per_page: 2,
43
58
  total: 10,
@@ -50,13 +65,6 @@ describe('Factory: Nutupane', function() {
50
65
  };
51
66
  }));
52
67
 
53
- beforeEach(inject(function(_$location_, _$timeout_, _Nutupane_, _$rootScope_) {
54
- $location = _$location_;
55
- $timeout = _$timeout_;
56
- Nutupane = _Nutupane_;
57
- $rootScope = _$rootScope_;
58
- }));
59
-
60
68
  describe("adds additional functionality to the Nutupane table by", function() {
61
69
  var nutupane;
62
70
 
@@ -144,7 +152,7 @@ describe('Factory: Nutupane', function() {
144
152
  });
145
153
 
146
154
  it("providing a method to perform a search", function() {
147
- spyOn(Resource, 'queryPaged');
155
+ spyOn(Resource, 'queryPaged').and.callThrough();
148
156
 
149
157
  nutupane.table.search();
150
158
 
@@ -203,6 +211,12 @@ describe('Factory: Nutupane', function() {
203
211
  expect(nutupane.table.numSelected).toBe(0);
204
212
  });
205
213
 
214
+ it("provides a way to check if the table supports pagination", function () {
215
+ expect(nutupane.table.hasPagination()).toBeTruthy();
216
+ nutupane.table.resource.subtotal = null;
217
+ expect(nutupane.table.hasPagination()).toBeFalsy();
218
+ });
219
+
206
220
  it("provides a way to tell if on the first page", function () {
207
221
  nutupane.table.firstPage();
208
222
  expect(nutupane.table.onFirstPage()).toBe(true);
@@ -391,11 +405,11 @@ describe('Factory: Nutupane', function() {
391
405
  });
392
406
 
393
407
  describe("provides a way to sort the table", function() {
394
- it ("defaults the sort to ascending if the previous sort does not match the new sort.", function() {
408
+ it("defaults the sort to ascending if the previous sort does not match the new sort.", function() {
395
409
  var expectedParams = {sort_by: 'name', sort_order: 'ASC', search: '', paged: true, page: 1, per_page: entriesPerPage};
396
410
  nutupane.table.resource.sort = {};
397
411
 
398
- spyOn(Resource, 'queryPaged');
412
+ spyOn(Resource, 'queryPaged').and.callThrough();
399
413
  nutupane.table.sortBy({id: "name"});
400
414
 
401
415
  expect(Resource.queryPaged).toHaveBeenCalledWith(expectedParams, jasmine.any(Function));
@@ -408,7 +422,7 @@ describe('Factory: Nutupane', function() {
408
422
  order: 'ASC'
409
423
  };
410
424
 
411
- spyOn(Resource, 'queryPaged');
425
+ spyOn(Resource, 'queryPaged').and.callThrough();
412
426
  nutupane.table.sortBy({id: "name"});
413
427
 
414
428
  expect(Resource.queryPaged).toHaveBeenCalledWith(expectedParams, jasmine.any(Function));
@@ -439,14 +453,13 @@ describe('Factory: Nutupane', function() {
439
453
  });
440
454
 
441
455
  it("provide a method to fetch records for the table via a custom action", function() {
442
- spyOn(Resource, 'customAction');
456
+ spyOn(Resource, 'customAction').and.callThrough();
443
457
  nutupane.query();
444
458
 
445
459
  expect(Resource.customAction).toHaveBeenCalled();
446
460
  });
447
461
 
448
462
  it("naming the URL search field based off the action", function() {
449
- spyOn(Resource, 'customAction');
450
463
  nutupane.table.search('*');
451
464
 
452
465
  expect($location.search()['customActionSearch']).toBe('*');
@@ -457,7 +470,48 @@ describe('Factory: Nutupane', function() {
457
470
 
458
471
  expect(nutupane.getParams()['test']).toBe('ABC');
459
472
  });
460
- });
461
473
 
474
+ it("be able to disable auto-load", function() {
475
+ spyOn(Resource, 'customAction')
476
+ nutupane = new Nutupane(Resource, {}, 'customAction', {'disableAutoLoad': true});
477
+ expect(nutupane.disableAutoLoad).toBe(true);
478
+ expect(Resource.customAction).not.toHaveBeenCalled();
479
+ });
480
+
481
+ it("be able to load results after initialization", function() {
482
+ spyOn(Resource, 'customAction').and.callThrough();
483
+ nutupane = new Nutupane(Resource, {}, 'customAction', {'disableAutoLoad': true});
484
+ expect(nutupane.disableAutoLoad).toBe(true);
485
+ nutupane.refresh();
486
+ expect(Resource.customAction).toHaveBeenCalled();
487
+ });
488
+
489
+ it("be able to enable autoload", function() {
490
+ spyOn(Resource, 'customAction').and.callThrough();
491
+ nutupane = new Nutupane(Resource, {}, 'customAction', {'disableAutoLoad': false});
492
+ expect(nutupane.disableAutoLoad).toBe(false);
493
+ expect(Resource.customAction).toHaveBeenCalled();
494
+ });
495
+
496
+ describe("when there was an error loading the resource", function() {
497
+ beforeEach(function() {
498
+ spyOn(Resource, 'customAction').and.callFake(function() {
499
+ return {
500
+ $promise: $q.reject('internal server error')
501
+ };
502
+ });
503
+ nutupane.load();
504
+ $rootScope.$apply();
505
+ });
506
+
507
+ it("ensures the table is not in 'refreshing' state", function() {
508
+ expect(nutupane.table.refreshing).toBe(false);
509
+ });
510
+
511
+ it("ensures the table is not in 'working' state", function() {
512
+ expect(nutupane.table.working).toBe(false);
513
+ });
514
+ });
515
+ });
462
516
  });
463
517
 
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: 5.0.6
4
+ version: 5.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-08 00:00:00.000000000 Z
12
+ date: 2017-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: angular-rails-templates
@@ -1760,47 +1760,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1760
1760
  version: '0'
1761
1761
  requirements: []
1762
1762
  rubyforge_project:
1763
- rubygems_version: 2.4.6
1763
+ rubygems_version: 2.6.11
1764
1764
  signing_key:
1765
1765
  specification_version: 4
1766
1766
  summary: UI library of AngularJS based components for Foreman
1767
1767
  test_files:
1768
- - test/features/bst-feature-flag.directive.test.js
1769
- - test/features/feature-flag.service.test.js
1770
1768
  - test/auth/authorization.service.test.js
1769
+ - test/bastion/test-constants.js
1770
+ - test/components/bst-alert.directive.test.js
1771
+ - test/components/bst-alerts.directive.test.js
1772
+ - test/components/bst-bookmark.directive.test.js
1773
+ - test/components/bst-bookmark.factory.test.js
1774
+ - test/components/bst-dropdown.directive.test.js
1775
+ - test/components/bst-edit.directive.test.js
1776
+ - test/components/bst-flyout.directive.test.js
1777
+ - test/components/bst-form-buttons.directive.test.js
1771
1778
  - test/components/bst-form-group.directive.test.js
1772
- - test/components/bst-table.directive.test.js
1773
- - test/components/page-title.directive.test.js
1779
+ - test/components/bst-global-notification.directive.test.js
1774
1780
  - test/components/bst-menu.directive.test.js
1775
- - test/components/bst-alerts.directive.test.js
1776
- - test/components/nutupane.factory.test.js
1777
- - test/components/path-selector.directive.test.js
1781
+ - test/components/bst-modal.directive.test.js
1782
+ - test/components/bst-table.directive.test.js
1778
1783
  - test/components/formatters/array-to-string.filter.test.js
1779
- - test/components/formatters/unlimited-filter.filter.test.js
1784
+ - test/components/formatters/boolean-to-yes-no.filter.test.js
1780
1785
  - test/components/formatters/capitalize.filter.test.js
1781
1786
  - test/components/formatters/key-value-to-string.filter.test.js
1782
- - test/components/formatters/boolean-to-yes-no.filter.test.js
1787
+ - test/components/formatters/unlimited-filter.filter.test.js
1788
+ - test/components/global-notification.service.test.js
1789
+ - test/components/nutupane.factory.test.js
1790
+ - test/components/page-title.directive.test.js
1783
1791
  - test/components/page-title.service.test.js
1784
- - test/components/bst-bookmark.factory.test.js
1785
- - test/components/bst-alert.directive.test.js
1786
- - test/components/bst-bookmark.directive.test.js
1787
- - test/components/bst-global-notification.directive.test.js
1788
- - test/components/bst-flyout.directive.test.js
1792
+ - test/components/path-selector.directive.test.js
1789
1793
  - test/components/table-cache.service.test.js
1790
- - test/components/bst-dropdown.directive.test.js
1791
1794
  - test/components/typeahead-empty.directive.test.js
1792
- - test/components/bst-form-buttons.directive.test.js
1793
- - test/components/global-notification.service.test.js
1794
- - test/components/bst-edit.directive.test.js
1795
- - test/components/bst-modal.directive.test.js
1795
+ - test/features/bst-feature-flag.directive.test.js
1796
+ - test/features/feature-flag.service.test.js
1797
+ - test/i18n/translate.service.test.js
1798
+ - test/menu/menu-expander.service.test.js
1796
1799
  - test/routing.module.test.js
1797
1800
  - test/test-mocks.module.js
1798
- - test/menu/menu-expander.service.test.js
1799
- - test/i18n/translate.service.test.js
1800
- - test/bastion/test-constants.js
1801
- - test/utils/form-utils.service.test.js
1801
+ - test/utils/bastion-resource.factory.test.js
1802
1802
  - test/utils/disable-link.directive.test.js
1803
+ - test/utils/form-utils.service.test.js
1804
+ - test/utils/round-up.filter.test.js
1803
1805
  - test/utils/stop-event.directive.test.js
1804
- - test/utils/bastion-resource.factory.test.js
1805
1806
  - test/utils/urlencode.filter.test.js
1806
- - test/utils/round-up.filter.test.js