-
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.
feat(citizenScienceRouting): start refactor for new datasets and citi…
…zen science api on server
- Loading branch information
Showing
7 changed files
with
179 additions
and
115 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
var csApiMock = angular.module("bawApp.citizenScience.csApiMock", ["bawApp.citizenScience.common"]); | ||
|
||
|
||
/** | ||
* Mocks the api responses for citizenScienceProjects that | ||
* will eventually go on the server | ||
*/ | ||
|
||
|
||
|
||
|
||
|
||
sampleLabels.factory("CsApi", [ | ||
"CitizenScienceCommon", | ||
"$http", | ||
function CsApi(CitizenScienceCommon, $http) { | ||
|
||
var self = this; | ||
|
||
self.useLocalData = true; | ||
|
||
self.sheets_api_url = "http://" + window.location.hostname + ":8081"; | ||
self.local_api_url = "/public/citizen_science"; | ||
|
||
|
||
/** | ||
* Constructs a url for the request by concatenating the arguments, joined by "/" | ||
* and appending to the relevant baseURL | ||
* @returns {string|*} | ||
*/ | ||
self.apiUrl = function () { | ||
// convert to array | ||
var base_url, url; | ||
if (self.useLocalData) { | ||
base_url = self.local_api_url; | ||
} else { | ||
base_url = self.sheets_api_url; | ||
} | ||
var args = Array.prototype.slice.call(arguments); | ||
|
||
url = [base_url].concat(args).join("/"); | ||
|
||
if (self.useLocalData) { | ||
url = url + ".json"; | ||
} | ||
|
||
return url; | ||
}; | ||
|
||
self.publicFunctions = { | ||
|
||
|
||
|
||
getSamples : function () { | ||
if ($scope.samples.length === 0) { | ||
|
||
var url = self.functions.apiUrl( | ||
"samples", | ||
$scope.csProject, | ||
UserProfile.profile.userName); | ||
//TODO: error handling | ||
$http.get(url).then(function (response) { | ||
var samples = response.data; | ||
$scope.samples = samples; | ||
$scope.currentSampleNum = 0; | ||
}); | ||
} | ||
} | ||
|
||
}; | ||
|
||
return publicFunctions; | ||
|
||
|
||
|
||
}]); | ||
|
||
|
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
Oops, something went wrong.