[admin] Add events

This commit is contained in:
nemunaire 2016-12-26 03:44:04 +01:00 committed by Pierre-Olivier Mercier
parent f0f39e4905
commit 8d725ef35b
5 changed files with 187 additions and 1 deletions

View file

@ -33,6 +33,14 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
controller: "TeamNewController",
templateUrl: "views/team-new.html"
})
.when("/events", {
controller: "EventsListController",
templateUrl: "views/event-list.html"
})
.when("/events/:eventId", {
controller: "EventController",
templateUrl: "views/event.html"
})
.when("/", {
templateUrl: "views/home.html"
});
@ -43,6 +51,11 @@ angular.module("FICApp")
.factory("Version", function($resource) {
return $resource("/api/version")
})
.factory("Event", function($resource) {
return $resource("/api/events/:eventId", { eventId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("Team", function($resource) {
return $resource("/api/teams/:teamId", { teamId: '@id' }, {
'update': {method: 'PUT'},
@ -166,6 +179,42 @@ angular.module("FICApp")
$scope.v = Version.get();
})
.controller("EventsListController", function($scope, Event, $location) {
$scope.events = Event.query();
$scope.fields = ["id", "kind", "txt", "time"];
$scope.clearEvents = function(id) {
Event.delete(function() {
$scope.events = [];
});
};
$scope.show = function(id) {
$location.url("/events/" + id);
};
})
.controller("EventController", function($scope, Event, $routeParams, $location) {
$scope.event = Event.get({ eventId: $routeParams.eventId });
$scope.fields = ["kind", "txt", "time"];
$scope.kinds = {
"alert-info": "Info",
"alert-warning": "Warning",
"alert-success": "Success"
};
$scope.saveEvent = function() {
if (this.event.id) {
this.event.$update();
} else {
this.event.$save(function() {
$location.url("/events/" + $scope.event.id);
});
}
}
$scope.deleteEvent = function() {
this.event.$remove(function() { $location.url("/events/");});
}
})
.controller("ThemesListController", function($scope, Theme, $location) {
$scope.themes = Theme.query();
$scope.fields = ["id", "name"];