2016-01-13 00:22:54 +00:00
|
|
|
angular.module("FICApp", ["ngRoute", "ngResource"])
|
|
|
|
.config(function($routeProvider, $locationProvider) {
|
|
|
|
$routeProvider
|
2016-01-22 16:37:29 +00:00
|
|
|
.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"
|
|
|
|
})
|
2016-01-13 00:22:54 +00:00
|
|
|
.when("/teams", {
|
|
|
|
controller: "TeamsListController",
|
|
|
|
templateUrl: "views/team-list.html"
|
|
|
|
})
|
|
|
|
.when("/teams/new", {
|
|
|
|
controller: "TeamNewController",
|
|
|
|
templateUrl: "views/team-new.html"
|
|
|
|
});
|
|
|
|
$locationProvider.html5Mode(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
angular.module("FICApp")
|
|
|
|
.factory("Team", function($resource) {
|
2016-01-22 16:37:29 +00:00
|
|
|
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'},
|
2016-01-13 00:22:54 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
angular.module("FICApp")
|
2016-01-22 16:37:29 +00:00
|
|
|
.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});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-01-13 00:22:54 +00:00
|
|
|
.controller("TeamsListController", function($scope, Team, $location) {
|
|
|
|
$scope.teams = Team.query();
|
|
|
|
$scope.fields = ["id", "name"];
|
|
|
|
|
|
|
|
$scope.show = function(id) {
|
|
|
|
$location.url("/teams/" + id);
|
|
|
|
};
|
2016-01-22 16:37:29 +00:00
|
|
|
})
|
|
|
|
.controller("TeamNewController", function($scope, Team, $location) {
|
|
|
|
$scope.contact = new Team({
|
|
|
|
|
|
|
|
})
|
2016-01-13 00:22:54 +00:00
|
|
|
});
|