You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/11/07 05:06:09 UTC
svn commit: r1406443 [2/2] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-web/app/ ambari-web/app/assets/data/dashboard/
ambari-web/app/controllers/ ambari-web/app/controllers/main/
ambari-web/app/controllers/wizard/ ambari-web/app/models/ ambar...
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/apps_view.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/apps_view.js?rev=1406443&r1=1406442&r2=1406443&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/apps_view.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/apps_view.js Wed Nov 7 04:06:08 2012
@@ -27,6 +27,7 @@ App.MainAppsView = Em.View.extend({
var app = App.store.find(App.App, item.get('appId'));
item.set('appName', app.get('appName'));
item.set('type', app.get('type'));
+ item.set('duration', date.dateFormatInterval(((item.get('lastUpdateTime') - item.get('startTime'))/1000)));
item.set('lastUpdateTime', date.dateFormat(item.get('lastUpdateTime')));
item.set('numJobsTotal' ,item.get('jobs').get('content').length);
item.get('jobs').forEach(function(item){
@@ -35,16 +36,111 @@ App.MainAppsView = Em.View.extend({
});
return content;
}.property('App.router.mainAppsController.content'),
- /*types: function(){
+ users: function(){
var result = new Array();
this.get('content').forEach(function(item){
- result.push(item.get('type'));
+ result.push(item.get('userName'));
});
- result = $.unique(result);
- return result;
- }.property('content'),*/
+ return jQuery.unique(result);
+ }.property('content'),
oTable:null,
filtered:null,
+ stared: function() {
+ var content = this.get('controller.staredRuns');
+ var avgJobs = 0.0, minJobs = 0, maxJobs = 0, avgInput = 0, minInput = 0, maxInput = 0, avgOutput = 0, minOutput = 0, maxOutput = 0, avgDuration = 0.0, minDuration = 0, maxDuration = 0, oldest = 0, youngest = 0;
+ if (content.length > 0) {
+ minJobs = content[0].get('numJobsTotal');
+ minInput = content[0].get('input');
+ minOutput = content[0].get('output');
+ oldest = date.dateUnformat(content[0].get('lastUpdateTime'));
+ youngest = date.dateUnformat(content[0].get('lastUpdateTime'));
+ minDuration = date.dateUnformatInterval(content[0].get('duration'));
+ }
+ content.forEach(function(item) {
+ avgJobs += item.get('numJobsTotal') / content.length;
+ avgInput += item.get('input') / content.length;
+ avgOutput += item.get('output') / content.length;
+ avgDuration += date.dateUnformatInterval(item.get('duration')) / content.length;
+ if (item.get('numJobsTotal') < minJobs) {
+ minJobs = item.get('numJobsTotal');
+ }
+ else {
+ if (item.get('numJobsTotal') > maxJobs) {
+ maxJobs = item.get('numJobsTotal');
+ }
+ }
+ if (item.get('input') < minInput) {
+ minInput = item.get('input');
+ }
+ else {
+ if (item.get('input') > maxInput) {
+ maxInput = item.get('input');
+ }
+ }
+ if (item.get('output') < minOutput) {
+ minOutput = item.get('output');
+ }
+ else {
+ if (item.get('output') > maxOutput) {
+ maxOutput = item.get('output');
+ }
+ }
+ if (date.dateUnformatInterval(item.get('duration')) < minDuration) {
+ minDuration = date.dateUnformatInterval(item.get('duration'));
+ }
+ else {
+ if (date.dateUnformatInterval(item.get('duration')) > maxDuration) {
+ maxDuration = date.dateUnformatInterval(item.get('duration'));
+ }
+ }
+ if (date.dateUnformat(item.get('lastUpdateTime')) < oldest) {
+ oldest = date.dateUnformat(item.get('lastUpdateTime'));
+ }
+ else {
+ if (date.dateUnformat(item.get('lastUpdateTime')) > youngest) {
+ youngest = date.dateUnformat(item.get('lastUpdateTime'));
+ }
+ }
+ });
+ oldest = oldest != 0 ? oldest.substring(0, 4) + '-' + oldest.substring(4, 6) + '-' + oldest.substring(6, 8) : '';
+ youngest = youngest != 0 ? youngest.substring(0, 4) + '-' + youngest.substring(4, 6) + '-' + youngest.substring(6, 8) : '';
+ ret = {
+ 'count': this.get('controller.staredRuns').length,
+ 'jobs': {
+ 'avg': avgJobs.toFixed(2),
+ 'min': minJobs,
+ 'max': maxJobs
+ },
+ 'input': {
+ 'avg': avgInput.toFixed(2),
+ 'min': minInput,
+ 'max': maxInput
+ },
+ 'output': {
+ 'avg': avgOutput.toFixed(2),
+ 'min': minOutput,
+ 'max': maxOutput
+ },
+ 'duration': {
+ 'avg': date.dateFormatInterval(Math.round(avgDuration)),
+ 'min': date.dateFormatInterval(minDuration),
+ 'max': date.dateFormatInterval(maxDuration)
+ },
+ 'times': {
+ 'oldest': oldest,
+ 'youngest': youngest
+ }
+ };
+ return ret;
+ }.property('controller.staredRunsLength'),
+ /*starsStats: function() {
+ var content = this.get('controller.staredRuns');
+ var avgJobs = 0.0, minJobs = 0, maxJobs = 0, avgInput = 0, minInput = 0, maxInput = 0, avgOutput = 0, minOutput = 0, maxOutput = 0;
+ content.forEach(function(item) {
+ avgJobs += item.get('numJobsTotal') / content.length;
+ });
+ this.set('avgJobs', 1);
+ }.property('controller.staredRunsLength'),*/
clearFilters:function(event){
this._childViews.forEach(function(item){
if(item.get('tagName') === 'input') {
@@ -89,8 +185,49 @@ App.MainAppsView = Em.View.extend({
});
this.set('oTable', oTable);
this.set('filtered', oTable.fnSettings().fnRecordsDisplay());
+
+ },
+ /**
+ * reset all filters in dataTable
+ *
+ * @param event
+ */
+ clearFilters:function(event){
+ this._childViews.forEach(function(item){
+ if(item.get('tagName') === 'input') {
+ item.set('value','');
+ }
+ if(item.get('tagName') === 'select') {
+ item.set('value','Any');
+ }
+ if(item.get('multiple')) {
+ item.get('clearFilter')(item);
+ }
+ });
+ this.get('oTable').fnFilterClear();
+ this.set('filtered',this.get('oTable').fnSettings().fnRecordsDisplay());
+ },
+ /**
+ * apply each filter to dataTable
+ *
+ * @param {parentView}
+ * @param {iColumn} number of column by which filter
+ * @param {value}
+ */
+ applyFilter:function(parentView, iColumn, value){
+ value = (value) ? value : '';
+ parentView.get('oTable').fnFilter(value, iColumn);
+ parentView.set('filtered',parentView.get('oTable').fnSettings().fnRecordsDisplay());
},
-//Column filter views
+ /**
+ * refresh average info in top block when filtered changes
+ */
+ averageRefresh:function(){
+
+ }.observes('filtered'),
+ /**
+ * dataTable filter views
+ */
typeSelectView: Em.Select.extend({
classNames:['input-small'],
selected: 'Any',
@@ -172,8 +309,7 @@ App.MainAppsView = Em.View.extend({
placeholder: 'Any ',
elementId: 'output_filter',
filtering:function(){
- this._parentView.get('oTable').fnFilter('' ,6);
- this._parentView.set('filtered',this._parentView.get('oTable').fnSettings().fnRecordsDisplay());
+ this.get('parentView').get('applyFilter')(this.get('parentView'), 6);
}.observes('value')
}),
durationFilterView: Em.TextField.extend({
@@ -182,11 +318,66 @@ App.MainAppsView = Em.View.extend({
placeholder: 'Any ',
elementId: 'duration_filter',
filtering:function(){
- this._parentView.get('oTable').fnFilter('' ,7);
- this._parentView.set('filtered',this._parentView.get('oTable').fnSettings().fnRecordsDisplay());
+ this.get('parentView').get('applyFilter')(this.get('parentView'), 7);
}.observes('value')
}),
-
+ userFilterView: Em.View.extend({
+ classNames:['btn-group'],
+ classNameBindings: ['open'],
+ multiple:true,
+ open: false,
+ isApplyDisabled:true,
+ users:function(){
+ var users = new Array();
+ for(var i = 0; i < this.get('parentView').get('users').length; i++)
+ users.push(Ember.Object.create({
+ name:this.get('parentView').get('users')[i],
+ checked:false
+ }));
+ return users;
+ }.property('parentView.users'),
+ template: Ember.Handlebars.compile(
+ '<button class="btn btn-info" '+
+ '{{action "clickFilterButton" target="view"}}>'+
+ 'User <span class="caret"></span></button>'+
+ '<ul class="dropdown-menu filter-components">'+
+ '<li><label class="checkbox">' +
+ '{{view Ember.Checkbox checkedBinding="view.allComponentsChecked"}} All</label></li>'+
+ '{{#each user in view.users}}<li><label class="checkbox">' +
+ '{{view Ember.Checkbox checkedBinding="user.checked"}}{{user.name}}'+
+ '</label></li>{{/each}}</ul>'+
+ '<button {{bindAttr disabled="view.isApplyDisabled"}}'+
+ 'class="btn" {{action "applyFilter" target="view"}}>'+
+ 'Apply</button>'
+ ),
+ allComponentsChecked:false,
+ toggleAllComponents: function(){
+ var checked = this.get('allComponentsChecked');
+ this.get('users').forEach(function(item){
+ item.set('checked',checked);
+ });
+ }.observes('allComponentsChecked'),
+ clickFilterButton:function(event){
+ this.set('open', !this.get('open'));
+ this.set('isApplyDisabled', !this.get('isApplyDisabled'));
+ },
+ clearFilter:function(self){
+ self.set('allComponentsChecked', true);
+ self.set('allComponentsChecked', false);
+ jQuery('#user_filter').val([]);
+ self.get('parentView').get('oTable').fnFilter('', 3);
+ },
+ applyFilter:function(){
+ var chosenUsers = new Array();
+ this.set('open', !this.get('open'));
+ this.set('isApplyDisabled', !this.get('isApplyDisabled'));
+ this.get('users').forEach(function(item){
+ if(item.get('checked')) chosenUsers.push(item.get('name'));
+ });
+ jQuery('#user_filter').val(chosenUsers);
+ this.get('parentView').get('applyFilter')(this.get('parentView'), 3);
+ }
+ }),
/**
* This Container View is used to render static table row(appTableRow) and additional dynamic content
*/
@@ -198,7 +389,7 @@ App.MainAppsView = Em.View.extend({
id: function(){
return this.get('run.id');
}.property("run.id"),
-
+ currentId: null,
/**
* Variable for dynamic view
*/
@@ -208,10 +399,11 @@ App.MainAppsView = Em.View.extend({
* Show additional content appropriated for this row
*/
expand : function(){
- var view = Ember.TextArea.create();
+ var view = App.MainAppsItemView.create();
this.set('contentView', view);
this.get('childViews').pushObject(view);
- this.set('controller.expandedRowId', this.get('id'));
+ this.set('currentId', this.get('id'));
+ //this.set('controller.expandedRowId', this.get('id'));
},
/**
@@ -228,6 +420,7 @@ App.MainAppsView = Em.View.extend({
}),
appTableRow: Em.View.extend({
+ templateName : require('templates/main/apps/list_row'),
classNames:['app-table-row'],
classNameBindings: ['rowClass'],
tagName: "tr",
@@ -245,31 +438,10 @@ App.MainAppsView = Em.View.extend({
this.get('parentView').expand();
- if(!target.next().hasClass("under-row")){
- $(".under-row").remove();
- this.drawUnderRow(target);
- }else{
- $(".under-row").remove();
- }
},
rowClass: function () {
return this.get('rowOpened') ? "row-opened" : "row-closed";
- }.property('rowOpened'),
- drawUnderRow:function(elem){
- $("" +
- "<tr class='under-row'>" +
- "<td colspan='9'>" +
- 'DAG & BAR placeholder'
- + "</td>" +
- "</tr>").insertAfter(elem);
- /*this.Appview = App.MainAppsRunsJobsView.create();
- this.Appview.appendTo('#hhhh');*/
- },
- deleteUnderRow: function(elem){
- elem.prev().remove();
- },
-
- templateName : require('templates/main/apps/list_row')
+ }.property('rowOpened')
})