stack_version_view.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var filters = require('views/common/filter_view');
  20. var sort = require('views/common/sort_view');
  21. App.MainStackVersionsView = App.TableView.extend({
  22. templateName: require('templates/main/admin/stack_versions/stack_versions'),
  23. content: function () {
  24. return this.get('controller.content');
  25. }.property('controller.content'),
  26. /**
  27. * return filtered number of all content number information displayed on the page footer bar
  28. * @returns {String}
  29. */
  30. filteredContentInfo: function () {
  31. return this.t('tableView.filters.filteredConfigVersionInfo').format(this.get('filteredCount'), this.get('content.length'));
  32. }.property('filteredCount', 'content.length'),
  33. /**
  34. * associations between stack version property and column index
  35. * @type {Array}
  36. */
  37. colPropAssoc: function () {
  38. var associations = [];
  39. associations[1] = 'name';
  40. associations[2] = 'version';
  41. associations[3] = 'operatingSystems';
  42. associations[4] = 'installedHostsCount';
  43. associations[5] = 'currentHostsCount';
  44. return associations;
  45. }.property(),
  46. sortView: sort.wrapperView,
  47. stackNameSort: sort.fieldView.extend({
  48. column: 1,
  49. name: 'name',
  50. displayName: Em.I18n.t('admin.stackVersions.table.header.stack'),
  51. type: 'version',
  52. classNames: ['first']
  53. }),
  54. stackVersionSort: sort.fieldView.extend({
  55. column: 2,
  56. name: 'version',
  57. displayName: Em.I18n.t('admin.stackVersions.table.header.version'),
  58. type: 'version'
  59. }),
  60. osSort: sort.fieldView.extend({
  61. column: 3,
  62. name: 'installedHostsCount',
  63. displayName: Em.I18n.t('admin.stackVersions.table.header.os')
  64. }),
  65. istalledSort: sort.fieldView.extend({
  66. column: 4,
  67. name: 'currentHostsCount',
  68. displayName: Em.I18n.t('admin.stackVersions.table.header.installed'),
  69. type: "number"
  70. }),
  71. currentSort: sort.fieldView.extend({
  72. column: 5,
  73. name: 'currentHostsCount',
  74. displayName: Em.I18n.t('admin.stackVersions.table.header.current'),
  75. type: "number"
  76. }),
  77. stackNameFilterView: filters.createSelectView({
  78. column: 1,
  79. fieldType: 'filter-input-width',
  80. content: function () {
  81. return ['All'].concat(App.StackVersion.find().mapProperty('name'));
  82. }.property('App.router.mainStackVersionsController.dataIsLoaded'),
  83. onChangeValue: function () {
  84. this.get('parentView').updateFilter(this.get('column'), this.get('actualValue'), 'select');
  85. },
  86. emptyValue: Em.I18n.t('common.all')
  87. }),
  88. stackVersionFilterView: filters.createTextView({
  89. column: 2,
  90. fieldType: 'filter-input-width',
  91. onChangeValue: function () {
  92. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  93. }
  94. }),
  95. osFilterView: filters.createTextView({
  96. column: 3,
  97. fieldType: 'filter-input-width',
  98. onChangeValue: function () {
  99. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  100. }
  101. }),
  102. currentFilterView: filters.createTextView({
  103. column: 4,
  104. fieldType: 'filter-input-width',
  105. onChangeValue: function () {
  106. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  107. }
  108. }),
  109. installedFilterView: filters.createTextView({
  110. column: 5,
  111. fieldType: 'filter-input-width',
  112. onChangeValue: function () {
  113. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  114. }
  115. }),
  116. StackVersionView: Em.View.extend({
  117. tagName: 'tr',
  118. didInsertElement: function () {
  119. App.tooltip(this.$("[rel='Tooltip']"));
  120. this.set('isOsCollapsed', true);
  121. },
  122. toggleOs: function(event) {
  123. this.set('isOsCollapsed', !this.get('isOsCollapsed'));
  124. this.$('.operating-systems').toggle();
  125. },
  126. labels: function() {
  127. return this.get('content.operatingSystems').getEach('name').join("<br />");
  128. }.property('content.operatingSystems.length')
  129. }),
  130. didInsertElement: function() {
  131. this.get('controller').load().done(function(){
  132. this.set('filteredContent',this.get('content'));
  133. }, this);
  134. }
  135. });