Browse Source

haifa

master
gsd 5 months ago
parent
commit
257a3419dd
  1. 27
      src/app/entities/servers/Countries.ts
  2. 2
      src/app/pages/main-page/AnnoncesListCarules.ts
  3. 2
      src/app/pages/main-page/main-page.component.html
  4. 48
      src/app/pages/servers-page/servers-page.component.html
  5. 86
      src/app/pages/servers-page/servers-page.component.ts
  6. 75
      src/app/pages/statistic-page/statistic-page.component.html
  7. 85
      src/app/pages/statistic-page/statistic-page.component.ts
  8. 19
      src/assets/flags/Flag_of_Belarus.svg
  9. 1
      src/assets/flags/Flag_of_Israel.svg
  10. 1
      src/assets/flags/Flag_of_Kazakhstan.svg
  11. 4
      src/assets/flags/Flag_of_Nazi.svg
  12. 1
      src/assets/flags/Flag_of_Russia.svg
  13. 18
      src/assets/flags/Flag_of_the_United_Nations.svg
  14. 25
      src/assets/flags/Flag_of_the_United_States.svg

27
src/app/entities/servers/Countries.ts

@ -0,0 +1,27 @@
import {StatExporter} from "./StatExporter";
export class Countries {
otherWorld: number = 0;
unitedStates: number = 0;
hohli: number = 0;
israel: number = 0;
kazakhstan: number = 0;
belarus: number = 0;
russian: number = 0;
static fromExporter(data: any): Countries {
const c: Countries = new Countries();
c.otherWorld += this.safeGetter(data, "Other world", 0);
c.unitedStates += this.safeGetter(data, "United States", 0);
c.hohli += this.safeGetter(data, "Ukraine", 0);
c.israel += this.safeGetter(data, "Israel", 0);
c.kazakhstan += this.safeGetter(data, "Kazakhstan", 0);
c.belarus += this.safeGetter(data, "Belarus", 0);
c.russian += this.safeGetter(data, "Russia", 0);
return c;
}
static safeGetter(from: any, what: string, def: any): any {
return what in from ? from[what] : def;
}
}

2
src/app/pages/main-page/AnnoncesListCarules.ts

@ -96,7 +96,7 @@ export class AnnoncesListCarules extends AbstractSearchTable<Annonce, any> {
getHeader():string {
switch (this.type) {
case "news": return "Интереснные приколы";
case "news": return "Интересные приколы";
case "reason4play": return "Почему стоит начать играть?";
default: return "Всякое говно";
}

2
src/app/pages/main-page/main-page.component.html

@ -59,7 +59,7 @@
</mat-form-field>
</div>
<div style="padding-bottom: 1%">
<mat-chip-list aria-label="Fish selection">
<mat-chip-list aria-label="fast search">
<mat-chip class="chips" *ngFor="let h of getSearchHistory()" (click)="searchPlayer(h)">{{h}}</mat-chip>
</mat-chip-list>
</div>

48
src/app/pages/servers-page/servers-page.component.html

@ -108,3 +108,51 @@
</mat-accordion>
</div>
</div>
<div class="content-in-center">
<div class="content-in-border">
<h2 style="color:#000;">График онлайна</h2>
<div *ngIf="!init">
<div style="display: flex; justify-content: space-between">
<mat-form-field appearance="fill">
<mat-label>Статистика по</mat-label>
<mat-select [(ngModel)]="selectedPeriod">
<mat-option *ngFor="let s of periods" [value]="s">
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" *ngIf="selectedPeriod.value=='minutes'">
<mat-label>Количество минут</mat-label>
<mat-select [(ngModel)]="selectedMinute">
<mat-option *ngFor="let s of minutes" [value]="s">
Разница в {{s}} минут
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Количество дней</mat-label>
<mat-select [(ngModel)]="selectedDays">
<mat-option *ngFor="let s of days" [value]="s">
За {{s}} дней
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Сервер</mat-label>
<mat-select [(ngModel)]="selectedServer">
<mat-option *ngFor="let s of serverList" [value]="s">
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="chart-container">
<canvas id="MyChart" >{{ chart }}</canvas>
</div>
<mat-progress-bar *ngIf="loading" mode="indeterminate"></mat-progress-bar>
<button mat-button mat-raised-button (click)="getGraph()" style="width: 100%">Обновить</button>
</div>
<button mat-button mat-raised-button *ngIf="init" (click)="getGraph()">Загрузить график</button>
</div>
</div>

86
src/app/pages/servers-page/servers-page.component.ts

@ -8,6 +8,11 @@ import {AuthService} from "../../services/auth.service";
import {Player} from "../../entities/servers/Player";
import {MatDialog} from "@angular/material/dialog";
import {SimpleActionDialog} from "../internal-components/dialogs/simple-action-dialog.component";
import {GraphData} from "../../entities/graph/GraphData";
import {Chart} from "chart.js/auto";
import {Period} from "../statistic-page/statistic-page.component";
import {GraphService} from "../../services/graph.service";
import {ServerService} from "../../services/server.service";
@Component({
selector: 'app-servers-page',
@ -18,12 +23,40 @@ export class ServersPageComponent implements OnInit {
servers:{[srv_name: string]:Server|any} = {};
constructor(private servers_ws:WebsocketServersListenerService,
//хуйня для графиков
serverList: {name: string, server_id: string }[] = [
{name: 'Выбрать все', server_id: '%'}
];
loading: boolean = false;
init: boolean = true;
periods:Period[] = [
{name: 'По дням', value: 'days'},
{name: 'По минутам', value: 'minutes'}
];
selectedPeriod:Period = this.periods[0];
days:number[] = [1,7,14,21,30,60,90,180];
selectedDays:number = 30;
minutes:number[] = [1, 5, 10, 15, 30]
selectedMinute:number = 5;
selectedServer: {name: string, server_id: string } = this.serverList[0];
chart!:Chart;
constructor(private graphService: GraphService,
private serverService: ServerService,
private servers_ws:WebsocketServersListenerService,
public actionService: ActionService,
public tf2data: Tf2dataService,
public authService: AuthService) { }
ngOnInit(): void {
this.getServers();
this.servers_ws.getServers().subscribe((r) => {
this.setServers(r.servers);
});
@ -68,4 +101,55 @@ export class ServersPageComponent implements OnInit {
serversExists():boolean {
return Object.keys(this.servers).length > 0;
}
getServers() {
this.serverService.getServers().subscribe(
(res) => {
const keys = Object.keys(res.data);
for (const key of keys) {
this.serverList.push({name: res.data[key].name, server_id: key});
}
}
)
}
getGraph() {
if (this.loading) {
return;
}
this.init = false;
this.loading = true;
console.log(this.selectedPeriod, this.selectedMinute, this.selectedDays, this.selectedServer);
switch (this.selectedPeriod.value) {
case 'days': {
this.graphService.getOnlineStatsOfDays(this.selectedDays, this.selectedServer?this.selectedServer.server_id:'%').subscribe(
(d) => this.processingData(GraphData.fromStatsOfPeakOfDay(d.reverse(), "red")),
(err) => this.actionService.showSnack('Произошла ошибка во время загрузки данных, попробуй позже'),
() => this.loading = false
); break;
}
case 'minutes': {
this.graphService.getOnlineStatsOfMinutes(this.selectedMinute, this.selectedDays, this.selectedServer?this.selectedServer.server_id:'%').subscribe(
(d) => this.processingData(GraphData.fromStatsOfPeakOfPerFiveMinutes(d.reverse(), "red")),
(err) => this.actionService.showSnack('Произошла ошибка во время загрузки данных, попробуй позже'),
() => this.loading = false
); break;
}
}
}
processingData(data:GraphData, reversed: boolean = true) {
if (this.chart)
this.chart.destroy();
this.chart = new Chart("MyChart", {
type: "line",
data: {
labels: data.labels,
datasets: data.data
}
});
}
}

75
src/app/pages/statistic-page/statistic-page.component.html

@ -20,50 +20,37 @@
<mat-card-subtitle>игроков за всё время</mat-card-subtitle>
</mat-card>
</div>
</div>
<div class="content-in-border">
<h2>График онлайна</h2>
<div *ngIf="!init">
<div style="display: flex; justify-content: space-between">
<mat-form-field appearance="fill">
<mat-label>Статистика по</mat-label>
<mat-select [(ngModel)]="selectedPeriod">
<mat-option *ngFor="let s of periods" [value]="s">
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" *ngIf="selectedPeriod.value=='minutes'">
<mat-label>Количество минут</mat-label>
<mat-select [(ngModel)]="selectedMinute">
<mat-option *ngFor="let s of minutes" [value]="s">
Разница в {{s}} минут
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Количество дней</mat-label>
<mat-select [(ngModel)]="selectedDays">
<mat-option *ngFor="let s of days" [value]="s">
За {{s}} дней
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Сервер</mat-label>
<mat-select [(ngModel)]="selectedServer">
<mat-option *ngFor="let s of serverList" [value]="s">
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="chart-container">
<canvas id="MyChart" >{{ chart }}</canvas>
</div>
<mat-progress-bar *ngIf="loading" mode="indeterminate"></mat-progress-bar>
<button mat-button mat-raised-button (click)="getGraph()" style="width: 100%">Обновить</button>
<h4>Мы патриоты, но уважаем и другие народы, смотрите сколько их понабежало к нам с начала года, но не все выдержали РУССКОЙ БАЗЫ в течении 5 минут. Ну или кто-то умеет пользоваться сервисами обходов блокировок</h4>
<div class="container responsive-grid-100">
<mat-card [ngStyle]="generateStyle4Country('Flag_of_Russia.svg')">
<mat-card-title style="color: white">{{countries.russian}}</mat-card-title>
<mat-card-subtitle style="color: white">Русских</mat-card-subtitle>
</mat-card>
<mat-card [ngStyle]="generateStyle4Country('Flag_of_Belarus.svg')">
<mat-card-title style="color: white">{{countries.belarus}}</mat-card-title>
<mat-card-subtitle style="color: white">Белоруссов</mat-card-subtitle>
</mat-card>
<mat-card style="color: white" [ngStyle]="generateStyle4Country('Flag_of_Kazakhstan.svg')">
<mat-card-title style="color: white">{{countries.kazakhstan}}</mat-card-title>
<mat-card-subtitle style="color: white">Казахов</mat-card-subtitle>
</mat-card>
<mat-card [ngStyle]="generateStyle4Country('Flag_of_Nazi.svg')">
<mat-card-title style="color: white">{{countries.hohli}}</mat-card-title>
<mat-card-subtitle style="color: white">Хохлов</mat-card-subtitle>
</mat-card>
<mat-card [ngStyle]="generateStyle4Country('Flag_of_Israel.svg')">
<mat-card-title style="color: white">{{countries.israel}}</mat-card-title>
<mat-card-subtitle style="color: white">Евреев</mat-card-subtitle>
</mat-card>
<mat-card [ngStyle]="generateStyle4Country('Flag_of_the_United_States.svg')">
<mat-card-title style="color: white">{{countries.unitedStates}}</mat-card-title>
<mat-card-subtitle style="color: white">Пендосов</mat-card-subtitle>
</mat-card>
<mat-card [ngStyle]="generateStyle4Country('Flag_of_the_United_Nations.svg')">
<mat-card-title style="color: white">{{countries.otherWorld}}</mat-card-title>
<mat-card-subtitle style="color: white">Прочий мир</mat-card-subtitle>
<!--мне тупа поебать что везте указан стиль руками не через стили файла-->
</mat-card>
</div>
<button mat-button mat-raised-button *ngIf="init" (click)="getGraph()">Загрузить график</button>
</div>
</div>

85
src/app/pages/statistic-page/statistic-page.component.ts

@ -1,11 +1,10 @@
import { Component, OnInit } from '@angular/core';
import {GraphService} from "../../services/graph.service";
import {Chart} from "chart.js/auto";
import {GraphData} from "../../entities/graph/GraphData";
import {ActionService} from "../../services/action.service";
import {Uniq} from "../../entities/servers/Uniq";
import {ServerService} from "../../services/server.service";
import {AuthService} from "../../services/auth.service";
import {StatExporter} from "../../entities/servers/StatExporter";
import {Countries} from "../../entities/servers/Countries";
export interface Period {
name: string
@ -19,39 +18,18 @@ export interface Period {
})
export class StatisticPageComponent implements OnInit {
init: boolean = true;
loading: boolean = false;
periods:Period[] = [
{name: 'По дням', value: 'days'},
{name: 'По минутам', value: 'minutes'}
];
selectedPeriod:Period = this.periods[0];
days:number[] = [1,7,14,21,30,60,90,180];
selectedDays:number = 30;
minutes:number[] = [1, 5, 10, 15, 30]
selectedMinute:number = 5;
serverList: {name: string, server_id: string }[] = [
{name: 'Выбрать все', server_id: '%'}
];
selectedServer: {name: string, server_id: string } = this.serverList[0];
chart!:Chart;
uniq!: Uniq;
constructor(private graphService: GraphService,
private actionService: ActionService,
countries: Countries = new Countries();
constructor(private actionService: ActionService,
private serverService: ServerService,
public authService: AuthService) {
}
ngOnInit(): void {
this.getServers();
this.getUniq();
this.getCountries();
}
getUniq() {
@ -60,53 +38,16 @@ export class StatisticPageComponent implements OnInit {
);
}
getServers() {
this.serverService.getServers().subscribe(
(res) => {
const keys = Object.keys(res.data);
for (const key of keys) {
this.serverList.push({name: res.data[key].name, server_id: key});
}
}
getCountries() {
this.serverService.getStats("countries").subscribe(
(res: StatExporter<any>) => this.countries = Countries.fromExporter(res.export())
)
}
getGraph() {
if (this.loading) {
return;
}
this.init = false;
this.loading = true;
console.log(this.selectedPeriod, this.selectedMinute, this.selectedDays, this.selectedServer);
switch (this.selectedPeriod.value) {
case 'days': {
this.graphService.getOnlineStatsOfDays(this.selectedDays, this.selectedServer?this.selectedServer.server_id:'%').subscribe(
(d) => this.processingData(GraphData.fromStatsOfPeakOfDay(d.reverse(), "red")),
(err) => this.actionService.showSnack('Произошла ошибка во время загрузки данных, попробуй позже'),
() => this.loading = false
); break;
}
case 'minutes': {
this.graphService.getOnlineStatsOfMinutes(this.selectedMinute, this.selectedDays, this.selectedServer?this.selectedServer.server_id:'%').subscribe(
(d) => this.processingData(GraphData.fromStatsOfPeakOfPerFiveMinutes(d.reverse(), "red")),
(err) => this.actionService.showSnack('Произошла ошибка во время загрузки данных, попробуй позже'),
() => this.loading = false
); break;
}
generateStyle4Country(countryName: string) {
return {
'background': 'linear-gradient(to right, black, transparent), url(\'../../../assets/flags/'+countryName+'\')',
'background-size': 'cover'
}
}
processingData(data:GraphData, reversed: boolean = true) {
if (this.chart)
this.chart.destroy();
this.chart = new Chart("MyChart", {
type: "line",
data: {
labels: data.labels,
datasets: data.data
}
});
}
}

19
src/assets/flags/Flag_of_Belarus.svg

@ -0,0 +1,19 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1200" height="600" viewBox="0 0 378 189">
<title>Flag of Belarus</title>
<defs>
<clipPath id="p">
<path d="m0 0h200v608h8v284l-8 8H0z"/>
</clipPath>
</defs>
<path fill="#ce1720" d="m0 0h378v189H0z"/>
<g transform="matrix(.21,0,0,.21,2,0)" clip-path="url(#p)" fill="#fff">
<g id="b">
<path id="a" d="m36 0v14h-9v14H16v16H8v13H-8V24H8V6H-8V0zm26 77v15h-8v12h-8V92h-8V77h-8V57h8V42h8V30h8v12h8v15h8v20zm-17-1h10V58H45zM19 183h8v-18h-8zm54 0h8v-18h-8zM-8 305H6v13h6v16h9v15h12v-15h9v-16h8v-13H38v-15h21v10h13v17h11v19h-8v14h-7v13h-6v14h-9v12h-7v11h-9v14H24v-15h-9v-14H8v-9H-8v-23H8v-20H-8z"/>
<use xlink:href="#a" transform="matrix(-1,0,0,1,200,0)"/>
<path d="m96 0v32h8V0h32v14h-8v14h-12v16h-8v13H92V44h-8V28H72V14h-8V0zm-2 274v-11h-6v-13h-7v-14h-8v-14h-8v-10h-9v-14H44v14h-9v10h-7v14h-8v14h-6v13H8v17H-8v-44H8v-20H-8v-33H8v14h10v14h10v-14h10v-14h8v-18h-8v-14H28v-14H18v14H8v14H-8v-41H8v-19H-8V77H8v13h8v16h11v13h9v15h7v12h14v-12h7v-15h9v-13h11V90h8V77h16v13h8v16h11v13h9v15h7v12h14v-12h7v-15h9v-13h11V90h8V77h16v28h-16v19h16v41h-16v-14h-10v-14h-10v14h-10v14h-8v18h8v14h10v14h10v-14h10v-14h16v33h-16v20h16v44h-16v-17h-6v-13h-6v-14h-8v-14h-7v-10h-9v-14h-12v14h-9v10h-8v14h-8v14h-7v13h-6v11zm2-167v27h8v-27zm-4 58v-14H82v-14H72v14H62v14h-8v18h8v14h10v14h10v-14h10v-14h16v14h10v14h10v-14h10v-14h8v-18h-8v-14h-10v-14h-10v14h-10v14zm4 46v27h8v-27z"/>
</g>
<use xlink:href="#b" transform="matrix(1,0,0,-1,0,900)"/>
<path d="m-8 408H8v14h7v8h8v14h7v12h-7v14h-8v8H8v14H-8zm216 0v84h-16v-14h-7v-8h-8v-14h-7v-12h7v-14h8v-8h7v-14zM62 459h8v-18h-8zm76 0v-18h-8v18zm-42-59h8v-18h-8zm0 100v18h8v-18zm-50-75h14v-11h10v-10h5v-10h6v-14h8v-14h4v-13h14v13h4v14h8v14h6v10h5v10h10v11h14v50h-14v11h-10v10h-5v10h-6v14h-8v14h-4v13H93v-13h-4v-14h-8v-14h-6v-10h-5v-10H60v-11H46zm50 9v-15h-8v-10h-8v25h8v9h5v14h-5v9h-8v25h8v-10h8v-15h8v15h8v10h8v-25h-8v-9h-5v-14h5v-9h8v-25h-8v10h-8v15z"/>
</g>
<path fill="#007c30" d="m44 126h334v63H44z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

1
src/assets/flags/Flag_of_Israel.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1100" height="800"><path d="M 0,0 H 1100 V 800 H 0 Z" fill="#fff"/><path d="M 0,75 H 1100 V 200 H 0 Z" fill="#0038b8"/><path d="M 0,600 H 1100 V 725 H 0 Z" fill="#0038b8"/><path d="M 423.81566,472.85253 H 676.18435 L 550.00001,254.29492 Z m 126.18435,72.85255 126.1843,-218.55765 H 423.81566 Z" fill="none" stroke="#0038b8" stroke-width="27.5"/></svg>

After

Width:  |  Height:  |  Size: 398 B

1
src/assets/flags/Flag_of_Kazakhstan.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.4 KiB

4
src/assets/flags/Flag_of_Nazi.svg

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="800">
<rect width="1200" height="800" fill="#0057B7"/>
<rect width="1200" height="400" y="400" fill="#FFD700"/>
</svg>

After

Width:  |  Height:  |  Size: 179 B

1
src/assets/flags/Flag_of_Russia.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9 6" width="900" height="600"><path fill="#fff" d="M0 0h9v3H0z"/><path fill="#d52b1e" d="M0 3h9v3H0z"/><path fill="#0039a6" d="M0 2h9v2H0z"/></svg>

After

Width:  |  Height:  |  Size: 200 B

18
src/assets/flags/Flag_of_the_United_Nations.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 33 KiB

25
src/assets/flags/Flag_of_the_United_States.svg

@ -0,0 +1,25 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1235" height="650" viewBox="0 0 7410 3900">
<path d="M0,0h7410v3900H0" fill="#b31942"/>
<path d="M0,450H7410m0,600H0m0,600H7410m0,600H0m0,600H7410m0,600H0" stroke="#FFF" stroke-width="300"/>
<path d="M0,0h2964v2100H0" fill="#0a3161"/>
<g fill="#FFF">
<g id="s18">
<g id="s9">
<g id="s5">
<g id="s4">
<path id="s" d="M247,90 317.534230,307.082039 132.873218,172.917961H361.126782L176.465770,307.082039z"/>
<use xlink:href="#s" y="420"/>
<use xlink:href="#s" y="840"/>
<use xlink:href="#s" y="1260"/>
</g>
<use xlink:href="#s" y="1680"/>
</g>
<use xlink:href="#s4" x="247" y="210"/>
</g>
<use xlink:href="#s9" x="494"/>
</g>
<use xlink:href="#s18" x="988"/>
<use xlink:href="#s9" x="1976"/>
<use xlink:href="#s5" x="2470"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 823 B

Loading…
Cancel
Save