From f4a3f4513cc23c1aef6337720df8ccc9b90140dc Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 7 Jan 2016 02:40:19 -0600 Subject: [PATCH] admin controller --- web/css/easyctf.css | 4 +-- web/index.html | 1 + web/js/easyctf.js | 17 ++++++++++- web/pages/admin/problems.html | 54 ++++++++++++++++++++++++++++------- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/web/css/easyctf.css b/web/css/easyctf.css index b92bdc0..3e8b653 100644 --- a/web/css/easyctf.css +++ b/web/css/easyctf.css @@ -8,12 +8,12 @@ font-weight: bold; } -* { +body { font-family: "Proxima Nova", Helvetica Neue, Helvetica, Arial, sans-serif; } .tab-content { - padding: 10px; + padding: 15px; > .tab-pane { display: none; } diff --git a/web/index.html b/web/index.html index 0b0c030..8012137 100644 --- a/web/index.html +++ b/web/index.html @@ -20,6 +20,7 @@ + diff --git a/web/js/easyctf.js b/web/js/easyctf.js index 972f335..7c23a0f 100644 --- a/web/js/easyctf.js +++ b/web/js/easyctf.js @@ -62,6 +62,7 @@ app.controller("mainController", ["$scope", "$http", function($scope, $http) { $scope.config.navbar.logged_in = result["logged_in"]; $scope.config.navbar.username = result["username"]; $scope.config.navbar.admin = result["admin"]; + $scope.$emit("adminStatus"); } else { $scope.config.navbar.logged_in = false; } @@ -91,8 +92,22 @@ app.controller("profileController", ["$controller", "$scope", "$http", "$routePa }); }]); -app.controller("adminProblemsController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { +app.controller("adminController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { $controller("mainController", { $scope: $scope }); + $scope.$on("adminStatus", function() { + if ($scope.config["navbar"].logged_in != true) { + location.href = "/login"; + return; + } + if ($scope.config["navbar"].admin != true) { + location.href = "/profile"; + return; + } + }); +}]); + +app.controller("adminProblemsController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { + $controller("adminController", { $scope: $scope }); $.post("/api/admin/problems/list", function(result) { if (result["success"] == 1) { $scope.problems = result["problems"]; diff --git a/web/pages/admin/problems.html b/web/pages/admin/problems.html index 2e6888e..ca0798e 100644 --- a/web/pages/admin/problems.html +++ b/web/pages/admin/problems.html @@ -2,6 +2,13 @@

Problem Editor

+ +