admin: improve human interface
This commit is contained in:
parent
61dc38c09c
commit
46dcff83c3
4 changed files with 111 additions and 7 deletions
|
@ -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({
|
||||
|
||||
})
|
||||
});
|
||||
|
|
Reference in a new issue