Merge pull request 'Some additions' (#4) from dev into master

Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
2024-03-11 15:37:03 +03:00
11 changed files with 37 additions and 16 deletions

View File

@@ -1,17 +1,15 @@
import { APP_INITIALIZER, ApplicationConfig } from "@angular/core"; import { APP_INITIALIZER, ApplicationConfig } from "@angular/core";
import { provideRouter } from "@angular/router";
import { provideHttpClient } from "@angular/common/http"; import { provideHttpClient } from "@angular/common/http";
import { routes } from "./app.routes";
import { TranslateService } from "./services/translate.service"; import { TranslateService } from "./services/translate.service";
export function setupTranslateServiceFactory(service: TranslateService) { export function setupTranslateServiceFactory(service: TranslateService) {
return () => service.use("en"); const lang = localStorage.getItem("lang") ?? "en";
return () => service.use(lang);
} }
export const appConfig: ApplicationConfig = { export const appConfig: ApplicationConfig = {
providers: [ providers: [
provideRouter(routes),
provideHttpClient(), provideHttpClient(),
TranslateService, TranslateService,
{ {

View File

@@ -1,4 +1,4 @@
<a [href]="url"> <a [href]="url">
<img [src]="svg" [alt]="url" [title]="text" /> <img [src]="svg" [alt]="url" [title]="text | translate" />
<span>{{ text | translate }}</span> <span>{{ text | translate }}</span>
</a> </a>

View File

@@ -10,7 +10,7 @@ a {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
gap: 0; gap: 0;
transition: 0.3s ease-in-out; transition: 0.5s ease-in-out;
span { span {
opacity: 0; opacity: 0;
visibility: hidden; visibility: hidden;
@@ -21,7 +21,7 @@ a {
font-size: 0.8rem; font-size: 0.8rem;
height: 0; height: 0;
font-weight: 600; font-weight: 600;
transition: opacity 0.3s ease-in-out; transition: all 0.6s ease-in-out;
} }
&:hover { &:hover {
transform: translateY(-1rem); transform: translateY(-1rem);

View File

@@ -15,8 +15,8 @@
#lang_btn #lang_btn
>{{ getLang() }}</span >{{ getLang() }}</span
> >
<a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb"> <a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb" [title]="source_code_btn_title | translate">
<fa-icon [icon]="faGithub" class="sourcecode-icon" title="Source code"></fa-icon> <fa-icon [icon]="faGithub" class="sourcecode-icon"></fa-icon>
</a> </a>
<fa-icon [icon]="faVolume"></fa-icon> <fa-icon [icon]="faVolume"></fa-icon>
<fa-icon [icon]="faPower"></fa-icon> <fa-icon [icon]="faPower"></fa-icon>

View File

@@ -57,6 +57,8 @@
align-items: center; align-items: center;
span { span {
font-weight: 600; font-weight: 600;
user-select: none;
-webkit-user-select: none;
} }
fa-icon { fa-icon {
font-size: 1.2rem; font-size: 1.2rem;

View File

@@ -3,17 +3,20 @@ import { Component, ElementRef, HostListener, ViewChild } from "@angular/core";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome"; import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { faGithub } from "@fortawesome/free-brands-svg-icons"; import { faGithub } from "@fortawesome/free-brands-svg-icons";
import { faPowerOff, faVolumeHigh } from "@fortawesome/free-solid-svg-icons"; import { faPowerOff, faVolumeHigh } from "@fortawesome/free-solid-svg-icons";
import { TranslationPipe } from '../../pipes/translation.pipe';
import { PanelSevice } from "../../services/panel.service"; import { PanelSevice } from "../../services/panel.service";
import { TranslateService } from "../../services/translate.service"; import { TranslateService } from "../../services/translate.service";
@Component({ @Component({
standalone: true, standalone: true,
selector: "app-panel", selector: "app-panel",
imports: [CommonModule, FontAwesomeModule], imports: [CommonModule, FontAwesomeModule, TranslationPipe],
templateUrl: "./panel.component.html", templateUrl: "./panel.component.html",
styleUrls: ["./panel.component.less"], styleUrls: ["./panel.component.less"],
}) })
export class PanelComponent { export class PanelComponent {
source_code_btn_title = "SOURCE_CODE_TITLE"
public time = ""; public time = "";
faGithub = faGithub; faGithub = faGithub;
faVolume = faVolumeHigh; faVolume = faVolumeHigh;
@@ -53,6 +56,18 @@ export class PanelComponent {
this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`; this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`;
} }
@HostListener("window:click", ["$event"])
private closeLangModal(event: MouseEvent) {
if (
this.langModal &&
this.langBtn &&
!this.langModal.nativeElement.contains(event.target as Node) &&
!this.langBtn.nativeElement.contains(event.target as Node)
) {
this.langModal.nativeElement.classList.remove("active");
}
}
toggleModal() { toggleModal() {
if (this.langModal) { if (this.langModal) {
this.langModal.nativeElement.classList.toggle("active"); this.langModal.nativeElement.classList.toggle("active");
@@ -63,6 +78,7 @@ export class PanelComponent {
} }
useLang(lang: string) { useLang(lang: string) {
this.langModal && this.langModal.nativeElement.classList.remove("active");
this.translateService.use(lang); this.translateService.use(lang);
} }

View File

@@ -5,12 +5,13 @@ import { Injectable } from "@angular/core";
export class TranslateService { export class TranslateService {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
data: Record<string, any> = {}; data: Record<string, any> = {};
lang = "en"; lang: string | null = null;
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
use(lang: string): Promise<object> { use(lang: string): Promise<object> {
this.lang = lang ?? "en"; this.lang = lang ?? "en";
localStorage.setItem("lang", this.lang);
return new Promise<object>((resolve) => { return new Promise<object>((resolve) => {
const langPath = `assets/i18n/${lang ?? "en"}.json`; const langPath = `assets/i18n/${this.lang}.json`;
this.http.get(langPath).subscribe({ this.http.get(langPath).subscribe({
next: (response) => { next: (response) => {
this.data = response ?? {}; this.data = response ?? {};

View File

@@ -4,5 +4,6 @@
"MODAL_TEXT": "Hello, World!", "MODAL_TEXT": "Hello, World!",
"TELEGRAM_LABEL": "Telegram channel", "TELEGRAM_LABEL": "Telegram channel",
"GITHUB_LABEL": "Admin's Github", "GITHUB_LABEL": "Admin's Github",
"GITEA_LABEL": "Neuro LLC Gitea" "GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "Source code"
} }

View File

@@ -4,5 +4,6 @@
"MODAL_TEXT": "こんにちは、世界!", "MODAL_TEXT": "こんにちは、世界!",
"TELEGRAM_LABEL": "Telegramチャンネル", "TELEGRAM_LABEL": "Telegramチャンネル",
"GITHUB_LABEL": "管理者Github", "GITHUB_LABEL": "管理者Github",
"GITEA_LABEL": "Neuro LLC Gitea" "GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "ソースコード"
} }

View File

@@ -4,5 +4,6 @@
"MODAL_TEXT": "Здравствуйте, мир!", "MODAL_TEXT": "Здравствуйте, мир!",
"TELEGRAM_LABEL": "Телеграм канал", "TELEGRAM_LABEL": "Телеграм канал",
"GITHUB_LABEL": "Github админа", "GITHUB_LABEL": "Github админа",
"GITEA_LABEL": "Neuro LLC Gitea" "GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "Исходный код"
} }

View File

@@ -47,7 +47,8 @@ ngneat-dialog {
} }
.btns { .btns {
fa-icon { fa-icon {
cursor: pointer; z-index: 999;
cursor: not-allowed;
} }
} }
.ngneat-drag-marker { .ngneat-drag-marker {