TG-118 : move OLA/.gitignore to OLA/backend/gitignore (import scripts file)
This commit is contained in:
52
frontend/app/scripts/services/DataService.js
Executable file
52
frontend/app/scripts/services/DataService.js
Executable file
@ -0,0 +1,52 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('clientApp')
|
||||
.factory('DataService', ['$http', '$q',
|
||||
function ($http, $q) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PUBLIC API.
|
||||
// ---------------------------------------------------------------------------
|
||||
return ({
|
||||
login: login,
|
||||
logout: logout
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PUBLIC METHODS.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function login(credentials) {
|
||||
// var request = $http.post(apiServer + '/api/AppUsers/login', credentials);
|
||||
// return request.then(handleSuccess, handleError);
|
||||
}
|
||||
|
||||
function logout() {
|
||||
// var request = $http.post(apiServer + '/api/AppUsers/logout', {});
|
||||
// return request.then(handleSuccess, handleError);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PRIVATE METHODS.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function handleSuccess(response) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
function handleError(response) {
|
||||
if (response.data === '' ||
|
||||
!angular.isDefined(response.status) ||
|
||||
response.statusText === '') {
|
||||
|
||||
return ($q.reject("An unknown error occurred."));
|
||||
}
|
||||
|
||||
// Otherwise, use expected error message.
|
||||
return ($q.reject('Error ' + response.status + ' (' + response.statusText + '): ' + response.data));
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
})();
|
Reference in New Issue
Block a user