Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Update survey results to work with assetIds

Robin Dekkers4de69430d176
diff --git a/ui/app/or-app/src/pages/page-mobile-geofences.ts b/ui/app/or-app/src/pages/page-mobile-geofences.ts
index 97c86f3ab..62d4b2249 100644
--- a/ui/app/or-app/src/pages/page-mobile-geofences.ts
+++ b/ui/app/or-app/src/pages/page-mobile-geofences.ts
@@ -108,7 +108,7 @@ class PageMobileGeofences<S extends AppStateKeyed> extends Page<S> {
background-color: var(--or-app-color2);
color: var(--or-app-color3);
text-decoration: none;
- max-width: 260px;
+ max-width: 230px;
-webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);
-moz-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);
diff --git a/ui/component/or-survey-results/src/index.ts b/ui/component/or-survey-results/src/index.ts
index 1105ae153..e7bc8230e 100644
--- a/ui/component/or-survey-results/src/index.ts
+++ b/ui/component/or-survey-results/src/index.ts
@@ -24,6 +24,9 @@ class OrSurveyResults extends LitElement {
@property({type: Object})
public survey?: Asset;
+ @property({type: Array})
+ public questions?: Asset[];
+
@property({type: String})
public surveyId?: string;
@@ -166,7 +169,18 @@ class OrSurveyResults extends LitElement {
console.error("Error: " + reason);
});
+ const surveyQuestQuery: AssetQuery = {
+ parents: [{id:surveyId}]
+ };
+ manager.rest.api.AssetResource.queryPublicAssets(surveyQuestQuery).then((response) => {
+ if (response && response.data) {
+ this.questions = response.data;
+ this.requestUpdate();
+ }
+ }).catch((reason) => {
+ console.error("Error: " + reason);
+ });
}
@@ -188,10 +202,11 @@ class OrSurveyResults extends LitElement {
return {
name: categoryName,
result: category[categoryName].map((question: any) => {
- const questionName = Object.keys(question)[0];
+ const questionId = Object.keys(question)[0];
+ const assetQuestion = this.questions ? this.questions.find((question)=> question.id === questionId) : null
return {
- name: questionName,
- value: question[questionName].map((answer: any) => {
+ name: assetQuestion ? assetQuestion.name : "",
+ value: question[questionId].map((answer: any) => {
const answerName = Object.keys(answer)[0];
const amount = answer[answerName];
if (typeof amount === "number" &&
@@ -205,7 +220,6 @@ class OrSurveyResults extends LitElement {
}
});
-
return computedResults;
}