Преглед на файлове

AMBARI-6584 Config History: Implement Config Version History Flow UI (with mock data). (atkach)

atkach преди 11 години
родител
ревизия
98f531d398

+ 1 - 0
ambari-web/app/messages.js

@@ -1932,6 +1932,7 @@ Em.I18n.translations = {
   'dashboard.configHistory.table.empty' : 'No history to display',
   'dashboard.configHistory.table.filteredHostsInfo': '{0} of {1} versions showing',
   'dashboard.configHistory.table.current': '(Current)',
+  'dashboard.configHistory.info-bar.authoredOn': 'authored on',
 
   'timeRange.presets.1hour':'1h',
   'timeRange.presets.12hour':'12h',

+ 111 - 1
ambari-web/app/styles/application.less

@@ -4846,7 +4846,117 @@ ul.inline li {
   }
 }
 
-.table {
+#config_history_flow {
+  .version-slider {
+    width: 100%;
+    height: 100px;
+    margin: 10px 0;
+    .flow-element {
+      width: 20%;
+      height: 100%;
+      .box {
+        position: relative;
+        width: 73%;
+        height: 100%;
+        background-color: #dcdcdc;
+        border: 1px solid #000000;
+        .top-right-label {
+          background-color: white;
+          position: absolute;
+          top: 0;
+          left: 0;
+          width: 20px;
+          border: solid #000000;
+          border-width: 0 1px 1px 0;
+          padding: 5px;
+          text-align: center;
+        }
+        .date {
+          margin-left: 35px;
+          line-height: 30px;
+          white-space: nowrap;
+        }
+        .content {
+          padding: 0 5px;
+        }
+        .current-label {
+          position: absolute;
+          border-top: 1px solid black;
+          bottom: 0;
+          left: 0;
+          width: 100%;
+          text-align: center;
+          font-weight: bold;
+          border-radius: 0;
+          padding: 0;
+          font-size: 14px;
+          line-height: 20px;
+        }
+      }
+      .arrow-box {
+        width: 25%;
+        height: 100%;
+        margin-left: 1px;
+        .big-arrow-right {
+          height: 100%;
+          background-size: 100% 25%;
+          background-position: 50% center;
+        }
+      }
+    }
+    .first {
+      .arrow-box {
+        display: none;
+      }
+      .box {
+        width: 100%;
+      }
+      width: 15%;
+    }
+
+    .arrow-right {
+      margin: 20px -15px 20px 10px;
+      border-top: 30px solid transparent;
+      border-bottom: 30px solid transparent;
+    }
+    .arrow-left {
+      margin: 20px 10px 20px -15px;
+      border-top: 30px solid transparent;
+      border-bottom: 30px solid transparent;
+    }
+    .visibleArrow {
+      border-right-color: black;
+      border-left-color: black;
+    }
+  }
+  .version-info-bar {
+    height: 60px;
+    border: 2px solid #a9a9a9;
+    background-color: #dcdcdc;
+    margin: 10px 0;
+    padding: 5px;
+
+    .label-wrapper {
+      line-height: 30px;
+      margin-left: 10px;
+      .label {
+        font-size: 14px;
+        padding: 5px;
+      }
+    }
+  }
+}
+
+.pointer {
+  cursor: pointer;
+}
+
+.big-arrow-right {
+  background-repeat: no-repeat;
+  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAA2CAQAAAAYac0YAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAAFxIAABcSAWef0lIAAAC8SURBVGje7dfBDcIwDIXhv4h7uwmMkA1YjZGyQcMktBO0l6oEDhBQJMfoPZ9y8qcosmKonZ6RpaDunKr3FlhggQUWWGCBBRZYYOsI3Cy4Y7G2v81E4PY4Hqw9HzIQ8xtunfsCbp/7BPbAzcA+uDu49cmQZyJ44kL0xE0EL28XEoHZCzcRmL1Mhg3rg7tjPXAzLByJJoiB8/dYq5T+d0d6a6qwwgorrLDCCiussMIK+x/Yrjr3UriFXX/ZwVZCWg1F9uJ6aQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNC0wNy0yM1QxMzoxNzowNyswMjowMP0r3LUAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTQtMDctMjNUMTM6MTc6MDcrMDI6MDCMdmQJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==);
+}
+
+.advanced-header-table {
   th.first, td.first {
     border-left-width: 1px;
   }

+ 62 - 0
ambari-web/app/templates/common/configs/config_history_flow.hbs

@@ -0,0 +1,62 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+
+<div id="config_history_flow">
+  <div class="version-slider">
+      <div {{bindAttr class=":pull-left :arrow-left :visibleArrow view.showLeftArrow::hide"}} {{action shiftBack target="view"}}></div>
+      {{#each serviceVersion in view.visibleServiceVersion}}
+          <div {{bindAttr class=":flow-element :pull-left serviceVersion.first:first"}}>
+              <div class="arrow-box pull-left"><div class="big-arrow-right"></div></div>
+              <div class="box pull-right">
+                  <div class="top-right-label">{{serviceVersion.version}}</div>
+                  <p class="date">{{serviceVersion.date}}</p>
+                  <p class="content">{{serviceVersion.author}}:&nbsp;{{serviceVersion.notes}}</p>
+                  {{#if serviceVersion.current}}
+                    <div class="current-label label label-success">{{t common.current}}</div>
+                  {{/if}}
+              </div>
+          </div>
+      {{/each}}
+      <div {{bindAttr class=":arrow-right :visibleArrow view.showRightArrow::hide"}} {{action shiftForward target="view"}}></div>
+  </div>
+  <div class="version-info-bar">
+    <div class="row-fluid">
+        <div class="btn-group pull-left">
+            <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+                <i class="icon-random"></i>
+                <span class="caret"></span>
+            </a>
+            <ul class="dropdown-menu">
+
+            </ul>
+        </div>
+        <div class="label-wrapper span8">
+            <span class="label label-success">{{t common.current}}: {{view.currentServiceVersion.version}}</span>
+            <strong>{{view.currentServiceVersion.author}}</strong>&nbsp;{{t dashboard.configHistory.info-bar.authoredOn}}&nbsp;<strong>{{view.currentServiceVersion.date}}</strong>
+        </div>
+        <div class="pull-right">
+            <div class="btn">{{t common.cancel}}</div>
+            <div class="btn btn-success">{{t common.save}}</div>
+        </div>
+    </div>
+    <div class="label-wrapper">
+      {{view.shortNotes}} {{#if view.showMoreLink}}<a class="pointer">{{t jobs.hive.more}}</a>{{/if}}
+    </div>
+  </div>
+</div>

+ 5 - 0
ambari-web/app/templates/common/configs/service_config.hbs

@@ -76,6 +76,11 @@
      </div>
 	</div>
 {{/if}}
+
+{{#if view.showConfigHistoryFlow}}
+  {{view App.ConfigHistoryFlowView serviceBinding="selectedService"}}
+{{/if}}
+
 <div class="accordion">
   {{#each category in selectedService.configCategories}}
     {{#if category.isCustomView}}

+ 1 - 1
ambari-web/app/templates/main/dashboard/config_history.hbs

@@ -17,7 +17,7 @@
 }}
 
 <div id="config_history">
-    <table class="table table-bordered table-striped" >
+    <table class="table advanced-header-table table-bordered table-striped" >
         <thead>
         {{#view view.sortView classNames="label-row"}}
             {{view view.parentView.versionSort}}

+ 1 - 1
ambari-web/app/templates/main/host.hbs

@@ -55,7 +55,7 @@
     </div>
   </div>
 
-  <table class="table table-bordered table-striped" id="hosts-table">
+  <table class="table advanced-header-table table-bordered table-striped" id="hosts-table">
     <thead>
       {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
         <th class="first"> </th>

+ 1 - 1
ambari-web/app/templates/main/jobs.hbs

@@ -29,7 +29,7 @@
          {{t jobs.type}} : <span class="label label-info">{{t jobs.type.hive}}</span>
         </div>
       </div>
-      <table id="jobs-table" class="table table-bordered table-striped">
+      <table id="jobs-table" class="table advanced-header-table table-bordered table-striped">
           <thead>
           {{#view view.sortView classNames="label-row" contentBinding="view.content"}}
               <th></th>

+ 1 - 1
ambari-web/app/templates/main/mirroring/datasets.hbs

@@ -46,7 +46,7 @@
           </div>
         {{/if}}
       </div>
-      <table class="table table-bordered dataset-thead">
+      <table class="table advanced-header-table table-bordered dataset-thead">
         <thead>
           {{#view view.sortView contentBinding="view.filteredContent" class="label-row"}}
             <th class="first"></th>

+ 1 - 0
ambari-web/app/views.js

@@ -32,6 +32,7 @@ require('views/common/form/field');
 require('views/common/quick_view_link_view');
 require('views/common/configs/services_config');
 require('views/common/configs/overriddenProperty_view');
+require('views/common/configs/config_history_flow');
 require('views/common/filter_combobox');
 require('views/common/filter_combo_cleanable');
 require('views/common/table_view');

+ 169 - 0
ambari-web/app/views/common/configs/config_history_flow.js

@@ -0,0 +1,169 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.ConfigHistoryFlowView = Em.View.extend({
+  templateName: require('templates/common/configs/config_history_flow'),
+
+  /**
+   * index of the first element(service version box) in viewport
+   */
+  startIndex: 0,
+  showLeftArrow: true,
+  showRightArrow: false,
+
+  currentServiceVersion: function () {
+    return this.get('serviceVersions').findProperty('current');
+  }.property('serviceVersions.@each.current'),
+  /**
+   * identify whether to show link that open whole content of notes
+   */
+  showMoreLink: function () {
+    //100 is number of symbols that fit into label
+    return (this.get('currentServiceVersion.notes.length') > 100);
+  }.property('currentServiceVersion.notes.length'),
+  /**
+   * formatted notes ready to display
+   */
+  shortNotes: function () {
+    //100 is number of symbols that fit into label
+    if (this.get('showMoreLink')) {
+      return this.get('currentServiceVersion.notes').slice(0, 100) + '...';
+    }
+    return this.get('currentServiceVersion.notes');
+  }.property('currentServiceVersion'),
+  /**
+   * service versions which in viewport and visible to user
+   */
+  visibleServiceVersion: function () {
+    return this.get('serviceVersions').slice(this.get('startIndex'), (this.get('startIndex') + 5));
+  }.property('startIndex'),
+
+  willInsertElement: function () {
+    var serviceVersions = this.get('serviceVersions');
+    var startIndex = 0;
+    var numberOfDisplayed = 5;
+
+    if (serviceVersions.length > numberOfDisplayed) {
+      startIndex = serviceVersions.length - numberOfDisplayed;
+      this.set('startIndex', startIndex);
+      this.adjustFlowView();
+    }
+  },
+  /**
+   *  define the first element in viewport
+   *  change visibility of arrows
+   */
+  adjustFlowView: function () {
+    var startIndex = this.get('startIndex');
+
+    this.get('serviceVersions').forEach(function (serviceVersion, index) {
+      serviceVersion.set('first', (index === startIndex));
+    });
+    this.set('showLeftArrow', (startIndex !== 0));
+    this.set('showRightArrow', ((startIndex + 5) !== this.get('serviceVersions.length')));
+  },
+  serviceVersions: [
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '1',
+      date: 'Apr 4, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '2',
+      date: 'Apr 4, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '3',
+      date: 'Apr 4, 2014',
+      author: 'user',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '4',
+      date: 'Apr 4, 2014',
+      author: 'user',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '5',
+      date: 'Apr 4, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '22',
+      date: 'Apr 9, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '33',
+      date: 'Apr 9, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '44',
+      date: 'Apr 9, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '55',
+      date: 'Apr 9, 2014',
+      author: 'admin',
+      notes: 'notes'
+    }),
+    Em.Object.create({
+      serviceName: 'HDFS',
+      version: '666',
+      date: 'Apr 9, 2014',
+      author: 'admin',
+      notes: 'notes',
+      current: true
+    })
+  ],
+  /**
+   * move back to the previous service version
+   */
+  shiftBack: function () {
+    this.decrementProperty('startIndex');
+    this.adjustFlowView();
+  },
+  /**
+   * move forward to the next service version
+   */
+  shiftForward: function () {
+    this.incrementProperty('startIndex');
+    this.adjustFlowView();
+  }
+});

+ 4 - 0
ambari-web/app/views/common/configs/services_config.js

@@ -48,6 +48,10 @@ App.ServiceConfigView = Em.View.extend({
         return false;
     }
   }.property('controller.name', 'controller.selectedService'),
+  showConfigHistoryFlow: function() {
+    //TODO change condition to actual
+    return (this.get('controller.name') === 'mainServiceInfoConfigsController' && this.get('controller.selectedConfigGroup.isDefault'))
+  }.property('controller.name', 'controller.selectedConfigGroup.isDefault'),
   toggleRestartMessageView: function () {
     this.$('.service-body').toggle('blind', 200);
     this.set('isRestartMessageCollapsed', !this.get('isRestartMessageCollapsed'));