You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by gn...@apache.org on 2017/02/24 17:18:01 UTC

ambari git commit: AMBARI-20142. Job Link URL not working.(Madhan Mohan Reddy via gauravn7)

Repository: ambari
Updated Branches:
  refs/heads/trunk f3877c132 -> 1d7ae2430


AMBARI-20142. Job Link URL not working.(Madhan Mohan Reddy via gauravn7)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1d7ae243
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1d7ae243
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1d7ae243

Branch: refs/heads/trunk
Commit: 1d7ae2430a4ca9735336fb86318c23d1584d8f1c
Parents: f3877c1
Author: Gaurav Nagar <gr...@gmail.com>
Authored: Fri Feb 24 22:47:46 2017 +0530
Committer: Gaurav Nagar <gr...@gmail.com>
Committed: Fri Feb 24 22:47:46 2017 +0530

----------------------------------------------------------------------
 .../ui/app/components/workflow-job-action.js    | 35 +++++++++++++++++
 .../ui/app/components/workflow-job-details.js   | 12 ++++--
 .../components/workflow-job-action.hbs          | 30 +++++++++++++++
 .../components/workflow-job-details.hbs         | 24 +++++-------
 .../main/resources/ui/app/utils/common-utils.js |  4 ++
 .../components/workflow-job-action-test.js      | 40 ++++++++++++++++++++
 6 files changed, 127 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-action.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-action.js
new file mode 100644
index 0000000..23a03c7
--- /dev/null
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-action.js
@@ -0,0 +1,35 @@
+/*
+*    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.
+*/
+import Ember from 'ember';
+import CommonUtils from "../utils/common-utils";
+
+export default Ember.Component.extend({
+  tagName: 'tr',
+  validTrackerUrl:Ember.computed('actionInfo.consoleUrl',function(){
+    var trackerUrl = this.get("actionInfo.consoleUrl");
+    if (trackerUrl && CommonUtils.startsWith(trackerUrl.trim(), "http")) {
+      return true;
+    }
+    return false;
+  }),
+
+  actions: {
+    getActionDetails(actionInfo) {
+      this.sendAction('getActionDetails', actionInfo)
+    }
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-details.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-details.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-details.js
index 7a868fa..dcbbab9 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-details.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/workflow-job-details.js
@@ -16,19 +16,25 @@
 */
 
 import Ember from 'ember';
+import CommonUtils from "../utils/common-utils";
+
 export default Ember.Component.extend({
   dagUrl:Ember.computed('model.id',function(){
     return Ember.ENV.API_URL+'/getDag?jobid='+this.get('model.id');
   }),
+  validTrackerUrl:Ember.computed('model.actionInfo.consoleUrl',function(){
+    var trackerUrl = this.get("model.actionInfo.consoleUrl");
+    if (trackerUrl && CommonUtils.startsWith(trackerUrl.trim(), "http")) {
+      return true;
+    }
+    return false;
+  }),
   actions :{
     getJobLog (params) {
       this.sendAction('getJobLog', params);
     },
     getActionDetails(action){
       this.sendAction('getActionDetails',action);
-    },
-    openConsoleUrl(url){
-      window.open(url, '_blank');
     }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-action.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-action.hbs
new file mode 100644
index 0000000..fe4c892
--- /dev/null
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-action.hbs
@@ -0,0 +1,30 @@
+{{!
+* 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.
+}}
+<td class="pointer action-link" {{action 'getActionDetails' actionInfo}}>{{actionInfo.name}}</td>
+<td>{{actionInfo.type}}</td>
+<td>{{actionInfo.status}}</td>
+<td>{{actionInfo.transition}}</td>
+<td>{{actionInfo.startTime}}</td>
+<td>{{actionInfo.endTime}}</td>
+<td>
+  {{#if validTrackerUrl}}
+    <a target="_blank" href="{{actionInfo.consoleUrl}}"><i class="fa fa-external-link action-link" aria-hidden="true"></i></a>
+  {{else}}
+    -
+  {{/if}}
+</td>

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-details.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-details.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-details.hbs
index b5565c8..dd972b9 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-details.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/workflow-job-details.hbs
@@ -83,20 +83,8 @@
         </tr>
       </thead>
       <tbody>
-        {{#each model.actions as |actionInfo|}}
-        <tr class="{{if (eq actionInfo model.actionDetails) "active"}}">
-          <td class="pointer action-link" {{action 'getActionDetails' actionInfo}}>{{actionInfo.name}}</td>
-          <td>{{actionInfo.type}}</td>
-          <td>{{actionInfo.status}}</td>
-          <td>{{actionInfo.transition}}</td>
-          <td>{{actionInfo.startTime}}</td>
-          <td>{{actionInfo.endTime}}</td>
-          {{#unless (eq "-" actionInfo.consoleUrl)}}
-            <td><a target="_blank" href="#" {{action 'openConsoleUrl'  actionInfo.consoleUrl preventDefault=true}}><i class="fa fa-external-link action-link" aria-hidden="true"></i></a></td>
-          {{else}}
-            <td>{{actionInfo.consoleUrl}}</td>
-          {{/unless}}
-        </tr>
+        {{#each model.actions as |actionInfo|}}        
+          {{workflow-job-action actionInfo=actionInfo getActionDetails="getActionDetails"}}
         {{/each}}
       </tbody>
     </table>
@@ -241,7 +229,13 @@
                 </div>
                 <div class="row">
                   <div class="col-md-4 text-bold">Job URL</div>
-                  <div class="col-md-8"><a target="_blank" href="{{model.actionInfo.consoleUrl}}"><i class="fa fa-external-link action-link" aria-hidden="true"></i></a></div>
+                  <div class="col-md-8">
+                    {{#if validTrackerUrl}}
+                      <a target="_blank" href="{{model.actionInfo.consoleUrl}}"><i class="fa fa-external-link action-link" aria-hidden="true"></i></a>
+                    {{else}}
+                      -
+                    {{/if}}
+                  </div>
                 </div>
                 <div class="row pull-right" {{action 'getActionDetails' model.actionInfo}}>
                   <div class="col-md-12">

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/app/utils/common-utils.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/utils/common-utils.js b/contrib/views/wfmanager/src/main/resources/ui/app/utils/common-utils.js
index 309c281..7ad4361 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/utils/common-utils.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/utils/common-utils.js
@@ -32,5 +32,9 @@ export default Ember.Object.create({
   },
   decodeXml(xml){
     return xml && xml.length > 0 ? xml.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '\"').replace(/&apos;/g, '\'') : xml;
+  },
+  startsWith (string,searchString, position){
+    position = position || 0;
+    return string.substr(position, searchString.length) === searchString;
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d7ae243/contrib/views/wfmanager/src/main/resources/ui/tests/integration/components/workflow-job-action-test.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/tests/integration/components/workflow-job-action-test.js b/contrib/views/wfmanager/src/main/resources/ui/tests/integration/components/workflow-job-action-test.js
new file mode 100644
index 0000000..67c6f25
--- /dev/null
+++ b/contrib/views/wfmanager/src/main/resources/ui/tests/integration/components/workflow-job-action-test.js
@@ -0,0 +1,40 @@
+/*
+ *    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.
+ */
+import { moduleForComponent, test } from 'ember-qunit';
+import hbs from 'htmlbars-inline-precompile';
+
+moduleForComponent('workflow-job-action', 'Integration | Component | workflow job action', {
+  integration: true
+});
+
+test('it renders', function(assert) {
+  // Set any properties with this.set('myProperty', 'value');
+  // Handle any actions with this.on('myAction', function(val) { ... });"
+
+  this.render(hbs`{{workflow-job-action}}`);
+
+  assert.equal(this.$().text().trim(), '');
+
+  // Template block usage:"
+  this.render(hbs`
+    {{#workflow-job-action}}
+      template block text
+    {{/workflow-job-action}}
+  `);
+
+  assert.equal(this.$().text().trim(), 'template block text');
+});