Added Login, TTS Login, Policies
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { HermesSocketService } from './hermes-socket.service';
|
||||
import EventService from './shared/services/EventService';
|
||||
|
||||
@ -39,6 +38,15 @@ export class HermesClientService {
|
||||
return this.listen();
|
||||
}
|
||||
|
||||
public disconnect() {
|
||||
if (!this.connected)
|
||||
return;
|
||||
|
||||
this.socket.close();
|
||||
this.connected = false;
|
||||
this.events.emit('tts_logoff', null);
|
||||
}
|
||||
|
||||
private send(op: number, data: any) {
|
||||
if (op != 0)
|
||||
console.log("TX:", data);
|
||||
@ -61,6 +69,54 @@ export class HermesClientService {
|
||||
});
|
||||
}
|
||||
|
||||
public createPolicy(groupId: string, path: string, usage: number, timespan: number) {
|
||||
if (!this.logged_in)
|
||||
return;
|
||||
|
||||
this.send(3, {
|
||||
request_id: null,
|
||||
type: "create_policy",
|
||||
data: {
|
||||
groupId, path, count: usage, span: timespan
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public deletePolicy(id: string) {
|
||||
if (!this.logged_in)
|
||||
return;
|
||||
|
||||
this.send(3, {
|
||||
request_id: null,
|
||||
type: "delete_policy",
|
||||
data: {
|
||||
id
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public fetchPolicies() {
|
||||
if (!this.logged_in)
|
||||
return;
|
||||
|
||||
this.send(3, {
|
||||
request_id: null,
|
||||
type: "get_policies",
|
||||
data: null,
|
||||
});
|
||||
}
|
||||
|
||||
public fetchPermissionsAndGroups() {
|
||||
if (!this.logged_in)
|
||||
return;
|
||||
|
||||
this.send(3, {
|
||||
request_id: null,
|
||||
type: "get_permissions",
|
||||
data: null,
|
||||
});
|
||||
}
|
||||
|
||||
public heartbeat() {
|
||||
const date = new Date()
|
||||
this.send(0, {
|
||||
@ -75,6 +131,19 @@ export class HermesClientService {
|
||||
this.subscriptions[code].push(action);
|
||||
}
|
||||
|
||||
public updatePolicy(id: string, groupId: string, path: string, usage: number, timespan: number) {
|
||||
if (!this.logged_in)
|
||||
return;
|
||||
|
||||
this.send(3, {
|
||||
request_id: null,
|
||||
type: "update_policy",
|
||||
data: {
|
||||
id, groupId, path, count: usage, span: timespan
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private listen() {
|
||||
return this.socket.subscribe({
|
||||
next: (message: any) => {
|
||||
|
Reference in New Issue
Block a user