diff --git a/src/app/citizenScience/_citizenScience.scss b/src/app/citizenScience/_citizenScience.scss index c5b95ff1..d9826ea0 100644 --- a/src/app/citizenScience/_citizenScience.scss +++ b/src/app/citizenScience/_citizenScience.scss @@ -68,9 +68,19 @@ opacity: 0.7; font-size: 0.8em; padding-bottom: 3px; + padding-top: 2px; + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: space-between; + + div { + font-size: 1em; + line-height: 1em; + } span { - margin: 1em; + margin: 2px 1em 2px 0.5em; } } diff --git a/src/app/citizenScience/datasetProgress/_progress.scss b/src/app/citizenScience/datasetProgress/_progress.scss index 3d476cfb..63113ea5 100644 --- a/src/app/citizenScience/datasetProgress/_progress.scss +++ b/src/app/citizenScience/datasetProgress/_progress.scss @@ -1,7 +1,7 @@ .dataset-progress-wrapper { - display: flex; + display: inline-block; .citSci-next { @@ -14,46 +14,50 @@ } } +} - .dataset-progress { - - display: flex; - background-color: #000000; +dataset-progress-indicator { + flex-grow: 0.8; + width: 30%; + max-width: 180px; + min-width: 70px; +} - .progress-summary { - margin-left: 15px; - background: #000000; - color: #aaa; +.dataset-progress-bar { - } + margin-right: 20px; + &.progress { + height: auto; + margin-bottom: 0px; + margin-top: 2px; + top: -1px; + position: relative; + vertical-align: text-bottom; + .progress-bar { + padding-top:1px; + padding-bottom:1px; - .progress-graphic { - margin-left: 15px; - background: #000000; - padding: 1px 1px 2px 2px; - display: block; - width: 23px; - height: 23px; - border-radius: 3px; - div { - display: block; - height: 1px; - width: 1px; - background: #00ca56; - margin:2px 2px 1px 1px; - float: left; - border-radius: 1px; + span { + color: #FFFFFF; } + + } + + span { + color: #000000; } + } +} + + -} diff --git a/src/app/citizenScience/datasetProgress/datasetProgress.js b/src/app/citizenScience/datasetProgress/datasetProgress.js index 73d812d8..fc2ee856 100644 --- a/src/app/citizenScience/datasetProgress/datasetProgress.js +++ b/src/app/citizenScience/datasetProgress/datasetProgress.js @@ -5,17 +5,14 @@ * - updates the selected labels to match what is stored for the selected sample */ - angular.module("bawApp.components.progress", ["bawApp.citizenScience.csSamples"]) .component("datasetProgress", { templateUrl: "citizenScience/datasetProgress/datasetProgress.tpl.html", - controller: ["$scope", "$routeParams", "CsSamples", "SampleLabels", "$url", "conf.paths", "QuestionResponse", "CitizenScienceCommon", - function ($scope, $routeParams, CsSamples, SampleLabels, $url, paths, QuestionResponse, CitizenScienceCommon) { + controller: ["$scope", "$routeParams", "CsSamples", "SampleLabels", "$url", "conf.paths", + function ($scope, $routeParams, CsSamples, SampleLabels, $url, paths) { var self = this; - - // routed dataset item id will link back to the unrouted listen page $scope.listenLink = $url.formatUri(paths.site.ngRoutes.citizenScience.listen, {studyName: $routeParams.studyName}); @@ -49,9 +46,6 @@ angular.module("bawApp.components.progress", ["bawApp.citizenScience.csSamples"] }); $scope.$watch(() => CsSamples.currentItem(), (newVal, oldVal) => { - - self.updateProgress(); - SampleLabels.reset(newVal.id); }); @@ -62,7 +56,7 @@ angular.module("bawApp.components.progress", ["bawApp.citizenScience.csSamples"] /** - * + * whether to disable the next button, both greying out and preventing actions * @return boolean */ $scope.nextDisabled = function (requireNextItemAvailable = false) { @@ -74,6 +68,11 @@ angular.module("bawApp.components.progress", ["bawApp.citizenScience.csSamples"] }; + /** + * Return the text that should display on the button. Might change depending on + * if they have selected a label or if there is another sample after the current. + * @return {*} + */ $scope.nextText = function () { if (SampleLabels.hasResponse()) { return "Submit response"; @@ -94,123 +93,6 @@ angular.module("bawApp.components.progress", ["bawApp.citizenScience.csSamples"] } }; - - $scope.progress = { - itemCount: 0, - responseCount: 0, - percent: 0, - breaks: false - - }; - - self.refreshIn = 0; - - - /** - * called each time we go to a new segment - * will increment response count. We only refresh from the server sometimes - * to save unecessary api calls. - */ - self.updateProgress = function () { - - if (self.refreshIn === 0) { - self.refreshProgress(); - self.refreshIn = 5; - } - $scope.progress.responseCount += 1; - self.updateProgressBreaks(); - self.refreshIn -= 1; - - }; - - - /** - * Update progress when the study changes. It will not be loaded when this controller is initialised - */ - $scope.$watch(() => CitizenScienceCommon.studyData.study, (newVal, oldVal) => { - self.refreshProgress(); - }); - - /** - * Watch the total items, because it will not be ready when the controller first loads - */ - $scope.$watch(CsSamples.totalItems, (newVal, oldVal) => { - if (typeof newVal === "number") { - $scope.progress.itemCount = newVal; - self.updateProgressBreaks(); - } - }); - - - /** - * gets the total number of dataset items and the total number of responses - * and calculates the percentage. - */ - self.refreshProgress = function () { - - // make sure the study has been loaded - if (CitizenScienceCommon.studyData.study) { - - // request 1 item to get the metadata showing the total number of items - var responseFilterParams = { - studyId: CitizenScienceCommon.studyData.study.id, - items: 1 - }; - - QuestionResponse.questionResponses(responseFilterParams).then((x) => { - - var totalResponses = x.data.meta.paging.total; - $scope.progress.responseCount = totalResponses; - self.updateProgressBreaks(); - self.refreshIn = 5; - - }); - - } - - }; - - /** - * Progress is rendered a 5x5 grid of divs - * each item represents 1 25th of the total number of items - * e.g. if there are 2500 items, the first point represents 100 items. - */ - self.updateProgressBreaks = function () { - - var numBreaks = 25; - - if (!$scope.progress.breaks) { - $scope.progress.breaks = new Array(numBreaks); - } - - if ($scope.progress.itemCount === 0) { - return; - } - - - var fullBreaks = ($scope.progress.responseCount / $scope.progress.itemCount) * numBreaks; - // number of completely full breaks. Because it's possible to be more than 100% complete - // this is also capped - var numFull = Math.min(Math.floor(fullBreaks), numBreaks); - - $scope.progress.breaks.fill(1, 0, numFull); - $scope.progress.breaks.fill(0, numFull , numBreaks); - if (numFull < numBreaks) { - $scope.progress.breaks[numFull] = fullBreaks % 1; - } - - var percent = Math.round(100 * $scope.progress.responseCount / $scope.progress.itemCount); - $scope.progress.percent = percent; - console.log("$scope.progress.percent", percent); - $scope.progress.percentCapped = Math.min(percent, 100); - - - - }; - - - - }], bindings: { datasetId: "=" diff --git a/src/app/citizenScience/datasetProgress/datasetProgress.tpl.html b/src/app/citizenScience/datasetProgress/datasetProgress.tpl.html index a171405c..f9e78f45 100644 --- a/src/app/citizenScience/datasetProgress/datasetProgress.tpl.html +++ b/src/app/citizenScience/datasetProgress/datasetProgress.tpl.html @@ -17,25 +17,6 @@ {{nextText()}} - - -
- - - {{progress.responseCount}} / {{progress.itemCount}} ({{progress.percent}} %) - - -
-
- -
- - - - -
- - diff --git a/src/app/citizenScience/datasetProgress/datasetProgressIndicator.js b/src/app/citizenScience/datasetProgress/datasetProgressIndicator.js new file mode 100644 index 00000000..37a6099f --- /dev/null +++ b/src/app/citizenScience/datasetProgress/datasetProgressIndicator.js @@ -0,0 +1,116 @@ +/** + * Component that + * - contains the button to move to the next sample, + * - loads the correct sample if specified in the url + * - updates the selected labels to match what is stored for the selected sample + */ + + +angular.module("bawApp.components.progressIndicator", ["bawApp.citizenScience.csSamples"]) + .component("datasetProgressIndicator", { + templateUrl: "citizenScience/datasetProgress/datasetProgressIndicator.tpl.html", + controller: ["$scope", "CsSamples", "QuestionResponse", "CitizenScienceCommon", + function ($scope, CsSamples, QuestionResponse, CitizenScienceCommon) { + + var self = this; + + $scope.progress = { + itemCount: 0, + responseCount: 0, + percent: -1, + percentCapped: -1, + message: "" + }; + + $scope.$watch(() => CsSamples.currentItem(), (newVal, oldVal) => { + self.updateProgress(); + }); + + self.refreshIn = 0; + + /** + * called each time we go to a new segment + * will increment response count. We only refresh from the server sometimes + * to save unecessary api calls. + */ + self.updateProgress = function () { + + if (self.refreshIn === 0) { + self.refreshProgress(); + self.refreshIn = 5; + } + $scope.progress.responseCount += 1; + self.updateProgressPercent(); + self.refreshIn -= 1; + + }; + + + /** + * Update progress when the study changes. It will not be loaded when this controller is initialised + */ + $scope.$watch(() => CitizenScienceCommon.studyData.study, (newVal, oldVal) => { + self.refreshProgress(); + }); + + /** + * Watch the total items, because it will not be ready when the controller first loads + */ + $scope.$watch(CsSamples.totalItems, (newVal, oldVal) => { + if (typeof newVal === "number") { + $scope.progress.itemCount = newVal; + self.updateProgressPercent(); + } + }); + + + /** + * gets the total number of responses from the server + */ + self.refreshProgress = function () { + + // make sure the study has been loaded + if (CitizenScienceCommon.studyData.study) { + + // request 1 item to get the metadata showing the total number of items + var responseFilterParams = { + studyId: CitizenScienceCommon.studyData.study.id, + items: 1 + }; + + QuestionResponse.questionResponses(responseFilterParams).then((x) => { + + var totalResponses = x.data.meta.paging.total; + $scope.progress.responseCount = totalResponses; + self.updateProgressPercent(); + self.refreshIn = 5; + + }); + + } + + }; + + + /** + * updates the percent tracker + * Necessary ecause we can go over 100% if there are more responses than items + */ + self.updateProgressPercent = function () { + + if ($scope.progress.itemCount === 0) { + return; + } + + var percent = Math.round(100 * $scope.progress.responseCount / $scope.progress.itemCount); + $scope.progress.percent = percent; + console.log("$scope.progress.percent", percent); + $scope.progress.percentCapped = Math.min(percent, 100); + $scope.progress.message = `${$scope.progress.responseCount} / ${$scope.progress.itemCount}`; + }; + + + }], + bindings: { + } + }); \ No newline at end of file diff --git a/src/app/citizenScience/datasetProgress/datasetProgressIndicator.tpl.html b/src/app/citizenScience/datasetProgress/datasetProgressIndicator.tpl.html new file mode 100644 index 00000000..b209ed78 --- /dev/null +++ b/src/app/citizenScience/datasetProgress/datasetProgressIndicator.tpl.html @@ -0,0 +1,16 @@ +
+
{{progress.message}} 
{{progress.message}} +
+ + + + + + + + + diff --git a/src/app/citizenScience/labels/thumbLabels/_thumbs.scss b/src/app/citizenScience/labels/thumbLabels/_thumbs.scss index 3fa8cbba..210e2691 100644 --- a/src/app/citizenScience/labels/thumbLabels/_thumbs.scss +++ b/src/app/citizenScience/labels/thumbLabels/_thumbs.scss @@ -83,6 +83,11 @@ $triangle: ' { + // x.id = i+1; + // return x; + // });; + // + // x.data.data[0].questionData = temp; + //TODO: update to allow multiple questions $scope.questionData = x.data.data[0].questionData; @@ -99,10 +109,12 @@ class CitizenScienceListenController { "bristlebird": { showSite: false, showDateTime: false, + showProgress: false, }, "koala-verification": { showSite: true, showDateTime: true, + showProgress: true } }[$scope.csProject]; @@ -157,6 +169,7 @@ class CitizenScienceListenController { angular .module("bawApp.citizenScience.listen", [ "bawApp.components.progress", + "bawApp.components.progressIndicator", "bawApp.citizenScience.common", "bawApp.citizenScience.sampleLabels", "bawApp.citizenScience.csLabels", diff --git a/src/app/citizenScience/listen/listen.tpl.html b/src/app/citizenScience/listen/listen.tpl.html index 5af4cdb4..cdfebeaf 100644 --- a/src/app/citizenScience/listen/listen.tpl.html +++ b/src/app/citizenScience/listen/listen.tpl.html @@ -15,10 +15,16 @@

{{studyTitle}}
-
- {{sampleInfo.site}} - {{sampleInfo.date}} - {{sampleInfo.time}} +
+ + {{sampleInfo.date}}   {{sampleInfo.time}} + + {{sampleInfo.site}} + + + + +