move REST logic into services
This commit is contained in:
parent
7fa4855d22
commit
b6b870fc06
4 changed files with 18 additions and 25 deletions
|
@ -6,7 +6,9 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<script src="/static/js/angular.min.js"></script>
|
<script src="/static/js/angular.min.js"></script>
|
||||||
<script src="/static/js/angular-route.js"></script>
|
<script src="/static/js/angular-route.js"></script>
|
||||||
|
<script src="/static/js/angular-resource.js"></script>
|
||||||
<script src="/js/app.js"></script>
|
<script src="/js/app.js"></script>
|
||||||
|
<script src="/js/services.js"></script>
|
||||||
<script src="/js/controllers.js"></script>
|
<script src="/js/controllers.js"></script>
|
||||||
<title>Event Man(ager)</title>
|
<title>Event Man(ager)</title>
|
||||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
@ -17,6 +19,7 @@
|
||||||
<div class="main-header" ng-controller="navigation as n">
|
<div class="main-header" ng-controller="navigation as n">
|
||||||
<input type="button" id="events-button" ng-click="n.go('/events')" class="btn btn-link" value="Events" />
|
<input type="button" id="events-button" ng-click="n.go('/events')" class="btn btn-link" value="Events" />
|
||||||
<input type="button" id="new-event-button" ng-click="n.go('/new-event')" class="btn btn-link" value="Add Event" />
|
<input type="button" id="new-event-button" ng-click="n.go('/new-event')" class="btn btn-link" value="Add Event" />
|
||||||
|
<input type="button" id="persons-button" ng-click="n.go('/persons')" class="btn btn-link" value="Persons" />
|
||||||
<input type="button" id="persons-button" ng-click="n.go('/new-person')" class="btn btn-link" value="Add Persons" />
|
<input type="button" id="persons-button" ng-click="n.go('/new-person')" class="btn btn-link" value="Add Persons" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
1
angular_app/js/app.js
vendored
1
angular_app/js/app.js
vendored
|
@ -1,5 +1,6 @@
|
||||||
var eventManApp = angular.module('eventManApp', [
|
var eventManApp = angular.module('eventManApp', [
|
||||||
'ngRoute',
|
'ngRoute',
|
||||||
|
'eventManServices',
|
||||||
'eventManControllers'
|
'eventManControllers'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
33
angular_app/js/controllers.js
vendored
33
angular_app/js/controllers.js
vendored
|
@ -12,41 +12,32 @@ eventManControllers.controller('navigation', ['$location',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('EventsListCtrl', ['$scope', '$http',
|
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
||||||
function ($scope, $http) {
|
function ($scope, Event) {
|
||||||
$http.get('/events').success(function(data) {
|
$scope.events = Event.all();
|
||||||
$scope.events = data.events;
|
|
||||||
});
|
|
||||||
$scope.orderProp = 'begin-datetime';
|
$scope.orderProp = 'begin-datetime';
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$http', '$routeParams',
|
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$routeParams',
|
||||||
function ($scope, $http, $routeParams) {
|
function ($scope, Event, $routeParams) {
|
||||||
$http.get("/events/" + $routeParams.eventID).success(function(data) {
|
$scope.event = Event.get($routeParams);
|
||||||
|
|
||||||
$scope.event = data.event;
|
|
||||||
});
|
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('PersonsListCtrl', ['$scope', '$http',
|
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person',
|
||||||
function ($scope, $http) {
|
function ($scope, Person) {
|
||||||
$http.get('/persons').success(function(data) {
|
$scope.persons = Person.all();
|
||||||
$scope.persons = data.persons;
|
|
||||||
});
|
|
||||||
$scope.orderProp = 'name';
|
$scope.orderProp = 'name';
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$http', '$routeParams',
|
eventManControllers.controller('PersonDetailsCtrl', ['$scope', 'Person', '$routeParams',
|
||||||
function ($scope, $http, $routeParams) {
|
function ($scope, Person, $routeParams) {
|
||||||
$http.get("/persons/" + $routeParams.personID).success(function(data) {
|
$scope.person = Person.get($routeParams);
|
||||||
$scope.person = data.person;
|
|
||||||
});
|
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PersonsHandler(BaseHandler):
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def get(self, id_=None):
|
def get(self, id_=None):
|
||||||
if id_ is not None:
|
if id_ is not None:
|
||||||
self.write({'person': MOCKUP_PERSONS[int(id_)]})
|
self.write(MOCKUP_PERSONS[int(id_)])
|
||||||
return
|
return
|
||||||
self.write({'persons': MOCKUP_PERSONS.values()})
|
self.write({'persons': MOCKUP_PERSONS.values()})
|
||||||
|
|
||||||
|
@ -75,13 +75,11 @@ class EventsHandler(BaseHandler):
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def get(self, id_=None):
|
def get(self, id_=None):
|
||||||
if id_ is not None:
|
if id_ is not None:
|
||||||
self.write({'event': MOCKUP_EVENTS[int(id_)]})
|
self.write(MOCKUP_EVENTS[int(id_)])
|
||||||
return
|
return
|
||||||
self.write({'events': MOCKUP_EVENTS.values()})
|
self.write({'events': MOCKUP_EVENTS.values()})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
define("port", default=5242, help="run on the given port", type=int)
|
define("port", default=5242, help="run on the given port", type=int)
|
||||||
define("data", default=os.path.join(os.path.dirname(__file__), "data"),
|
define("data", default=os.path.join(os.path.dirname(__file__), "data"),
|
||||||
|
|
Loading…
Reference in a new issue