Skip to content

Commit

Permalink
refactor(project metadata page): enable error handler (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snehal Kumbhar committed Mar 20, 2021
1 parent 86a5fb8 commit a4004ed
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/app/project/board/board.component.ts
Expand Up @@ -14,7 +14,7 @@ import {
ReadProject,
SingleProject
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken, Session, SessionService } from '@dasch-swiss/dsp-ui';
import { DspApiConnectionToken, NotificationService, Session, SessionService } from '@dasch-swiss/dsp-ui';
import { DialogComponent } from 'src/app/main/dialog/dialog.component';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { CacheService } from '../../main/cache/cache.service';
Expand Down Expand Up @@ -72,7 +72,8 @@ export class BoardComponent implements OnInit {
private _dialog: MatDialog,
private _route: ActivatedRoute,
private _titleService: Title,
private _snackBar: MatSnackBar
private _snackBar: MatSnackBar,
private _notification: NotificationService,
) {
// get the shortcode of the current project
this._route.parent.paramMap.subscribe((params: Params) => {
Expand All @@ -92,7 +93,6 @@ export class BoardComponent implements OnInit {
this.session = this._session.getSession();
// is the logged-in user system admin?
this.sysAdmin = this.session.user.sysAdmin;

}

// get project info from backend
Expand Down Expand Up @@ -164,12 +164,18 @@ export class BoardComponent implements OnInit {
this.getProjectForDataset();
},
(error: ApiResponseError) => {
// --> TODO: enable the error handler as soon as DSP-1391 is solved
// this._errorHandler.showMessage(error);
if (error.status === 404) {
// the DSP-API returns a 404 with generic message if metadata is not defined
// for the selected project. Below we update the error message.
this._notification.openSnackBar('Metadata is not defined for the selected project');
} else {
// use default error behavior
this._errorHandler.showMessage(error);
}

this.metadataLoading = false;
}
);

this.metadataLoading = false;
}

getProjectForDataset() {
Expand Down

0 comments on commit a4004ed

Please sign in to comment.