|
@@ -18,68 +18,83 @@
|
|
|
|
|
|
var App = require('app');
|
|
var App = require('app');
|
|
var filters = require('views/common/filter_view');
|
|
var filters = require('views/common/filter_view');
|
|
|
|
+var sort = require('views/common/sort_view');
|
|
|
|
|
|
-App.MainJobsView = Em.View.extend({
|
|
|
|
|
|
+App.MainJobsView = App.TableView.extend({
|
|
templateName: require('templates/main/jobs'),
|
|
templateName: require('templates/main/jobs'),
|
|
|
|
|
|
- showNumberOfJobs: Em.Select.extend({
|
|
|
|
- selected: '10',
|
|
|
|
- content: ['10', '25', '50', '100', "250", "500"]
|
|
|
|
|
|
+ content: function () {
|
|
|
|
+ return this.get('controller.content');
|
|
|
|
+ }.property('controller.content.length'),
|
|
|
|
+
|
|
|
|
+ didInsertElement: function () {
|
|
|
|
+ this.set('filteredContent', this.get('controller.content'));
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ sortView: sort.wrapperView,
|
|
|
|
+ idSort: sort.fieldView.extend({
|
|
|
|
+ column: 0,
|
|
|
|
+ name: 'id',
|
|
|
|
+ displayName: Em.I18n.t('jobs.column.id'),
|
|
|
|
+ type: 'string'
|
|
|
|
+ }),
|
|
|
|
+ userSort: sort.fieldView.extend({
|
|
|
|
+ column: 1,
|
|
|
|
+ name: 'user',
|
|
|
|
+ displayName: Em.I18n.t('jobs.column.user'),
|
|
|
|
+ type: 'string'
|
|
|
|
+ }),
|
|
|
|
+ startTimeSort: sort.fieldView.extend({
|
|
|
|
+ column: 2,
|
|
|
|
+ name: 'startTime',
|
|
|
|
+ displayName: Em.I18n.t('jobs.column.start.time'),
|
|
|
|
+ type: 'number'
|
|
|
|
+ }),
|
|
|
|
+ endTimeSort: sort.fieldView.extend({
|
|
|
|
+ column: 3,
|
|
|
|
+ name: 'endTime',
|
|
|
|
+ displayName: Em.I18n.t('jobs.column.end.time'),
|
|
|
|
+ type: 'number'
|
|
|
|
+ }),
|
|
|
|
+ durationSort: sort.fieldView.extend({
|
|
|
|
+ column: 4,
|
|
|
|
+ name: 'duration',
|
|
|
|
+ displayName: Em.I18n.t('jobs.column.duration'),
|
|
|
|
+ type: 'number'
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Select View with list of "rows-per-page" options
|
|
|
|
+ * @type {Ember.View}
|
|
|
|
+ */
|
|
|
|
+ rowsPerPageSelectView: Em.Select.extend({
|
|
|
|
+ content: ['10', '25', '50', '100', "250", "500"],
|
|
|
|
+ change: function () {
|
|
|
|
+ this.get('parentView').saveDisplayLength();
|
|
|
|
+ }
|
|
}),
|
|
}),
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * return filtered number of all content number information displayed on the page footer bar
|
|
|
|
+ * @returns {String}
|
|
|
|
+ */
|
|
filteredJobs: function () {
|
|
filteredJobs: function () {
|
|
- return Em.I18n.t('jobs.filtered.jobs').format(0,0);
|
|
|
|
- }.property(),
|
|
|
|
|
|
+ return Em.I18n.t('jobs.filtered.jobs').format(this.get('filteredContent.length'), this.get('content').get('length'));
|
|
|
|
+ }.property('content.length', 'filteredContent.length'),
|
|
|
|
|
|
/**
|
|
/**
|
|
* Filter-field for Jobs ID.
|
|
* Filter-field for Jobs ID.
|
|
* Based on <code>filters</code> library
|
|
* Based on <code>filters</code> library
|
|
*/
|
|
*/
|
|
- jobsIdFilterView: filters.createTextView({
|
|
|
|
|
|
+ /*jobsIdFilterView: filters.createTextView({
|
|
valueBinding: "controller.filterObject.id"
|
|
valueBinding: "controller.filterObject.id"
|
|
- }),
|
|
|
|
-
|
|
|
|
- wrapSorting: Ember.View.extend({
|
|
|
|
- tagName: 'tr'
|
|
|
|
- }),
|
|
|
|
|
|
+ }),*/
|
|
|
|
|
|
- sortingColumns: Ember.View.extend({
|
|
|
|
- tagName: 'th',
|
|
|
|
- classNameBindings: ['class', 'widthClass'],
|
|
|
|
- class: "sorting",
|
|
|
|
- widthClass: "",
|
|
|
|
- content: null,
|
|
|
|
- defaultColumn: 8,
|
|
|
|
-
|
|
|
|
- didInsertElement: function () {
|
|
|
|
- this.set("widthClass", "col" + this.get('content.index'));
|
|
|
|
- if (this.get('content.index') == this.get('defaultColumn')) {
|
|
|
|
- this.setControllerObj(this.content.index, "DESC");
|
|
|
|
- this.set("class", "sorting_desc");
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- click: function (event) {
|
|
|
|
- console.log(this.get('class'));
|
|
|
|
- if (this.get('class') == "sorting") {
|
|
|
|
- this.resetSortClass();
|
|
|
|
- this.setControllerObj(this.get('content.index'), "ASC");
|
|
|
|
- this.set("class", "sorting_asc");
|
|
|
|
- } else if (this.get('class') == "sorting_asc") {
|
|
|
|
- this.setControllerObj(this.get('content.index'), "DESC");
|
|
|
|
- this.set("class", "sorting_desc");
|
|
|
|
- } else if (this.get('class') == "sorting_desc") {
|
|
|
|
- this.setControllerObj(this.get('content.index'), "ASC");
|
|
|
|
- this.set("class", "sorting_asc");
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- resetSortClass: function () {
|
|
|
|
- this.get("parentView.childViews").map(function (a, e) {
|
|
|
|
- a.get("childViews")[0].set("class", "sorting")
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- setControllerObj: function (col, dir) {
|
|
|
|
- this.set("controller.filterObject.iSortCol_0", col);
|
|
|
|
- this.set("controller.filterObject.sSortDir_0", dir);
|
|
|
|
|
|
+ jobsIdFilterView: filters.createTextView({
|
|
|
|
+ column: 0,
|
|
|
|
+ fieldType: 'width70',
|
|
|
|
+ onChangeValue: function(){
|
|
|
|
+ this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
|
|
}
|
|
}
|
|
}),
|
|
}),
|
|
|
|
|
|
@@ -88,6 +103,9 @@ App.MainJobsView = Em.View.extend({
|
|
* Based on <code>filters</code> library
|
|
* Based on <code>filters</code> library
|
|
*/
|
|
*/
|
|
userFilterView: filters.createComponentView({
|
|
userFilterView: filters.createComponentView({
|
|
|
|
+
|
|
|
|
+ column: 1,
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Inner FilterView. Used just to render component. Value bind to <code>mainview.value</code> property
|
|
* Inner FilterView. Used just to render component. Value bind to <code>mainview.value</code> property
|
|
* Base methods was implemented in <code>filters.componentFieldView</code>
|
|
* Base methods was implemented in <code>filters.componentFieldView</code>
|
|
@@ -97,14 +115,7 @@ App.MainJobsView = Em.View.extend({
|
|
|
|
|
|
usersBinding: 'controller.users',
|
|
usersBinding: 'controller.users',
|
|
|
|
|
|
- allComponentsChecked:false,
|
|
|
|
- toggleAllComponents:function () {
|
|
|
|
- var checked = this.get('allComponentsChecked');
|
|
|
|
- this.get('users').setEach('checked', checked);
|
|
|
|
- }.observes('allComponentsChecked'),
|
|
|
|
-
|
|
|
|
clearFilter:function() {
|
|
clearFilter:function() {
|
|
- this.set('allComponentsChecked', false);
|
|
|
|
this.get('users').setEach('checked', false);
|
|
this.get('users').setEach('checked', false);
|
|
this._super();
|
|
this._super();
|
|
},
|
|
},
|
|
@@ -113,10 +124,30 @@ App.MainJobsView = Em.View.extend({
|
|
this._super();
|
|
this._super();
|
|
var chosenUsers = this.get('users').filterProperty('checked', true).mapProperty('name');
|
|
var chosenUsers = this.get('users').filterProperty('checked', true).mapProperty('name');
|
|
this.set('value', chosenUsers.toString());
|
|
this.set('value', chosenUsers.toString());
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Verify that checked checkboxes are equal to value
|
|
|
|
+ */
|
|
|
|
+ checkUsers: function() {
|
|
|
|
+ var users = this.get('value').split(',');
|
|
|
|
+ var self = this;
|
|
|
|
+ if (users) {
|
|
|
|
+ users.forEach(function(userName) {
|
|
|
|
+ var u = self.get("users").findProperty('name', userName);
|
|
|
|
+ if (u) {
|
|
|
|
+ if (!u.checked) {
|
|
|
|
+ u.checked = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }.observes('users.length')
|
|
}),
|
|
}),
|
|
|
|
|
|
- valueBinding: 'controller.filterObject.user'
|
|
|
|
|
|
+ onChangeValue: function(){
|
|
|
|
+ this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'multiple');
|
|
|
|
+ }
|
|
}),
|
|
}),
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -125,17 +156,36 @@ App.MainJobsView = Em.View.extend({
|
|
*/
|
|
*/
|
|
startTimeFilterView: filters.createSelectView({
|
|
startTimeFilterView: filters.createSelectView({
|
|
fieldType: 'input-medium',
|
|
fieldType: 'input-medium',
|
|
- valueBinding: "controller.filterObject.startTime",
|
|
|
|
- content: ['Any', 'Past 1 hour', 'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days', 'Custom']
|
|
|
|
|
|
+ column: 2,
|
|
|
|
+ content: ['Any', 'Past 1 hour', 'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days'],
|
|
|
|
+ onChangeValue: function () {
|
|
|
|
+ this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'date');
|
|
|
|
+ }
|
|
}),
|
|
}),
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Filter-field for Start Time.
|
|
|
|
|
|
+ * Filter-field for End Time.
|
|
* Based on <code>filters</code> library
|
|
* Based on <code>filters</code> library
|
|
*/
|
|
*/
|
|
endTimeFilterView: filters.createSelectView({
|
|
endTimeFilterView: filters.createSelectView({
|
|
fieldType: 'input-medium',
|
|
fieldType: 'input-medium',
|
|
- valueBinding: "controller.filterObject.endTime",
|
|
|
|
- content: ['Any', 'Custom']
|
|
|
|
- })
|
|
|
|
|
|
+ column: 3,
|
|
|
|
+ content: ['Any'],
|
|
|
|
+ onChangeValue: function () {
|
|
|
|
+ this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'date');
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * associations between content (jobs list) property and column index
|
|
|
|
+ */
|
|
|
|
+ colPropAssoc: function () {
|
|
|
|
+ var associations = [];
|
|
|
|
+ associations[0] = 'id';
|
|
|
|
+ associations[1] = 'user';
|
|
|
|
+ associations[2] = 'startTime';
|
|
|
|
+ associations[3] = 'endTime';
|
|
|
|
+ return associations;
|
|
|
|
+ }.property()
|
|
|
|
+
|
|
})
|
|
})
|