diff --git a/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.html b/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.html index 61b941db1..6622f5754 100644 --- a/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.html +++ b/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.html @@ -50,12 +50,13 @@

{{formLabel.title}}



-

- {{loginErrorServer ? formLabel.error.server : formLabel.error.failed}} -

+

{{formLabel.error.failed}}

+ + +

A user is already logged in:

diff --git a/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.ts b/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.ts index 0a324c450..be2d0b01c 100644 --- a/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.ts +++ b/projects/dsp-ui/src/lib/action/components/login-form/login-form.component.ts @@ -61,8 +61,7 @@ export class LoginFormComponent implements OnInit { errorMessage: ApiResponseError; // specific error messages - loginErrorUser = false; - loginErrorPw = false; + loginFailed = false; loginErrorServer = false; // labels for the login form @@ -157,15 +156,13 @@ export class LoginFormComponent implements OnInit { }, (error: ApiResponseError) => { // error handling - this.loginErrorUser = (error.status === 404); - this.loginErrorPw = (error.status === 401); + this.loginFailed = (error.status === 401 || error.status === 404); this.loginErrorServer = (error.status === 0 || error.status >= 500 && error.status < 600); this.loginSuccess.emit(false); this.errorMessage = error; this.loading = false; - // TODO: update error handling similar to the old method (see commented code below) } ); } @@ -190,7 +187,7 @@ export class LoginFormComponent implements OnInit { }, (error: ApiResponseError) => { console.error(error); - this.loginSuccess.emit(false); + this.logoutSuccess.emit(false); this.loading = false; } ); diff --git a/projects/dsp-ui/src/lib/action/components/message/message.component.html b/projects/dsp-ui/src/lib/action/components/message/message.component.html index 1604edaa0..27a8db647 100644 --- a/projects/dsp-ui/src/lib/action/components/message/message.component.html +++ b/projects/dsp-ui/src/lib/action/components/message/message.component.html @@ -1,4 +1,4 @@ - + {{message?.type | uppercase }} {{message?.status}} | {{message?.statusMsg}} @@ -15,6 +15,12 @@ + + +

{{apiError.error.toString()}}

+
+
+

{{links.title}}

@@ -25,11 +31,24 @@ - + + +

{{message.footnote}}

+ + +

+ Please come back in a few minutes and try to reload the page. +

+ + + + mail_outline Contact the support team + +
-
diff --git a/projects/dsp-ui/src/lib/action/components/message/message.component.scss b/projects/dsp-ui/src/lib/action/components/message/message.component.scss index f127a54e0..75e3d1cba 100644 --- a/projects/dsp-ui/src/lib/action/components/message/message.component.scss +++ b/projects/dsp-ui/src/lib/action/components/message/message.component.scss @@ -73,6 +73,15 @@ $warn: rgb(244, 67, 54); .message-footnote { padding: 24px; + + .bolder { + font-weight: bolder; + } + + .action { + margin: 48px auto 0 auto; + display: table; + } } } diff --git a/projects/dsp-ui/src/lib/action/components/message/message.component.spec.ts b/projects/dsp-ui/src/lib/action/components/message/message.component.spec.ts index ef8eb8e0b..0f41f39b7 100644 --- a/projects/dsp-ui/src/lib/action/components/message/message.component.spec.ts +++ b/projects/dsp-ui/src/lib/action/components/message/message.component.spec.ts @@ -13,7 +13,7 @@ import { DspMessageData, MessageComponent } from './message.component'; * Test host component to simulate parent component. */ @Component({ - template: `` + template: `` }) class ShortMessageTestHostComponent implements OnInit { @@ -27,7 +27,7 @@ class ShortMessageTestHostComponent implements OnInit { footnote: 'Close it' }; - short = true; + size = 'short'; constructor() { } @@ -39,7 +39,7 @@ class ShortMessageTestHostComponent implements OnInit { * Test host component to simulate parent component. */ @Component({ - template: `` + template: `` }) class LongMessageTestHostComponent implements OnInit { @@ -52,8 +52,6 @@ class LongMessageTestHostComponent implements OnInit { error: 'error message' }; - short = false; - constructor() { } @@ -64,7 +62,7 @@ class LongMessageTestHostComponent implements OnInit { * Test host component to simulate parent component. */ @Component({ - template: `` + template: `` }) class ShortMessageWithDurationTestHostComponent implements OnInit { @@ -78,7 +76,7 @@ class ShortMessageWithDurationTestHostComponent implements OnInit { footnote: 'Close it' }; - short = true; + size = 'short'; constructor() { } diff --git a/projects/dsp-ui/src/lib/action/components/message/message.component.ts b/projects/dsp-ui/src/lib/action/components/message/message.component.ts index 49a0e2ed4..2985b9c48 100644 --- a/projects/dsp-ui/src/lib/action/components/message/message.component.ts +++ b/projects/dsp-ui/src/lib/action/components/message/message.component.ts @@ -1,6 +1,7 @@ import { Location } from '@angular/common'; import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; +import { ApiResponseError } from '@dasch-swiss/dsp-js'; import { StatusMsg } from '../../../../assets/i18n/statusMsg'; /** @@ -19,36 +20,50 @@ export class DspMessageData { } @Component({ - selector: 'dsp-message', - templateUrl: './message.component.html', - styleUrls: ['./message.component.scss'] + selector: 'dsp-message', + templateUrl: './message.component.html', + styleUrls: ['./message.component.scss'] }) export class MessageComponent implements OnInit { /** - * Message type: DspMessageData or ApiServiceError + * Message type: DspMessageData * - * @param message This type needs at least a status number (0-511). - * In this case, or if type is ApiServiceError, it takes the default status messages + * @param message This type needs at least a status number (0-599). + * In this case, or if type is ApiResponseError, it takes the default status messages * from the list of HTTP status codes (https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) */ @Input() message: DspMessageData = new DspMessageData(); - // TODO: Refactor Inputs into one parameter (i.e. 'size') - // https://github.com/dasch-swiss/knora-ui-ng-lib/pull/95#discussion_r435978988 + /** + * Message type: ApiResponseError + * @param apiError + */ + @Input() apiError?: ApiResponseError; + + /** + * Size of the message: long, medium or short? + * @param size Default size is 'long' + */ + @Input() size: 'short' | 'medium' | 'long' = 'long'; /** + * @deprecated * @param short Show short message only * A small message box to notify the user an event has occured. */ - @Input() short = false; + @Input() short = (this.size === 'short'); /** + * @deprecated * @param medium Show medium message * A message box without footnote or links. */ - @Input() medium = false; + @Input() medium = (this.size === 'medium'); + /** + * @param duration How long should the message be displayed + */ @Input() duration?: number; statusMsg: any; @@ -87,14 +102,6 @@ export class MessageComponent implements OnInit { ] }; - footnote: any = { - text: 'If you think this is a mistake, please', - team: { - dasch: - ' inform the DaSCH development team.' - } - }; - constructor( private _router: Router, private _location: Location, @@ -103,6 +110,16 @@ export class MessageComponent implements OnInit { ) { } ngOnInit() { + // temporary solution as long we have to support the deprecated inputs "short" and "medium" + if (this.short || this.medium) { + this.size = (this.short ? 'short' : 'medium') + } + + + if (this.apiError) { + this.message.status = this.apiError.status; + } + this.statusMsg = this._status.default; if (!this.message) { @@ -170,11 +187,7 @@ export class MessageComponent implements OnInit { msg.statusText !== undefined ? msg.statusText : this.statusMsg[s].description; - tmpMsg.footnote = - msg.footnote !== undefined - ? msg.footnote - : this.footnote.text + ' ' + this.footnote.team.dasch; - this.showLinks = !this.medium; + this.showLinks = (this.size === 'long'); break; case s >= 500 && s < 600: // the message is a server side (api) error @@ -188,8 +201,6 @@ export class MessageComponent implements OnInit { msg.statusText !== undefined ? msg.statusText : this.statusMsg[s].description; - tmpMsg.footnote = - this.footnote.text + ' ' + this.footnote.team.dasch; this.showLinks = false; break; default: @@ -212,4 +223,8 @@ export class MessageComponent implements OnInit { this.disable = !this.disable; } + reload() { + window.location.reload(); + } + } diff --git a/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.html b/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.html index f8da6879f..45065fa48 100644 --- a/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.html +++ b/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.html @@ -1,4 +1,4 @@ -
+
+ + diff --git a/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.ts b/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.ts index 7c9b12f21..1c16f39c1 100644 --- a/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.ts +++ b/projects/dsp-ui/src/lib/search/advanced-search/advanced-search.component.ts @@ -69,6 +69,8 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy { formChangesSubscription: Subscription; + errorMessage: ApiResponseError; + // reference to the component that controls the resource class selection @ViewChild('resourceClass') resourceClassComponent: SelectResourceClassComponent; @@ -133,7 +135,7 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy { this.ontologiesMetadata = response; }, (error: ApiResponseError) => { - console.error(error); + this.errorMessage = error; }); } diff --git a/projects/dsp-ui/src/lib/search/search.module.ts b/projects/dsp-ui/src/lib/search/search.module.ts index 621183c84..1ae2a24ff 100644 --- a/projects/dsp-ui/src/lib/search/search.module.ts +++ b/projects/dsp-ui/src/lib/search/search.module.ts @@ -34,6 +34,7 @@ import { SearchListValueComponent } from './advanced-search/select-property/spec import { SearchDisplayListComponent } from './advanced-search/select-property/specify-property-value/search-list-value/search-display-list/search-display-list.component'; import { SearchTextValueComponent } from './advanced-search/select-property/specify-property-value/search-text-value/search-text-value.component'; import { SearchUriValueComponent } from './advanced-search/select-property/specify-property-value/search-uri-value/search-uri-value.component'; +import { DspActionModule } from '../action'; @@ -75,6 +76,7 @@ import { SearchUriValueComponent } from './advanced-search/select-property/speci MatInputModule, MatDatepickerModule, MatAutocompleteModule, + DspActionModule, DspViewerModule, TextFieldModule ], diff --git a/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.html b/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.html index a837df138..17bbaf0fe 100644 --- a/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.html +++ b/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.html @@ -33,13 +33,18 @@
-
+
+ +
+ +
+
diff --git a/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.ts b/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.ts index d9dc42224..8fdc8fc36 100644 --- a/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.ts +++ b/projects/dsp-ui/src/lib/viewer/views/list-view/list-view.component.ts @@ -98,7 +98,6 @@ export class ListViewComponent implements OnChanges { }, (error: ApiResponseError) => { this.errorMessage = error; - console.error(error); } ); } @@ -111,7 +110,6 @@ export class ListViewComponent implements OnChanges { }, (error: ApiResponseError) => { this.errorMessage = error; - console.error(error); this.loading = false; } ); @@ -128,7 +126,6 @@ export class ListViewComponent implements OnChanges { }, (error: ApiResponseError) => { this.errorMessage = error; - console.error(error); } ); } @@ -144,7 +141,6 @@ export class ListViewComponent implements OnChanges { }, (error: ApiResponseError) => { this.errorMessage = error; - console.error(error); this.loading = false; } ); diff --git a/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.html b/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.html index 2370579ce..c5d9432e3 100644 --- a/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.html +++ b/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.html @@ -1,4 +1,4 @@ -
+
+ + + + diff --git a/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.ts b/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.ts index 9367231f2..6413f2c5a 100644 --- a/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.ts +++ b/projects/dsp-ui/src/lib/viewer/views/resource-view/resource-view.component.ts @@ -73,6 +73,8 @@ export class ResourceViewComponent implements OnInit, OnChanges, OnDestroy { resource: ReadResource; + errorMessage: ApiResponseError; + resPropInfoVals: PropertyInfoValues[] = []; // array of resource properties systemPropDefs: SystemPropertyDefinition[] = []; // array of system properties @@ -145,7 +147,7 @@ export class ResourceViewComponent implements OnInit, OnChanges, OnDestroy { }, (error: ApiResponseError) => { - console.error('Error to get resource: ', error); + this.errorMessage = error; }); } diff --git a/src/app/action-playground/action-playground.component.html b/src/app/action-playground/action-playground.component.html index 136a098b9..79154d7e6 100644 --- a/src/app/action-playground/action-playground.component.html +++ b/src/app/action-playground/action-playground.component.html @@ -53,10 +53,15 @@

Message Component

+

Short

- - + +

Medium

+ + +

Large

+

Open a message with a display duration of 2 seconds