-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#277 register and login user, create scenario
- Loading branch information
Showing
6 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
angular.module('DojoIBL') | ||
|
||
.service('ActivityService', function ($q, Activity, CacheFactory) { | ||
.service('ActivityService', function ($q, Activity, CacheFactory, ML4WUser, ML4WScenario) { | ||
|
||
CacheFactory('activitiesCache', { | ||
maxAge: 24 * 60 * 60 * 1000, // Items added to this cache expire after 1 day | ||
|
@@ -227,6 +227,43 @@ angular.module('DojoIBL') | |
removeCachedActivity: function(){ | ||
var dataCache = CacheFactory.get('activitiesTempCache'); | ||
dataCache.remove("cachedActivity"); | ||
}, | ||
createML4WScenario: function(title, token){ | ||
var scenario = { | ||
title: title, | ||
description: "Angel", | ||
token: token, | ||
screenData: [{}] | ||
}; | ||
|
||
var newScenario = new ML4WScenario(scenario); | ||
return newScenario.$save(); | ||
}, | ||
registerML4WUser: function(user, pass){ | ||
var user = { | ||
firstname: "Angel", | ||
lastname: "Angel", | ||
email: "[email protected]", | ||
username: user, | ||
password: pass | ||
}; | ||
|
||
var newUser = new ML4WUser(user); | ||
return newUser.$save(); | ||
}, | ||
loginML4WUser: function(user, pass){ | ||
var deferred = $q.defer(); | ||
|
||
var user = { | ||
username: user, | ||
password: pass | ||
}; | ||
|
||
ML4WUser.login(user).$promise.then(function (data) { | ||
deferred.resolve(data); | ||
}); | ||
|
||
return deferred.promise; | ||
} | ||
} | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters