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 {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 repoService: RepositoryService,
) {
}
async ngOnInit() {
this.errorBroker.errorCb = (err: { message: string }) => this.showError(err);
this.errorBroker.infoCb = (info: string) => this.showInfo(info);
await this.repoService.loadRepositories();
}
private showError(err: { message: string }) {
this.snackBar.open(err.message, undefined, {
panelClass: "warn",
duration: 2000,
});
}
private showInfo(info: string) {
this.snackBar.open(info, undefined, {
panelClass: "primary",
duration: 2000,
});
}
3 years ago
}