This commit is contained in:
caf 2023-01-20 14:19:53 +04:00
parent 9800f035f9
commit cf846fa8ee
5 changed files with 71 additions and 3 deletions

View File

@ -91,6 +91,13 @@ export interface Terminals {
id: string;
public_id: string;
}
export interface TerminalDetails extends Terminals {
socket_data: {
closed: boolean,
connected: boolean,
last_ping: string,
}
}
export interface Notification {
id: string;

View File

@ -38,7 +38,10 @@
<td style="width: 16%">{{terminals.public_id}}</td>
<td style="width: 16%">{{terminals.division_id}}</td>
<td style="width: 16%">{{terminals.area_types}}</td>
<td style="width: 16%"></td>
<td
style="width: 16%"
[ngClass]="{disconnected: terminals.connection_status == 'disconnected', connected: terminals.connection_status == 'connected'}"
>{{terminals.connection_status}}</td>
<td><button (click)="updateTerminal1(terminals.id, terminals.public_id, terminals.division_id, terminals.area_types)">Изменить</button></td>
<td><button (click)="confirm(terminals.id)">Удалить</button></td>
</tr>
@ -91,6 +94,30 @@
</th> -->
</tr>
<tr *ngIf="terminal">
<th>
Статус:
</th>
<th>
{{terminal.socket_data.connected ? 'Соединен' : 'Отключен'}}
</th>
</tr>
<tr>
<th>
Обновлено:
</th>
<th>
{{terminal?.socket_data?.last_ping | date:'dd.MM.yy, HH:mm:ss'}}
</th>
</tr>
<tr>
<th>
Закрыто:
</th>
<th>
{{terminal?.socket_data?.closed ? 'Да' : 'Нет'}}
</th>
</tr>
</ng-template>
</p-table>
<div *ngIf="create; else change">

View File

@ -12,6 +12,14 @@ tr {
display: none;
}
.disconnected {
background-color: rgb(255, 120, 120);;
}
.connectede {
background-color: rgb(120, 255, 143);;
}
ul.selectedAreasList {
padding: 0;
list-style-type: none;

View File

@ -1,9 +1,10 @@
import { Component, OnInit } from "@angular/core";
import { JsonrpcService, RpcService } from "src/app/services/jsonrpc.service";
import { MessageService } from "primeng/api";
import { Terminals, Areas, Divisions } from "src/app/interface/data";
import { Terminals, Areas, Divisions, TerminalDetails } from "src/app/interface/data";
import { ScrollPanelModule } from 'primeng/scrollpanel';
import { ConfirmationService, FilterService, FilterMatchMode, SelectItem } from 'primeng/api';
import { StringMapWithRename } from "@angular/compiler/src/compiler_facade_interface";
@Component({
@ -13,6 +14,7 @@ import { ConfirmationService, FilterService, FilterMatchMode, SelectItem } from
})
export class TerminalsComponent implements OnInit {
public terminals: Terminals[] = [];
public terminal?: TerminalDetails;
public new_ter = true;
public choose = this.jsonRpcService.ClientChoose;
public create = false;
@ -94,6 +96,29 @@ export class TerminalsComponent implements OnInit {
}
async getTerminal(id: string) {
await this.jsonRpcService.rpc2({
method: 'getTerminal',
params: {
"client_id": this.choose,
"id": id
}
}, RpcService.authService, false)
.subscribe({
next: (result) => {
let data = result.result;
this.terminal = data;
},
error: (err) => {
console.log('ERROR: ', err)
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка!',
})
}
});
}
getAreas() {
this.jsonRpcService.rpc2({
method: 'getAreas',
@ -141,6 +166,7 @@ export class TerminalsComponent implements OnInit {
async updateTerminal1(id: any, public_id: any, division_id: any, area_types: any[]) {
this.reset();
this.new_ter = false;
this.getTerminal(id);
setTimeout(() => document.getElementsByTagName("input")[0].value = public_id, 100);
setTimeout(() => document.getElementsByTagName("input")[1].value = division_id, 100);
this.jsonRpcService.changeId = id;

View File

@ -1,5 +1,5 @@
export const environment = {
production: true,
appSelfDeliveryEndPoint: 'http://selfdelivery-pitsburg.mydatahosting.ru/admin_api',
appSelfDeliveryEndPoint: 'http://selfdelivery-pitsburg.mydatahosting.ru/admin_api',
systemId: 'dfe16ca16a3598b812',
};