stack_version_view.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. * @type {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] = 'repositoryVersion.displayName';
  40. associations[2] = 'repositoryVersion.operatingSystems';
  41. associations[3] = 'installedHosts.length';
  42. associations[4] = 'currentHosts.length';
  43. return associations;
  44. }.property(),
  45. sortView: sort.wrapperView,
  46. stackVersionSort: sort.fieldView.extend({
  47. column: 1,
  48. name: 'repositoryVersion.displayName',
  49. displayName: Em.I18n.t('admin.stackVersions.table.header.version'),
  50. type: 'version',
  51. classNames: ['first']
  52. }),
  53. osSort: sort.fieldView.extend({
  54. column: 2,
  55. name: 'repositoryVersion.operatingSystems.length',
  56. displayName: Em.I18n.t('admin.stackVersions.table.header.os'),
  57. type: 'number'
  58. }),
  59. installedSort: sort.fieldView.extend({
  60. column: 3,
  61. name: 'installedHosts.length',
  62. displayName: Em.I18n.t('admin.stackVersions.table.header.installed'),
  63. type: "number"
  64. }),
  65. currentSort: sort.fieldView.extend({
  66. column: 4,
  67. name: 'currentHosts.length',
  68. displayName: Em.I18n.t('admin.stackVersions.table.header.current'),
  69. type: "number"
  70. }),
  71. stackVersionFilterView: filters.createTextView({
  72. column: 1,
  73. fieldType: 'filter-input-width',
  74. onChangeValue: function () {
  75. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  76. }
  77. }),
  78. osFilterView: filters.createSelectView({
  79. column: 2,
  80. fieldType: 'filter-input-width',
  81. content: function () {
  82. var names = App.OS.find().mapProperty('osType').uniq();
  83. return [
  84. {
  85. value: '',
  86. label: Em.I18n.t('common.all')
  87. }
  88. ].concat(names.map(function (name) {
  89. return {
  90. value: name,
  91. label: name
  92. }
  93. }));
  94. }.property('App.router.mainStackVersionsController.dataIsLoaded'),
  95. onChangeValue: function () {
  96. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'os');
  97. }
  98. }),
  99. installedFilterView: filters.createTextView({
  100. column: 3,
  101. fieldType: 'filter-input-width',
  102. onChangeValue: function () {
  103. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  104. }
  105. }),
  106. currentFilterView: filters.createTextView({
  107. column: 4,
  108. fieldType: 'filter-input-width',
  109. onChangeValue: function () {
  110. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  111. }
  112. }),
  113. didInsertElement: function() {
  114. this.set('controller.isPolling', true);
  115. this.get('controller').load();
  116. this.get('controller').doPolling();
  117. },
  118. willDestroyElement: function () {
  119. this.set('controller.isPolling', false);
  120. clearTimeout(this.get('controller.timeoutRef'));
  121. },
  122. StackVersionView: Em.View.extend({
  123. tagName: 'tr',
  124. versionStateMap: {
  125. 'current': {
  126. 'id': 'current',
  127. 'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.current')
  128. },
  129. 'installed': {
  130. 'id': 'installed',
  131. 'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.installed')
  132. },
  133. 'not_installed': {
  134. 'id': 'installing',
  135. 'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.not_installed')
  136. }
  137. },
  138. })
  139. });