Repository: ambari Updated Branches: refs/heads/trunk 8b4dd3a48 -> d2862fc65
AMBARI-19604. Need to perform sanity checks before starting the oozie view. (Padma Priya N via gauravn7) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d2862fc6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d2862fc6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d2862fc6 Branch: refs/heads/trunk Commit: d2862fc6513f6f9c1077c3a7de06ab698e29b22a Parents: 8b4dd3a Author: Gaurav Nagar <grv...@gmail.com> Authored: Fri Jan 27 11:26:18 2017 +0530 Committer: Gaurav Nagar <grv...@gmail.com> Committed: Fri Jan 27 11:27:31 2017 +0530 ---------------------------------------------------------------------- .../main/resources/ui/app/controllers/index.js | 39 +++++++++ .../src/main/resources/ui/app/routes/index.js | 90 +++++++++++++++++++- .../ui/app/templates/design-loading.hbs | 26 ++++++ .../main/resources/ui/app/templates/index.hbs | 74 ++++++++++++++++ .../main/resources/ui/app/templates/loading.hbs | 26 ------ 5 files changed, 227 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d2862fc6/contrib/views/wfmanager/src/main/resources/ui/app/controllers/index.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/controllers/index.js b/contrib/views/wfmanager/src/main/resources/ui/app/controllers/index.js new file mode 100644 index 0000000..f4d93ea --- /dev/null +++ b/contrib/views/wfmanager/src/main/resources/ui/app/controllers/index.js @@ -0,0 +1,39 @@ +/* +* 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'; + +export default Ember.Controller.extend({ + progressWidth : '10%', + serviceChecksComplete : false, + issues : Ember.A([]), + serviceChecks : Ember.A([ + {'name':'oozie', 'checkCompleted':false, isAvailable : true, 'displayName' : 'Oozie Test', 'errorMessage' : 'Oozie service check failed'}, + {'name':'hdfs', 'checkCompleted':false, isAvailable : true, 'displayName' : 'HDFS Test', 'errorMessage' : 'HDFS service check failed'}, + {'name':'homeDir', 'checkCompleted':false, isAvailable : true, 'displayName' : 'User Home Directory Test', 'errorMessage' : 'User home directory not found'} + ]), + width : Ember.computed('serviceChecks.@each.checkCompleted','serviceChecks.@each.isAvailable', function(){ + let width = 10; + this.get('serviceChecks').forEach((check)=>{ + if(check.checkCompleted && check.isAvailable){ + width += 30; + } + }); + return Ember.String.htmlSafe(`${width}%`); + }) + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d2862fc6/contrib/views/wfmanager/src/main/resources/ui/app/routes/index.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/routes/index.js b/contrib/views/wfmanager/src/main/resources/ui/app/routes/index.js index 23609e9..b9ea770 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/routes/index.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/routes/index.js @@ -18,7 +18,93 @@ import Ember from 'ember'; export default Ember.Route.extend({ - beforeModel() { - this.transitionTo('design'); + afterModel(){ + let ooziePromise = this.checkOozie(); + let hdfsPromise = this.checkHdfs(); + let homeDirPromise = this.checkUserHome(); + let serviceChecks = this.controllerFor('index').get('serviceChecks'); + this.controllerFor('index').get('issues').clear(); + this.processServiceCheckPromise(ooziePromise, serviceChecks.findBy('name', 'oozie')); + this.processServiceCheckPromise(hdfsPromise, serviceChecks.findBy('name', 'hdfs')); + this.processServiceCheckPromise(homeDirPromise, serviceChecks.findBy('name', 'homeDir')); + Promise.all([ooziePromise, hdfsPromise, homeDirPromise]).then(()=>{ + this.controllerFor('index').set('serviceChecksComplete', true); + Ember.run.later(()=>{ + this.transitionTo('design'); + }, 2000); + }).catch((errors)=>{ + this.controllerFor('index').set('serviceChecksComplete', true); + this.controllerFor('index').set('errors', errors); + }); + }, + processServiceCheckPromise(promise, serviceCheck){ + promise.then(()=>{ + Ember.set(serviceCheck, 'isAvailable', true); + }).catch((e)=>{ + console.error(e); + Ember.set(serviceCheck, 'isAvailable', false); + }).finally(()=>{ + Ember.set(serviceCheck, 'checkCompleted', true); + }); + }, + checkOozie(){ + return new Ember.RSVP.Promise((resolve, reject) => { + var url = Ember.ENV.API_URL + "/v1/admin/configuration"; + Ember.$.ajax({ + url: url, + method: "GET", + dataType: "text", + contentType: "text/plain;charset=utf-8", + beforeSend: function(request) { + request.setRequestHeader("X-Requested-By", "workflow-designer"); + }, + success : function(response){ + resolve(true); + }, + error : function(response){ + reject(response); + } + }); + }); + }, + checkHdfs(){ + return new Ember.RSVP.Promise((resolve, reject) => { + var url = Ember.ENV.API_URL + "/hdfsCheck"; + Ember.$.ajax({ + url: url, + method: "GET", + dataType: "text", + contentType: "text/plain;charset=utf-8", + beforeSend: function(request) { + request.setRequestHeader("X-Requested-By", "workflow-designer"); + }, + success : function(response){ + resolve(true); + }, + error : function(response){ + reject(response); + } + }); + }); + }, + checkUserHome(){ + return new Ember.RSVP.Promise((resolve, reject) => { + var url = Ember.ENV.API_URL + "/homeDirCheck"; + Ember.$.ajax({ + url: url, + method: "GET", + dataType: "text", + contentType: "text/plain;charset=utf-8", + beforeSend: function(request) { + request.setRequestHeader("X-Requested-By", "workflow-designer"); + }, + success : function(response){ + resolve(true); + }, + error : function(response){ + reject(response); + } + }); + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d2862fc6/contrib/views/wfmanager/src/main/resources/ui/app/templates/design-loading.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/design-loading.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/design-loading.hbs new file mode 100644 index 0000000..9f4fc79 --- /dev/null +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/design-loading.hbs @@ -0,0 +1,26 @@ +{{! +* 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. +}} +<style type="text/css"> +.loading-container { + position: relative; + top: 200px; +} +</style> +<div class='loading-container'> + {{spin-spinner lines=13 length=20 width=10}} +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/d2862fc6/contrib/views/wfmanager/src/main/resources/ui/app/templates/index.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/index.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/index.hbs new file mode 100644 index 0000000..d96be85 --- /dev/null +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/index.hbs @@ -0,0 +1,74 @@ +{{! +* 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 class="container"> + {{#if serviceChecksComplete }} + {{#if errors}} + <h3>Service checks failed.</h3> + {{else}} + <h3>Service checks completed.</h3> + {{/if}} + {{else}} + <h3>Service checks in progress.</h3> + {{/if}} + {{#if errors}} + <div class="progress active"> + <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width:{{width}}"> + <span class="sr-only">70% Complete</span> + </div> + </div> + {{else}} + <div class="progress progress-striped active"> + <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width:{{width}}"> + <span class="sr-only">70% Complete</span> + </div> + </div> + {{/if}} + <ul class="list-group"> + {{#each serviceChecks as |check|}} + <li class="list-group-item"> + <span> + {{#if (and check.isAvailable check.checkCompleted)}} + <i class="fa fa-check"></i> + {{else if (and (not check.isAvailable) check.checkCompleted)}} + <i class="fa fa-remove"></i> + {{else if (not check.checkCompleted)}} + <i class="fa fa-arrow-right"></i> + {{/if}} + </span> + <span>{{check.displayName}}</span> + </li> + {{/each}} + </ul> + {{#if errors}} + <div class=""> + <h3>Issues detected</h3> + {{#each serviceChecks as |check|}} + {{#if (and (not check.isAvailable) check.checkCompleted)}} + {{check.errorMessage}} <br> + {{/if}} + {{/each}} + </div> + <div class=""> + {{#link-to 'design' class="backto-dashboard"}} + <button type="button" class="btn btn-default pull-right" title="You can continue to Workflow Designer View. But some functionalities may be unavailable."> + <i class="fa fa-arrow-right marginright5"></i> Continue + </button> + {{/link-to}} + </div> + {{/if}} +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/d2862fc6/contrib/views/wfmanager/src/main/resources/ui/app/templates/loading.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/loading.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/loading.hbs deleted file mode 100644 index 9f4fc79..0000000 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/loading.hbs +++ /dev/null @@ -1,26 +0,0 @@ -{{! -* 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. -}} -<style type="text/css"> -.loading-container { - position: relative; - top: 200px; -} -</style> -<div class='loading-container'> - {{spin-spinner lines=13 length=20 width=10}} -</div>