diff --git a/app/mobile-content/exhibits/shared/exhibit.service.ts b/app/mobile-content/exhibits/shared/exhibit.service.ts index 6eb8180bf..bb97713ec 100644 --- a/app/mobile-content/exhibits/shared/exhibit.service.ts +++ b/app/mobile-content/exhibits/shared/exhibit.service.ts @@ -168,6 +168,17 @@ export class ExhibitService { ); } + getExhibitStatistics(id: number) { + return this.mobileContentApiService.getUrl('/api/Exhibits/Statistic/' + id, {}) + .toPromise() + .then( + (response: Response) => response.json() + ) + .catch( + (error: any) => ExhibitService.handleError(error) + ); + } + /** * Gets the history of changes * @param id Id of the Exhibit you want to be deleted diff --git a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.css b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.css index a6f890d96..6d85f006d 100644 --- a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.css +++ b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.css @@ -19,6 +19,15 @@ img { margin-right: 10px; } +.float-left { + float: left; +} + +.float-right { + float: right; + margin-right: 200px; +} + .right { width: 40%; display: flex; diff --git a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.html b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.html index 1c95ab213..0163ac4d5 100644 --- a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.html +++ b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.html @@ -19,9 +19,28 @@

{{ 'tags' | translate }}

{{ tag.title }} -
-

{{ 'ratings' | translate }}

- +
+
+

{{ 'ratings' | translate }}

+ +
+
+

{{ 'visits' | translate }}

+ + + + + + + + + + + + + +
{{ 'last day' | translate }}{{ statistics.day }}
{{ 'last month' | translate }}{{ statistics.month }}
{{ 'last year' | translate }}{{ statistics.year }}
+
diff --git a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.ts b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.ts index ba6e838d3..4556eeadf 100644 --- a/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.ts +++ b/app/mobile-content/exhibits/view-exhibit/view-exhibit.component.ts @@ -33,11 +33,12 @@ export class ViewExhibitComponent implements OnInit { tags: Tag[] = []; imageUrl: SafeUrl; rating: any; + statistics: any; private deleteDialogRef: MdDialogRef; private changeHistoryDialogRef: MdDialogRef; - constructor( + constructor( private route: ActivatedRoute, private dialog: MdDialog, private domSanitizer: DomSanitizer, @@ -70,6 +71,7 @@ export class ViewExhibitComponent implements OnInit { this.getTags(); this.getImage(); this.getRating(); + this.getStatistics(); }) .catch((error: any) => { this.toasterService.pop('error', this.translate('Error fetching exhibit'), error); @@ -79,27 +81,27 @@ export class ViewExhibitComponent implements OnInit { deleteExhibit(exhibit: Exhibit) { let context = this; this.deleteDialogRef = this.dialog.open(ConfirmDeleteDialogComponent, { - data: { - title: this.translateService.instant('delete exhibit'), - message: this.translateService.instant('confirm delete exhibit', { name: exhibit.name }) - } + data: { + title: this.translateService.instant('delete exhibit'), + message: this.translateService.instant('confirm delete exhibit', { name: exhibit.name }) + } }); this.deleteDialogRef.afterClosed().subscribe( - (confirmed: boolean) => { - if (confirmed) { - this.exhibitService.deleteExhibit(exhibit.id) - .then( - () => { - this.toasterService.pop('success', 'Success', exhibit.name + ' - ' + this.translate('exhibit deleted')); - this.router.navigate(['../../'], {relativeTo: this.route}); + (confirmed: boolean) => { + if (confirmed) { + this.exhibitService.deleteExhibit(exhibit.id) + .then( + () => { + this.toasterService.pop('success', 'Success', exhibit.name + ' - ' + this.translate('exhibit deleted')); + this.router.navigate(['../../'], { relativeTo: this.route }); + } + ).catch( + error => this.toasterService.pop('error', this.translate('Error while saving'), error) + ); } - ).catch( - error => this.toasterService.pop('error', this.translate('Error while saving'), error) - ); } - } ); - } + } private getTags() { for (let tagId of this.exhibit.tags) { @@ -123,37 +125,49 @@ export class ViewExhibitComponent implements OnInit { }); } - private openHistory() { - let context = this; - this.exhibitService.getHistory(this.exhibit.id) - .then( - (response) => { - this.changeHistoryDialogRef = this.dialog.open(ChangeHistoryComponent, { width: '60%', - data: { - title: context.exhibit.name, - data: response - } - }); - } - ).catch( - (error: any) => { - this.toasterService.pop('error', this.translate('Error fetching history') , error); - } - ); - } - - private getRating() { - this.exhibitService.getExhibitRating(this.exhibit.id) - .then( - (response) => { - this.rating = response; - } - ).catch( - (error: any) => { - this.toasterService.pop('error', this.translate('Error fetching ratings') , error); - } - ); - } + private openHistory() { + let context = this; + this.exhibitService.getHistory(this.exhibit.id) + .then( + (response) => { + this.changeHistoryDialogRef = this.dialog.open(ChangeHistoryComponent, { + width: '60%', + data: { + title: context.exhibit.name, + data: response + } + }); + } + ).catch( + (error: any) => { + this.toasterService.pop('error', this.translate('Error fetching history'), error); + } + ); + } + + private getRating() { + this.exhibitService.getExhibitRating(this.exhibit.id) + .then( + (response) => { + this.rating = response; + } + ).catch( + (error: any) => { + this.toasterService.pop('error', this.translate('Error fetching ratings'), error); + } + ); + } + + private getStatistics() { + this.exhibitService.getExhibitStatistics(this.exhibit.id) + .then( + (response) => this.statistics = response + ) + .catch( + (error: any) => this.toasterService.pop('error', this.translate('Error fetching statistic'), error) + ); + } + private translate(data: string): string { let translatedResponse: string; diff --git a/i18n/de.json b/i18n/de.json index c3f52b734..f37de91e4 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -506,5 +506,9 @@ "error deleting question": "Fehler beim Löschen der Frage", "success deleting question": "Frage erfolgreich gelöscht", "delete question": "Frage löschen", - "confirm delete question": "Möchten Sie die Frage „{{name}}“ löschen?" + "confirm delete question": "Möchten Sie die Frage „{{name}}“ löschen?", + "visits": "Besuche", + "last day": "Letzter Tag", + "last month": "Letzter Monat", + "last year": "Letztes Jahr" } diff --git a/i18n/en.json b/i18n/en.json index 71b050a7c..b72376e04 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -412,5 +412,9 @@ "error deleting question": "Error while deleting question", "success deleting question": "Successfully deleted question", "delete question": "Delete question", - "confirm delete question": "Do you want to delete the question „{{name}}“?" + "confirm delete question": "Do you want to delete the question „{{name}}“?", + "visits": "Visits", + "last day": "Last day", + "last month": "Last month", + "last year": "Last year" }