Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be6b2f9887 | |||
| a6876cfb0b |
@@ -1,13 +1,21 @@
|
||||
<div class="btns">
|
||||
<nwui-button (click)="fileInput.click()">
|
||||
<span><i class="lni lni-upload"></i> Upload</span>
|
||||
<input type="file" (change)="submitFile($event)" #fileInput style="display: none" />
|
||||
</nwui-button>
|
||||
<nwui-button (click)="onClearClicked()">
|
||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
||||
<input type="file" (change)="submitFile($event)" accept=".nps" #fileInput style="display: none" />
|
||||
</nwui-button>
|
||||
<nwui-button (click)="onSaveClicked()">
|
||||
<span><i class="lni lni-save"></i> Save</span>
|
||||
</nwui-button>
|
||||
@if (this.elements.length){
|
||||
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
||||
<span><i class="lni lni-trash-can"></i> Clear translations</span>
|
||||
</nwui-button>
|
||||
<nwui-button (click)="getAllTranslations()">
|
||||
<span><i class="lni lni-google"></i> Translate all</span>
|
||||
</nwui-button>
|
||||
<nwui-button (click)="onClearClicked()">
|
||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
||||
</nwui-button>
|
||||
}
|
||||
</div>
|
||||
<app-text-list [elements]="elements"></app-text-list>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { NgIf } from '@angular/common';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { NWUIButtonComponent } from '@nwaifu-ui';
|
||||
import { TextListComponent } from './components/text_list/text_list.component';
|
||||
@@ -7,7 +8,7 @@ import { saveOriginalFile } from './lib/file_tools';
|
||||
import { parse } from './lib/parser';
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [TextListComponent, NWUIButtonComponent],
|
||||
imports: [TextListComponent, NWUIButtonComponent, NgIf],
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.scss',
|
||||
@@ -16,6 +17,7 @@ export class AppComponent implements OnInit {
|
||||
title = 'NitroPlusTranslator';
|
||||
elements: TranslateData[] = [];
|
||||
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
|
||||
@ViewChild(TextListComponent) text_list: TextListComponent | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
||||
@@ -85,4 +87,22 @@ export class AppComponent implements OnInit {
|
||||
element.click();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Dialog windows for clear op
|
||||
clearAllTranslations() {
|
||||
if (this.text_list)
|
||||
if (this.text_list.translate_blocks) {
|
||||
this.text_list.translate_blocks.filter((item) => item.item.translated_text).forEach((item) => item.clear());
|
||||
}
|
||||
}
|
||||
|
||||
getAllTranslations() {
|
||||
if (this.text_list)
|
||||
if (this.text_list.translate_blocks)
|
||||
this.text_list.translate_blocks.forEach((item) => item.sendToGoogleTranslate());
|
||||
}
|
||||
|
||||
get has_translations(): boolean {
|
||||
return this.elements.some((i) => i.translated_text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<h1 *ngIf="elements_data.length">Всего: {{ elements_data.length }}</h1>
|
||||
<div id="elements">
|
||||
@for(item of elements_data; track $index) {
|
||||
<app-translate-block [index]="$index" [item]="item"></app-translate-block>
|
||||
<app-translate-block #translateBlock [index]="$index" [item]="item"></app-translate-block>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Component, Input, QueryList, ViewChildren } from '@angular/core';
|
||||
import { TranslateData } from '../../dto/translate_data.dto';
|
||||
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
|
||||
|
||||
@@ -11,6 +11,7 @@ import { TranslateBlockComponent } from '../translate_block/translate_block.comp
|
||||
imports: [CommonModule, TranslateBlockComponent],
|
||||
})
|
||||
export class TextListComponent {
|
||||
@ViewChildren('translateBlock') translate_blocks: QueryList<TranslateBlockComponent> | null = null;
|
||||
elements_data: TranslateData[] = [];
|
||||
@Input() set elements(el: TranslateData[]) {
|
||||
this.elements_data = el;
|
||||
|
||||
Reference in New Issue
Block a user