Minor bugfixes

This commit is contained in:
Geomitron
2024-01-16 09:26:03 -06:00
parent f9c599726f
commit 4f883bf4fa
5 changed files with 48 additions and 38 deletions

View File

@@ -40,7 +40,17 @@
} }
</div> </div>
<div class="form-control"> <div class="form-control">
<textarea class="textarea textarea-bordered h-24" placeholder="More details (optional)" [formControl]="reportExtraInfo"></textarea> <div class="label">
<span class="label-text">More details <span class="text-error">*</span></span>
</div>
<textarea
required
class="textarea textarea-bordered h-24"
[class.border-error]="reportExtraInfo.invalid && reportExtraInfo.touched"
placeholder="Please be specific. Vague reports may be ignored if the problem is not obvious."
[formControl]="reportExtraInfo">
</textarea>
<span *ngIf="reportExtraInfo.invalid && reportExtraInfo.touched" class="text-error">Please provide more details.</span>
</div> </div>
<div class="form-control flex-row justify-end"> <div class="form-control flex-row justify-end">
<button class="btn btn-primary" (click)="report()">Submit</button> <button class="btn btn-primary" (click)="report()">Submit</button>
@@ -65,11 +75,19 @@
<th></th> <th></th>
} }
<th class="text-neutral-content">Uploaded</th> <th class="text-neutral-content">Uploaded</th>
<th class="text-neutral-content"> <th>
<span class="label-text cursor-help underline decoration-dotted" title="The MD5 hash of the chart folder or .sng file.">Hash</span> <span
class="label-text cursor-help underline decoration-dotted text-neutral-content"
title="The MD5 hash of the chart folder or .sng file.">
Hash
</span>
</th> </th>
<th class="text-neutral-content"> <th>
<span class="label-text cursor-help underline decoration-dotted" title="The MD5 hash of just the .chart or .mid file.">Chart Hash</span> <span
class="label-text cursor-help underline decoration-dotted text-neutral-content"
title="The MD5 hash of just the .chart or .mid file.">
Chart Hash
</span>
</th> </th>
<th class="text-neutral-content">Google Drive Location</th> <th class="text-neutral-content">Google Drive Location</th>
</tr> </tr>

View File

@@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormControl } from '@angular/forms' import { FormControl, Validators } from '@angular/forms'
import { sortBy } from 'lodash' import { sortBy } from 'lodash'
import { environment } from 'src-angular/environments/environment' import { environment } from 'src-angular/environments/environment'
@@ -33,7 +33,7 @@ export class ChartSidebarMenutComponent implements OnInit {
this.selectedVersion.valueChanges.subscribe(v => this.selectedVersionChanges.emit(v)) this.selectedVersion.valueChanges.subscribe(v => this.selectedVersionChanges.emit(v))
this.reportOption = new FormControl<string>(this.reportOptions[0], { nonNullable: true }) this.reportOption = new FormControl<string>(this.reportOptions[0], { nonNullable: true })
this.reportExtraInfo = new FormControl<string>('', { nonNullable: true }) this.reportExtraInfo = new FormControl<string>('', { nonNullable: true, validators: [Validators.required] })
} }
get displayVersions() { get displayVersions() {
@@ -78,6 +78,7 @@ export class ChartSidebarMenutComponent implements OnInit {
} }
report() { report() {
if (this.reportExtraInfo.valid) {
this.http.post(`${environment.apiUrl}/report`, { this.http.post(`${environment.apiUrl}/report`, {
chartId: this.selectedVersion.value.chartId, chartId: this.selectedVersion.value.chartId,
reason: this.reportOption.value, reason: this.reportOption.value,
@@ -86,5 +87,8 @@ export class ChartSidebarMenutComponent implements OnInit {
this.reportMessage = response.message this.reportMessage = response.message
this.reportSent = true this.reportSent = true
}) })
} else {
this.reportExtraInfo.markAsTouched()
}
} }
} }

View File

@@ -87,22 +87,6 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
} }
} }
get logoType() {
switch (localStorage.getItem('theme')) {
case 'emerald': return 'emerald'
case 'halloween': return 'halloween'
case 'lemonade': return 'lemonade'
case 'night': return 'night'
case 'synthwave': return 'synthwave'
case 'aqua': return 'orange'
case 'valentine': return 'valentine'
case 'winter': return 'winter'
case 'aren': return 'aren'
case 'froogs': return 'froogs'
default: return 'default'
}
}
get todayDate() { get todayDate() {
return dayjs().format('YYYY-MM-DD') return dayjs().format('YYYY-MM-DD')
} }

View File

@@ -101,7 +101,9 @@ export class SearchService {
if (!nextPage) { if (!nextPage) {
// Don't reload results if they are the same // Don't reload results if they are the same
if (this.groupedSongs && xorBy(this.songsResponse.data, response.data, r => r.chartId).length === 0) { if (this.groupedSongs
&& xorBy(this.songsResponse!.data, response.data, r => r.chartId).length === 0
&& this.songsResponse!.found === response.found) {
return return
} else { } else {
this.groupedSongs = [] this.groupedSongs = []
@@ -130,7 +132,7 @@ export class SearchService {
this.isDefaultSearch = false this.isDefaultSearch = false
let retries = 10 let retries = 10
return this.http.post<{ data: SearchResult['data'] }>(`${environment.apiUrl}/search/advanced`, search).pipe( return this.http.post<{ data: SearchResult['data']; found: number }>(`${environment.apiUrl}/search/advanced`, search).pipe(
catchError((err, caught) => { catchError((err, caught) => {
if (err.status === 400 || retries-- <= 0) { if (err.status === 400 || retries-- <= 0) {
this.searchLoading = false this.searchLoading = false
@@ -144,7 +146,9 @@ export class SearchService {
this.searchLoading = false this.searchLoading = false
// Don't reload results if they are the same // Don't reload results if they are the same
if (this.groupedSongs && xorBy(this.songsResponse.data, response.data, r => r.chartId).length === 0) { if (this.groupedSongs
&& xorBy(this.songsResponse!.data, response.data, r => r.chartId).length === 0
&& this.songsResponse!.found === response.found) {
return return
} else { } else {
this.groupedSongs = [] this.groupedSongs = []

View File

@@ -118,9 +118,9 @@ export function instrumentToDiff(instrument: Instrument | 'vocals') {
* @returns a string representation of `ms` that looks like HH:MM:SS * @returns a string representation of `ms` that looks like HH:MM:SS
*/ */
export function msToRoughTime(ms: number) { export function msToRoughTime(ms: number) {
const seconds = _.round((ms / 1000) % 60) const seconds = _.floor((ms / 1000) % 60)
const minutes = Math.floor((ms / 1000 / 60) % 60) const minutes = _.floor((ms / 1000 / 60) % 60)
const hours = Math.floor((ms / 1000 / 60 / 60) % 24) const hours = _.floor((ms / 1000 / 60 / 60) % 24)
return `${hours ? `${hours}:` : ''}${minutes}:${_.padStart(String(seconds), 2, '0')}` return `${hours ? `${hours}:` : ''}${minutes}:${_.padStart(String(seconds), 2, '0')}`
} }
@@ -129,7 +129,7 @@ const allowedTags = [
'gradient', 'i', 'indent', 'line-height', 'line-indent', 'link', 'lowercase', 'gradient', 'i', 'indent', 'line-height', 'line-indent', 'link', 'lowercase',
'margin', 'mark', 'mspace', 'nobr', 'noparse', 'page', 'pos', 'rotate', 's', 'margin', 'mark', 'mspace', 'nobr', 'noparse', 'page', 'pos', 'rotate', 's',
'size', 'smallcaps', 'space', 'sprite', 'strikethrough', 'style', 'sub', 'sup', 'size', 'smallcaps', 'space', 'sprite', 'strikethrough', 'style', 'sub', 'sup',
'u', 'uppercase', 'voffset', 'width', 'u', 'uppercase', 'voffset', 'width', '#',
] ]
const tagPattern = allowedTags.map(tag => `\\b${tag}\\b`).join('|') const tagPattern = allowedTags.map(tag => `\\b${tag}\\b`).join('|')
/** /**