Browse Source

доксинг граф

master
gsd 2 weeks ago
parent
commit
16f6e98892
  1. 4
      src/app/app.module.ts
  2. 84
      src/app/pages/internal-components/abstract.perperiod.graph.component.ts
  3. 62
      src/app/pages/internal-components/doxing.graph.component.ts
  4. 3
      src/app/pages/internal-components/usertime.graph.component.ts
  5. 5
      src/app/pages/profile-page/profile-page.component.html
  6. 4
      src/app/services/auth.service.ts
  7. 9
      src/app/services/graph.service.ts
  8. 4
      src/proxy.conf.json

4
src/app/app.module.ts

@ -88,6 +88,7 @@ import {MatRadioModule} from "@angular/material/radio";
import {UsertimeGraphComponent} from "./pages/internal-components/usertime.graph.component";
import {VipGraphComponents} from "./pages/internal-components/vip.graph.components";
import {ConnectionsGraphComponent} from "./pages/internal-components/connections.graph.component";
import {DoxingGraphComponent} from "./pages/internal-components/doxing.graph.component";
registerLocaleData(localeRu, "ru")
@ -143,7 +144,8 @@ registerLocaleData(localeRu, "ru")
//graph
UsertimeGraphComponent,
VipGraphComponents,
ConnectionsGraphComponent
ConnectionsGraphComponent,
DoxingGraphComponent
],
imports: [
BrowserModule,

84
src/app/pages/internal-components/abstract.perperiod.graph.component.ts

@ -1,6 +1,6 @@
import {Component, OnInit} from "@angular/core";
import {Chart} from "chart.js/auto";
import {PerPeriodStatistic} from "../../services/graph.service";
import {CountryCityPerPeriodStatistic, PerPeriodStatistic} from "../../services/graph.service";
import {ServerService} from "../../services/server.service";
import {SearchFilter} from "../../entities/search/SearchFilter";
import {BaseUtils} from "../../utils/BaseUtils";
@ -72,11 +72,12 @@ export abstract class AbstractPerperiodGraphComponent implements OnInit {
return filter;
}
public updateGraph(objs: PerPeriodStatistic[],
public updateGraph(objs: PerPeriodStatistic[]|CountryCityPerPeriodStatistic[],
canvasName: string,
tooltopFooter:any = null,
text = "",
timeDelimiter:number = -1) {
timeDelimiter:number = -1,
sortKey: 'srv_id'|'countryAndCity' = 'srv_id') {
let chartConfig = {type: 'bar', data: {}, options: {
plugins: {
title: {
@ -111,8 +112,8 @@ export abstract class AbstractPerperiodGraphComponent implements OnInit {
* },
*/
};
let valueOnServer: {[srv_name: string]: number[]} = {}
let srvList: string[] = [];
let sortingKeyStore: {[name: string]: number[]} = {}
let sortingList: string[] = [];
let maxValue = 0;
//////
@ -140,7 +141,8 @@ export abstract class AbstractPerperiodGraphComponent implements OnInit {
}
console.log(timeDelimiter)
const groupByDate = objs.reduce((acc: {[date: string]: PerPeriodStatistic[]}, obj) => {
// @ts-ignore
const groupByDate = objs.reduce((acc: {[date: string]: PerPeriodStatistic[]|CountryCityPerPeriodStatistic[]}, obj) => {
const key = obj.date;
if (!acc[key]) acc[key] = [];
acc[key].push(obj)
@ -151,44 +153,76 @@ export abstract class AbstractPerperiodGraphComponent implements OnInit {
chartData.labels.forEach(
(date) => {
// @ts-ignore
groupByDate[date].forEach((stat) => {
if (srvList.indexOf(stat.srv_id) == -1)
srvList.push(stat.srv_id)
switch (sortKey) {
case "srv_id": {
if (sortingList.indexOf(stat.srv_id) == -1)
sortingList.push(stat.srv_id)
break;
}
case "countryAndCity": {
if (sortingList.indexOf(stat.countryAndCity) == -1)
sortingList.push(stat.countryAndCity)
break;
}
}
})
}
);
//console.log(srvList)
srvList.forEach((srv) => {
valueOnServer[srv] = [];
//console.log(sortingList)
sortingList.forEach((obj) => {
sortingKeyStore[obj] = [];
});
chartData.labels.forEach(
(date) => {
let filled: string[] = [];
groupByDate[date].forEach(
// @ts-ignore
(obj) => {
if (timeDelimiter == -1) {
valueOnServer[obj.srv_id].push(obj.value);
} else {
valueOnServer[obj.srv_id].push(obj.value / timeDelimiter);
switch (sortKey) {
case "srv_id": {
if (timeDelimiter == -1) {
sortingKeyStore[obj.srv_id].push(obj.value);
} else {
sortingKeyStore[obj.srv_id].push(obj.value / timeDelimiter);
}
filled.push(obj.srv_id);
break;
}
case "countryAndCity": { //todo maybe get key
sortingKeyStore[obj.countryAndCity].push(1);
filled.push(obj.countryAndCity);
break;
}
}
filled.push(obj.srv_id);
}
)
srvList.forEach(
(srv) => {
if (filled.indexOf(srv) == -1) {
valueOnServer[srv].push(0);
sortingList.forEach(
(sortingElement) => {
if (filled.indexOf(sortingElement) == -1) {
sortingKeyStore[sortingElement].push(0);
}
}
)
},
)
//console.log(valueOnServer)
Object.keys(valueOnServer).forEach(
//console.log(sortingKeyStore)
Object.keys(sortingKeyStore).forEach(
(key) => {
chartData.datasets.push(
{label: this.getServerName(key) + " ("+key+")", data: valueOnServer[key]}
)
switch (sortKey) {
case "srv_id": {
chartData.datasets.push(
{label: this.getServerName(key) + " ("+key+")", data: sortingKeyStore[key]}
);
break;
}
case "countryAndCity": {
chartData.datasets.push(
{label: key, data: sortingKeyStore[key]}
)
}
}
}
)
///

62
src/app/pages/internal-components/doxing.graph.component.ts

@ -0,0 +1,62 @@
import {AbstractPerperiodGraphComponent} from "./abstract.perperiod.graph.component";
import {Component, Input} from "@angular/core";
import {ServerService} from "../../services/server.service";
import {GraphService} from "../../services/graph.service";
import {MatSnackBar} from "@angular/material/snack-bar";
@Component({
selector: 'app-doxing-graph',
template: `
<div>
<mat-radio-group
style="display: flex; justify-content: center;flex-direction: row;"
[(ngModel)]="settingsOfChart.period"
[disabled]="settingsOfChart.loading"
(ngModelChange)="updateDoxingGraph()">
<mat-radio-button style="padding-right: 1%; padding-left: 1%" value="day">За месяц</mat-radio-button>
<mat-radio-button style="padding-right: 1%; padding-left: 1%" value="month">За год</mat-radio-button>
<mat-radio-button style="padding-right: 1%; padding-left: 1%" value="year">За 10 лет</mat-radio-button>
</mat-radio-group>
</div>
<div class="chart-container">
<canvas id="doxingCanvasChart" >{{ settingsOfChart.chart }}</canvas>
</div>`
})
export class DoxingGraphComponent extends AbstractPerperiodGraphComponent {
@Input("steam64")
steam64: string|null = null;
constructor(protected override serverService: ServerService,
private graphService: GraphService,
private snack: MatSnackBar) {
super(serverService);
}
doxingTabChanged(event: any, tabIndex: number): boolean {
if (event.index == tabIndex) {
this.updateDoxingGraph();
}
return true;
}
updateDoxingGraph() {
if (this.steam64) {
if (this.settingsOfChart.loading) return;
this.settingsOfChart.loading = true;
this.graphService.getDoxingOnPeriod(this.getSearchFilter(this.steam64)).subscribe(
(objs) => {
this.updateGraph(objs, "doxingCanvasChart",
(items: any) => "",
"fff",
-1,
'countryAndCity')
}, (err) => {
this.settingsOfChart.loading = false;
this.snack.open("Ошибка загрузка данных");
}
)
} else
this.snack.open("Используется только в профиле")
}
}

3
src/app/pages/internal-components/usertime.graph.component.ts

@ -39,10 +39,11 @@ export class UsertimeGraphComponent extends AbstractPerperiodGraphComponent {
super(serverService);
}
usertimeTabChanged(event: any, tabIndex: number) {
usertimeTabChanged(event: any, tabIndex: number):boolean {
if (event.index == tabIndex) {
this.updateUsertimeGraph()
}
return true;
}
updateUsertimeGraph() {

5
src/app/pages/profile-page/profile-page.component.html

@ -109,7 +109,7 @@
Наиграно времени
</mat-panel-title>
</mat-expansion-panel-header>
<mat-tab-group (selectedTabChange)="usertimegraph.usertimeTabChanged($event, 1)">
<mat-tab-group (selectedTabChange)="usertimegraph.usertimeTabChanged($event, 1) && doxinggraph.doxingTabChanged($event, 2)">
<mat-tab label="По серверами">
<mat-list role="list">
<mat-list-item role="listitem" *ngFor="let gametime of profile.gametime | keyvalue">
@ -121,6 +121,9 @@
<mat-tab label="По датам">
<app-usertime-graph #usertimegraph [steam64]="steam64"></app-usertime-graph>
</mat-tab>
<mat-tab label="Доксинг" [disabled]="!authService.isModerator()">
<app-doxing-graph #doxinggraph [steam64]="steam64"></app-doxing-graph>
</mat-tab>
</mat-tab-group>
</mat-expansion-panel>
<!--История банов-->

4
src/app/services/auth.service.ts

@ -75,11 +75,11 @@ export class AuthService {
}
isAdmin() {
return this.permition && this.permition?.flags.indexOf("z") != -1;
return this.isAuth() && this.permition && this.permition?.flags.indexOf("z") != -1;
}
isModerator() {
return this.isAdmin() || (this.permition && this.permition?.flags.indexOf("cde") != -1);
return this.isAdmin() || (this.isAuth() && this.permition && this.permition?.flags.indexOf("cde") != -1);
}
searchPlayer(account: number|string|undefined) {

9
src/app/services/graph.service.ts

@ -16,6 +16,10 @@ export interface VipPerPeriodStatistic extends PerPeriodStatistic {
amount: number;
}
export interface CountryCityPerPeriodStatistic extends PerPeriodStatistic {
countryAndCity: string;
}
@Injectable({
providedIn: 'root'
})
@ -45,4 +49,9 @@ export class GraphService {
// @ts-ignore
return this.http.post(`api/web/vip/graph`, filter);
}
public getDoxingOnPeriod(filter: SearchFilter): Observable<CountryCityPerPeriodStatistic[]> {
// @ts-ignore
return this.http.post(`api/web/doxing/graph`, filter);
}
}

4
src/proxy.conf.json

@ -1,10 +1,10 @@
{
"/api": {
"target": "http://192.168.3.3:26272/",
"target": "http://gigaboss.goyda.network:26272/",
"secure": false
},
"/site_content": {
"target": "https://192.168.3.3:14088/",
"target": "https://gigaboss.goyda.network:14088/",
"secure": false
}
}

Loading…
Cancel
Save