Compare commits
5 Commits
v0.1.0
...
e3dac5bc83
| Author | SHA1 | Date | |
|---|---|---|---|
| e3dac5bc83 | |||
| 90582949d5 | |||
| a9436a5af7 | |||
| 8cd5dd1f8e | |||
| f9a7b812fe |
@@ -24,6 +24,7 @@
|
||||
"@fortawesome/free-brands-svg-icons": "^6.4.2",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
||||
"@ngneat/dialog": "5.0.0",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.14.3"
|
||||
|
||||
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@@ -44,6 +44,9 @@ dependencies:
|
||||
'@fortawesome/free-solid-svg-icons':
|
||||
specifier: ^6.4.2
|
||||
version: 6.5.1
|
||||
'@ngneat/dialog':
|
||||
specifier: 5.0.0
|
||||
version: 5.0.0(@angular/core@17.2.3)
|
||||
rxjs:
|
||||
specifier: ~7.8.0
|
||||
version: 7.8.1
|
||||
@@ -2433,6 +2436,15 @@ packages:
|
||||
call-bind: 1.0.7
|
||||
dev: true
|
||||
|
||||
/@ngneat/dialog@5.0.0(@angular/core@17.2.3):
|
||||
resolution: {integrity: sha512-+qLGaLcNXQ5PVtlv4htqHsJ4JV9TZ+wy89rtYMsno/jZuB63usMITPEB7TgtEPgpbyDDcYVagA6eQqYMEgZPOA==}
|
||||
peerDependencies:
|
||||
'@angular/core': '>=17.0.0'
|
||||
dependencies:
|
||||
'@angular/core': 17.2.3(rxjs@7.8.1)(zone.js@0.14.4)
|
||||
tslib: 2.3.1
|
||||
dev: false
|
||||
|
||||
/@ngtools/webpack@17.2.2(@angular/compiler-cli@17.2.3)(typescript@5.3.3)(webpack@5.90.1):
|
||||
resolution: {integrity: sha512-HgvClGO6WVq4VA5d0ZvlDG5hrj8lQzRH99Gt87URm7G8E5XkatysdOsMqUQsJz+OwFWhP4PvTRWVblpBDiDl/A==}
|
||||
engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'}
|
||||
@@ -5893,8 +5905,6 @@ packages:
|
||||
peerDependenciesMeta:
|
||||
webpack:
|
||||
optional: true
|
||||
webpack-sources:
|
||||
optional: true
|
||||
dependencies:
|
||||
webpack: 5.90.1(esbuild@0.20.0)
|
||||
webpack-sources: 3.2.3
|
||||
@@ -8054,6 +8064,10 @@ packages:
|
||||
strip-bom: 3.0.0
|
||||
dev: true
|
||||
|
||||
/tslib@2.3.1:
|
||||
resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==}
|
||||
dev: false
|
||||
|
||||
/tslib@2.6.2:
|
||||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
||||
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
<app-panel></app-panel>
|
||||
</header>
|
||||
<main class="main">
|
||||
<app-modal></app-modal>
|
||||
<app-dock></app-dock>
|
||||
</main>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: calc(100% - 2rem);
|
||||
background: url("../assets/img/wallpaper.png");
|
||||
background-size: cover;
|
||||
background-image: url("../assets/img/wallpaper.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { RouterOutlet } from "@angular/router";
|
||||
import { DockComponent } from "./modules/dock/dock.component";
|
||||
import { ModalComponent } from "./modules/modal/modal.component";
|
||||
import { PanelComponent } from "./modules/panel/panel.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
standalone: true,
|
||||
imports: [RouterOutlet, PanelComponent, DockComponent],
|
||||
imports: [PanelComponent, DockComponent, ModalComponent],
|
||||
templateUrl: "./app.component.html",
|
||||
styleUrl: "./app.component.less",
|
||||
})
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { APP_INITIALIZER, ApplicationConfig } from "@angular/core";
|
||||
import { provideRouter } from "@angular/router";
|
||||
|
||||
import { routes } from './app.routes';
|
||||
import { provideHttpClient } from "@angular/common/http";
|
||||
import { routes } from "./app.routes";
|
||||
import { TranslateService } from "./services/translate.service";
|
||||
|
||||
export function setupTranslateServiceFactory(service: TranslateService) {
|
||||
return () => service.use("en");
|
||||
}
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideRouter(routes)]
|
||||
providers: [
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
TranslateService,
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: setupTranslateServiceFactory,
|
||||
deps: [TranslateService],
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -16,19 +16,19 @@ export class DockComponent {
|
||||
id: 0,
|
||||
svg: "../../../assets/svg/logo-telegram.svg",
|
||||
url: "https://t.me/neur0w0men",
|
||||
text: "Telegram channel",
|
||||
text: "TELEGRAM_LABEL",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
svg: "../../../assets/svg/logo-github.svg",
|
||||
url: "https://github.com/MrSedan",
|
||||
text: "Admin's GitHub",
|
||||
text: "GITHUB_LABEL",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
svg: "../../../assets/svg/logo-gitea.svg",
|
||||
url: "https://git.nwaifu.su",
|
||||
text: "Gitea",
|
||||
text: "GITEA_LABEL",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<a [href]="url">
|
||||
<img [src]="svg" [alt]="url" [title]="text" />
|
||||
<span>{{ text }}</span>
|
||||
<span>{{ text | translate }}</span>
|
||||
</a>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input } from "@angular/core";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-link",
|
||||
imports: [CommonModule],
|
||||
imports: [CommonModule, TranslationPipe],
|
||||
templateUrl: "./link.component.html",
|
||||
styleUrls: ["./link.component.less"],
|
||||
})
|
||||
|
||||
1
src/app/modules/modal/modal.component.html
Normal file
1
src/app/modules/modal/modal.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<div class="modal-window" #modal></div>
|
||||
0
src/app/modules/modal/modal.component.less
Normal file
0
src/app/modules/modal/modal.component.less
Normal file
31
src/app/modules/modal/modal.component.ts
Normal file
31
src/app/modules/modal/modal.component.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
|
||||
import { DialogRef, DialogService } from "@ngneat/dialog";
|
||||
import { WindowComponent } from "../window/window.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-modal",
|
||||
templateUrl: "./modal.component.html",
|
||||
styleUrls: ["./modal.component.less"],
|
||||
imports: [CommonModule],
|
||||
standalone: true,
|
||||
})
|
||||
export class ModalComponent implements AfterViewInit {
|
||||
dialogRef: DialogRef | undefined = undefined;
|
||||
@ViewChild("modal") modal: ElementRef | undefined = undefined;
|
||||
constructor(private dialogService: DialogService, private ref: ElementRef) {}
|
||||
ngAfterViewInit(): void {
|
||||
this.dialogRef = this.dialogService.open(WindowComponent, {
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
backdrop: false,
|
||||
closeButton: false,
|
||||
container: this.modal ?? this.ref,
|
||||
enableClose: false,
|
||||
dragConstraint: "constrain",
|
||||
id: "info-modal",
|
||||
minWidth: "300px",
|
||||
minHeight: "10rem",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,14 @@
|
||||
<span>{{ time }}</span>
|
||||
</div>
|
||||
<div class="right-menu">
|
||||
<span class="lang">en</span>
|
||||
<span
|
||||
class="lang cursor-pointer"
|
||||
(click)="toggleModal()"
|
||||
(keydown)="toggleModal()"
|
||||
tabindex="0"
|
||||
#lang_btn
|
||||
>{{ getLang() }}</span
|
||||
>
|
||||
<a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb">
|
||||
<fa-icon [icon]="faGithub" class="sourcecode-icon" title="Source code"></fa-icon>
|
||||
</a>
|
||||
@@ -15,3 +22,8 @@
|
||||
<fa-icon [icon]="faPower"></fa-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lang-choose" #lang_modal>
|
||||
<p (click)="useLang('en')" (keypress)="useLang('en')" tabindex="0"><b>en</b> - English</p>
|
||||
<p (click)="useLang('ru')" (keypress)="useLang('ru')" tabindex="0"><b>ru</b> - Русский</p>
|
||||
<p (click)="useLang('ja')" (keypress)="useLang('ja')" tabindex="0"><b>ja</b> - 日本語</p>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.panel {
|
||||
z-index: 99999;
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
@@ -62,3 +63,43 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.lang-choose {
|
||||
position: absolute;
|
||||
display: none;
|
||||
&.active {
|
||||
display: flex;
|
||||
}
|
||||
top: 0;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
gap: 0;
|
||||
background-color: var(--black);
|
||||
margin-block-start: 3rem;
|
||||
z-index: 9999;
|
||||
margin-inline-end: 1rem;
|
||||
color: var(--white);
|
||||
padding: 1rem 0;
|
||||
border-radius: 15px;
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) rotate(45deg);
|
||||
vertical-align: middle;
|
||||
top: -0.5rem;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 10px solid var(--black);
|
||||
}
|
||||
p {
|
||||
line-height: 2rem;
|
||||
width: 100%;
|
||||
padding: 0.5rem 1rem;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
import { Component, ElementRef, HostListener, ViewChild } from "@angular/core";
|
||||
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
|
||||
import { faGithub } from "@fortawesome/free-brands-svg-icons";
|
||||
import { faPowerOff, faVolumeHigh } from "@fortawesome/free-solid-svg-icons";
|
||||
import { PanelSevice } from "../../services/panel.service";
|
||||
import { TranslateService } from "../../services/translate.service";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -17,7 +18,11 @@ export class PanelComponent {
|
||||
faGithub = faGithub;
|
||||
faVolume = faVolumeHigh;
|
||||
faPower = faPowerOff;
|
||||
constructor(private panelService: PanelSevice) {
|
||||
showLangModalBool = false;
|
||||
@ViewChild("lang_modal") langModal: ElementRef<HTMLDivElement> | null = null;
|
||||
@ViewChild("lang_btn") langBtn: ElementRef<HTMLSpanElement> | null = null;
|
||||
|
||||
constructor(private panelService: PanelSevice, private translateService: TranslateService) {
|
||||
this.time = this.getTime();
|
||||
setInterval(() => {
|
||||
this.time = this.getTime();
|
||||
@@ -26,7 +31,7 @@ export class PanelComponent {
|
||||
|
||||
private getTime() {
|
||||
const time = this.panelService.getTime();
|
||||
return time.toLocaleDateString("en-US", {
|
||||
return time.toLocaleDateString(this.translateService.translate("TIME_SCHEMA"), {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
@@ -37,4 +42,31 @@ export class PanelComponent {
|
||||
goToSource() {
|
||||
window.open("https://git.nwaifu.su/neuro_llc/NwaifuWeb", "_blank");
|
||||
}
|
||||
|
||||
@HostListener("window:resize")
|
||||
private moveLangModal() {
|
||||
if (!this.langModal || !this.langBtn) {
|
||||
return;
|
||||
}
|
||||
|
||||
const x = this.langBtn.nativeElement.getBoundingClientRect().x;
|
||||
this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`;
|
||||
}
|
||||
|
||||
toggleModal() {
|
||||
if (this.langModal) {
|
||||
this.langModal.nativeElement.classList.toggle("active");
|
||||
if (this.langModal.nativeElement.classList.contains("active")) {
|
||||
this.moveLangModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useLang(lang: string) {
|
||||
this.translateService.use(lang);
|
||||
}
|
||||
|
||||
getLang() {
|
||||
return this.translateService.lang;
|
||||
}
|
||||
}
|
||||
|
||||
10
src/app/modules/window/window.component.html
Normal file
10
src/app/modules/window/window.component.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="panel">
|
||||
<span>{{ modal_title | translate }}</span>
|
||||
<div class="btns">
|
||||
<fa-icon [icon]="faMenu"></fa-icon>
|
||||
<fa-icon [icon]="faClose"></fa-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h1>{{ modal_text | translate }}</h1>
|
||||
</div>
|
||||
24
src/app/modules/window/window.component.less
Normal file
24
src/app/modules/window/window.component.less
Normal file
@@ -0,0 +1,24 @@
|
||||
.panel {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
height: 3rem;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 1rem;
|
||||
background-color: var(--black);
|
||||
color: var(--white);
|
||||
span {
|
||||
font-size: 600;
|
||||
}
|
||||
.btns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
.content {
|
||||
margin: 1rem;
|
||||
}
|
||||
22
src/app/modules/window/window.component.ts
Normal file
22
src/app/modules/window/window.component.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
|
||||
import { faBars, faXmark } from "@fortawesome/free-solid-svg-icons";
|
||||
import { DialogRef } from "@ngneat/dialog";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
|
||||
@Component({
|
||||
selector: "app-window",
|
||||
standalone: true,
|
||||
imports: [CommonModule, FontAwesomeModule, TranslationPipe],
|
||||
templateUrl: "./window.component.html",
|
||||
styleUrls: ["./window.component.less"],
|
||||
// changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class WindowComponent {
|
||||
modal_text = "MODAL_TEXT";
|
||||
modal_title = "MODAL_TITLE";
|
||||
faClose = faXmark;
|
||||
faMenu = faBars;
|
||||
constructor(public ref: DialogRef) {}
|
||||
}
|
||||
14
src/app/pipes/translation.pipe.ts
Normal file
14
src/app/pipes/translation.pipe.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Pipe, PipeTransform } from "@angular/core";
|
||||
import { TranslateService } from "../services/translate.service";
|
||||
|
||||
@Pipe({
|
||||
name: "translate",
|
||||
standalone: true,
|
||||
pure: false,
|
||||
})
|
||||
export class TranslationPipe implements PipeTransform {
|
||||
constructor(private translateService: TranslateService) {}
|
||||
transform(key: string) {
|
||||
return this.translateService.data[key] ?? key;
|
||||
}
|
||||
}
|
||||
30
src/app/services/translate.service.ts
Normal file
30
src/app/services/translate.service.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export class TranslateService {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: Record<string, any> = {};
|
||||
lang = "en";
|
||||
constructor(private http: HttpClient) {}
|
||||
use(lang: string): Promise<object> {
|
||||
this.lang = lang ?? "en";
|
||||
return new Promise<object>((resolve) => {
|
||||
const langPath = `assets/i18n/${lang ?? "en"}.json`;
|
||||
this.http.get(langPath).subscribe({
|
||||
next: (response) => {
|
||||
this.data = response ?? {};
|
||||
resolve(this.data);
|
||||
},
|
||||
error: () => {
|
||||
this.data = {};
|
||||
resolve(this.data);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
translate(key: string) {
|
||||
return this.data[key] ?? key;
|
||||
}
|
||||
}
|
||||
8
src/assets/i18n/en.json
Normal file
8
src/assets/i18n/en.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"MODAL_TITLE": "Info",
|
||||
"TIME_SCHEMA": "en-US",
|
||||
"MODAL_TEXT": "Hello, World!",
|
||||
"TELEGRAM_LABEL": "Telegram channel",
|
||||
"GITHUB_LABEL": "Admin's Github",
|
||||
"GITEA_LABEL": "Neuro LLC Gitea"
|
||||
}
|
||||
8
src/assets/i18n/ja.json
Normal file
8
src/assets/i18n/ja.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"MODAL_TITLE": "情報",
|
||||
"TIME_SCHEMA": "ja-JP",
|
||||
"MODAL_TEXT": "こんにちは、世界!",
|
||||
"TELEGRAM_LABEL": "Telegramチャンネル",
|
||||
"GITHUB_LABEL": "管理者Github",
|
||||
"GITEA_LABEL": "Neuro LLC Gitea"
|
||||
}
|
||||
8
src/assets/i18n/ru.json
Normal file
8
src/assets/i18n/ru.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"MODAL_TITLE": "Информация",
|
||||
"TIME_SCHEMA": "ru-RU",
|
||||
"MODAL_TEXT": "Здравствуйте, мир!",
|
||||
"TELEGRAM_LABEL": "Телеграм канал",
|
||||
"GITHUB_LABEL": "Github админа",
|
||||
"GITEA_LABEL": "Neuro LLC Gitea"
|
||||
}
|
||||
@@ -35,3 +35,24 @@ body {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
ngneat-dialog {
|
||||
.ngneat-dialog-backdrop {
|
||||
pointer-events: none;
|
||||
.ngneat-dialog-content {
|
||||
pointer-events: all;
|
||||
border-radius: 10px;
|
||||
span {
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
}
|
||||
.btns {
|
||||
fa-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.ngneat-drag-marker {
|
||||
height: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user