diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 9510bea..475c85a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,4 +1,4 @@
-import { NgModule } from '@angular/core';
+import {LOCALE_ID, NgModule} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
@@ -27,6 +27,10 @@ import {BanService} from "./services/ban.service";
import {MatAutocompleteModule} from "@angular/material/autocomplete";
import {FormsModule} from "@angular/forms";
import {ServerService} from "./services/server.service";
+import {registerLocaleData} from "@angular/common";
+import localeRu from "@angular/common/locales/ru";
+
+registerLocaleData(localeRu, "ru")
@NgModule({
declarations: [
@@ -57,6 +61,7 @@ import {ServerService} from "./services/server.service";
FormsModule
],
providers: [
+ {provide: LOCALE_ID, useValue: 'ru' },
AnnonceService,
PlayerService,
BanService,
diff --git a/src/app/entities/servers/Player.ts b/src/app/entities/servers/Player.ts
index 28018e6..d18004d 100644
--- a/src/app/entities/servers/Player.ts
+++ b/src/app/entities/servers/Player.ts
@@ -1,6 +1,7 @@
export interface Player {
clz: number|null;
deads: number;
+ duration: string;
duration_seconds: number;
id: number;
loss: number;
diff --git a/src/app/entities/servers/Server.ts b/src/app/entities/servers/Server.ts
index 646b0b5..3b0fb46 100644
--- a/src/app/entities/servers/Server.ts
+++ b/src/app/entities/servers/Server.ts
@@ -19,4 +19,5 @@ export interface Server {
status: boolean;
uniq: Uniq;
workshop: string|null;
+ ip:string;
}
diff --git a/src/app/pages/rules-page/rules-page.component.html b/src/app/pages/rules-page/rules-page.component.html
index e765bae..e7f3c82 100644
--- a/src/app/pages/rules-page/rules-page.component.html
+++ b/src/app/pages/rules-page/rules-page.component.html
@@ -6,7 +6,7 @@
-
+
{{rule.name}}
{{rule.ban}}
diff --git a/src/app/pages/servers-page/servers-page.component.html b/src/app/pages/servers-page/servers-page.component.html
index 497ceb4..7bf87d3 100644
--- a/src/app/pages/servers-page/servers-page.component.html
+++ b/src/app/pages/servers-page/servers-page.component.html
@@ -6,7 +6,7 @@
-
+
{{server.value.name}}
@@ -16,19 +16,79 @@
-
{{server.value.description}}
-
+
+
+ {{server.value.status?'Включен':'Выключен'}}
+ сейчас сервер
+
+
+ {{server.value.player_count}}
+ игроков сейчас играет
+
+
+ {{server.value.uniq.day}}
+ игроков играло сегодня
+
+
+ {{server.value.uniq.month}}
+ игроков играло за месяц
+
+
+ {{server.value.uniq.year}}
+ игроков играло за год
+
+
+ {{server.value.last_update * 1000 | date: "hh:mm:ss"}}
+ обновление информации
+
+
+ {{server.value.dockerStats.cpu.percent}}%
+ нагрузка сервера
+
+
+
+
+ {{mapClearName(server.value.map)}}
+ Текущая карта
+
+
+ Подключиться
+ через Steam
+
+
+ Адрес сервера
+ {{server.value.ip}}
+
+
+ Скачать карту
+ из воркшопа
+
+
+ 0">
- {{player.name}}
+ Посмотреть игроков на сервере
- {{player.score}} / {{player.deads}} / {{player.duration_seconds}}
- Ид игрока: {{player.id}}
- Пинг: {{player.ping}}
- Потери пакетов: {{player.loss}}
+
+
+
+ {{player.name}}
+
+
+ {{player.score}} / {{player.deads}} / {{player.duration}}
+
+
+ Ид игрока: {{player.id}}
+ Пинг: {{player.ping}}
+ Потери пакетов: {{player.loss}}
+
diff --git a/src/app/pages/servers-page/servers-page.component.scss b/src/app/pages/servers-page/servers-page.component.scss
index e69de29..e624b13 100644
--- a/src/app/pages/servers-page/servers-page.component.scss
+++ b/src/app/pages/servers-page/servers-page.component.scss
@@ -0,0 +1,3 @@
+.container {
+ padding: 24px;
+}
diff --git a/src/app/pages/servers-page/servers-page.component.ts b/src/app/pages/servers-page/servers-page.component.ts
index a1a4557..3a36aee 100644
--- a/src/app/pages/servers-page/servers-page.component.ts
+++ b/src/app/pages/servers-page/servers-page.component.ts
@@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core';
import {WebsocketServersListenerService} from "../../services/websocket-servers-listener.service";
import {Server} from "../../entities/servers/Server";
+import {KeyValue} from "@angular/common";
+import {ActionService} from "../../services/action.service";
@Component({
selector: 'app-servers-page',
@@ -9,19 +11,55 @@ import {Server} from "../../entities/servers/Server";
})
export class ServersPageComponent implements OnInit {
- servers:{[srv_name: string]:Server} = {};
+ servers:{[srv_name: string]:Server|any} = {};
- constructor(private servers_ws:WebsocketServersListenerService) { }
+ constructor(private servers_ws:WebsocketServersListenerService,
+ public actionService: ActionService) { }
ngOnInit(): void {
this.servers_ws.getServers().subscribe((r) => {
- if (r.state == 0) this.servers = r.servers;
- else {
- for (let srv_name of Object.keys(r.servers)) {
- Object.assign(this.servers[srv_name], r.servers[srv_name]);
+ this.setServers(r.servers);
+ });
+ }
+
+ private updateProp(obj: TObj, key: K, value: TObj[K]) {
+ return {...obj, [key]: value};
+ }
+
+ setServers(servers: {[srv_name: string]:Server|any}) {
+ const keys_current = Object.keys(this.servers);
+ const keys_update = Object.keys(servers);
+ for (const srv_name of keys_update) {
+ if (keys_current.indexOf(srv_name) == -1) {
+ //init
+ this.servers[srv_name] = servers[srv_name];
+ } else {
+ const keys_on_server = Object.keys(servers[srv_name]);
+ for (const server_key of keys_on_server) {
+ if (server_key == "players") {
+ for (const player_update of servers[srv_name]["players"]) {
+ for (const player_current of this.servers[srv_name]["players"]) {
+ if (player_update.id == player_current.id) {
+ //todo rework this shit
+ Object.assign(player_current, player_update);
+ }
+ }
+ }
+ } else {
+ this.servers[srv_name][server_key]=servers[srv_name][server_key];
+ }
}
}
- });
+ }
+ }
+
+ public playerCountOrder = (s1: KeyValue, s2: KeyValue): number => {
+ return s2.value.player_count - s1.value.player_count;
+ }
+
+ public mapClearName(name: string|undefined) {
+ // @ts-ignore
+ return name.split("workshop/").pop().split(".ugc").shift()
}
}
diff --git a/src/app/services/action.service.ts b/src/app/services/action.service.ts
new file mode 100644
index 0000000..b2f451f
--- /dev/null
+++ b/src/app/services/action.service.ts
@@ -0,0 +1,33 @@
+import { Injectable } from '@angular/core';
+import {MatSnackBar, MatSnackBarRef} from "@angular/material/snack-bar";
+import {Router} from "@angular/router";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ActionService {
+
+ constructor(private snack: MatSnackBar,
+ private router: Router) { }
+
+ public copyToClipboard(text:string):boolean {
+ navigator.clipboard.writeText(text);
+ return true;
+ }
+
+ public showSnack(text: string, action: string = "Закрыть", duration: number = 3): boolean {
+ this.snack.open(text, action, {duration: duration*1000})
+ return true;
+ }
+
+ public goToUrlViaRouter(...url: string[]): boolean {
+ this.router.navigate(url)
+ return true;
+ }
+
+ public goToUrlViaTab(url: string|null): boolean {
+ if (url == null) return false;
+ window.open(url, "_blank");
+ return true;
+ }
+}
diff --git a/src/styles.scss b/src/styles.scss
index 6252715..69479b8 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -180,3 +180,17 @@ span {
padding: 15px;
margin-top: 15px
}
+
+
+.responsive-grid-100 {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
+ gap: 24px;
+}
+
+.responsive-grid-250 {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
+ gap: 24px;
+}
+