User code problems admin view

Shows the most recent 1000 log entries
Url: admin/user-code-problems
This commit is contained in:
Matt Lott 2014-10-24 15:11:55 -07:00
parent f4426f2e43
commit 185c977cdb
5 changed files with 77 additions and 1 deletions

View file

@ -34,6 +34,7 @@ module.exports = class CocoRouter extends Backbone.Router
'admin/level-sessions': go('admin/LevelSessionsView')
'admin/users': go('admin/UsersView')
'admin/base': go('admin/BaseView')
'admin/user-code-problems': go('admin/UserCodeProblemsView')
'beta': go('HomeView')

View file

@ -1052,8 +1052,10 @@
av_entities_active_instances_url: "Active Instances"
av_entities_employer_list_url: "Employer List"
av_entities_candidates_list_url: "Candidate List"
av_entities_user_code_problems_list_url: "User Code Problems List"
av_other_sub_title: "Other"
av_other_debug_base_url: "Base (for debugging base.jade)"
u_title: "User List"
ucp_title: "User Code Problems"
lg_title: "Latest Games"
clas: "CLAs"

View file

@ -33,6 +33,8 @@ block content
a(href="/admin/employers", data-i18n="admin.av_entities_employer_list_url") Employer List
li
a(href="/admin/candidates", data-i18n="admin.av_entities_candidates_list_url") Candidate List
li
a(href="/admin/user-code-problems", data-i18n="admin.av_entities_user_code_problems_list_url") User Code Problems List
h4(data-i18n="admin.av_other_sub_title") Other

View file

@ -0,0 +1,33 @@
extends /templates/base
block content
h1(data-i18n="admin.ucp_title") User Code Problems
table.table.table-striped.table-bordered.table-condensed#users
thead(style='font-weight:bold')
tr
td language
//- td errType
//- td errLevel
//- td errId
td levelID
td codeSnippet
td errHint
td errMessage
//- td code
td created
tbody
each problem in userCodeProblems
tr
td #{problem.language}
//- td #{problem.errType}
//- td #{problem.errLevel}
//- td #{problem.errId}
td #{problem.levelID}
td #{problem.codeSnippet}
td #{problem.errHint}
td #{problem.errMessage}
//- td #{problem.code}
td #{new Date(problem.created).toLocaleString()}

View file

@ -0,0 +1,38 @@
RootView = require 'views/kinds/RootView'
template = require 'templates/admin/user-code-problems'
UserCodeProblem = require 'models/UserCodeProblem'
module.exports = class UserCodeProblemsView extends RootView
# TODO: Pagination, choosing filters on the page itself.
id: 'admin-user-code-problems-view'
template: template
constructor: (options) ->
super options
@getUserCodeProblems()
getUserCodeProblems: ->
# can have this page show arbitrary conditions, see mongoose queries
# http://mongoosejs.com/docs/queries.html
# Each list in conditions is a function call.
# The first arg is the function name
# The rest are the args for the function
conditions = [
['limit', 1000]
['sort', '-created']
]
conditions = $.param({conditions:JSON.stringify(conditions)})
UserCodeProblemCollection = Backbone.Collection.extend({
model: UserCodeProblem
url: '/db/user.code.problem?' + conditions
})
@userCodeProblems = new UserCodeProblemCollection()
@userCodeProblems.fetch()
@listenTo(@userCodeProblems, 'all', @render)
getRenderData: ->
c = super()
c.userCodeProblems = (problem.attributes for problem in @userCodeProblems.models)
c