You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by pa...@apache.org on 2016/05/24 07:01:49 UTC
ambari git commit: AMBARI-16792. Capacity Scheduler View - Edit and
validate queue name (Akhil PB via pallavkul)
Repository: ambari
Updated Branches:
refs/heads/trunk 047db3485 -> 3249bf6cf
AMBARI-16792. Capacity Scheduler View - Edit and validate queue name (Akhil PB via pallavkul)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3249bf6c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3249bf6c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3249bf6c
Branch: refs/heads/trunk
Commit: 3249bf6cfa4cc6becbd3dfeec83ac864894ca504
Parents: 047db34
Author: Pallav Kulshreshtha <pa...@gmail.com>
Authored: Tue May 24 12:31:34 2016 +0530
Committer: Pallav Kulshreshtha <pa...@gmail.com>
Committed: Tue May 24 12:31:34 2016 +0530
----------------------------------------------------------------------
.../resources/ui/app/components/queueMapping.js | 2 +-
.../resources/ui/app/controllers/editqueue.js | 48 +++++++++++++++++++-
.../resources/ui/app/controllers/queuesconf.js | 44 +++++++++++++++---
.../resources/ui/app/styles/application.less | 10 ++++
.../ui/app/templates/capsched/queuesconf.hbs | 26 +++++++----
.../templates/capsched/queuesconf/editqueue.hbs | 46 +++++++++++++++----
6 files changed, 149 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/queueMapping.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/queueMapping.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/queueMapping.js
index 02062a6..bbf0cab 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/queueMapping.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/queueMapping.js
@@ -125,7 +125,7 @@
}.property('selection')
}),
- isCollapsed: true,
+ isCollapsed: false,
doExpandCollapse: function(){
var that = this;
this.$('#collapseQueueMappingsBtn').on('click', function(e){
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/editqueue.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/editqueue.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/editqueue.js
index 69be18c..e981ea5 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/editqueue.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/editqueue.js
@@ -47,9 +47,53 @@ App.CapschedQueuesconfEditqueueController = Ember.Controller.extend({
},
mouseUp: function(){
return false;
+ },
+ editQueueName: function() {
+ this.set('enableEditQName', true);
+ this.set('updatedQName', this.get('content.name'));
+ },
+ cancelQNameEdit: function() {
+ this.set('enableEditQName', false);
+ this.set('isInvalidQName', false);
+ this.set('invalidQNameMessage', '');
+ },
+ renameQueue: function() {
+ if (this.validateQName()) {
+ return;
+ }
+ this.set('content.name', this.get('updatedQName'));
+ this.set('enableEditQName', false);
}
},
+ updatedQName: '',
+ enableEditQName: false,
+ isInvalidQName: false,
+ invalidQNameMessage: '',
+
+ validateQName: function() {
+ var qName = this.get('updatedQName'),
+ originalQName = this.get('content.name'),
+ qParentPath = this.get('content.parentPath'),
+ qPath = [qParentPath, qName].join('.'),
+ qAlreadyExists = this.store.hasRecordForId('queue', qPath.toLowerCase());
+ if (Ember.isBlank(qName)) {
+ this.set('isInvalidQName', true);
+ this.set('invalidQNameMessage', 'Enter queue name');
+ } else if (qAlreadyExists && qName !== originalQName) {
+ this.set('isInvalidQName', true);
+ this.set('invalidQNameMessage', 'Queue already exists');
+ } else {
+ this.set('isInvalidQName', false);
+ this.set('invalidQNameMessage', '');
+ }
+ return this.get('isInvalidQName');
+ },
+
+ qNameDidChage: function() {
+ this.validateQName();
+ }.observes('updatedQName', 'updatedQName.length'),
+
/**
* Collection of modified fields in queue.
* @type {Object} - { [fileldName] : {Boolean} }
@@ -292,7 +336,7 @@ App.CapschedQueuesconfEditqueueController = Ember.Controller.extend({
return totalCapacity;
}.property('childrenQueues.length', 'childrenQueues.@each.capacity'),
- pattern: 'width: %@%',
+ widthPattern: 'width: %@%',
warnInvalidCapacity: function() {
var totalCap = this.get('childrenQueuesTotalCapacity');
@@ -307,7 +351,7 @@ App.CapschedQueuesconfEditqueueController = Ember.Controller.extend({
if (totalCap > 100) {
totalCap = 100;
}
- return this.get('pattern').fmt(totalCap);
+ return this.get('widthPattern').fmt(totalCap);
}.property('childrenQueuesTotalCapacity'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queuesconf.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queuesconf.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queuesconf.js
index 89d0e89..14ea85c 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queuesconf.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queuesconf.js
@@ -31,19 +31,23 @@ App.CapschedQueuesconfController = Ember.Controller.extend({
this.set('showQueueNameInput', true);
},
createNewQueue: function() {
+ if (this.validateQueueName()) {
+ return;
+ }
var store = this.get('store'),
queueName = this.get('newQueueName'),
parentPath = this.get('selectedQueue.path'),
- queuePath = parentPath + "." + queueName,
+ queuePath = [parentPath, queueName].join('.'),
depth = parentPath.split('.').length,
+ queueAlreadyExists = store.hasRecordForId('queue', queuePath.toLowerCase()),
leafQueueNames = store.getById('queue', parentPath.toLowerCase()).get('queuesArray'),
- newInLeaf = Em.isEmpty(leafQueueNames),
- existed = store.get('deletedQueues').findBy('path', [parentPath, queueName].join('.')),
+ newInLeaf = Ember.isEmpty(leafQueueNames),
+ existed = store.get('deletedQueues').findBy('path', queuePath),
totalLeafCapacity,
freeLeafCapacity,
newQueue;
- this.send('cancelCreateQueue');
+ this.send('clearCreateQueue');
if (existed) {
newQueue = store.createFromDeleted(existed);
@@ -52,9 +56,9 @@ App.CapschedQueuesconfController = Ember.Controller.extend({
totalLeafCapacity = leafQueueNames.reduce(function (capacity, qName) {
return store.getById('queue', [parentPath, qName].join('.').toLowerCase()).get('capacity') + capacity;
}, 0);
-
freeLeafCapacity = (totalLeafCapacity < 100) ? 100 - totalLeafCapacity : 0;
}
+
var qCapacity = (newInLeaf) ? 100 : freeLeafCapacity;
newQueue = store.createRecord('queue', {
@@ -88,11 +92,13 @@ App.CapschedQueuesconfController = Ember.Controller.extend({
}).catch(Em.run.bind(this, 'saveQueuesConfigError', opt));
},
- cancelCreateQueue: function() {
+ clearCreateQueue: function() {
this.set('newQueueName', '');
this.set('showQueueNameInput', false);
+ this.set('isInvalidQueueName', false);
+ this.set('invalidQueueNameMessage', '');
},
- clearAlert:function () {
+ clearAlert: function () {
this.set('alertMessage', null);
}
},
@@ -101,6 +107,30 @@ App.CapschedQueuesconfController = Ember.Controller.extend({
newQueue: null,
newQueueName: '',
showQueueNameInput: false,
+ isInvalidQueueName: false,
+ invalidQueueNameMessage: '',
+
+ validateQueueName: function() {
+ var parentPath = this.get('selectedQueue.path'),
+ queueName = this.get('newQueueName'),
+ queuePath = [parentPath, queueName].join('.'),
+ qAlreadyExists = this.store.hasRecordForId('queue', queuePath.toLowerCase());
+ if (Ember.isBlank(queueName)) {
+ this.set('isInvalidQueueName', true);
+ this.set('invalidQueueNameMessage', 'Enter queue name');
+ } else if (qAlreadyExists) {
+ this.set('isInvalidQueueName', true);
+ this.set('invalidQueueNameMessage', 'Queue already exists');
+ } else {
+ this.set('isInvalidQueueName', false);
+ this.set('invalidQueueNameMessage', '');
+ }
+ return this.get('isInvalidQueueName');
+ },
+
+ queueNameDidChange: function() {
+ this.validateQueueName();
+ }.observes('newQueueName', 'newQueueName.length'),
/**
* True if newQueue is not empty.
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less b/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
index a60d39d..89b8eb7 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
@@ -1165,3 +1165,13 @@
display: inline-block;
}
}
+
+.invalid-qname-tooltip {
+ opacity: 1;
+ .tooltip-inner {
+ background-color: #a94442;
+ }
+ .tooltip-arrow {
+ border-bottom-color: #a94442 !important;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf.hbs b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf.hbs
index d57b2ba..3837a03 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf.hbs
@@ -42,13 +42,21 @@
</div>
</div>
{{#if showQueueNameInput}}
- <div class="add-newqueuename-wrapper">
- {{input type="text" name="addNewQueueName" class="form-control input-sm new-queue-name" value=newQueueName placeholder="Enter queue name..."}}
- <div class="btn-group btn-group-sm pull-right">
- <button type="button" class="btn btn-primary" name="createNewQueueBtn" {{action "createNewQueue"}}>Create</button>
- <button type="button" class="btn btn-default" name="cancelNewQueueBtn" {{action "cancelCreateQueue"}}>Cancel</button>
+ <div {{bind-attr class=":add-newqueuename-wrapper isInvalidQueueName:has-error"}} class="add-newqueuename-wrapper">
+ {{input type="text" name="addNewQueueName" class="form-control input-sm new-queue-name" value=newQueueName placeholder="Enter queue name..."}}
+ <div class="btn-group btn-group-sm pull-right">
+ <button type="button" class="btn btn-primary" name="createNewQueueBtn" {{action "createNewQueue"}}>Create</button>
+ <button type="button" class="btn btn-default" name="cancelNewQueueBtn" {{action "clearCreateQueue"}}>Cancel</button>
+ </div>
+ {{#if isInvalidQueueName}}
+ <div class="tooltip bottom invalid-qname-tooltip" role="tooltip">
+ <div class="tooltip-arrow"></div>
+ <div class="tooltip-inner">
+ {{invalidQueueNameMessage}}
+ </div>
+ </div>
+ {{/if}}
</div>
- </div>
{{/if}}
{{/if}}
{{/if}}
@@ -65,8 +73,10 @@
</div>
</div>
</div>
- <div class="btn btn-group-sm col-sm-offset-3">
- <button type="button" class="btn btn-success" name="saveQueuesconfBtn" {{action "showSaveConfigDialog" target="view"}}>Save And Refresh Queues</button>
+ <div class="btn btn-group-sm col-sm-offset-2">
+ <button type="button" class="btn btn-success" name="saveOnly">Save Only</button>
+ <button type="button" class="btn btn-success" name="saveAndRefresh" {{action "showSaveConfigDialog" target="view"}}>Save And Refresh Queues</button>
+ <button type="button" class="btn btn-warning" name="saveAndRestart">Save And Restart RM</button>
<button type="button" class="btn btn-danger" name="cancelQueuesconfBtn">Cancel Changes</button>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3249bf6c/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf/editqueue.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf/editqueue.hbs b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf/editqueue.hbs
index c5c910a..aad16c2 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf/editqueue.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capsched/queuesconf/editqueue.hbs
@@ -19,17 +19,45 @@
<div class="edit-queue-wrapper">
<div class="row edit-queuename-wrapper">
- <div class="col-md-8 col-sm-8">
- <label>Queue Name</label>
- {{input type="text" name="queueName" class="form-control input-sm input-queue-name" value=content.name readonly=isRoot}}
- {{#if queueDirtyFields.name}}
- <div class="btn-group btn-group-xs" >
- <a {{action 'rollbackProp' 'name' content}} href="#" class="btn btn-default btn-warning">
- <i class="fa fa-undo"></i>
- </a>
+ {{#if isOperator}}
+ {{#if enableEditQName}}
+ <div {{bind-attr class="isInvalidQName:has-error :col-md-10 :col-sm-10"}} class="">
+ {{input type="text" name="queueName" class="form-control input-sm input-queue-name" value=updatedQName}}
+ <div class="btn-group btn-group-sm">
+ <button type="button" name="renameQ" class="btn btn-primary" {{action "renameQueue"}} {{bind-attr disabled=isInvalidQName}}>Rename</button>
+ <button type="button" name="cancelQEdit" class="btn btn-default" {{action "cancelQNameEdit"}}>Cancel</button>
+ </div>
+ {{#if isInvalidQName}}
+ <div class="tooltip bottom invalid-qname-tooltip" role="tooltip">
+ <div class="tooltip-arrow"></div>
+ <div class="tooltip-inner">
+ {{invalidQNameMessage}}
+ </div>
+ </div>
+ {{/if}}
+ </div>
+ {{else}}
+ <div class="col-md-8 col-sm-8">
+ <label>Queue Name: </label>
+ <span>{{content.name}}</span>
+ {{#unless isRoot}}
+ <a href="#" class="edit-qname-btn" {{action "editQueueName"}}>
+ <i class="fa fa-pencil-square-o"></i>
+ </a>
+ {{/unless}}
+ {{#if queueDirtyFields.name}}
+ <div class="btn-group btn-group-xs">
+ <a {{action 'rollbackProp' 'name' content}} href="#" class="btn btn-default btn-warning"><i class="fa fa-undo"></i></a>
+ </div>
+ {{/if}}
</div>
{{/if}}
- </div>
+ {{else}}
+ <div class="col-md-8 col-sm-8">
+ <label>Queue Name: </label>
+ <span>{{content.name}}</span>
+ </div>
+ {{/if}}
</div>
<div class="queue-capacity-wrapper">