Bläddra i källkod

AMBARI-990. Refactor App Browser. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1406897 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 år sedan
förälder
incheckning
573ef74745

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -388,6 +388,8 @@ AMBARI-666 branch (unreleased changes)
   AMBARI-676. Seperate directory for ambari-server. (jitendra)
 
   IMPROVEMENTS
+ 
+  AMBARI-990. Refactor App Browser. (yusaku)
 
   AMBARI-979. More refactoring of App Browser code. (yusaku)
 

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 18 - 14
ambari-web/app/models/job.js


+ 1 - 1
ambari-web/app/models/run.js

@@ -34,7 +34,7 @@ App.Run = DS.Model.extend({
   appId:DS.attr('number'),
   jobs:DS.hasMany('App.Job'),
   duration: function() {
-    return date.dateFormatInterval(((parseInt(this.get('lastUpdateTime')) - parseInt(this.get('startTime')))/1000));
+    return date.dateFormatInterval(parseInt((parseInt(this.get('lastUpdateTime')) - parseInt(this.get('startTime')))/1000));
   }.property('lastUpdateTime', 'startTime'),
   isRunning: function () {
     if (!this.get('isLoaded')) {

+ 70 - 2
ambari-web/app/styles/apps.less

@@ -18,11 +18,14 @@
   .dropdown-menu label.checkbox {
     margin-left: 10px;
   }
-  span.icon-star{
+  .icon-star{
     color: gray;
     &.stared {
       color: inherit;
     }
+    &:hover {
+      text-decoration: none;
+    }
   }
   a.a {
     cursor: pointer;
@@ -54,12 +57,15 @@
   .clear {
     clear:both;
   }
-  .dataTable {
+  > div > .dataTable {
     border: 1px solid silver;
     th {
       border-top:none;
     }
   }
+  .content {
+    padding: 0;
+  }
   .app-table-row.hover{
     opacity:0.8 ;
   }
@@ -69,6 +75,12 @@
   #filter_info {
     float:left;
     padding-top:10px;
+
+    > .span3 > a.selected{
+      cursor: default;
+      text-decoration: none;
+      color: #000;
+    }
   }
   .page-bar {
     border: 1px solid silver;
@@ -93,5 +105,61 @@
       }
     }
   }
+  #graph1 {
+    margin-left: 30px;
+  }
+  #graph2 {
+    margin-right: 30px;
+  }
+
+  tr.containerRow > td{
+    background: #f9f9f9;
+  }
+
+  svg{
+    vertical-align: top; //remove extra spaces after svg element
+  }
+
+  ul.nav-tabs{
+    margin-bottom: 0;
+  }
+
+  #jobs, #bars{
+    border: 1px solid #ddd;
+    border-top: none;
+    background: #fff;
+    padding: 10px;
+    box-sizing: border-box;
+  }
+
+  #jobs h2{
+    margin-top: 0;
+  }
+//fix stripped in inner table
+  .table-striped tbody tr:nth-child(odd)
+  td .table-striped tbody
+  tr:nth-child(odd) td,
+  tr:nth-child(even) th{
+    background: none;
+  }
+
+  .sorting_asc { background: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAgICAgICAgICAwMDAwMDAwMDAwEBAQEBAQECAQECAgIBAgIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD/8AAEQgAEwATAwERAAIRAQMRAf/EAHgAAAMBAQAAAAAAAAAAAAAAAAAFCAYKAQACAQUAAAAAAAAAAAAAAAAABQMCBAYHCBAAAQUAAQMEAwAAAAAAAAAAAwECBAUGABESByExIghBMxQRAAIBAwMDAwUAAAAAAAAAAAECAwAEBRESBiExUUHhB2GBIhMU/9oADAMBAAIRAxEAPwDvA8k+Qc54sxGj32qlNi0ucrjTj/JqGlmROyJXQ2u/bOsZTmBExPd70/HXmQcW41lOX5+145h0L391KEHhR3Z28Ii6sx9AKgubiO1gaeU6Io19h9TUg/S/7eP+wia3NbBIFbuqiyn3VTCjIMArHHTJarEDGGiNU8vOKVsc7/VxBuGR3yV683X86/Cq/GpssrhP2S8emiSKRm1JS5VfyLH0WfQug7KwZR0CilWHy39++ObQTgkgeV9ux+xq9uc6U8pLfZzP6mClZpKWrvq1DilJAt4Mewh/0hRyBOsaUMoVKLvXtVU6t6+nL/HZTJYi4/rxU81tdbSu+N2Rtp7jcpB0OnUa9aoeOOVdsgDL4I1pFS+NPHmcsQ2+fw+UpLWOwwwWNVQ1kCaIcgaiONkmLGEZrDDXtcnXo5PfjC+5VybKWrWWSyF5cWbEEpJNI6kqdQSrMRqD1B9KjS2t423xoqt5AArb8QVPRwoo4UUcKK//2Q==) no-repeat 85% 50%; }
+  .sorting_desc { background: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAgICAgICAgICAwMDAwMDAwMDAwEBAQEBAQECAQECAgIBAgIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD/8AAEQgAEwATAwERAAIRAQMRAf/EAIEAAAIDAQAAAAAAAAAAAAAAAAAGBwgJCgEBAAIDAQAAAAAAAAAAAAAAAAMFBAYHCBAAAAUDAwMFAAAAAAAAAAAAAQIDBAUABgcSNTYRFQgTZFUWZhEAAAQEAggGAwAAAAAAAAAAAAECAxEhBAYSMjFBYRMzFDQFUZFSYmMHJFRk/9oADAMBAAIRAxEAPwDv4oAKACgCKc1tMmusb3Eph6cSgsgx7fucEZxGRks2llGIGVWgVm8q1dt0+6ogKaapSgdNbQPXTqAdwsN602bopk3vTnUW24rduwccbU2S5E8Sm1JM92czSZwNOKUYDFrCqTp1corDUFMpEcYap+Ipb4P5O8n81y9xXXlG50yY+thR3AEivqFvRDmduvSUrhuLtrFNXqCFvJm1LAQ5RMuchB6gBy13f7+tP6lsOipuz2jSGdy1ZJeNzmXnEtU+pWFTikmbxyTEjgglKKZpMU3ZanudYtTtSr8dMoYSKKvKMte0aUV5YGxgoASbD2iQ4Tyi6uB7Rvz/AHD9R8r7/wBWr64uta6/pKfq+JwUZP5/1/hwCFjIeTMrLo0np93q2xDtVCJh/9k=) no-repeat 85% 50%; }
+  .sorting { background: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAgICAgICAgICAwMDAwMDAwMDAwEBAQEBAQECAQECAgIBAgIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD/8AAEQgAEwATAwERAAIRAQMRAf/EAGgAAAIDAQAAAAAAAAAAAAAAAAUHAAYICgEBAQAAAAAAAAAAAAAAAAAAAAEQAAEEAQIFAgcAAAAAAAAAAAECAwQFABEGIRI0NQcTFDFBMmNUZRYRAQEBAQAAAAAAAAAAAAAAAAABEUH/2gAMAwEAAhEDEQA/AO93cd/XbXpLC9tHQ1Dr46nljUBby/gzGZB+p+Q6QhA+ZOApfDnllW/ha1tv6Ee7iyH5kRlvlbTIqHndWkNJ0HO7XFQbWeJUkpUeOpySrZh65UUnyFUW1ztaexRmIbaPyzoLE6vg2UWW9GC1e0XHnsSGEqfQohCwApK9OIGuAjfBP9VuG0m39vGqINVUe4r2xF21TVsuXZOI9N9lMmLBYkttQ21auBKhqtSUngCMkW5xqjKiYASh6SR2Tulr2HpOvf6j9p+V9/mwDeB//9k=) no-repeat 85% 50%; }
+
+  a.paginate_disabled_next, a.paginate_disabled_previous {
+    color: gray;
+    &:hover {
+      color: gray;
+      text-decoration: none;
+    }
+  }
+
+  a.paginate_enabled_next, a.paginate_enabled_previous {
+    &:hover {
+      text-decoration: none;
+    }
+  }
+
 }
 

+ 27 - 21
ambari-web/app/templates/main/apps.hbs

@@ -16,10 +16,10 @@
 * limitations under the License.
 -->
 <div id="apps">
-  <div class="breadcrumb">
+  <!--<div class="breadcrumb">
     <li><a href='#' {{action "routeHome" target="controller"}}><i class="icon-home"></i></a><span class="divider">/</span></li>
     <li class="active">Apps</li>
-  </div>
+  </div>-->
   <table class="table table-bordered table-stripe avg-table" >
             <tbody>
             <tr >
@@ -54,7 +54,11 @@
             </tbody>
   </table>
     <div id="filter_info" class="row">
-      <div class="span3">Show: <a href="javascript:void(0)">Filtered ({{view.filtered}})</a>&nbsp;&#124;&nbsp;<a href="javascript:void(0)">Starred ({{view.staredData.count}})</a></div>
+      <div class="span3">Show:
+        <a href="javascript:void(0)" class="selected" {{action "changeViewType" target="view"}} data-view-type="all">All ({{view.content.length}})</a> &#124;
+        <a href="javascript:void(0)" {{action "changeViewType" target="view"}} data-view-type="filtered">Filtered ({{view.filtered}})</a> &#124;
+        <a href="javascript:void(0)" {{action "changeViewType" target="view"}} data-view-type="starred">Starred ({{view.staredData.count}})</a>
+      </div>
       <div class="span2"><a href="#" {{action "clearFilters" target="view"}}>Clear filters</a>&nbsp;&#124;&nbsp;<a href="#" {{action "clearStars" target="controller"}}>Clear stars</a></div>
     </div>
     <div>
@@ -62,27 +66,29 @@
     <table class="table table-striped" id="dataTable">
     <thead>
     <tr>
-      <th>App ID <i class="icon-question-sign"></i></th>
-      <th>Name <i class="icon-question-sign"></i></th>
-      <th>Type <i class="icon-question-sign"></i></th>
-      <th>User <i class="icon-question-sign"></i></th>
-      <th>Jobs <i class="icon-question-sign"></i></th>
-      <th>Input <i class="icon-question-sign"></i></th>
-      <th>Output <i class="icon-question-sign"></i></th>
-      <th>Duration <i class="icon-question-sign"></i></th>
+      <th></th>
+      <th>App ID</th>
+      <th>Name</th>
+      <th>Type</th>
+      <th>User</th>
+      <th>Jobs</th>
+      <th>Input</th>
+      <th>Output</th>
+      <th>Duration</th>
       <th>Run Date</th>
     </tr>
     <tr>
-          <th>{{view view.appidFilterView}}</th>
-          <th>{{view view.nameFilterView}}</th>
-          <th>{{view view.typeSelectView}}</th>
-          <th>{{view view.userFilterView}}<input id="user_filter" type="hidden"></th>
-          <th>{{view view.jobsFilterView}}</th>
-          <th>{{view view.inputFilterView}}</th>
-          <th>{{view view.outputFilterView}}</th>
-          <th>{{view view.durationFilterView}}</th>
-          <th>{{view view.rundateSelectView}}</th>
-        </tr>
+      <th></th>
+      <th>{{view view.appidFilterView}}</th>
+      <th>{{view view.nameFilterView}}</th>
+      <th>{{view view.typeSelectView}}</th>
+      <th>{{view view.userFilterView}}<input id="user_filter" type="hidden"></th>
+      <th>{{view view.jobsFilterView}}</th>
+      <th>{{view view.inputFilterView}}</th>
+      <th>{{view view.outputFilterView}}</th>
+      <th>{{view view.durationFilterView}}</th>
+      <th>{{view view.rundateSelectView}}</th>
+    </tr>
     </thead>
     <tbody>
     {{#each run in view.content}}

+ 11 - 11
ambari-web/app/templates/main/apps/item.hbs

@@ -15,17 +15,17 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 -->
-<td colspan="9">
-<ul class="nav nav-tabs">
-  {{#each tab in view.menuTabs}}
-  <li {{bindAttr class="tab.active"}} {{action "switchTab" tab target="view" }}>
-  <a href="javascript:void(0)">{{tab.label}}</a>
-  </li>
-  {{/each}}
-</ul>
-<div id="content">
-  {{view view.containerView currentViewBinding="App.MainAppsItemDagView"}}
-</div>
+<td colspan="10">
+  <ul class="nav nav-tabs">
+    {{#each tab in view.menuTabs}}
+    <li {{bindAttr class="tab.active"}} {{action "switchTab" tab target="view" }}>
+      <a href="javascript:void(0)">{{tab.label}}</a>
+    </li>
+    {{/each}}
+  </ul>
+  <div class="content">
+    {{view view.containerView currentViewBinding="App.MainAppsItemDagView"}}
+  </div>
  </td>
 
 

+ 10 - 12
ambari-web/app/templates/main/apps/item/bar.hbs

@@ -16,42 +16,40 @@
 * limitations under the License.
 -->
 
-<h2>Bar</h2>
 <div class="btn-group">
   <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
-    Job
+    Job {{view.activeJob.id}} - {{view.activeJob.jobId}}
     <span class="caret"></span>
   </button>
   <ul class="dropdown-menu">
     {{#each job in view.content}}
-    <li><a {{action "selectJob" job target="view"}} href="javascript:void(null)">{{job.id}}</a></li>
+    <li><a {{action "selectJob" job target="view"}} href="javascript:void(null)">Job {{job.id}} - {{job.jobId}}</a></li>
     {{/each}}
   </ul>
 </div>
 <div></div>
-<div id="graph1">
+<div id="graph1" class="pull-left">
   <div style="float:left">
     <div id="graph1_desc" class="graph_desc">
-      Job Timeline
+      <h4>Job Timeline</h4>
     </div>
     <div id="chart"></div>
     <div id="timeline1"></div>
   </div>
-  <div id="legend_container" style="float:left;margin-top:60px">
+  <div id="legend_container" style="margin-top:60px">
     <div id="legend"></div>
   </div>
-  <div style="clear: both"></div>
 </div>
-<div id="graph2">
+<div id="graph2" class="pull-right">
   <div style="float:left">
     <div id="graph2_desc" class="graph_desc">
-      Job Tasks' View
+      <h4>Job Tasks' View</h4>
     </div>
     <div id="job_tasks"></div>
     <div id="timeline2"></div>
   </div>
-  <div id="tasks_legend_container" style="float:left;margin-top:60px">
+  <div id="tasks_legend_container" style="margin-top:60px">
     <div id="tasks_legend"></div>
   </div>
-  <div style="clear: both"></div>
-</div>
+</div>
+<div class="clearfix"></div>

+ 6 - 11
ambari-web/app/templates/main/apps/item/dag.hbs

@@ -15,12 +15,8 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 -->
-<div id="jobs" class="box">
-  <div class="box-header">
-    <div>
-      <div id="dag_viewer"></div>
-    </div>
-    <h2>Jobs list</h2>
+    <div id="dag_viewer"></div>
+
     <table class="table table-bordered table-striped" id="innerTable">
       <thead>
       <tr>
@@ -40,15 +36,14 @@
         <td>{{job.id}}</td>
         <td>{{job.jobId}}</td>
         <td>{{job.status}}</td>
-        <td>{{job.maps}}</td>
-        <td>{{job.reduces}}</td>
+        <td>{{job.maps}}&nbsp;({{job.mapsProgress}}%)</td>
+        <td>{{job.reduces}}&nbsp;({{job.reducesProgress}}%)</td>
         <td>{{job.input}}</td>
         <td>{{job.output}}</td>
-        <td>{{job.mapsRuntime}}</td>
+        <td>{{job.duration}}</td>
       </tr>
       {{/each}}
       </tbody>
     </table>
-  </div>
-</div>
+
 

+ 2 - 1
ambari-web/app/templates/main/apps/list_row.hbs

@@ -16,7 +16,8 @@
 * limitations under the License.
 -->
 
-<td><a href='#' {{action "starClick" target="controller"}}"><span class="icon-star"></span><span class="hidden">{{run.id}}</span></a>&nbsp;<a href="javascript:void(0)">ID&nbsp;{{run.appId}}</a></td>
+<td><a href="#" {{action "starClick" target="controller"}}"><span class="icon-star"></span><span class="hidden">{{run.id}}</span></a></td>
+<td><a href="javascript:void(0)">ID&nbsp;{{run.appId}}</a></td>
 <td>{{run.appName}}</td>
 <td>{{run.type}}</td>
 <td>{{run.userName}}</td>

+ 6 - 7
ambari-web/app/utils/data_table.js

@@ -113,12 +113,12 @@ jQuery.extend(jQuery.fn.dataTableExt.oApi, {
 jQuery.extend($.fn.dataTableExt.afnFiltering.push(
     function (oSettings, aData, iDataIndex) {
       var inputFilters = [
-        {iColumn: '3', elementId: 'user_filter', type: 'multiple'},
-        {iColumn: '4', elementId: 'jobs_filter', type: 'number' },
-        {iColumn: '5', elementId: 'input_filter', type: 'number' },
-        {iColumn: '6', elementId: 'output_filter', type: 'number' },
-        {iColumn: '7', elementId: 'duration_filter', type: 'time' },
-        {iColumn: '8', elementId: 'rundate_filter', type: 'date' }
+        {iColumn: '4', elementId: 'user_filter', type: 'multiple'},
+        {iColumn: '5', elementId: 'jobs_filter', type: 'number' },
+        {iColumn: '6', elementId: 'input_filter', type: 'number' },
+        {iColumn: '7', elementId: 'output_filter', type: 'number' },
+        {iColumn: '8', elementId: 'duration_filter', type: 'time' },
+        {iColumn: '9', elementId: 'rundate_filter', type: 'date' }
       ];
       var match = true;
       for (i = 0; i < inputFilters.length; i++) {
@@ -246,7 +246,6 @@ jQuery.extend($.fn.dataTableExt.afnFiltering.push(
 )
 );
 
-
 jQuery.extend(jQuery.fn.dataTableExt.oApi, {
   "fnFilterClear": function (oSettings) {
     /* Remove global filter */

+ 1 - 0
ambari-web/app/views/main/apps/item/bar_view.js

@@ -20,6 +20,7 @@ var App = require('app');
 var graph = require('utils/graph');
 
 App.MainAppsItemBarView = Em.View.extend({
+    elementId: 'bars',
     templateName: require('templates/main/apps/item/bar'),
     content:function(){
         return this.get('parentView.jobs');

+ 32 - 10
ambari-web/app/views/main/apps/item/dag_view.js

@@ -20,17 +20,26 @@ var App = require('app');
 
 App.MainAppsItemDagView = Em.View.extend({
   templateName: require('templates/main/apps/item/dag'),
+  elementId : 'jobs',
   content:function(){
-    return this.get('parentView.jobs');
+    var content = this.get('parentView.jobs');
+    content.forEach(function(job){
+      job.set('mapsProgress', Math.round((job.get('finishedMaps') / job.get('maps'))*100));
+      job.set('reducesProgress', Math.round((job.get('finishedReduces') / job.get('reduces'))*100));
+    });
+    return content;
   }.property('parentView.jobs'),
   classNames:['table','dataTable'],
+  /**
+   * convert content to special jobs object for DagViewer
+   */
   jobs: function(){
     var c = this.get('content');
-    var result = new Array();
+    var result = [];
     c.forEach(function(item, index){
       result[index] = new Object({
         'name' : item.get('id'),
-        'status' : (item.get('status') == 'COMPLETE')? true : false,
+        'status' : item.get('status') == 'COMPLETE',
         'info' : [],
         'input' : 2,
         'output' : 3
@@ -39,12 +48,25 @@ App.MainAppsItemDagView = Em.View.extend({
     return result;
   }.property('content'),
   didInsertElement:function (){
-    var innerTable = this.$('#innerTable').dataTable({});
-    var dagSchema = this.get('parentView.parentView.run').get('workflowContext');
-    var jobs = this.get('content');
-    var graph = new DagViewer(false,'dag_viewer')
-        .setPhysicalParametrs(800,250,-800,0.01)
-        .setData(dagSchema,jobs)
-        .drawDag(10,20,100);
+    var innerTable = this.$('#innerTable').dataTable({
+      "sDom": 'rt<"page-bar"lip><"clear">',
+      "oLanguage": {
+        "sSearch": "<i class='icon-question-sign'>&nbsp;Search</i>",
+        "sLengthMenu": "Show: _MENU_",
+        "sInfo": "_START_ - _END_ of _TOTAL_",
+        "oPaginate":{
+          "sPrevious": "<i class='icon-arrow-left'></i>",
+          "sNext": "<i class='icon-arrow-right'></i>"
+        }
+      },
+      "iDisplayLength": 5,
+      "aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
+    });
+    var dagSchema = this.get('parentView.parentView.content').get('workflowContext');
+    var jobs = this.get('jobs');
+    var graph = new DagViewer(false, 'dag_viewer')
+        .setPhysicalParametrs(800, 250, -800, 0.01)
+        .setData(dagSchema, jobs)
+        .drawDag(10, 20, 100);
   }
 });

+ 21 - 17
ambari-web/app/views/main/apps/item_view.js

@@ -20,6 +20,7 @@ var App = require('app');
 
 App.MainAppsItemView = Em.View.extend({
   tagName: 'tr',
+  classNames : ['containerRow'],
   templateName:require('templates/main/apps/item'),
   menuTabs:[
     Em.Object.create({
@@ -28,39 +29,42 @@ App.MainAppsItemView = Em.View.extend({
       content:'App.MainAppsItemDagView'
     }),
     Em.Object.create({
-      label:'Jobs',
+      label:'Charts',
       active:'',
       content:'App.MainAppsItemBarView'
     })
   ],
-  run:function(){
-    return this.get('parentView.run');
-  }.property('parentView.run'),
+  content:function(){
+    return App.router.get('mainAppsItemController.content');
+  }.property('App.router.mainAppsItemController.content'),
   activeTab:null,
   switchTab:function(event){
     var tabs = this.get('menuTabs');
     for(var i = 0; i < tabs.length; i++){
-      if(tabs[i] === event.context) tabs[i].set('active', 'active');
-      else tabs[i].set('active', '');
+      if(tabs[i] === event.context){
+        tabs[i].set('active', 'active');
+      }
+      else {
+        tabs[i].set('active', '');
+      }
     }
     this.set('activeTab', event.context);
   },
+  didInsertElement: function(){
+    var tabs = this.get('menuTabs');
+    tabs[0].set('active', 'active');
+    tabs[1].set('active', '');
+  },
   containerView:Em.ContainerView.extend({
-    elementId:'cont',
     jobs:function(){
-      return this.get('parentView.run').get('jobs');
-    }.property('parentView.run'),
+      return this.get('parentView.content').get('jobs');
+    }.property('parentView.content'),
     onchange:function(){
-      var view;
-      if(this.get('parentView.activeTab').get('label') === 'DAG'){
-        var view = App.MainAppsItemDagView.create();
-      }
-      if(this.get('parentView.activeTab').get('label') === 'Jobs'){
-        var view = App.MainAppsItemBarView.create();
-      }
+      var view = this.get('parentView.activeTab.content').split('.')[1];
+      view = App[view].create();
+
       if(this.get('childViews')){
         this.get('childViews').get('firstObject').destroy();
-        this.get('childViews').removeObject(this.get('childViews').get('firstObject'));
       }
       this.get('childViews').pushObject(view);
     }.observes('parentView.activeTab')

+ 90 - 46
ambari-web/app/views/main/apps_view.js

@@ -27,16 +27,26 @@ App.MainAppsView = Em.View.extend({
    */
   content:function () {
     var content =  this.get('controller').get('content');
-    content.forEach(function(item){
-      var app = App.store.find(App.App, item.get('appId'));
-      item.set('appName', app.get('appName'));
-      item.set('type', app.get('type'));
-      item.set('numJobsTotal' ,item.get('jobs').get('content').length);
-      item.get('jobs').forEach(function(item) {
+    content.forEach(function(run){
+      var app = App.store.find(App.App, run.get('appId'));
+      run.set('appName', app.get('appName'));
+      run.set('type', app.get('type'));
+      run.set('numJobsTotal' ,run.get('jobs').get('content').length);
+      run.get('jobs').forEach(function(job) {
+
       });
     });
     return content;
   }.property('App.router.mainAppsController.content'),
+
+  /**
+   * Choose view type for apps list:
+   * all - show all runs
+   * filtered - show only filtered runs
+   * starred - show only filtered runs with stars selected
+   */
+  viewType : 'all',
+
   /**
    * List of users
    */
@@ -193,37 +203,61 @@ App.MainAppsView = Em.View.extend({
     };
     return ret;
   },
-  /**
-   * Reset filters
-   * @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');
-      }
-    });
-    this.get('oTable').fnFilterClear();
-    this.set('filtered',this.get('oTable').fnSettings().fnRecordsDisplay());
-  },
   /**
    * Click on big star on the avg block
    */
   avgStarClick: function() {
     this.set('whatAvgShow', !this.get('whatAvgShow'));
-    event.srcElement.classList.toggle('active');
+    $('a.icon-star.a').toggleClass('active');
   },
   /**
    * "turn off" stars in the table
    */
-  clearStars: function(){
+  clearStars: function() {
     if (this.get('controller.staredRunsLength') == 0 && this.get('smallStarsIcons') != null) {
       this.get('smallStarsIcons').removeClass('stared');
+      this.set('whatAvgShow', true);
+      $('a.icon-star.a').removeClass('active');
     }
   }.observes('controller.staredRunsLength'),
+  /**
+   * Reset filters and "turn off" stars
+   */
+  showAll: function() {
+    this.clearFilters();
+    this.clearStars();
+  },
+
+  /**
+   * Onclick handler for <code>Show All/Filtered/Starred</code> links
+   */
+  changeViewType: function(event){
+    if($(event.toElement).hasClass('selected')){
+      return;
+    }
+
+    $(event.toElement).parent().children('.selected').removeClass('selected');
+    $(event.toElement).addClass('selected');
+
+    var viewType = $(event.toElement).data('view-type');
+    console.log(viewType);
+
+    switch(viewType){
+      case 'all':
+        //do stuff here
+        break;
+
+      case 'starred':
+        break;
+
+      case 'filtered':
+      default:
+        //do stuff here
+        break;
+    };
+
+  },
+
   /**
    * jQuery dataTable init
    */
@@ -237,9 +271,11 @@ App.MainAppsView = Em.View.extend({
         // no need more. 31.10.2012
       },
       "oLanguage": {
-        "sSearch": "<i class='icon-question-sign'>&nbsp;Search</i>",
+        "sSearch": "Search:",
         "sLengthMenu": "Show: _MENU_",
-        "sInfo": "_START_ - _END_ of _TOTAL_",
+        "sInfo": "_START_ - _END_ of _TOTAL_ (_TOTAL_ total)",
+        "sInfoEmpty": "0 - _END_ of _TOTAL_ (_TOTAL_ total)",
+        "sInfoFiltered": "",
         "oPaginate":{
           "sPrevious": "<i class='icon-arrow-left'></i>",
           "sNext": "<i class='icon-arrow-right'></i>"
@@ -249,6 +285,7 @@ App.MainAppsView = Em.View.extend({
       "iDisplayLength": 10,
       "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
       "aoColumns":[
+        { "bSortable": false  },
         null,
         null,
         null,
@@ -316,9 +353,9 @@ App.MainAppsView = Em.View.extend({
     content:['Any', 'Pig', 'Hive', 'mapReduce'],
     change:function(event){
       if(this.get('selection') === 'Any') {
-        this._parentView.get('oTable').fnFilter('', 2);
+        this._parentView.get('oTable').fnFilter('', 3);
       } else {
-      this._parentView.get('oTable').fnFilter(this.get('selection'), 2);
+      this._parentView.get('oTable').fnFilter(this.get('selection'), 3);
       }
       this._parentView.set('filtered',this._parentView.get('oTable').fnSettings().fnRecordsDisplay());
     }
@@ -335,7 +372,7 @@ App.MainAppsView = Em.View.extend({
     classNames:['input-medium'],
     elementId: 'rundate_filter',
     change:function(event) {
-      this.get('parentView').get('applyFilter')(this.get('parentView'), 8);
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 9);
     }
   }),
   /**
@@ -345,8 +382,9 @@ App.MainAppsView = Em.View.extend({
     classNames:['input-small'],
     type:'text',
     placeholder: 'Any ID',
-    filtering:function(){
-        this.get('parentView').get('applyFilter')(this.get('parentView'), 0, this.get('value'));
+    elementId:'appid_filter',
+    filtering:function() {
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 1, this.get('value'));
     }.observes('value')
   }),
   /**
@@ -357,7 +395,7 @@ App.MainAppsView = Em.View.extend({
     type:'text',
     placeholder: 'Any Name',
     filtering:function(){
-      this.get('parentView').get('applyFilter')(this.get('parentView'), 1, this.get('value'));
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 2, this.get('value'));
     }.observes('value')
   }),
   /**
@@ -369,7 +407,7 @@ App.MainAppsView = Em.View.extend({
     placeholder: 'Any ',
     elementId:'jobs_filter',
     filtering:function(){
-      this.get('parentView').get('applyFilter')(this.get('parentView'), 4);
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 5);
     }.observes('value')
   }),
   /**
@@ -381,7 +419,7 @@ App.MainAppsView = Em.View.extend({
     placeholder: 'Any ',
     elementId: 'input_filter',
     filtering:function(){
-      this.get('parentView').get('applyFilter')(this.get('parentView'), 5);
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 6);
     }.observes('value')
   }),
   /**
@@ -393,7 +431,7 @@ App.MainAppsView = Em.View.extend({
     placeholder: 'Any ',
     elementId: 'output_filter',
     filtering:function(){
-        this.get('parentView').get('applyFilter')(this.get('parentView'), 6);
+        this.get('parentView').get('applyFilter')(this.get('parentView'), 7);
     }.observes('value')
   }),
   /**
@@ -405,7 +443,7 @@ App.MainAppsView = Em.View.extend({
     placeholder: 'Any ',
     elementId: 'duration_filter',
     filtering:function(){
-      this.get('parentView').get('applyFilter')(this.get('parentView'), 7);
+      this.get('parentView').get('applyFilter')(this.get('parentView'), 8);
     }.observes('value')
   }),
   /**
@@ -457,7 +495,7 @@ App.MainAppsView = Em.View.extend({
       jQuery('#user_filter').val([]);
       self.get('parentView').get('oTable').fnFilter('', 3);
     },
-    applyFilter:function(){
+    applyFilter:function() {
       var chosenUsers = new Array();
       this.set('open', !this.get('open'));
       this.set('isApplyDisabled', !this.get('isApplyDisabled'));
@@ -481,27 +519,33 @@ App.MainAppsView = Em.View.extend({
   containerRow : Em.ContainerView.extend({
 
     /**
-     * Uniq row id
+     * Unique row id
      */
-    id: function(){
+    id: function() {
       return this.get('run.id');
     }.property("run.id"),
-
+    /**
+     * Delete expanded row from table
+     *
+     * @param row
+     */
+    deleteRow:function(row){
+      row.get('rowChildView').destroy();
+      row.set('rowView', null);
+      row.set('rowChildView', null);
+    },
     /**
      * Show/hide additional content appropriated for this row
      */
     expandToggle : function(){
       var newView = App.MainAppsItemView.create();
       var expandedView = this.get('parentView.expandedRow');
+      App.router.get('mainAppsItemController').set('content', this.get('run'));
       if(expandedView.get('rowView')) {
         if(this === expandedView.get('rowView')) {
-          expandedView.get('rowView').get('childViews').removeObject(expandedView.get('rowChildView'));
-          expandedView.get('rowChildView').destroy();
-          expandedView.set('rowView', null);
-          expandedView.set('rowChildView', null);
+          this.get('deleteRow')(expandedView);
         } else {
-          //expandedView.get('rowView').get('childViews').removeObject(expandedView.get('rowChildView'));
-          expandedView.get('rowChildView').destroy();
+          this.get('deleteRow')(expandedView);
           expandedView.set('rowView', this);
           expandedView.set('rowChildView', newView);
           this.get('childViews').pushObject(newView);

Vissa filer visades inte eftersom för många filer har ändrats