admin: improve human interface
This commit is contained in:
parent
61dc38c09c
commit
46dcff83c3
4 changed files with 111 additions and 7 deletions
|
@ -9,8 +9,7 @@
|
|||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>Hello World!</h1>
|
||||
<h2>{{message}}</h2>
|
||||
<h1>Challenge FIC Epita!</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12" ng-view></div>
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
angular.module("FICApp", ["ngRoute", "ngResource"])
|
||||
.config(function($routeProvider, $locationProvider) {
|
||||
$routeProvider
|
||||
.when("/themes", {
|
||||
controller: "ThemesListController",
|
||||
templateUrl: "views/theme-list.html"
|
||||
})
|
||||
.when("/themes/:themeId", {
|
||||
controller: "ThemeController",
|
||||
templateUrl: "views/theme.html"
|
||||
})
|
||||
.when("/themes/:themeId/:exerciceId", {
|
||||
controller: "ExerciceController",
|
||||
templateUrl: "views/exercice.html"
|
||||
})
|
||||
.when("/teams", {
|
||||
controller: "TeamsListController",
|
||||
templateUrl: "views/team-list.html"
|
||||
|
@ -10,19 +22,63 @@ angular.module("FICApp", ["ngRoute", "ngResource"])
|
|||
templateUrl: "views/team-new.html"
|
||||
});
|
||||
$locationProvider.html5Mode(true);
|
||||
})
|
||||
.run(function($rootScope) {
|
||||
$rootScope.message = "Hello Angular!";
|
||||
});
|
||||
|
||||
angular.module("FICApp")
|
||||
.factory("Team", function($resource) {
|
||||
return $resource("/api/teams/:id", { id: '@id' }, {
|
||||
'update': { method: "PATCH" }
|
||||
return $resource("/api/teams/:teamId", { teamId: '@id' }, {
|
||||
'save': {method: 'PATCH'},
|
||||
})
|
||||
});
|
||||
angular.module("FICApp")
|
||||
.factory("Theme", function($resource) {
|
||||
return $resource("/api/themes/:themeId", null, {
|
||||
'save': {method: 'PATCH'},
|
||||
})
|
||||
});
|
||||
angular.module("FICApp")
|
||||
.factory("Exercice", function($resource) {
|
||||
return $resource("/api/themes/:themeId/:exerciceId", null, {
|
||||
'query': {method: "GET", url: "/api/themes/:themeId/exercices", isArray: true},
|
||||
'save': {method: 'PATCH'},
|
||||
})
|
||||
});
|
||||
|
||||
angular.module("FICApp")
|
||||
.controller("ThemesListController", function($scope, Theme, $location) {
|
||||
$scope.themes = Theme.query();
|
||||
$scope.fields = ["id", "name"];
|
||||
|
||||
$scope.show = function(id) {
|
||||
$location.url("/themes/" + id);
|
||||
};
|
||||
})
|
||||
.controller("ThemeController", function($scope, Theme, $routeParams) {
|
||||
$scope.theme = Theme.get({ themeId: $routeParams.themeId });
|
||||
$scope.fields = ["name"];
|
||||
|
||||
$scope.saveTheme = function() {
|
||||
this.theme.$save({themeId: this.theme.themeId});
|
||||
}
|
||||
})
|
||||
|
||||
.controller("ExercicesListController", function($scope, Exercice, $routeParams, $location) {
|
||||
$scope.exercices = Exercice.query({ themeId: $routeParams.themeId });
|
||||
$scope.fields = ["id", "title", "statement", "videoURI"];
|
||||
|
||||
$scope.show = function(id) {
|
||||
$location.url("/themes/" + $routeParams.themeId + "/" + id);
|
||||
};
|
||||
})
|
||||
.controller("ExerciceController", function($scope, Theme, $routeParams) {
|
||||
$scope.exercice = Exercice.get({ themeId: $routeParams.themeId });
|
||||
$scope.fields = ["name", "statement", "hint", "videoURI"];
|
||||
|
||||
$scope.saveTheme = function() {
|
||||
this.exercice.$save({ themeId: this.exercice.themeId, exerciceId: this.exercice.exerciceId});
|
||||
}
|
||||
})
|
||||
|
||||
.controller("TeamsListController", function($scope, Team, $location) {
|
||||
$scope.teams = Team.query();
|
||||
$scope.fields = ["id", "name"];
|
||||
|
@ -30,4 +86,9 @@ angular.module("FICApp")
|
|||
$scope.show = function(id) {
|
||||
$location.url("/teams/" + id);
|
||||
};
|
||||
})
|
||||
.controller("TeamNewController", function($scope, Team, $location) {
|
||||
$scope.contact = new Team({
|
||||
|
||||
})
|
||||
});
|
||||
|
|
17
admin/static/views/theme-list.html
Normal file
17
admin/static/views/theme-list.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<p><input type="search" class="form-control" placeholder="Search" ng-model="query"></p>
|
||||
<table class="table table-hover table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="field in fields">
|
||||
{{ field }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="theme in themes | filter: query" ng-click="show(theme.id)">
|
||||
<td ng-repeat="field in fields">
|
||||
{{ theme[field] }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
27
admin/static/views/theme.html
Normal file
27
admin/static/views/theme.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<form class="form" ng-submit="ssubmit()">
|
||||
<div class="form-group" ng-repeat="field in fields">
|
||||
<label for="{{ field }}">{{ field }}</label>
|
||||
<input type="text" class="form-control" id="{{ field }}" ng-model="theme[field]">
|
||||
</div>
|
||||
<button class="btn btn-primary" ng-click="saveTheme()">Save</button>
|
||||
</form>
|
||||
|
||||
<div ng-controller="ExercicesListController">
|
||||
<p><input type="search" class="form-control" placeholder="Search" ng-model="query"></p>
|
||||
<table class="table table-hover table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="field in fields">
|
||||
{{ field }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="team in teams | filter: query" ng-click="show(team.id)">
|
||||
<td ng-repeat="field in fields">
|
||||
{{ team[field] }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
Reference in a new issue