diff --git a/static/src/js/app/admin/admin.js b/static/src/js/app/admin/admin.js index c1ab398..989cbf7 100644 --- a/static/src/js/app/admin/admin.js +++ b/static/src/js/app/admin/admin.js @@ -21,43 +21,110 @@ define("admin", ["jquery", "avalon"], function ($, avalon) { hash = "index/index"; } + var superAdminNav = [ + { name: "首页", + children: [{name: "主页", hash: "#index/index"}, + {name: "监控", hash: "#monitor/monitor"}, + {name: "统计", hash: "#statistics/statistics"}] + }, + { + name: "通用", + children: [{name: "公告管理", hash: "#announcement/announcement"}, + {name: "用户管理", hash: "#user/user_list"}] + }, + { + name: "题目管理", + children: [{name: "题目列表", hash: "#problem/problem_list"}, + {name: "创建题目", hash: "#problem/add_problem"}] + }, + { + name: "比赛管理", + children: [{name: "比赛列表", hash: "#contest/contest_list"}, + {name: "创建比赛", hash: "#contest/add_contest"}] + }, + { + name: "小组管理", + children: [{name: "小组列表", hash: "#group/group"}, + {name: "加入小组请求", hash: "#group/join_group_request_list"}] + } + ]; + + var adminNav = [ + { name: "首页", + children: [{name: "主页", hash: "#index/index"}] + }, + { + name: "通用", + children: [{name: "公告管理", hash: "#announcement/announcement"}] + }, + { + name: "比赛管理", + children: [{name: "比赛列表", hash: "#contest/contest_list"}, + {name: "创建比赛", hash: "#contest/add_contest"}] + }, + { + name: "小组管理", + children: [{name: "小组列表", hash: "#group/group"}, + {name: "加入小组请求", hash: "#group/join_group_request_list"}] + } + ]; + var vm = avalon.define({ $id: "admin", template_url: "template/" + hash + ".html", groupId: -1, problemId: -1, + adminNavList: [], hide_loading: function () { $("#loading-gif").hide(); + }, + getLiId: function(hash){ + return hash.replace("#", "li-").replace("/", "-"); } }); - vm.$watch("showGroupDetailPage", function(groupId){ + + $.ajax({ + url: "/api/user/", + method: "get", + dataType: "json", + success: function(data){ + if(!data.code){ + if (data.data.admin_type == 2){ + vm.adminNavList = superAdminNav; + } + else{ + vm.adminNavList = adminNav; + } + } + } + }); + + vm.$watch("showGroupDetailPage", function (groupId) { vm.groupId = groupId; vm.template_url = "template/group/group_detail.html"; }); - vm.$watch("showEditProblemPage", function(problemId){ + vm.$watch("showEditProblemPage", function (problemId) { vm.problemId = problemId; vm.template_url = "template/problem/edit_problem.html"; }); - vm.$watch("showProblemListPage", function(){ - vm.template_url = "template/problem/problem_list.html"; + vm.$watch("showProblemListPage", function () { + vm.template_url = "template/problem/problem_list.html"; }); - vm.$watch("showGroupListPage", function(){ - vm.template_url = "template/group/group.html"; + vm.$watch("showGroupListPage", function () { + vm.template_url = "template/group/group.html"; }); - vm.$watch("showProblemSubmissionPage", function(problemId){ + vm.$watch("showProblemSubmissionPage", function (problemId) { vm.problemId = problemId; vm.template_url = "template/problem/submission_list.html"; }); avalon.scan(); - li_active("#li-" + hash.replace("/", "-")); - window.onhashchange = function () { var hash = window.location.hash.substring(1); if (hash) { @@ -66,6 +133,7 @@ define("admin", ["jquery", "avalon"], function ($, avalon) { show_template("template/" + hash + ".html"); } }; + setTimeout(function(){li_active("#li-" + hash.replace("/", "-"));}, 500) }); diff --git a/template/admin/admin.html b/template/admin/admin.html index b233809..1179182 100644 --- a/template/admin/admin.html +++ b/template/admin/admin.html @@ -1,3 +1,4 @@ +{% verbatim %} @@ -8,10 +9,6 @@ 在线评测系统 - 后台管理 - - {% block css_block %}{% endblock %} - - @@ -70,7 +67,13 @@
@@ -133,4 +137,5 @@ - \ No newline at end of file + +{% endverbatim %} \ No newline at end of file