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.
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
3 years ago
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
||
3 years ago
|
import {Repository} from "../../models/Repository";
|
||
|
import {RepositoryService} from "../../services/repository/repository.service";
|
||
3 years ago
|
import {MatTabChangeEvent, MatTabGroup} from "@angular/material/tabs";
|
||
3 years ago
|
import {TagService} from "../../services/tag/tag.service";
|
||
3 years ago
|
import {TabService} from "../../services/tab/tab.service";
|
||
3 years ago
|
|
||
|
@Component({
|
||
3 years ago
|
selector: 'app-core',
|
||
|
templateUrl: './core.component.html',
|
||
|
styleUrls: ['./core.component.scss']
|
||
3 years ago
|
})
|
||
3 years ago
|
export class CoreComponent implements OnInit {
|
||
3 years ago
|
|
||
|
public selectedRepository: Repository | undefined;
|
||
|
|
||
|
@ViewChild("tabGroup") tabGroup!: MatTabGroup;
|
||
|
|
||
3 years ago
|
|
||
3 years ago
|
constructor(
|
||
|
private tabService: TabService,
|
||
|
private repoService: RepositoryService,
|
||
|
private tagService: TagService)
|
||
|
{}
|
||
3 years ago
|
|
||
3 years ago
|
public async ngOnInit(): Promise<void> {
|
||
3 years ago
|
this.selectedRepository = this.repoService.selectedRepository.getValue();
|
||
3 years ago
|
this.repoService.selectedRepository.subscribe(async (selected) => {
|
||
3 years ago
|
this.selectedRepository = selected;
|
||
|
this.updateSelectedTab();
|
||
3 years ago
|
await this.loadRepoData();
|
||
3 years ago
|
});
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
public updateSelectedTab() {
|
||
3 years ago
|
if (!this.tabGroup) {
|
||
|
return;
|
||
|
}
|
||
3 years ago
|
if (!this.selectedRepository) {
|
||
|
this.tabGroup.selectedIndex = 0;
|
||
|
} else if (this.tabGroup.selectedIndex === 0) {
|
||
|
this.tabGroup.selectedIndex = 1;
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
async loadRepoData() {
|
||
|
await this.tagService.loadTags();
|
||
|
}
|
||
3 years ago
|
|
||
|
public onTabSelectionChange(event: MatTabChangeEvent): void {
|
||
|
this.tabService.setSelectedTab(event.index);
|
||
|
}
|
||
3 years ago
|
}
|