diff --git a/README.md b/README.md index 04cc42bfc..4dc939fdc 100755 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ Certain values can be overriden using Firebase Remote Config. Specifically, the | `app_credits_body` | Body of the popup box that appears when you tap on the app logo on the left hand side of the homepage. | `Made with ♥ for you by the RADAR-Base community.` | | `auto_next_questionnaire_types` | String list of question/question input types where the questionnaire will automatically move to the next question upon answering the question. It is recommended to always include timed and audio types. | `timed,audio` | | `skippable_questionnaire_types` | String list of question/question input types where the next button is enabled by default, allowing the question to be skippable. | `audio` | +| `show_task_calendar_name` | The task calendar by default shows the task timestamp instead of the task name. This allows showing of the task name instead of the timestamp. | `false` | +| `show_task_progress_count` | In the questionnaire page, by default, only the task progress bar is shown. This config will enable the showing of the "question number / total questions" count. | `false` | #### Conditions @@ -305,9 +307,10 @@ Here are some common errors you might find during installation. When you are running `ionic cordova run ios`, you might encounter the problem, we solved this problem by refering this [issue](https://github.com/dpa99c/cordova-custom-config/issues/144) with `cordova-custom-config`. We enter the following command at the root directory. + ``` cd plugins/cordova-custom-config -yarn install +yarn install ``` ### Error: Failed to fetch platform. Probably this is either a connection problem. diff --git a/config.xml b/config.xml index 22d52d7ed..dd3233eef 100755 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + RADAR Questionnaire An application that collects active data for research. RADAR-Base diff --git a/src/app/core/services/kafka/kafka.service.ts b/src/app/core/services/kafka/kafka.service.ts index 0f93c3bca..55e9fdea8 100755 --- a/src/app/core/services/kafka/kafka.service.ts +++ b/src/app/core/services/kafka/kafka.service.ts @@ -85,8 +85,14 @@ export class KafkaService { } private fetchTopics() { - return this.http.get(this.KAFKA_CLIENT_URL + this.URI_topics, {observe: 'body'}) - .toPromise() + return this.getAccessToken() + .then(accessToken => this.http.get(this.KAFKA_CLIENT_URL + this.URI_topics, + { + observe: 'body', + headers: new HttpHeaders() + .set('Authorization', 'Bearer ' + accessToken) + .set('Accept', DefaultClientAcceptType), + }).toPromise()) .then((topics: string[]) => { this.topics = topics this.lastTopicFetch = Date.now() @@ -173,7 +179,7 @@ export class KafkaService { .then(data => this.http .post(this.KAFKA_CLIENT_URL + this.URI_topics + topic, data, { - headers: headers + headers }) .toPromise() ) @@ -205,12 +211,17 @@ export class KafkaService { }) } - getKafkaHeaders() { + getAccessToken() { return Promise.all([this.updateURI(), this.token.refresh()]) .then(() => this.token.getTokens()) - .then(tokens => + .then(tokens => tokens.access_token) + } + + getKafkaHeaders() { + return this.getAccessToken() + .then(accessToken => new HttpHeaders() - .set('Authorization', 'Bearer ' + tokens.access_token) + .set('Authorization', 'Bearer ' + accessToken) .set('Content-Type', DefaultKafkaRequestContentType) .set('Accept', DefaultClientAcceptType) ) diff --git a/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.html b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.html new file mode 100755 index 000000000..2f69b5ac1 --- /dev/null +++ b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.html @@ -0,0 +1,43 @@ +
+ + +
+
+ {{ taskLabel }} +
+
+ +
+
+
+
+
+ + {{ task.estimatedCompletionTime }} + min +
+
+ + {{ task.nQuestions }} + x +
+
+
+
+ +
+
+ +
+
+
+
+
+
diff --git a/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.scss b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.scss new file mode 100755 index 000000000..ccebe446f --- /dev/null +++ b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.scss @@ -0,0 +1,92 @@ +task-calendar-row { + #task-item { + display: block; + margin-bottom: 3px; + padding: 3px 9px; + padding-bottom: 0; + background-color: $cl-primary-40; + text-align: center; + font-size: 18px; + } + + .task-item-name { + font-size: 15px !important; + } + + .units { + margin-right: 2px; + font-size: 12px; + } + + .icon-padding { + padding-right: 5px; + padding-left: 5px; + } + + .extra-info-icon { + padding-left: 3px; + } + + .icon-xsm { + height: 14px; + } + + .task-info-left { + display: inline-flex; + float: left; + padding-left: 5px; + width: auto; + } + + .task-info-right { + display: inline-flex; + float: right; + margin-right: 10px; + max-width: 160px; + width: 160px; + } + + .metrics { + display: inline-flex; + float: left; + margin-right: 8px; + text-align: left; + } + + .metric-time { + float: left; + margin-right: 10px; + width: 64px; + white-space: nowrap; + } + + .metric-q { + float: left; + width: 56px; + white-space: nowrap; + } + + .status-div { + float: right; + margin-top: -8px; + margin-right: 8px; + margin-bottom: -7px; + padding-top: 5px; + padding-bottom: 5px; + width: 24px; + } + + .status { + color: map-get($colors, tertiary); + font-size: 26px; + } + + .status-checked { + padding-top: 2px; + width: 23px; + height: 23px; + border-radius: 50%; + background-color: map-get($colors, tertiary); + font-size: 21px; + } +} diff --git a/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.ts b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.ts new file mode 100755 index 000000000..e8159ebd5 --- /dev/null +++ b/src/app/pages/home/components/task-calendar-row/task-calendar-row.component.ts @@ -0,0 +1,28 @@ +import { Component, Input, OnInit } from '@angular/core' + +import { LocalizationService } from '../../../../core/services/misc/localization.service' +import { Task } from '../../../../shared/models/task' + +@Component({ + selector: 'task-calendar-row', + templateUrl: 'task-calendar-row.component.html' +}) +export class TaskCalendarRowComponent implements OnInit { + @Input() + isTaskNameShown: boolean + @Input() + task + + taskLabel: string + + constructor(private localization: LocalizationService) {} + + ngOnInit() { + if (this.isTaskNameShown) this.taskLabel = this.task.name + else this.taskLabel = this.getStartTime(this.task) + } + + getStartTime(task: Task) { + return this.localization.moment(task.timestamp).format('HH:mm') + } +} diff --git a/src/app/pages/home/components/task-calendar-row/task-calendar-row.module.ts b/src/app/pages/home/components/task-calendar-row/task-calendar-row.module.ts new file mode 100644 index 000000000..3f7a7e467 --- /dev/null +++ b/src/app/pages/home/components/task-calendar-row/task-calendar-row.module.ts @@ -0,0 +1,19 @@ +import { CommonModule } from '@angular/common' +import { NgModule } from '@angular/core' +import { IonicModule } from 'ionic-angular' +import { MomentModule } from 'ngx-moment' + +import { TaskCalendarRowComponent } from './task-calendar-row.component' + +const COMPONENTS = [TaskCalendarRowComponent] + +@NgModule({ + imports: [ + MomentModule, + CommonModule, + IonicModule.forRoot(TaskCalendarRowComponent) + ], + declarations: COMPONENTS, + exports: COMPONENTS +}) +export class TaskCalendarRowModule {} diff --git a/src/app/pages/home/components/task-calendar/task-calendar.component.html b/src/app/pages/home/components/task-calendar/task-calendar.component.html index 10d57e343..3d1dcff2b 100755 --- a/src/app/pages/home/components/task-calendar/task-calendar.component.html +++ b/src/app/pages/home/components/task-calendar/task-calendar.component.html @@ -1,41 +1,24 @@
- - - - - -
- {{ "TASK_CALENDAR_TITLE" | translate }} + + + +
+ {{ 'TASK_CALENDAR_TITLE' | translate }}
-
- {{ (sortedTasks.key/1000) | amFromUnix | amDateFormat:'MMM D' }} +
+ {{ sortedTasks.key / 1000 | amFromUnix | amDateFormat: 'MMM D' }}
- +
- + {{ currentTime }} @@ -44,74 +27,23 @@
-
- - -
-
{{ getStartTime(task) }}
-
- -
-
-
-
-
- - {{ task.estimatedCompletionTime }} - min -
-
- - {{ task.nQuestions }} - x -
-
-
-
- -
-
- -
-
-
-
-
-
+ [task]="task" + (tap)="clicked(task)" + [isTaskNameShown]="isTaskNameShown" + >
- + {{ currentTime }} @@ -123,5 +55,4 @@ -
diff --git a/src/app/pages/home/components/task-calendar/task-calendar.component.scss b/src/app/pages/home/components/task-calendar/task-calendar.component.scss index c91cd0c6a..28c2925a9 100755 --- a/src/app/pages/home/components/task-calendar/task-calendar.component.scss +++ b/src/app/pages/home/components/task-calendar/task-calendar.component.scss @@ -35,92 +35,6 @@ task-calendar { font-size: 18px; } - #task-item { - display: block; - margin-bottom: 3px; - padding: 3px 9px; - padding-bottom: 0; - background-color: $cl-primary-40; - text-align: center; - font-size: 18px; - } - - .units { - margin-right: 2px; - font-size: 12px; - } - - .icon-padding { - padding-right: 5px; - padding-left: 5px; - } - - .extra-info-icon { - padding-left: 3px; - } - - .icon-xsm { - height: 14px; - } - - .task-info-left { - display: inline-flex; - float: left; - padding-left: 5px; - width: 80px; - } - - .task-info-right { - display: inline-flex; - float: right; - margin-right: 10px; - max-width: 160px; - width: 160px; - } - - .metrics { - display: inline-flex; - float: left; - margin-right: 12px; - text-align: left; - } - - .metric-time { - float: left; - margin-right: 10px; - width: 64px; - white-space: nowrap; - } - - .metric-q { - float: left; - width: 56px; - white-space: nowrap; - } - - .status-div { - float: right; - margin-top: -8px; - margin-right: 8px; - margin-bottom: -8px; - padding-top: 5px; - width: 24px; - } - - .status { - color: map-get($colors, tertiary); - font-size: 28px; - } - - .status-checked { - padding-top: 2px; - width: 23px; - height: 23px; - border-radius: 50%; - background-color: map-get($colors, tertiary); - font-size: 21px; - } - .current-time-div { padding-top: 2px; height: 38px; diff --git a/src/app/pages/home/components/task-calendar/task-calendar.component.ts b/src/app/pages/home/components/task-calendar/task-calendar.component.ts index d9af7a823..509c25f1f 100755 --- a/src/app/pages/home/components/task-calendar/task-calendar.component.ts +++ b/src/app/pages/home/components/task-calendar/task-calendar.component.ts @@ -23,6 +23,8 @@ export class TaskCalendarComponent implements OnChanges { tasks: Map @Input() currentDate: number + @Input() + isTaskNameShown: boolean currentTime timeIndex: number diff --git a/src/app/pages/home/components/task-calendar/task-calendar.module.ts b/src/app/pages/home/components/task-calendar/task-calendar.module.ts index c98ba502a..b4abd549e 100644 --- a/src/app/pages/home/components/task-calendar/task-calendar.module.ts +++ b/src/app/pages/home/components/task-calendar/task-calendar.module.ts @@ -4,6 +4,7 @@ import { IonicModule } from 'ionic-angular' import { MomentModule } from 'ngx-moment' import { PipesModule } from '../../../../shared/pipes/pipes.module' +import { TaskCalendarRowModule } from '../task-calendar-row/task-calendar-row.module' import { TaskCalendarComponent } from './task-calendar.component' const COMPONENTS = [TaskCalendarComponent] @@ -13,7 +14,8 @@ const COMPONENTS = [TaskCalendarComponent] MomentModule, CommonModule, IonicModule.forRoot(TaskCalendarComponent), - PipesModule + PipesModule, + TaskCalendarRowModule ], declarations: COMPONENTS, exports: COMPONENTS diff --git a/src/app/pages/home/containers/home-page.component.html b/src/app/pages/home/containers/home-page.component.html index 0e7f5852b..0b2ef6607 100755 --- a/src/app/pages/home/containers/home-page.component.html +++ b/src/app/pages/home/containers/home-page.component.html @@ -84,6 +84,7 @@ (task)="startQuestionnaire($event)" [tasks]="sortedTasks | async" [currentDate]="currentDate.getTime()" + [isTaskNameShown]="isTaskNameShown" >
diff --git a/src/app/pages/home/containers/home-page.component.ts b/src/app/pages/home/containers/home-page.component.ts index 2fbe6c5f0..d00ced3d6 100755 --- a/src/app/pages/home/containers/home-page.component.ts +++ b/src/app/pages/home/containers/home-page.component.ts @@ -42,6 +42,7 @@ export class HomePageComponent implements OnDestroy { taskIsNow = false checkTaskInterval showMiscTasksButton: Promise + isTaskCalendarTaskNameShown = false APP_CREDITS = '© RADAR-Base' HTML_BREAK = '
' @@ -61,6 +62,7 @@ export class HomePageComponent implements OnDestroy { this.navCtrl.setRoot(HomePageComponent) } ) + this.getisTaskCalendarTaskNameShown() } getIsLoadingSpinnerShown() { @@ -70,6 +72,12 @@ export class HomePageComponent implements OnDestroy { ) } + getisTaskCalendarTaskNameShown() { + this.tasksService + .getIsTaskCalendarTaskNameShown() + .then(res => (this.isTaskCalendarTaskNameShown = res)) + } + getIsStartButtonShown() { return ( this.taskIsNow && diff --git a/src/app/pages/home/services/tasks.service.ts b/src/app/pages/home/services/tasks.service.ts index c44535e0a..febe82138 100644 --- a/src/app/pages/home/services/tasks.service.ts +++ b/src/app/pages/home/services/tasks.service.ts @@ -4,7 +4,8 @@ import { DefaultAppCreditsBody, DefaultAppCreditsTitle, DefaultOnDemandAssessmentIcon, - DefaultPlatformInstance + DefaultPlatformInstance, + DefaultShowTaskCalendarName } from '../../../../assets/data/defaultConfig' import { QuestionnaireService } from '../../../core/services/config/questionnaire.service' import { RemoteConfigService } from '../../../core/services/config/remote-config.service' @@ -176,4 +177,16 @@ export class TasksService { ) .then(res => JSON.parse(res)) } + + getIsTaskCalendarTaskNameShown() { + return this.remoteConfig + .read() + .then(config => + config.getOrDefault( + ConfigKeys.SHOW_TASK_CALENDAR_NAME, + DefaultShowTaskCalendarName + ) + ) + .then(res => JSON.parse(res)) + } } diff --git a/src/app/pages/questions/components/question/descriptive-input/descriptive-input.component.html b/src/app/pages/questions/components/question/descriptive-input/descriptive-input.component.html index 533d40c82..d68370a12 100755 --- a/src/app/pages/questions/components/question/descriptive-input/descriptive-input.component.html +++ b/src/app/pages/questions/components/question/descriptive-input/descriptive-input.component.html @@ -1,5 +1,5 @@
-
+
diff --git a/src/app/pages/questions/components/toolbar/toolbar.component.html b/src/app/pages/questions/components/toolbar/toolbar.component.html index 4d2e998ec..f1176bf4e 100644 --- a/src/app/pages/questions/components/toolbar/toolbar.component.html +++ b/src/app/pages/questions/components/toolbar/toolbar.component.html @@ -1,7 +1,10 @@ - +
+ + {{ currentQuestionId + '/' + totalQuestions }} +