Add "Tools" tab with chart issue scanner

This commit is contained in:
Geomitron
2024-12-22 18:35:43 -06:00
parent d2e40b7c24
commit a7113384e8
15 changed files with 866 additions and 13 deletions

View File

@@ -0,0 +1,77 @@
import { Component, ElementRef, NgZone, ViewChild } from '@angular/core'
import { SettingsService } from 'src-angular/app/core/services/settings.service'
@Component({
selector: 'app-tools',
templateUrl: './tools.component.html',
})
export class ToolsComponent {
@ViewChild('themeDropdown', { static: true }) themeDropdown: ElementRef
@ViewChild('scanErrorModal') scanErrorModal: ElementRef<HTMLDialogElement>
public scanning = false
public buttonText = 'Scan for issues'
public scanErrorText = ''
constructor(
zone: NgZone,
public settingsService: SettingsService,
) {
window.electron.on.updateIssueScan(({ status, message }) => zone.run(() => {
if (status === 'progress') {
this.buttonText = message
} else if (status === 'error') {
this.scanning = false
this.scanErrorText = message
this.scanErrorModal.nativeElement.showModal()
} else if (status === 'done') {
this.scanning = false
this.buttonText = 'Complete! (click to scan again)'
}
}))
}
openIssueScanDirectory() {
if (this.settingsService.issueScanDirectory) {
window.electron.emit.showFolder(this.settingsService.issueScanDirectory)
}
}
async getIssueScanDirectory() {
const result = await window.electron.invoke.showOpenDialog({
title: 'Choose issue scan folder',
defaultPath: this.settingsService.issueScanDirectory || '',
properties: ['openDirectory'],
})
if (result.canceled === false) {
this.settingsService.issueScanDirectory = result.filePaths[0]
}
}
openSpreadsheetOutputDirectory() {
if (this.settingsService.spreadsheetOutputDirectory) {
window.electron.emit.showFolder(this.settingsService.spreadsheetOutputDirectory)
}
}
async getSpreadsheetOutputDirectory() {
const result = await window.electron.invoke.showOpenDialog({
title: 'Choose spreadsheet output folder',
defaultPath: this.settingsService.spreadsheetOutputDirectory || '',
properties: ['openDirectory'],
})
if (result.canceled === false) {
this.settingsService.spreadsheetOutputDirectory = result.filePaths[0]
}
}
async scanIssues() {
if (this.settingsService.issueScanDirectory && this.settingsService.spreadsheetOutputDirectory) {
this.scanning = true
window.electron.emit.scanIssues()
}
}
}