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:09:24 UTC
ambari git commit: AMBARI-20166. Workflow Manager. Nominal time
should accept variables.(Padma Priya N via gauravn7)
Repository: ambari
Updated Branches:
refs/heads/trunk 2cd4a3f33 -> dfdd00fd0
AMBARI-20166. Workflow Manager. Nominal time should accept variables.(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/dfdd00fd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dfdd00fd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dfdd00fd
Branch: refs/heads/trunk
Commit: dfdd00fd0b073de7b7de6556a120ddc7f4103be3
Parents: 2cd4a3f
Author: Gaurav Nagar <gr...@gmail.com>
Authored: Fri Feb 24 22:39:13 2017 +0530
Committer: Gaurav Nagar <gr...@gmail.com>
Committed: Fri Feb 24 22:39:13 2017 +0530
----------------------------------------------------------------------
.../resources/ui/app/components/sla-info.js | 37 --------------------
.../resources/ui/app/domain/mapping-utils.js | 20 +++++++++--
.../main/resources/ui/app/domain/sla-info.js | 12 +++++--
.../ui/app/templates/components/sla-info.hbs | 12 ++-----
4 files changed, 30 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/dfdd00fd/contrib/views/wfmanager/src/main/resources/ui/app/components/sla-info.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/sla-info.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/sla-info.js
index bcc209b..be5d6f9 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/sla-info.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/sla-info.js
@@ -19,24 +19,6 @@ import { validator, buildValidations } from 'ember-cp-validations';
import { v1, v4 } from "ember-uuid";
const Validations = buildValidations({
- 'nominalTime': {
- validators: [
- validator('presence', {
- presence : true,
- disabled(model, attribute) {
- return !model.get('slaEnabled');
- },
- dependentKeys : ['slaEnabled']
- }),
- validator('date', {
- disabled(model, attribute) {
- return !model.get('slaEnabled');
- },
- format: 'MM/DD/YYYY hh:mm A',
- dependentKeys : ['slaEnabled']
- }),
- ]
- },
'slaInfo.shouldEnd.time': {
validators: [
validator('presence', {
@@ -125,14 +107,6 @@ export default Ember.Component.extend(Validations, {
this.set('slaEnabled', false);
}
Ember.addObserver(this, 'slaEnabled', this, this.slaObserver);
- if(this.get('slaInfo.nominalTime')){
- var date = new Date(this.get('slaInfo.nominalTime'));
- if(date && !isNaN(date.getTime())){
- var utcDate = new Date(date.getTime() + date.getTimezoneOffset()*60*1000);
- this.set('nominalTime', moment(utcDate).format("MM/DD/YYYY hh:mm A"));
- }
- }
- Ember.addObserver(this, 'nominalTime', this, this.nominalTimeObserver);
this.set('collapseId', v1());
}.on('init'),
alertEventsObserver : function(){
@@ -142,24 +116,13 @@ export default Ember.Component.extend(Validations, {
onDestroy : function(){
Ember.removeObserver(this, 'alertEvents.@each.alertEnabled', this, this.alertEventsObserver);
Ember.removeObserver(this, 'slaEnabled', this, this.slaObserver);
- Ember.removeObserver(this, 'nominalTime', this, this.nominalTimeObserver);
}.on('willDestroyElement'),
elementsInserted : function() {
- this.$('input[name="nominalTime"]').datetimepicker({
- useCurrent: false,
- showClose : true,
- format: 'MM/DD/YYYY hh:mm A',
- defaultDate : this.get('slaInfo.nominalTime')
- });
this.sendAction('register','slaInfo', this);
if(this.get('slaEnabled')){
this.$('#slaCollapse').collapse('show');
}
}.on('didInsertElement'),
- nominalTimeObserver : function(){
- var date = new Date(this.get('nominalTime'));
- this.set('slaInfo.nominalTime',moment(date).format("YYYY-MM-DDTHH:mm")+'Z');
- },
slaObserver : function(){
if(this.get('slaEnabled')){
this.$('#slaCollapse').collapse('show');
http://git-wip-us.apache.org/repos/asf/ambari/blob/dfdd00fd/contrib/views/wfmanager/src/main/resources/ui/app/domain/mapping-utils.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/mapping-utils.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/mapping-utils.js
index 153b538..2b45c9e 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/mapping-utils.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/mapping-utils.js
@@ -216,7 +216,7 @@ var SLAMapper= Ember.Object.extend({
var slaPrefix="sla";
slaInfo["__prefix"]=slaPrefix;
if (sla.nominalTime){
- slaInfo[slaPrefix+":"+"nominal-time"]=sla.nominalTime;
+ slaInfo[slaPrefix+":"+"nominal-time"]=sla.nominalTime.value;
}
if (sla.shouldStart && sla.shouldStart.time){
slaInfo[slaPrefix+":"+"should-start"]="${"+sla.shouldStart.time+ "*"+sla.shouldStart.unit+"}";
@@ -245,7 +245,7 @@ var SLAMapper= Ember.Object.extend({
handleImport(domain,infoJson,key){
var sla=domain[key]=SlaInfo.create({});
if (infoJson["nominal-time"] && infoJson["nominal-time"].__text){
- sla.nominalTime=infoJson["nominal-time"].__text;
+ sla.nominalTime= this.extractDateField(infoJson["nominal-time"].__text);
}
if (infoJson["alert-contact"]&& infoJson["alert-contact"].__text){
sla.alertContact=infoJson["alert-contact"].__text;
@@ -273,6 +273,20 @@ var SLAMapper= Ember.Object.extend({
parseSlaTime(str,key){
var timePeriod= str.substring(str.indexOf("{")+1,str.indexOf("}"));
return timePeriod.split("*");
- }
+ },
+ extractDateField(value){
+ var dateField = {};
+ var date = new Date(value);
+ dateField.value = value;
+ if(isNaN(date.getTime())){
+ dateField.displayValue = value;
+ dateField.type = 'expr';
+ }else{
+ dateField.type = 'date';
+ var utcDate = new Date(date.getTime() + date.getTimezoneOffset()*60*1000);
+ dateField.displayValue = moment(utcDate).format("MM/DD/YYYY hh:mm A");
+ }
+ return dateField;
+ },
});
export {MappingMixin,ConfigurationMapper,PrepareMapper,SLAMapper};
http://git-wip-us.apache.org/repos/asf/ambari/blob/dfdd00fd/contrib/views/wfmanager/src/main/resources/ui/app/domain/sla-info.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/sla-info.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/sla-info.js
index 9d90280..ceb0d27 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/sla-info.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/sla-info.js
@@ -24,7 +24,11 @@ var SlaInfo = Ember.Object.extend(Ember.Copyable,{
return slaInfo;
},
init (){
- this.nominalTime=undefined;
+ this.nominalTime={
+ value : undefined,
+ displayValue : undefined,
+ type : 'date'
+ };
this.shouldStart = {
time : undefined,
unit : undefined
@@ -40,7 +44,11 @@ var SlaInfo = Ember.Object.extend(Ember.Copyable,{
this.alertEvents = undefined;
this.alertContacts = undefined;
},
- nominalTime:undefined,
+ nominalTime:{
+ value : undefined,
+ displayValue : undefined,
+ type : 'date'
+ },
shouldStart : {
time : undefined,
unit : undefined
http://git-wip-us.apache.org/repos/asf/ambari/blob/dfdd00fd/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sla-info.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sla-info.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sla-info.hbs
index 2ebc259..b9ba143 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sla-info.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sla-info.hbs
@@ -22,16 +22,10 @@
</div>
<div id="{{collapseId}}" class="panel-collapse collapse panel-body">
<div class="form-group">
- <label class="control-label col-xs-2">Enabled</label>
- <span class="col-xs-2 paddingtop7">{{input type="checkbox" checked=slaEnabled}}</span>
- </div>
- <div class="form-group">
- <label class="control-label col-xs-2 padding10">Nominal Time<span class="requiredField"> *</span></label>
- <div class="col-xs-3 padding10">
- {{input type="text" name="nominalTime" title="Date in UTC Format" class="form-control" value=nominalTime placeholder="Nominal Time"}}
- {{field-error model=this field='nominalTime' showErrorMessage=showErrorMessage}}
- </div>
+ <label class="control-label col-xs-2">Enabled</label>
+ <span class="col-xs-2 paddingtop7">{{input type="checkbox" checked=slaEnabled}}</span>
</div>
+ {{#date-with-expr required=true inputName="nominalTime" label="Nominal Time" inputPlaceholder="Nominal Time" dateField=slaInfo.nominalTime}}{{/date-with-expr}}
<div class="form-group">
<label class="control-label col-xs-2">Should Start</label>
<div class="col-xs-3">