You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mediarepo/mediarepo-ui/src/app/app.component.ts

43 lines
1.2 KiB
TypeScript

import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {RepositoryService} from "./services/repository/repository.service";
import {DataloaderService} from "./services/dataloader/dataloader.service";
import {MatSnackBar} from "@angular/material/snack-bar";
import {ErrorBrokerService} from "./services/error-broker/error-broker.service";
3 years ago
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
3 years ago
})
export class AppComponent implements OnInit{
3 years ago
title = 'mediarepo-ui';
constructor(
private router: Router,
private snackBar: MatSnackBar,
private errorBroker: ErrorBrokerService,
private dataloaderService: DataloaderService,
private repoService: RepositoryService,
) {
}
async ngOnInit() {
this.errorBroker.errorCb = (err: { message: string }) => {
console.error(err);
this.showError(err)
};
await this.dataloaderService.loadData();
if (this.repoService.selectedRepository.getValue() == undefined) {
await this.router.navigate(["repositories"])
}
}
private showError(err: { message: string }) {
this.snackBar.open(err.message, undefined, {
panelClass: "warn",
duration: 2000,
});
}
3 years ago
}