From 8d1dc1b1bac3b43e473df858f6223955ba839c75 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Mon, 5 Jan 2015 14:40:23 -0500 Subject: [PATCH 1/2] hide icon for run-now when daemon task --- SingularityUI/app/controllers/RequestDetail.coffee | 1 + .../requestDetail/requestScheduledTasks.hbs | 8 +++++--- SingularityUI/app/views/request.coffee | 4 ++-- SingularityUI/app/views/simpleSubview.coffee | 13 +++++++------ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SingularityUI/app/controllers/RequestDetail.coffee b/SingularityUI/app/controllers/RequestDetail.coffee index 0d546817c0..ee9b51a60a 100644 --- a/SingularityUI/app/controllers/RequestDetail.coffee +++ b/SingularityUI/app/controllers/RequestDetail.coffee @@ -65,6 +65,7 @@ class RequestDetailController extends Controller template: @templates.activeTasks @subviews.scheduledTasks = new SimpleSubview + model: @models.request collection: @collections.scheduledTasks template: @templates.scheduledTasks diff --git a/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs b/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs index e4bb13402b..a50cccefdb 100644 --- a/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs +++ b/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs @@ -26,9 +26,11 @@ {{timestampFromNow pendingTask.pendingTaskId.nextRunAt}} - - - + {{#unless ../modelData.attributes.daemon}} + + + + {{/unless}} { } diff --git a/SingularityUI/app/views/request.coffee b/SingularityUI/app/views/request.coffee index ad763d33cf..eb52fbe216 100644 --- a/SingularityUI/app/views/request.coffee +++ b/SingularityUI/app/views/request.coffee @@ -70,7 +70,7 @@ class RequestView extends View scaleRequest: (e) => @model.promptScale => @trigger 'refreshrequest' - + pauseRequest: (e) => @model.promptPause => @trigger 'refreshrequest' @@ -78,7 +78,7 @@ class RequestView extends View unpauseRequest: (e) => @model.promptUnpause => @trigger 'refreshrequest' - + bounceRequest: (e) => @model.promptBounce => @trigger 'refreshrequest' diff --git a/SingularityUI/app/views/simpleSubview.coffee b/SingularityUI/app/views/simpleSubview.coffee index 5e7d7ff63b..e2753f973c 100644 --- a/SingularityUI/app/views/simpleSubview.coffee +++ b/SingularityUI/app/views/simpleSubview.coffee @@ -20,18 +20,19 @@ class SimpleSubview extends View for eventName in ['sync', 'add', 'remove', 'change'] @listenTo @data, eventName, @render - + @listenTo @data, 'reset', => @$el.empty() render: -> return if not @data.synced and @data.isEmpty?() - + @$el.html @template - config: config - data: @data.toJSON() - synced: @data.synced - expanded: @expanded + config: config + data: @data.toJSON() + synced: @data.synced + expanded: @expanded + modelData: @model?.toJSON() @$('.actions-column a[title]').tooltip() From 521aa2c7cea60576d15e136ebd7a2f98e0602a85 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Tue, 6 Jan 2015 11:37:27 -0500 Subject: [PATCH 2/2] cleaner solution for getting extra data to template --- .../app/controllers/RequestDetail.coffee | 7 ++++--- .../requestDetail/requestScheduledTasks.hbs | 2 +- SingularityUI/app/views/simpleSubview.coffee | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/SingularityUI/app/controllers/RequestDetail.coffee b/SingularityUI/app/controllers/RequestDetail.coffee index ee9b51a60a..c84ad5804f 100644 --- a/SingularityUI/app/controllers/RequestDetail.coffee +++ b/SingularityUI/app/controllers/RequestDetail.coffee @@ -65,9 +65,10 @@ class RequestDetailController extends Controller template: @templates.activeTasks @subviews.scheduledTasks = new SimpleSubview - model: @models.request - collection: @collections.scheduledTasks - template: @templates.scheduledTasks + collection: @collections.scheduledTasks + template: @templates.scheduledTasks + extraRenderData: (subView) => + { request: @models.request.toJSON() } @subviews.taskHistory = new ExpandableTableSubview collection: @collections.taskHistory diff --git a/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs b/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs index a50cccefdb..584c095139 100644 --- a/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs +++ b/SingularityUI/app/templates/requestDetail/requestScheduledTasks.hbs @@ -26,7 +26,7 @@ {{timestampFromNow pendingTask.pendingTaskId.nextRunAt}} - {{#unless ../modelData.attributes.daemon}} + {{#unless ../request.attributes.daemon}} diff --git a/SingularityUI/app/views/simpleSubview.coffee b/SingularityUI/app/views/simpleSubview.coffee index e2753f973c..375940ef9e 100644 --- a/SingularityUI/app/views/simpleSubview.coffee +++ b/SingularityUI/app/views/simpleSubview.coffee @@ -15,7 +15,8 @@ class SimpleSubview extends View _.extend super, 'click [data-action="expandToggle"]': 'expandToggle' - initialize: ({@template}) -> + initialize: (@params) -> + { @template } = @params @data = if @collection? then @collection else @model for eventName in ['sync', 'add', 'remove', 'change'] @@ -27,16 +28,22 @@ class SimpleSubview extends View render: -> return if not @data.synced and @data.isEmpty?() - @$el.html @template + @$el.html @template(@renderData()) + + @$('.actions-column a[title]').tooltip() + + utils.setupCopyLinks @$el if @$('.horizontal-description-list').length + + renderData: -> + data = config: config data: @data.toJSON() synced: @data.synced expanded: @expanded - modelData: @model?.toJSON() - - @$('.actions-column a[title]').tooltip() + if @params.extraRenderData? + _.extend data, @params.extraRenderData(this) - utils.setupCopyLinks @$el if @$('.horizontal-description-list').length + data expandToggle: (event) -> @expanded = not @expanded