initial plumb of scoreboard
This commit is contained in:
parent
615ca5afe3
commit
b0f66f16fb
@ -71,6 +71,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter {
|
||||
registry.addViewController("/login").setViewName("login");
|
||||
registry.addViewController("/lesson_content").setViewName("lesson_content");
|
||||
registry.addViewController("/start.mvc").setViewName("main_new");
|
||||
registry.addViewController("/scoreboard").setViewName("scoreboard");
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Scoreboard {
|
||||
private List<String> flagsCaptured;
|
||||
}
|
||||
|
||||
@GetMapping("/scoreboard")
|
||||
@GetMapping("/scoreboard-data")
|
||||
public List<Ranking> getRankings() {
|
||||
List<WebGoatUser> allUsers = userRepository.findAll();
|
||||
List<Ranking> rankings = Lists.newArrayList();
|
||||
|
@ -8,7 +8,6 @@ define(['jquery',
|
||||
'goatApp/view/SolutionView',
|
||||
'goatApp/view/HintView',
|
||||
'goatApp/view/HelpControlsView',
|
||||
'goatApp/view/CookieView',
|
||||
'goatApp/view/ParamView',
|
||||
'goatApp/model/ParamModel',
|
||||
'goatApp/view/DeveloperControlsView',
|
||||
@ -32,7 +31,6 @@ define(['jquery',
|
||||
SolutionView,
|
||||
HintView,
|
||||
HelpControlsView,
|
||||
CookieView,
|
||||
ParamView,
|
||||
ParamModel,
|
||||
DeveloperControlsView,
|
||||
@ -130,7 +128,6 @@ define(['jquery',
|
||||
this.solutionView = new SolutionView();
|
||||
this.sourceView = new SourceView();
|
||||
this.lessonHintView = new HintView();
|
||||
this.cookieView = new CookieView();
|
||||
|
||||
//TODO: instantiate model with values (not sure why was not working before)
|
||||
var paramModel = new ParamModel({});
|
||||
|
@ -1,13 +1,13 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/CookieModel'],
|
||||
'goatApp/model/FlagModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
CookieModel) {
|
||||
FlagModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url:'service/cookie.mvc',
|
||||
model:CookieModel
|
||||
url:'/WebGoat/scoreboard-data',
|
||||
model:FlagModel
|
||||
});
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/support/goatAsyncErrorHandler',
|
||||
'goatApp/view/ScoreboardView'],
|
||||
function ($,
|
||||
_,
|
||||
Backbone,
|
||||
asyncErrorHandler,
|
||||
ScoreboardView) {
|
||||
'use strict'
|
||||
return {
|
||||
initApp: function () {
|
||||
scoreboard = new ScoreboardView();
|
||||
}
|
||||
};
|
||||
});
|
@ -1,34 +0,0 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/CookieCollection'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
CookieCollection) {
|
||||
return Backbone.View.extend({
|
||||
el:'#cookies-view',
|
||||
|
||||
initialize: function() {
|
||||
this.collection = new CookieCollection();
|
||||
this.listenTo(this.collection,'reset',this.render)
|
||||
this.collection.fetch({reset:true});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html('')
|
||||
var cookieTable;
|
||||
this.collection.each(function(model) {
|
||||
cookieTable = $('<table>',{'class':'cookie-table table-striped table-nonfluid'});
|
||||
_.each(model.keys(), function(attribute) {
|
||||
var newRow = $('<tr>');
|
||||
newRow.append($('<th>',{text:_.escape(attribute)}))
|
||||
newRow.append($('<td>',{text:_.escape(model.get(attribute))}));
|
||||
cookieTable.append(newRow);
|
||||
});
|
||||
});
|
||||
this.$el.append($('<h4>',{text:'Cookie/s'}));
|
||||
this.$el.append(cookieTable);
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/FlagsCollection'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
FlagsCollection) {
|
||||
return Backbone.View.extend({
|
||||
el:'#scoreboard',
|
||||
|
||||
initialize: function() {
|
||||
this.collection = new FlagsCollection();
|
||||
this.listenTo(this.collection,'reset',this.render)
|
||||
this.collection.fetch({reset:true});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html('test')
|
||||
//TODO: add template (table) to iterate over ...
|
||||
//this.collection.toJSON(); << put that in the template data
|
||||
//TODO: set up next poll here with listenToOnce
|
||||
}
|
||||
});
|
||||
});
|
47
webgoat-container/src/main/resources/static/js/scoreboard.js
Normal file
47
webgoat-container/src/main/resources/static/js/scoreboard.js
Normal file
@ -0,0 +1,47 @@
|
||||
//main.js
|
||||
/*
|
||||
/js
|
||||
js/main.js << main file for require.js
|
||||
--/libs/(jquery,backbone,etc.) << base libs
|
||||
--/goatApp/ << base dir for goat application, js-wise
|
||||
--/goatApp/model
|
||||
--/goatApp/view
|
||||
--/goatApp/support
|
||||
--/goatApp/controller
|
||||
*/
|
||||
|
||||
require.config({
|
||||
baseUrl: "js/",
|
||||
paths: {
|
||||
jquery: 'libs/jquery-2.2.4.min',
|
||||
jqueryui: 'libs/jquery-ui-1.10.4',
|
||||
underscore: 'libs/underscore-min',
|
||||
backbone: 'libs/backbone-min',
|
||||
text: 'libs/text',
|
||||
templates: 'goatApp/templates',
|
||||
polyglot: 'libs/polyglot.min'
|
||||
},
|
||||
|
||||
map: {
|
||||
'libs/jquery-base' : {'jquery':'libs/jquery-2.2.4.min'},
|
||||
'libs/jquery-vuln' : {'jquery':'libs/jquery-2.1.4.min'}
|
||||
},
|
||||
|
||||
shim: {
|
||||
"jqueryui": {
|
||||
exports:"$",
|
||||
deps: ['jquery']
|
||||
},
|
||||
underscore: {
|
||||
exports: "_"
|
||||
},
|
||||
backbone: {
|
||||
deps: ['underscore', 'jquery'],
|
||||
exports: 'Backbone'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
require(['jquery','libs/jquery-base','libs/jquery-vuln','jqueryui', 'underscore','backbone','goatApp/scoreboardApp'], function($,jqueryBase,jqueryVuln,jqueryui,_,Backbone,ScoreboardApp){
|
||||
ScoreboardApp.initApp();
|
||||
});
|
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<meta http-equiv="Expires" CONTENT="-1"/>
|
||||
<meta http-equiv="Pragma" CONTENT="no-cache"/>
|
||||
<meta http-equiv="Cache-Control" CONTENT="no-cache"/>
|
||||
<meta http-equiv="Cache-Control" CONTENT="no-store"/>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<id class="no-js lt-ie9 lt-ie8 lt-ie7"/> <![endif]-->
|
||||
<!--[if IE 7]>
|
||||
<id class="no-js lt-ie9 lt-ie8"/> <![endif]-->
|
||||
<!--[if IE 8]>
|
||||
<id class="no-js lt-ie9"/> <![endif]-->
|
||||
<!--[if gt IE 8]><!-->
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="shortcut icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
|
||||
|
||||
<!-- Require.js used to load js asynchronously -->
|
||||
<script src="js/libs/require.min.js" data-main="js/scoreboard.js"/>
|
||||
<meta http-equiv="Content-Type" content="text/id; charset=ISO-8859-1"/>
|
||||
<title>WebGoat</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="scoreboard-wrapper">
|
||||
<div id="scoreboard">
|
||||
<!-- will use _ template here -->
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user