mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Component, ElementRef, ViewChild } from '@angular/core'
|
|
|
|
import { keys, pickBy } from 'lodash'
|
|
|
|
import { DownloadService } from '../../../core/services/download.service'
|
|
import { SearchService } from '../../../core/services/search.service'
|
|
import { SelectionService } from '../../../core/services/selection.service'
|
|
|
|
@Component({
|
|
selector: 'app-status-bar',
|
|
templateUrl: './status-bar.component.html',
|
|
})
|
|
export class StatusBarComponent {
|
|
|
|
@ViewChild('downloadsModal', { static: false }) downloadsModalComponent: ElementRef
|
|
|
|
constructor(
|
|
public downloadService: DownloadService,
|
|
public searchService: SearchService,
|
|
private selectionService: SelectionService,
|
|
) {
|
|
this.downloadService.downloadCountChanges.subscribe(downloadCount => {
|
|
if (downloadCount === 0) {
|
|
this.downloadsModalComponent.nativeElement.close()
|
|
}
|
|
})
|
|
}
|
|
|
|
get selectedGroupIds() {
|
|
return keys(pickBy(this.selectionService.selections)).map(k => Number(k))
|
|
}
|
|
|
|
async downloadSelected() {
|
|
const selectedGroupIds = this.selectedGroupIds
|
|
for (const chart of this.searchService.groupedSongs.filter(gs => selectedGroupIds.includes(gs[0].groupId))) {
|
|
this.downloadService.addDownload(chart[0])
|
|
}
|
|
}
|
|
|
|
clearCompleted() {
|
|
this.downloadService.cancelAllCompleted()
|
|
}
|
|
}
|