jobs_view.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. App.MainJobsView = Em.View.extend({
  21. templateName: require('templates/main/jobs'),
  22. showNumberOfJobs: Em.Select.extend({
  23. selected: '10',
  24. content: ['10', '25', '50', '100', "250", "500"]
  25. }),
  26. filteredJobs: function () {
  27. return Em.I18n.t('jobs.filtered.jobs').format(0,0);
  28. }.property(),
  29. /**
  30. * Filter-field for Jobs ID.
  31. * Based on <code>filters</code> library
  32. */
  33. jobsIdFilterView: filters.createTextView({
  34. valueBinding: "controller.filterObject.id"
  35. }),
  36. wrapSorting: Ember.View.extend({
  37. tagName: 'tr'
  38. }),
  39. sortingColumns: Ember.View.extend({
  40. tagName: 'th',
  41. classNameBindings: ['class', 'widthClass'],
  42. class: "sorting",
  43. widthClass: "",
  44. content: null,
  45. defaultColumn: 8,
  46. didInsertElement: function () {
  47. this.set("widthClass", "col" + this.get('content.index'));
  48. if (this.get('content.index') == this.get('defaultColumn')) {
  49. this.setControllerObj(this.content.index, "DESC");
  50. this.set("class", "sorting_desc");
  51. }
  52. },
  53. click: function (event) {
  54. console.log(this.get('class'));
  55. if (this.get('class') == "sorting") {
  56. this.resetSortClass();
  57. this.setControllerObj(this.get('content.index'), "ASC");
  58. this.set("class", "sorting_asc");
  59. } else if (this.get('class') == "sorting_asc") {
  60. this.setControllerObj(this.get('content.index'), "DESC");
  61. this.set("class", "sorting_desc");
  62. } else if (this.get('class') == "sorting_desc") {
  63. this.setControllerObj(this.get('content.index'), "ASC");
  64. this.set("class", "sorting_asc");
  65. }
  66. },
  67. resetSortClass: function () {
  68. this.get("parentView.childViews").map(function (a, e) {
  69. a.get("childViews")[0].set("class", "sorting")
  70. });
  71. },
  72. setControllerObj: function (col, dir) {
  73. this.set("controller.filterObject.iSortCol_0", col);
  74. this.set("controller.filterObject.sSortDir_0", dir);
  75. }
  76. }),
  77. /**
  78. * Filter-list for User.
  79. * Based on <code>filters</code> library
  80. */
  81. userFilterView: filters.createComponentView({
  82. /**
  83. * Inner FilterView. Used just to render component. Value bind to <code>mainview.value</code> property
  84. * Base methods was implemented in <code>filters.componentFieldView</code>
  85. */
  86. filterView: filters.componentFieldView.extend({
  87. templateName:require('templates/main/apps/user_filter'),
  88. usersBinding: 'controller.users',
  89. allComponentsChecked:false,
  90. toggleAllComponents:function () {
  91. var checked = this.get('allComponentsChecked');
  92. this.get('users').setEach('checked', checked);
  93. }.observes('allComponentsChecked'),
  94. clearFilter:function() {
  95. this.set('allComponentsChecked', false);
  96. this.get('users').setEach('checked', false);
  97. this._super();
  98. },
  99. applyFilter:function() {
  100. this._super();
  101. var chosenUsers = this.get('users').filterProperty('checked', true).mapProperty('name');
  102. this.set('value', chosenUsers.toString());
  103. }
  104. }),
  105. valueBinding: 'controller.filterObject.user'
  106. }),
  107. /**
  108. * Filter-field for Start Time.
  109. * Based on <code>filters</code> library
  110. */
  111. startTimeFilterView: filters.createSelectView({
  112. fieldType: 'input-medium',
  113. valueBinding: "controller.filterObject.startTime",
  114. content: ['Any', 'Past 1 hour', 'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days', 'Custom']
  115. }),
  116. /**
  117. * Filter-field for Start Time.
  118. * Based on <code>filters</code> library
  119. */
  120. endTimeFilterView: filters.createSelectView({
  121. fieldType: 'input-medium',
  122. valueBinding: "controller.filterObject.endTime",
  123. content: ['Any', 'Custom']
  124. })
  125. })