Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give meaningful titles to all pages #713

Merged
merged 3 commits into from Oct 14, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions SingularityUI/app/controllers/Controller.coffee
@@ -1,6 +1,6 @@
# Base controller to be extended by other classes
class Controller

# Reference to the primary view being used
view: undefined
# Subviews that will be used by the primary view
Expand All @@ -10,7 +10,11 @@ class Controller
models: {}
collections: {}

constructor: (params) -> @initialize?(params)
constructor: (params) ->
# Reset the title between each page
@title ''
@initialize?(params)

# Initialize should bootstrap models/controllers and views
initialize: ->

Expand All @@ -22,6 +26,12 @@ class Controller
setView: (@view) ->
@view.on 'refreshrequest', => @refresh()

title: (pageTitle) ->
if pageTitle == ''
document.title = config.title
else
document.title = pageTitle + ' - ' + config.title

# e.g. `myModel.fetch().error @ignore404`
ignore404: (response) -> app.caughtError() if response.status is 404

Expand Down
2 changes: 1 addition & 1 deletion SingularityUI/app/controllers/Dashboard.coffee
Expand Up @@ -8,7 +8,7 @@ class DashboardController extends Controller

initialize: ->
app.showPageLoader()

@title 'Dashboard'
@collections.requests = new Requests [], state: 'all'

@collections.requests.fetch().done =>
Expand Down
2 changes: 2 additions & 0 deletions SingularityUI/app/controllers/DeployDetail.coffee
Expand Up @@ -20,6 +20,8 @@ class DeployDetailController extends Controller
healthChecks: require '../templates/deployDetail/deployHealthChecks'

initialize: ({@requestId, @deployId}) ->
@title "#{ @requestId } deploy #{ @deployId }"

#
# Data stuff
#
Expand Down
3 changes: 2 additions & 1 deletion SingularityUI/app/controllers/NewDeploy.coffee
Expand Up @@ -8,13 +8,14 @@ class NewDeployController extends Controller

initialize: ({requestId}) ->
app.showPageLoader()
@title 'New Deploy'

@models.request = new Request id: requestId

@models.request.fetch().done =>
@setView new NewDeployView
model: @models.request

app.showView @view

module.exports = NewDeployController
1 change: 1 addition & 0 deletions SingularityUI/app/controllers/NotFound.coffee
Expand Up @@ -5,6 +5,7 @@ NotFoundView = require '../views/notFound'
class NotFoundController extends Controller

initialize: ->
@title 'Not Found'
@setView new NotFoundView
app.showView @view

Expand Down
1 change: 1 addition & 0 deletions SingularityUI/app/controllers/Racks.coffee
Expand Up @@ -9,6 +9,7 @@ class RacksController extends Controller

initialize: ({@state}) ->
app.showPageLoader()
@title 'Racks'
@collections.racks = new Racks []
@setView new RacksView _.extend {@state},
collection: @collections.racks
Expand Down
6 changes: 4 additions & 2 deletions SingularityUI/app/controllers/RequestDetail.coffee
Expand Up @@ -29,6 +29,8 @@ class RequestDetailController extends Controller
requestHistory: require '../templates/requestDetail/requestHistory'

initialize: ({@requestId}) ->
@title @requestId

#
# Data stuff
#
Expand Down Expand Up @@ -56,7 +58,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 @@ -124,7 +126,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 Down
4 changes: 3 additions & 1 deletion SingularityUI/app/controllers/RequestsTable.coffee
Expand Up @@ -7,14 +7,16 @@ RequestsTableView = require '../views/requests'
class RequestsTableController extends Controller

initialize: ({@state, @subFilter, @searchFilter}) ->
@title 'Requests'

# We want the view to handle the page loader for this one
@collections.requests = new Requests [], {@state}

@setView new RequestsTableView _.extend {@state, @subFilter, @searchFilter},
collection: @collections.requests

@collections.requests.fetch()

app.showView @view

refresh: ->
Expand Down
2 changes: 2 additions & 0 deletions SingularityUI/app/controllers/Slaves.coffee
Expand Up @@ -9,6 +9,8 @@ class SlavesController extends Controller

initialize: ({@state}) ->
app.showPageLoader()
@title 'Slaves'

@collections.slaves = new Slaves []
@setView new SlavesView _.extend {@state},
collection: @collections.slaves
Expand Down
3 changes: 2 additions & 1 deletion SingularityUI/app/controllers/Status.coffee
Expand Up @@ -5,9 +5,10 @@ State = require '../models/State'
StatusView = require '../views/status'

class StatusController extends Controller

initialize: ->
app.showPageLoader()
@title 'Status'

@models.state = new State

Expand Down
4 changes: 3 additions & 1 deletion SingularityUI/app/controllers/Tail.coffee
Expand Up @@ -9,10 +9,12 @@ TailView = require '../views/tail'
class TailController extends Controller

initialize: ({@taskId, @path, @offset}) ->
@title 'Tail of ' + @path

@models.ajaxError = new AjaxError
@collections.logLines = new LogLines [], {@taskId, @path, ajaxError: @models.ajaxError}
@models.taskHistory = new TaskHistory {@taskId}

@setView new TailView _.extend {@taskId, @path, @offset},
collection: @collections.logLines
model: @models.taskHistory
Expand Down
6 changes: 4 additions & 2 deletions SingularityUI/app/controllers/TaskDetail.coffee
Expand Up @@ -30,6 +30,8 @@ class TaskDetailController extends Controller
resourceUsage: require '../templates/taskDetail/taskResourceUsage'

initialize: ({@taskId, @filePath}) ->
@title @taskId

#
# Models / collections
#
Expand Down Expand Up @@ -111,9 +113,9 @@ class TaskDetailController extends Controller
@models.resourceUsage?.fetch()
.done =>
# Store current resource usage to compare against future resource usage
@models.resourceUsage.setCpuUsage() if @models.resourceUsage.get('previousUsage')
@models.resourceUsage.setCpuUsage() if @models.resourceUsage.get('previousUsage')
@models.resourceUsage.set('previousUsage', @models.resourceUsage.toJSON())

if not @resourcesFetched
setTimeout (=> @fetchResourceUsage() ), 2000
@resourcesFetched = true
Expand Down
6 changes: 4 additions & 2 deletions SingularityUI/app/controllers/TasksTable.coffee
Expand Up @@ -11,12 +11,14 @@ TasksTableView = require '../views/tasks'
class TasksTableController extends Controller

initialize: ({@state, @searchFilter}) ->
@title 'Tasks'

if @state is 'decommissioning'
@collections.tasks = new Tasks [], state: 'active'
else if @state is 'scheduled'
@collections.tasks = new Tasks [], {state: 'scheduled', addPropertyString: 'pendingTask'}
# @collections.tasks.setPropertyString('pendingTask')

else
@collections.tasks = new Tasks [], {@state}
@collections.slaves = new Slaves []
Expand All @@ -29,7 +31,7 @@ class TasksTableController extends Controller

# Fetch a pending task's full details
@view.on 'getPendingTask', (task) => @getPendingTask(task)

@collections.slaves.fetch()
@collections.tasks.fetch()
app.showView @view
Expand Down