-
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(citizenScience): responses page for viewing locally saved responses
- Loading branch information
Showing
9 changed files
with
242 additions
and
74 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
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,85 @@ | ||
var csLabels = angular.module("bawApp.citizenScience.csLabels", ["bawApp.citizenScience.common"]); | ||
|
||
|
||
/** | ||
* Manages the data for labels that will be applied to cs samples | ||
*/ | ||
csLabels.factory("CsLabels", [ | ||
"CitizenScienceCommon", | ||
"$http", | ||
function CsLabels(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. Allows experimenting with different sources | ||
* for the data without changing everything | ||
* @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 = { | ||
|
||
|
||
/** | ||
* Gets all labels associated with the specified citizen science project | ||
* @param project string | ||
*/ | ||
getLabels: function (project) { | ||
var response = $http.get(self.apiUrl( | ||
"labels", | ||
project | ||
)); | ||
|
||
return response.then(function (response) { | ||
var labels = []; | ||
if (Array.isArray(response.data)) { | ||
labels = response.data; | ||
} | ||
|
||
return labels; | ||
}); | ||
}, | ||
|
||
/** | ||
* Gets all settings associated with the specified citizen science project | ||
* @param project string | ||
* @returns {HttpPromise} | ||
*/ | ||
getSettings: function (project) { | ||
return $http.get(self.apiUrl( | ||
"settings", | ||
project | ||
)); | ||
} | ||
|
||
}; | ||
|
||
return self.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
Oops, something went wrong.