Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PaginableCollection = require './PaginableCollection'
class HistoricalTasks extends PaginableCollection

model: class TaskHistoryItem extends Backbone.Model
ignoreAttributes: ['id']
ignoreAttributes: ['id', 'canBeRunNow']

url: -> "#{ config.apiRoot }/history/request/#{ @requestId }/tasks"

Expand Down
15 changes: 11 additions & 4 deletions SingularityUI/app/controllers/RequestDetail.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RequestDetailController extends Controller
@subviews.header = new SimpleSubview
model: @models.request
template: @templates.header

# would have used header subview for this info,
# but header expects a request model that
# no longer exists if a request is deleted
Expand Down Expand Up @@ -109,6 +109,10 @@ class RequestDetailController extends Controller

app.showView @view

addRequestInfo: =>
for t in @collections.taskHistory.models
t.attributes.canBeRunNow = @models.request.attributes.canBeRunNow

refresh: ->
requestFetch = @models.request.fetch()

Expand All @@ -124,7 +128,7 @@ class RequestDetailController extends Controller
@collections.activeTasks.fetch().error @ignore404
@collections.scheduledTasks.fetch().error @ignore404
@collections.scheduledTasks.fetch({reset: true}).error @ignore404

if @collections.requestHistory.currentPage is 1
requestHistoryFetch = @collections.requestHistory.fetch()
requestHistoryFetch.error => @ignore404
Expand All @@ -133,8 +137,11 @@ class RequestDetailController extends Controller
if @collections.requestHistory.length is 0
app.router.notFound()

if @collections.taskHistory.currentPage is 1
@collections.taskHistory.fetch().error @ignore404
requestFetch.done =>
if @collections.taskHistory.currentPage is 1
@collections.taskHistory.fetch
error: @ignore404
success: @addRequestInfo
if @collections.deployHistory.currentPage is 1
@collections.deployHistory.fetch().error @ignore404

Expand Down
82 changes: 73 additions & 9 deletions SingularityUI/app/models/Request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ runTemplate = require '../templates/vex/requestRun'
removeTemplate = require '../templates/vex/requestRemove'
bounceTemplate = require '../templates/vex/requestBounce'
exitCooldownTemplate = require '../templates/vex/exitCooldown'
TaskHistory = require '../models/TaskHistory'

class Request extends Model

Expand Down Expand Up @@ -74,7 +75,7 @@ class Request extends Model
options.processData = false

$.ajax options

scale: (confirmedOrPromptData) =>
$.ajax
url: "#{ @url() }/instances?user=#{ app.getUsername() }"
Expand All @@ -83,7 +84,7 @@ class Request extends Model
data: JSON.stringify
id: @get "id"
instances: confirmedOrPromptData

bounce: =>
$.ajax
url: "#{ @url() }/bounce?user=#{ app.getUsername() }"
Expand Down Expand Up @@ -114,7 +115,7 @@ class Request extends Model

promptScale: (callback) =>
vex.dialog.prompt
message: scaleTemplate
message: scaleTemplate
id: @get "id"
buttons: [
$.extend _.clone(vex.dialog.buttons.YES), text: 'Scale'
Expand All @@ -134,16 +135,20 @@ class Request extends Model

promptRun: (callback) =>
vex.dialog.prompt
message: ""
input: runTemplate id: @get "id"
message: "<h3>Run Task</h3>"
input: runTemplate
id: @get "id"
prefix: @localStorageCommandLineInputKeyPrefix
commands: localStorage.getItem(@localStorageCommandLineInputKeyPrefix + @id)

buttons: [
$.extend _.clone(vex.dialog.buttons.YES), text: 'Run now'
vex.dialog.buttons.NO
]

beforeClose: =>
return if @data is false

fileName = @data.filename.trim()
commandLineInput = @data.commandLineInput.trim()

Expand All @@ -152,22 +157,81 @@ class Request extends Model
return false

else
localStorage.setItem(@localStorageCommandLineInputKeyPrefix + @id, commandLineInput) if commandLineInput?
history = localStorage.getItem(@localStorageCommandLineInputKeyPrefix + @id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if we could move all this local storage related stuff out to some utility file. it always bugged me that we already have all this vex stuff in a model file, maybe we can tackle that in another issue, but it would be nice if we could lean this out a bit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that too. It would make sense move localstorage and vex interactions into utilities. We should probably make another issue though since it would add a lot of clutter.


if history?
last = history.split(",")[history.split(",").length - 1]
history += ","
else
history = ""

if commandLineInput != last
localStorage.setItem(@localStorageCommandLineInputKeyPrefix + @id, history + commandLineInput) if commandLineInput?
localStorage.setItem('taskRunRedirectFilename', fileName) if filename?
localStorage.setItem('taskRunAutoTail', @data.autoTail)
@data.id = @get 'id'

@run( @data.commandLineInput ).done callback( @data )
return true

afterOpen: =>
afterOpen: =>
$('#filename').val localStorage.getItem('taskRunRedirectFilename')
$('#commandLineInput').val localStorage.getItem(@localStorageCommandLineInputKeyPrefix + @id)
$('#autoTail').prop 'checked', (localStorage.getItem('taskRunAutoTail') is 'on')
cmdString = localStorage.getItem(@localStorageCommandLineInputKeyPrefix + @id)
commands = if cmdString then cmdString.split(",").reverse() else []
$('#commandLineInput').val commands[0]
localStorage.setItem(@localStorageCommandLineInputKeyPrefix + "historyIndex", 0);
localStorage.setItem(@localStorageCommandLineInputKeyPrefix + "historyLength", commands.length);

callback: (data) =>
@data = data


promptRerun: (taskId, callback) =>
task = new TaskHistory {taskId}
task.fetch()
.done =>
command = task.attributes.task.taskRequest.pendingTask.cmdLineArgsList
vex.dialog.prompt
message: "<h3>Rerun Task</h3>"
input: runTemplate
id: @get "id"
command: command
buttons: [
$.extend _.clone(vex.dialog.buttons.YES), text: 'Run now'
vex.dialog.buttons.NO
]

beforeClose: =>
return if @data is false

fileName = @data.filename.trim()
commandLineInput = @data.commandLineInput.trim()

if fileName.length is 0 and @data.autoTail is 'on'
$(window.noFilenameError).removeClass('hide')
return false

else
localStorage.setItem('taskRunRedirectFilename', fileName) if filename?
localStorage.setItem('taskRunAutoTail', @data.autoTail)
@data.id = @get 'id'

@run( @data.commandLineInput ).done callback( @data )
return true

afterOpen: =>
$('#filename').val localStorage.getItem('taskRunRedirectFilename')
if command is ""
history = localStorage.getItem(@localStorageCommandLineInputKeyPrefix + @id)
if !!history
history = history.split(",")
$('#commandLineInput').val history[history.length - 1]
$('#autoTail').prop 'checked', (localStorage.getItem('taskRunAutoTail') is 'on')

callback: (data) =>
@data = data

promptRemove: (callback) =>
vex.dialog.confirm
message: removeTemplate id: @get "id"
Expand Down
126 changes: 75 additions & 51 deletions SingularityUI/app/templates/deployDetail/deployInfo.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,81 @@

<div class="row">
<ul class="list-unstyled horizontal-description-list">
<li class="col-md-4">
<div>
<h4>Initiated<a data-clipboard-text="{{ timestampFromNow data.deployMarker.timestamp }}">Copy</a></h4>
<p>{{ timestampFromNow data.deployMarker.timestamp }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Completed<a data-clipboard-text="{{ timestampFromNow data.deployResult.timestamp }}">Copy</a></h4>
<p>{{ timestampFromNow data.deployResult.timestamp }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Command<a data-clipboard-text="{{ data.deploy.executorData.cmd }}">Copy</a></h4>
<p>{{ data.deploy.executorData.cmd }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Resources<a data-clipboard-text="CPUs: {{ data.deploy.resources.cpus }} |
Memory (Mb): {{ data.deploy.resources.memoryMb }} |
Ports: {{ data.deploy.resources.numPorts }}">Copy</a></h4>
<p>CPUs: {{ data.deploy.resources.cpus }} | Memory (MB): {{ data.deploy.resources.memoryMb }} | Ports: {{ data.deploy.resources.numPorts }}
</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Number of Tasks<a data-clipboard-text="{{ data.deployStatistics.numTasks }}">Copy</a></h4>
<p>{{ data.deployStatistics.numTasks }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Last Task State<a data-clipboard-text="{{ humanizeText data.deployStatistics.lastTaskState }}">Copy</a></h4>
<p>{{ humanizeText data.deployStatistics.lastTaskState }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Sequential Retries<a data-clipboard-text="{{ data.deployStatistics.numSequentialRetries }}">Copy</a></h4>
<p>{{ data.deployStatistics.numSequentialRetries }}</p>
</div>
</li>
<li class="col-md-4">
<div>
<h4>Average Runtime Milliseconds<a data-clipboard-text="{{ data.deployStatistics.averageRuntimeMillis }}">Copy</a></h4>
<p>{{ data.deployStatistics.averageRuntimeMillis }}</p>
</div>
</li>
{{#if data.deployMarker.timestamp }}
<li class="col-md-4">
<div>
<h4>Initiated<a data-clipboard-text="{{ timestampFromNow data.deployMarker.timestamp }}">Copy</a></h4>
<p>{{ timestampFromNow data.deployMarker.timestamp }}</p>
</div>
</li>
{{/if}}
{{#if data.deployResult.timestamp}}
<li class="col-md-4">
<div>
<h4>Completed<a data-clipboard-text="{{ timestampFromNow data.deployResult.timestamp }}">Copy</a></h4>
<p>{{ timestampFromNow data.deployResult.timestamp }}</p>
</div>
</li>
{{/if}}
{{#if data.deploy.executorData.cmd}}
<li class="col-md-4">
<div>
<h4>Command<a data-clipboard-text="{{ data.deploy.executorData.cmd }}">Copy</a></h4>
<p>{{ data.deploy.executorData.cmd }}</p>
</div>
</li>
{{/if}}
{{#if data.deploy.resources.cpus}}
<li class="col-md-4">
<div>
<h4>Resources<a data-clipboard-text="CPUs: {{ data.deploy.resources.cpus }} |
Memory (Mb): {{ data.deploy.resources.memoryMb }} |
Ports: {{ data.deploy.resources.numPorts }}">Copy</a></h4>
<p>CPUs: {{ data.deploy.resources.cpus }} | Memory (MB): {{ data.deploy.resources.memoryMb }} | Ports: {{ data.deploy.resources.numPorts }}
</p>
</div>
</li>
{{/if}}
{{#if data.deployStatistics.numTasks}}
<li class="col-md-4">
<div>
<h4>Number of Tasks<a data-clipboard-text="{{ data.deployStatistics.numTasks }}">Copy</a></h4>
<p>{{ data.deployStatistics.numTasks }}</p>
</div>
</li>
{{/if}}
{{#if data.deployStatistics.lastTaskState}}
<li class="col-md-4">
<div>
<h4>Last Task State<a data-clipboard-text="{{ humanizeText data.deployStatistics.lastTaskState }}">Copy</a></h4>
<p>{{ humanizeText data.deployStatistics.lastTaskState }}</p>
</div>
</li>
{{/if}}
{{#if data.deployStatistics.numSequentialRetries}}
<li class="col-md-4">
<div>
<h4>Sequential Retries<a data-clipboard-text="{{ data.deployStatistics.numSequentialRetries }}">Copy</a></h4>
<p>{{ data.deployStatistics.numSequentialRetries }}</p>
</div>
</li>
{{/if}}
{{#if data.deployStatistics.averageRuntimeMillis}}
<li class="col-md-4">
<div>
<h4>Average Runtime Milliseconds<a data-clipboard-text="{{ data.deployStatistics.averageRuntimeMillis }}">Copy</a></h4>
<p>{{ data.deployStatistics.averageRuntimeMillis }}</p>
</div>
</li>
{{/if}}
{{#if data.deploy.executorData.extraCmdLineArgs}}
<li class="col-md-4">
<div>
<h4>Extra Command Line Arguments<a data-clipboard-text="{{ data.deploy.executorData.extraCmdLineArgs }}">Copy</a></h4>
<p>{{ data.deploy.executorData.extraCmdLineArgs }}</p>
</div>
</li>
{{/if}}
</ul>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<th class="hidden-xs">
{{! Actions }}
</th>
<th class="hidden-xs">
{{! Actions }}
</th>
</tr>
</thead>
<tbody>
Expand All @@ -53,9 +56,18 @@
</td>
<td class="hidden-xs actions-column">
<a href="{{ appRoot }}/task/{{ taskId.id }}/tail/{{ substituteTaskId ../../config.finishedTaskLogPath taskId.id }}" title="Log">
...
···
</a>
</td>
{{#if canBeRunNow}}
<td class="hidden-xs actions-column">
<a data-action="rerun-task" data-taskId="{{ id }}" title="Rerun">
</a>
</td>
{{else}}
<td class="hidden-xs actions-column"></td>
{{/if}}
<td class="hidden-xs actions-column">
<a data-action="viewJSON" title="JSON">
{ }
Expand Down
16 changes: 16 additions & 0 deletions SingularityUI/app/templates/taskDetail/taskInfo.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,21 @@
</div>
</li>
{{/if}}
{{#if data.task.taskRequest.deploy.executorData.extraCmdLineArgs}}
<li class="col-md-4">
<div>
<h4>Extra Cmd Line Arguments (for Deploy)</h4>
<p>{{ data.task.taskRequest.deploy.executorData.extraCmdLineArgs }}</p>
</div>
</li>
{{/if}}
{{#if data.task.taskRequest.pendingTask.cmdLineArgsList }}
<li class="col-md-4">
<div>
<h4>Extra Cmd Line Arguments (for Task)</h4>
<p>{{ data.task.taskRequest.pendingTask.cmdLineArgsList }}</p>
</div>
</li>
{{/if}}
</ul>
</div>
2 changes: 1 addition & 1 deletion SingularityUI/app/templates/vex/requestRun.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<p>Additional command line input: <small>(optional)</small></p>
<div class="vex-dialog-input">
<input id='commandLineInput' name="commandLineInput" type="text" class="vex-dialog-prompt-input" placeholder="" value="">
<input id='commandLineInput' name="commandLineInput" type="text" class="vex-dialog-prompt-input" placeholder="" value="{{ command }}">
</div>
<hr class='border-color-light-gray'>

Expand Down
Loading