Update to Angular v17 syntax

This commit is contained in:
Geomitron
2023-12-25 10:43:21 -06:00
parent 199374b2e2
commit f931a1b221
8 changed files with 146 additions and 194 deletions

View File

@@ -1,4 +1,6 @@
<div *ngIf="settingsLoaded" class="flex flex-col h-screen">
<app-toolbar></app-toolbar>
<router-outlet></router-outlet>
</div>
@if (settingsLoaded) {
<div class="flex flex-col h-screen">
<app-toolbar></app-toolbar>
<router-outlet></router-outlet>
</div>
}

View File

@@ -16,7 +16,6 @@ import { DownloadsModalComponent } from './components/browse/status-bar/download
import { StatusBarComponent } from './components/browse/status-bar/status-bar.component'
import { SettingsComponent } from './components/settings/settings.component'
import { ToolbarComponent } from './components/toolbar/toolbar.component'
import { CheckboxDirective } from './core/directives/checkbox.directive'
import { RemoveStyleTagsPipe } from './core/pipes/remove-style-tags.pipe'
@NgModule({
@@ -32,7 +31,6 @@ import { RemoveStyleTagsPipe } from './core/pipes/remove-style-tags.pipe'
ChartSidebarMenutComponent,
ResultTableRowComponent,
DownloadsModalComponent,
CheckboxDirective,
RemoveStyleTagsPipe,
SettingsComponent,
],

View File

@@ -113,10 +113,11 @@
<ul>
@for (breadcrumb of getVersionBreadcrumbs(version); track $index) {
<li>
<ng-container *ngIf="breadcrumb.link">
@if (breadcrumb.link) {
<a (click)="openUrl(breadcrumb.link)" class="link link-hover">{{ breadcrumb.name }}</a>
</ng-container>
<ng-container *ngIf="!breadcrumb.link">{{ breadcrumb.name }}</ng-container>
} @else {
{{ breadcrumb.name }}
}
</li>
}
</ul>

View File

@@ -1,134 +1,136 @@
<div class="flex h-full flex-col" *ngIf="selectedChart">
<div class="relative">
@if (albumArtMd5) {
@if (hasIcons && icon) {
<div class="tooltip absolute bottom-3 left-3" [attr.data-tip]="iconTooltip">
<img
class="w-16"
src="https://clonehero.gitlab.io/sources/icons/{{ icon }}"
[alt]="selectedChart.icon"
(load)="iconLoading = false"
(error)="iconLoading = false"
[class.hidden]="iconLoading" />
</div>
}
@if (albumLoading) {
<div class="skeleton w-full aspect-square"></div>
}
<img
src="https://files.enchor.us/{{ albumArtMd5 }}.jpg"
alt="Album art"
(load)="albumLoading = false"
(error)="albumLoading = false"
[class.hidden]="albumLoading" />
}
</div>
<div
class="flex flex-1 p-2 gap-1 justify-between overflow-x-hidden overflow-y-auto scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-track-base-300 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
<div class="flex flex-1 flex-col gap-1">
<div>
<!-- TODO: Change this to a dropdown if there is more than one chart -->
<b>Charter: </b>
<a class="link link-hover" (click)="onSourceLinkClicked()">{{ selectedChart.charter | removeStyleTags }}</a>
</div>
<div class="whitespace-nowrap">
<span class="font-bold">Length:</span>
{{ effectiveLength }} (+{{ extraLengthSeconds }}s)
<div
class="tooltip tooltip-bottom cursor-help [text-wrap:balance]"
data-tip="The time between the first and last note. The second value is the extra time at the start and end of the song without notes.">
<i class="bi bi-info-circle text-xs"></i>
</div>
</div>
<div class="flex flex-wrap">
<div class="flex-1">
@if (hasIssues) {
<div class="dropdown dropdown-hover">
<label tabindex="0" class="cursor-help"><i class="bi bi-exclamation-triangle text-lg -my-3 ml-1"></i> Issues Detected</label>
<div tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box min-w-max">
@if (metadataIssues.length > 0) {
<div class="menu-title">Metadata Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of metadataIssues" class="list-item">{{ getMetadataIssueText(issue) }}</li>
</ul>
}
@if (folderIssues.length > 0) {
<div class="menu-title">Chart Folder Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of folderIssues" class="list-item">{{ getFolderIssueText(issue) }}</li>
</ul>
}
@if (chartIssues.length > 0) {
<div class="menu-title">Chart Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of chartIssues" class="list-item">{{ getChartIssueText(issue) }}</li>
</ul>
}
@for (trackIssues of trackIssuesGroups; track $index) {
<div class="menu-title">{{ trackIssues.groupName }}</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of trackIssues.issues" class="list-item">{{ getTrackIssueText(issue) }}</li>
</ul>
}
</div>
</div>
}
@if (selectedChart.modchart) {
<div><i class="bi bi-star text-lg -my-3 ml-1"></i> Modchart</div>
}
@for (pair of boolProperties; track $index) {
<p class="flex items-center">
<i class="bi text-2xl -my-3" [ngClass]="pair.value ? 'bi-check2' : 'bi-x'" [ngStyle]="{ color: pair.value ? 'green' : 'red' }"> </i>
<span class="ml-1 whitespace-nowrap" [class.font-bold]="pair.value">{{ pair.text }}</span>
</p>
}
</div>
</div>
</div>
<div class="flex flex-1 flex-col gap-1">
<div
class="flex flex-wrap gap-1 max-h-40 min-h-[44px] max-w-[234px] overflow-y-auto scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-track-base-300 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
@if (selectedChart.notesData.hasVocals) {
<app-chart-sidebar-instrument [chart]="selectedChart" instrument="vocals" />
}
@for (instrument of instruments; track $index) {
<app-chart-sidebar-instrument [chart]="selectedChart" [instrument]="instrument" />
}
</div>
<div class="flex flex-1 flex-col">
@if (instruments.length > 1 || difficulties.length > 1) {
<div class="flex flex-wrap gap-1">
@if (instruments.length > 1) {
<select class="select select-bordered select-sm grow-[40]" [formControl]="instrumentDropdown">
@for (instrument of instruments; track $index) {
<option [value]="instrument">{{ shortInstrumentDisplay(instrument) }}</option>
}
</select>
}
@if (difficulties.length > 1) {
<select class="select select-bordered select-sm flex-1" [formControl]="difficultyDropdown">
@for (difficulty of difficulties; track $index) {
<option [value]="difficulty">{{ difficultyDisplay(difficulty) }}</option>
}
</select>
}
@if (selectedChart) {
<div class="flex h-full flex-col">
<div class="relative">
@if (albumArtMd5) {
@if (hasIcons && icon) {
<div class="tooltip absolute bottom-3 left-3" [attr.data-tip]="iconTooltip">
<img
class="w-16"
src="https://clonehero.gitlab.io/sources/icons/{{ icon }}"
[alt]="selectedChart.icon"
(load)="iconLoading = false"
(error)="iconLoading = false"
[class.hidden]="iconLoading" />
</div>
}
<p class="font-bold whitespace-nowrap">Average NPS: {{ averageNps || 'N/A' }}</p>
<p class="font-bold whitespace-nowrap">Maximum NPS: {{ maximumNps }}</p>
<p class="font-bold whitespace-nowrap">Note Count: {{ noteCount }}</p>
@if (albumLoading) {
<div class="skeleton w-full aspect-square"></div>
}
<img
src="https://files.enchor.us/{{ albumArtMd5 }}.jpg"
alt="Album art"
(load)="albumLoading = false"
(error)="albumLoading = false"
[class.hidden]="albumLoading" />
}
</div>
<div
class="flex flex-1 p-2 gap-1 justify-between overflow-x-hidden overflow-y-auto scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-track-base-300 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
<div class="flex flex-1 flex-col gap-1">
<div>
<!-- TODO: Change this to a dropdown if there is more than one chart -->
<b>Charter: </b>
<a class="link link-hover" (click)="onSourceLinkClicked()">{{ selectedChart.charter | removeStyleTags }}</a>
</div>
<div class="whitespace-nowrap">
<span class="font-bold">Length:</span>
{{ effectiveLength }} (+{{ extraLengthSeconds }}s)
<div
class="tooltip tooltip-bottom cursor-help [text-wrap:balance]"
data-tip="The time between the first and last note. The second value is the extra time at the start and end of the song without notes.">
<i class="bi bi-info-circle text-xs"></i>
</div>
</div>
<div class="flex flex-wrap">
<div class="flex-1">
@if (hasIssues) {
<div class="dropdown dropdown-hover">
<label tabindex="0" class="cursor-help"><i class="bi bi-exclamation-triangle text-lg -my-3 ml-1"></i> Issues Detected</label>
<div tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box min-w-max">
@if (metadataIssues.length > 0) {
<div class="menu-title">Metadata Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of metadataIssues" class="list-item">{{ getMetadataIssueText(issue) }}</li>
</ul>
}
@if (folderIssues.length > 0) {
<div class="menu-title">Chart Folder Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of folderIssues" class="list-item">{{ getFolderIssueText(issue) }}</li>
</ul>
}
@if (chartIssues.length > 0) {
<div class="menu-title">Chart Issues Found:</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of chartIssues" class="list-item">{{ getChartIssueText(issue) }}</li>
</ul>
}
@for (trackIssues of trackIssuesGroups; track $index) {
<div class="menu-title">{{ trackIssues.groupName }}</div>
<ul class="list-disc ml-9 min-w-[246px] max-w-[min(26.1vw,444px)]">
<li *ngFor="let issue of trackIssues.issues" class="list-item">{{ getTrackIssueText(issue) }}</li>
</ul>
}
</div>
</div>
}
@if (selectedChart.modchart) {
<div><i class="bi bi-star text-lg -my-3 ml-1"></i> Modchart</div>
}
@for (pair of boolProperties; track $index) {
<p class="flex items-center">
<i class="bi text-2xl -my-3" [ngClass]="pair.value ? 'bi-check2' : 'bi-x'" [ngStyle]="{ color: pair.value ? 'green' : 'red' }"> </i>
<span class="ml-1 whitespace-nowrap" [class.font-bold]="pair.value">{{ pair.text }}</span>
</p>
}
</div>
</div>
</div>
<div class="flex flex-1 flex-col gap-1">
<div
class="flex flex-wrap gap-1 max-h-40 min-h-[44px] max-w-[234px] overflow-y-auto scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-track-base-300 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
@if (selectedChart.notesData.hasVocals) {
<app-chart-sidebar-instrument [chart]="selectedChart" instrument="vocals" />
}
@for (instrument of instruments; track $index) {
<app-chart-sidebar-instrument [chart]="selectedChart" [instrument]="instrument" />
}
</div>
<div class="flex flex-1 flex-col">
@if (instruments.length > 1 || difficulties.length > 1) {
<div class="flex flex-wrap gap-1">
@if (instruments.length > 1) {
<select class="select select-bordered select-sm grow-[40]" [formControl]="instrumentDropdown">
@for (instrument of instruments; track $index) {
<option [value]="instrument">{{ shortInstrumentDisplay(instrument) }}</option>
}
</select>
}
@if (difficulties.length > 1) {
<select class="select select-bordered select-sm flex-1" [formControl]="difficultyDropdown">
@for (difficulty of difficulties; track $index) {
<option [value]="difficulty">{{ difficultyDisplay(difficulty) }}</option>
}
</select>
}
</div>
}
<p class="font-bold whitespace-nowrap">Average NPS: {{ averageNps || 'N/A' }}</p>
<p class="font-bold whitespace-nowrap">Maximum NPS: {{ maximumNps }}</p>
<p class="font-bold whitespace-nowrap">Note Count: {{ noteCount }}</p>
</div>
</div>
</div>
<div class="join">
<button class="btn rounded-md flex-1 join-item btn-primary" (click)="onDownloadClicked()">Download</button>
<div
#menu
class="cursor-pointer bg-neutral rounded-md join-item dropdown dropdown-top dropdown-end p-1 flex items-center"
(click)="showMenu()"
[class.dropdown-open]="menuVisible">
<i class="bi bi-three-dots text-2xl px-1 text-neutral-content"></i>
<app-chart-sidebar-menu [chartVersions]="charts![0]" (selectedVersionChanges)="selectedChart = $event" />
</div>
</div>
</div>
<div class="join">
<button class="btn rounded-md flex-1 join-item btn-primary" (click)="onDownloadClicked()">Download</button>
<div
#menu
class="cursor-pointer bg-neutral rounded-md join-item dropdown dropdown-top dropdown-end p-1 flex items-center"
(click)="showMenu()"
[class.dropdown-open]="menuVisible">
<i class="bi bi-three-dots text-2xl px-1 text-neutral-content"></i>
<app-chart-sidebar-menu [chartVersions]="charts![0]" (selectedVersionChanges)="selectedChart = $event" />
</div>
</div>
</div>
}

View File

@@ -1,10 +1,9 @@
import { Component, EventEmitter, HostBinding, OnInit, Output, QueryList, ViewChild, ViewChildren } from '@angular/core'
import { Component, EventEmitter, HostBinding, OnInit, Output, QueryList, ViewChildren } from '@angular/core'
import { sortBy } from 'lodash'
import { SettingsService } from 'src-angular/app/core/services/settings.service'
import { ChartData } from 'src-shared/interfaces/search.interface'
import { CheckboxDirective } from '../../../core/directives/checkbox.directive'
import { SearchService } from '../../../core/services/search.service'
import { SelectionService } from '../../../core/services/selection.service'
import { ResultTableRowComponent } from './result-table-row/result-table-row.component'
@@ -18,7 +17,6 @@ export class ResultTableComponent implements OnInit {
@Output() rowClicked = new EventEmitter<ChartData[]>()
@ViewChild(CheckboxDirective, { static: true }) checkboxColumn: CheckboxDirective
@ViewChildren('tableRow') tableRows: QueryList<ResultTableRowComponent>
activeSong: ChartData[] | null = null

View File

@@ -1,6 +1,6 @@
<div class="flex flex-col gap-4 min-h-0">
<div
class="flex flex-col gap-1 p-1 overflow-y-auto max-h-[75vh] scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
class="flex flex-col gap-2 p-1 overflow-y-auto max-h-[75vh] scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-thumb-neutral scrollbar-thumb-rounded-full">
@for (download of downloadService.downloads; track download.md5) {
<div
class="card bg-neutral text-neutral-content shadow-xl"
@@ -46,16 +46,6 @@
</div>
</div>
</div>
<div id="downloadTitle">
<span style="flex-grow: 1"></span>
<i class="inside right close icon" (click)="downloadService.cancelDownload(download.md5)"></i>
</div>
<div id="downloadText">
<span style="flex-grow: 1"></span>
<span *ngIf="!download.isPath" class="description"></span>
<span *ngIf="download.isPath" class="description"> </span>
</div>
<div id="downloadProgressDiv"></div>
}
</div>
<div *ngIf="downloadService.completedCount > 1" class="flex justify-end">

View File

@@ -10,9 +10,9 @@
readonly
type="text"
placeholder="No directory selected!" />
<button *ngIf="settingsService.libraryDirectory !== undefined" (click)="openLibraryDirectory()" class="join-item btn btn-neutral">
Open Folder
</button>
@if (settingsService.libraryDirectory !== undefined) {
<button (click)="openLibraryDirectory()" class="join-item btn btn-neutral">Open Folder</button>
}
<button (click)="getLibraryDirectory()" class="join-item btn btn-primary">Choose</button>
</div>
</label>

View File

@@ -1,39 +0,0 @@
import { Directive, ElementRef, EventEmitter, Output } from '@angular/core'
@Directive({
selector: '[appCheckbox]',
})
export class CheckboxDirective {
@Output() checked = new EventEmitter<boolean>()
_isChecked = false
constructor(private checkbox: ElementRef) { }
// ngAfterViewInit() {
// TODO
// $(this.checkbox.nativeElement).checkbox({
// onChecked: () => {
// this.checked.emit(true)
// this._isChecked = true
// },
// onUnchecked: () => {
// this.checked.emit(false)
// this._isChecked = false
// },
// })
// }
check(isChecked: boolean) {
this._isChecked = isChecked
if (isChecked) {
this.checkbox.nativeElement.checked = true
} else {
this.checkbox.nativeElement.checked = false
}
}
get isChecked() {
return this._isChecked
}
}