($scope, $http, $location, SessionService, SessionCollection, UserService, UserCollection, api)
| 2 | |
| 3 | module.controller('MainController', Main); |
| 4 | function Main($scope, $http, $location, SessionService, SessionCollection, UserService, UserCollection, api) { |
| 5 | $scope.sessions = SessionService.query(); |
| 6 | $scope.sessionname = "games"; |
| 7 | $scope.sessionid = ""; |
| 8 | $scope.username = "random"; |
| 9 | |
| 10 | $scope.createSession = function (sessionname, username) { |
| 11 | var sessionid; |
| 12 | var userid; |
| 13 | CreateUser = UserCollection.createUser(username, null); |
| 14 | CreateSession = CreateUser.then(function(createUserResult){ |
| 15 | userid = createUserResult.id; |
| 16 | return SessionCollection.createSession(sessionname, createUserResult.id); |
| 17 | }); |
| 18 | JoinSession = CreateSession.then(function(createSessionResult) { |
| 19 | console.log("session id: " + createSessionResult.id); |
| 20 | sessionid = createSessionResult.id; |
| 21 | return SessionCollection.joinSession(createSessionResult.id, createSessionResult.owner); |
| 22 | }); |
| 23 | JoinSession.then(function(){ |
| 24 | $location.path('/session/'+ sessionid+ '/' + userid); |
| 25 | }); |
| 26 | }; |
| 27 | |
| 28 | $scope.joinSession = function(sessionid, username) { |
| 29 | var userid; |
| 30 | CreateUser = UserCollection.createUser(username, null); |
| 31 | JoinSession = CreateUser.then(function(createUserResult) { |
| 32 | userid = createUserResult.id; |
| 33 | return SessionCollection.joinSession(sessionid, createUserResult.id); |
| 34 | }); |
| 35 | JoinSession.then(function(joinSessionResult){ |
| 36 | $location.path('/session/'+ sessionid+ '/' + userid); |
| 37 | }); |
| 38 | }; |
| 39 | |
| 40 | } |
nothing calls this directly
no outgoing calls
no test coverage detected