|
|
|
@@ -1,16 +1,16 @@
|
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
|
import { LazyLoadEvent } from 'primeng/api';
|
|
|
|
|
import { catchError, debounceTime, throwError } from 'rxjs';
|
|
|
|
|
import { ServerDTO } from 'src/app/models/discord/server.dto';
|
|
|
|
|
import { ServerSelectCriterion } from 'src/app/models/selection/server/server-select-criterion.dto';
|
|
|
|
|
import { ConfirmationDialogService } from 'src/app/services/confirmation-dialog/confirmation-dialog.service';
|
|
|
|
|
import { DataService } from 'src/app/services/data/data.service';
|
|
|
|
|
import { ServerService } from 'src/app/services/data/server.service';
|
|
|
|
|
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
|
|
|
|
import { ToastService } from 'src/app/services/toast/toast.service';
|
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
|
|
|
|
|
import { Router } from "@angular/router";
|
|
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
|
|
|
import { Apollo } from "apollo-angular";
|
|
|
|
|
import { LazyLoadEvent } from "primeng/api";
|
|
|
|
|
import { debounceTime } from "rxjs";
|
|
|
|
|
import { ConfirmationDialogService } from "src/app/services/confirmation-dialog/confirmation-dialog.service";
|
|
|
|
|
import { DataService } from "src/app/services/data/data.service";
|
|
|
|
|
import { ServerService } from "src/app/services/data/server.service";
|
|
|
|
|
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
|
|
|
|
import { ToastService } from "src/app/services/toast/toast.service";
|
|
|
|
|
import { Server } from "../../../../../models/data/server.model";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-dashboard',
|
|
|
|
@@ -19,15 +19,8 @@ import { ToastService } from 'src/app/services/toast/toast.service';
|
|
|
|
|
})
|
|
|
|
|
export class DashboardComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
servers: ServerDTO[] = [];
|
|
|
|
|
servers: Server[] = [];
|
|
|
|
|
|
|
|
|
|
searchCriterions: ServerSelectCriterion = {
|
|
|
|
|
name: null,
|
|
|
|
|
pageIndex: 0,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
sortColumn: null,
|
|
|
|
|
sortDirection: null
|
|
|
|
|
};
|
|
|
|
|
totalRecords!: number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -43,13 +36,15 @@ export class DashboardComponent implements OnInit {
|
|
|
|
|
private fb: FormBuilder,
|
|
|
|
|
private translate: TranslateService,
|
|
|
|
|
private router: Router,
|
|
|
|
|
private serverService: ServerService
|
|
|
|
|
private serverService: ServerService,
|
|
|
|
|
private apollo: Apollo
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
|
|
this.spinnerService.showSpinner();
|
|
|
|
|
|
|
|
|
|
this.setFilterForm();
|
|
|
|
|
this.loadNextPage();
|
|
|
|
|
await this.loadNextPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setFilterForm() {
|
|
|
|
@@ -59,46 +54,46 @@ export class DashboardComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
this.filterForm.valueChanges.pipe(
|
|
|
|
|
debounceTime(600)
|
|
|
|
|
).subscribe(changes => {
|
|
|
|
|
if (changes.name) {
|
|
|
|
|
this.searchCriterions.name = changes.name;
|
|
|
|
|
} else {
|
|
|
|
|
this.searchCriterions.name = null;
|
|
|
|
|
}
|
|
|
|
|
).subscribe(async changes => {
|
|
|
|
|
// if (changes.name) {
|
|
|
|
|
// this.searchCriterions.name = changes.name;
|
|
|
|
|
// } else {
|
|
|
|
|
// this.searchCriterions.name = null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (this.searchCriterions.pageSize)
|
|
|
|
|
// this.searchCriterions.pageSize = 10;
|
|
|
|
|
//
|
|
|
|
|
// if (this.searchCriterions.pageSize)
|
|
|
|
|
// this.searchCriterions.pageIndex = 0;
|
|
|
|
|
|
|
|
|
|
if (this.searchCriterions.pageSize)
|
|
|
|
|
this.searchCriterions.pageSize = 10;
|
|
|
|
|
|
|
|
|
|
if (this.searchCriterions.pageSize)
|
|
|
|
|
this.searchCriterions.pageIndex = 0;
|
|
|
|
|
|
|
|
|
|
this.loadNextPage();
|
|
|
|
|
await this.loadNextPage();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadNextPage() {
|
|
|
|
|
async loadNextPage() {
|
|
|
|
|
this.spinnerService.showSpinner();
|
|
|
|
|
this.data.getFilteredServers(this.searchCriterions).pipe(catchError(err => {
|
|
|
|
|
this.spinnerService.hideSpinner();
|
|
|
|
|
return throwError(() => err);
|
|
|
|
|
})).subscribe(list => {
|
|
|
|
|
this.totalRecords = list.totalCount;
|
|
|
|
|
this.servers = list.servers;
|
|
|
|
|
this.spinnerService.hideSpinner();
|
|
|
|
|
});
|
|
|
|
|
// this.data.getFilteredServers(this.searchCriterions).pipe(catchError(err => {
|
|
|
|
|
// this.spinnerService.hideSpinner();
|
|
|
|
|
// return throwError(() => err);
|
|
|
|
|
// })).subscribe(list => {
|
|
|
|
|
// this.totalRecords = list.totalCount;
|
|
|
|
|
// this.servers = list.servers;
|
|
|
|
|
// this.spinnerService.hideSpinner();
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextPage(event: LazyLoadEvent) {
|
|
|
|
|
this.searchCriterions.pageSize = event.rows ?? 0;
|
|
|
|
|
if (event.first != null && event.rows != null)
|
|
|
|
|
this.searchCriterions.pageIndex = event.first / event.rows;
|
|
|
|
|
this.searchCriterions.sortColumn = event.sortField ?? null;
|
|
|
|
|
this.searchCriterions.sortDirection = event.sortOrder === 1 ? 'asc' : event.sortOrder === -1 ? 'desc' : 'asc';
|
|
|
|
|
|
|
|
|
|
if (event.filters) {
|
|
|
|
|
// + "" => convert to string
|
|
|
|
|
this.searchCriterions.name = event.filters['name'] ? event.filters['name'] + "" : null;
|
|
|
|
|
}
|
|
|
|
|
// this.searchCriterions.pageSize = event.rows ?? 0;
|
|
|
|
|
// if (event.first != null && event.rows != null)
|
|
|
|
|
// this.searchCriterions.pageIndex = event.first / event.rows;
|
|
|
|
|
// this.searchCriterions.sortColumn = event.sortField ?? null;
|
|
|
|
|
// this.searchCriterions.sortDirection = event.sortOrder === 1 ? 'asc' : event.sortOrder === -1 ? 'desc' : 'asc';
|
|
|
|
|
//
|
|
|
|
|
// if (event.filters) {
|
|
|
|
|
// // + "" => convert to string
|
|
|
|
|
// this.searchCriterions.name = event.filters['name'] ? event.filters['name'] + "" : null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
this.loadNextPage();
|
|
|
|
|
}
|
|
|
|
@@ -107,7 +102,7 @@ export class DashboardComponent implements OnInit {
|
|
|
|
|
this.filterForm.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectServer(server: ServerDTO) {
|
|
|
|
|
selectServer(server: Server) {
|
|
|
|
|
this.serverService.server$.next(server);
|
|
|
|
|
this.router.navigate(['/server']);
|
|
|
|
|
}
|
|
|
|
|