mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Clickable folder link after download
This commit is contained in:
@@ -20,7 +20,10 @@
|
|||||||
Download Anyway
|
Download Anyway
|
||||||
</button>
|
</button>
|
||||||
<div class="header">{{download.header}}</div>
|
<div class="header">{{download.header}}</div>
|
||||||
<div class="description">{{download.description}}</div>
|
<div *ngIf="download.type != 'done'" class="description">{{download.description}}</div>
|
||||||
|
<div *ngIf="download.type == 'done'" class="description">
|
||||||
|
<a (click)="openFolder(download.description)">{{download.description}}</a>
|
||||||
|
</div>
|
||||||
<div appProgressBar [percent]="download.percent" class="ui progress">
|
<div appProgressBar [percent]="download.percent" class="ui progress">
|
||||||
<div class="bar">
|
<div class="bar">
|
||||||
<div class="progress"></div>
|
<div class="progress"></div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, ChangeDetectorRef } from '@angular/core'
|
import { Component, ChangeDetectorRef } from '@angular/core'
|
||||||
import { DownloadProgress } from '../../../../../electron/shared/interfaces/download.interface'
|
import { DownloadProgress } from '../../../../../electron/shared/interfaces/download.interface'
|
||||||
import { DownloadService } from '../../../../core/services/download.service'
|
import { DownloadService } from '../../../../core/services/download.service'
|
||||||
|
import { ElectronService } from 'src/app/core/services/electron.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-downloads-modal',
|
selector: 'app-downloads-modal',
|
||||||
@@ -11,7 +12,7 @@ export class DownloadsModalComponent {
|
|||||||
|
|
||||||
downloads: DownloadProgress[] = []
|
downloads: DownloadProgress[] = []
|
||||||
|
|
||||||
constructor(private downloadService: DownloadService, ref: ChangeDetectorRef) {
|
constructor(private electronService: ElectronService, private downloadService: DownloadService, ref: ChangeDetectorRef) {
|
||||||
downloadService.onDownloadUpdated(download => {
|
downloadService.onDownloadUpdated(download => {
|
||||||
const index = this.downloads.findIndex(thisDownload => thisDownload.versionID == download.versionID)
|
const index = this.downloads.findIndex(thisDownload => thisDownload.versionID == download.versionID)
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@@ -45,8 +46,13 @@ export class DownloadsModalComponent {
|
|||||||
getBackgroundColor(download: DownloadProgress) {
|
getBackgroundColor(download: DownloadProgress) {
|
||||||
switch(download.type) {
|
switch(download.type) {
|
||||||
case 'good': return 'unset'
|
case 'good': return 'unset'
|
||||||
|
case 'done': return 'unset'
|
||||||
case 'warning': return 'yellow'
|
case 'warning': return 'yellow'
|
||||||
case 'error': return 'indianred'
|
case 'error': return 'indianred'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openFolder(filepath: string) {
|
||||||
|
this.electronService.sendIPC('open-folder', filepath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ export class DownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addDownload(versionID: number, newDownload: NewDownload) {
|
addDownload(versionID: number, newDownload: NewDownload) {
|
||||||
|
if (this.downloads.findIndex(download => download.versionID == versionID) != -1) { return } // Don't download something twice
|
||||||
this.electronService.receiveIPC('download-updated', result => {
|
this.electronService.receiveIPC('download-updated', result => {
|
||||||
this.downloadUpdatedEmitter.emit(result)
|
this.downloadUpdatedEmitter.emit(result)
|
||||||
|
|
||||||
|
|||||||
10
src/electron/ipc/OpenFolderHandler.ipc.ts
Normal file
10
src/electron/ipc/OpenFolderHandler.ipc.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { IPCEmitHandler } from '../shared/IPCHandler'
|
||||||
|
import { shell } from 'electron'
|
||||||
|
|
||||||
|
export default class OpenFolderHandler implements IPCEmitHandler<'open-folder'> {
|
||||||
|
event: 'open-folder' = 'open-folder'
|
||||||
|
|
||||||
|
async handler(filepath: string) {
|
||||||
|
shell.showItemInFolder(filepath)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -161,7 +161,7 @@ export class DownloadHandler implements IPCEmitHandler<'download'> {
|
|||||||
download.header = `Download complete.`
|
download.header = `Download complete.`
|
||||||
download.description = filepath
|
download.description = filepath
|
||||||
download.percent = 100
|
download.percent = 100
|
||||||
download.type = 'good'
|
download.type = 'done'
|
||||||
emitIPCEvent('download-updated', download)
|
emitIPCEvent('download-updated', download)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { DownloadHandler } from '../ipc/download/DownloadHandler'
|
|||||||
import { Settings } from './Settings'
|
import { Settings } from './Settings'
|
||||||
import InitSettingsHandler from '../ipc/InitSettingsHandler.ipc'
|
import InitSettingsHandler from '../ipc/InitSettingsHandler.ipc'
|
||||||
import BatchSongDetailsHandler from '../ipc/BatchSongDetailsHandler.ipc'
|
import BatchSongDetailsHandler from '../ipc/BatchSongDetailsHandler.ipc'
|
||||||
|
import OpenFolderHandler from '../ipc/OpenFolderHandler.ipc'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To add a new IPC listener:
|
* To add a new IPC listener:
|
||||||
@@ -57,13 +58,15 @@ export interface IPCInvokeHandler<E extends keyof IPCInvokeEvents> {
|
|||||||
|
|
||||||
export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[]{
|
export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[]{
|
||||||
return [
|
return [
|
||||||
new DownloadHandler()
|
new DownloadHandler(),
|
||||||
|
new OpenFolderHandler()
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IPCEmitEvents = {
|
export type IPCEmitEvents = {
|
||||||
'download': Download
|
'download': Download
|
||||||
'download-updated': DownloadProgress
|
'download-updated': DownloadProgress
|
||||||
|
'open-folder': string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPCEmitHandler<E extends keyof IPCEmitEvents> {
|
export interface IPCEmitHandler<E extends keyof IPCEmitEvents> {
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ export interface DownloadProgress {
|
|||||||
header: string
|
header: string
|
||||||
description: string
|
description: string
|
||||||
percent: number
|
percent: number
|
||||||
type: 'good' | 'warning' | 'error' | 'cancel'
|
type: 'good' | 'warning' | 'error' | 'cancel' | 'done'
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user