|
@@ -23,51 +23,77 @@ export default class AdminCommands extends Vue {
|
|
|
|
|
|
requestCmds = [
|
|
requestCmds = [
|
|
{ keyword: 'login', label: 'getCurrentLogins' },
|
|
{ keyword: 'login', label: 'getCurrentLogins' },
|
|
- { keyword: 'conn', label: 'getCurrentConnections' },
|
|
|
|
- { keyword: 'sub', label: 'getSubscriptions' },
|
|
|
|
|
|
+ // { keyword: 'conn', label: 'getCurrentConnections' },
|
|
|
|
+ // { keyword: 'sub', label: 'getSubscriptions' },
|
|
{ keyword: 'req', label: 'getRequests' },
|
|
{ keyword: 'req', label: 'getRequests' },
|
|
- { keyword: 'res', label: 'getResponses' },
|
|
|
|
|
|
+ // { keyword: 'res', label: 'getResponses' },
|
|
];
|
|
];
|
|
|
|
|
|
socket = null
|
|
socket = null
|
|
responses = []
|
|
responses = []
|
|
url = 'http://localhost:3111'
|
|
url = 'http://localhost:3111'
|
|
|
|
+ cnt = 0
|
|
|
|
|
|
- addResponse(cnt, data) {
|
|
|
|
- const response = JSON.stringify(data,null,3)
|
|
|
|
- // if(Array.isArray(data) && data.length > 0 )
|
|
|
|
- // console.log(response)
|
|
|
|
- this.responses.unshift({cnt, data: JSON.stringify(data,null,3)})
|
|
|
|
|
|
+ setResponse(data) {
|
|
|
|
+ if(! Array.isArray(data)) {
|
|
|
|
+ data = []
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.responses = []
|
|
|
|
+ for (let index = 0; index < data.length; index++) {
|
|
|
|
+ this.responses.push({
|
|
|
|
+ cnt: this.cnt++,
|
|
|
|
+ data: JSON.stringify(
|
|
|
|
+ this.parseData(data[index]),
|
|
|
|
+ null, 3
|
|
|
|
+ )
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ parseData(data) {
|
|
|
|
+ if( data?.token ) {
|
|
|
|
+ return this.parseLogin(data)
|
|
|
|
+ }
|
|
|
|
+ return this.parseRequest(data)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ parseLogin(data) {
|
|
|
|
+ return {
|
|
|
|
+ "token": data.token,
|
|
|
|
+ "lastActionOn": data.lastActionOn,
|
|
|
|
+ "connections": data.connections.map(c => ({
|
|
|
|
+ "client": c.client,
|
|
|
|
+ "transport": c.transport,
|
|
|
|
+ "id": c.id,
|
|
|
|
+ }))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ parseRequest(data) {
|
|
|
|
+ const result = {
|
|
|
|
+ ucpId: data.Message.header.security.ucpId,
|
|
|
|
+ receivedDate: data.ReceivedDateTime,
|
|
|
|
+ messageID: data.Message.header.messageID,
|
|
|
|
+ messageType: data.Message.header.messageType,
|
|
|
|
+ }
|
|
|
|
+ if( result.messageType == 'Command' ) {
|
|
|
|
+ result['command'] = data.Message.header.command
|
|
|
|
+ if(result['command']=='Start') {
|
|
|
|
+ result['ucpId'] = null
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ result['query'] = data.Message.header.query
|
|
|
|
+ }
|
|
|
|
+ return result
|
|
}
|
|
}
|
|
- // parseLogin(data) {
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- x = [
|
|
|
|
- {
|
|
|
|
- "id": "9z55r61",
|
|
|
|
- "token": "9z55r67016",
|
|
|
|
- "lastActionOn": "2021-07-17T13:25:04.406Z",
|
|
|
|
- "timeout": 10000,
|
|
|
|
- "connections": [
|
|
|
|
- {
|
|
|
|
- "isDone": false,
|
|
|
|
- "client": {
|
|
|
|
- "transport": "socketio",
|
|
|
|
- "id": "O6vmYhBbpHiDmibmAAAE",
|
|
|
|
- "address": "::1",
|
|
|
|
- "url": "/socket.io/?EIO=3&transport=polling&t=Ngqf3qf"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
|
|
+
|
|
connect(){
|
|
connect(){
|
|
const socket = io.connect(this.url)
|
|
const socket = io.connect(this.url)
|
|
let cnt = 0;
|
|
let cnt = 0;
|
|
socket.on('admin_response', (data) => {
|
|
socket.on('admin_response', (data) => {
|
|
cnt++;
|
|
cnt++;
|
|
- this.addResponse(cnt, data);
|
|
|
|
|
|
+ this.setResponse(data?.data);
|
|
})
|
|
})
|
|
|
|
|
|
socket.on('connect', (ws) => {
|
|
socket.on('connect', (ws) => {
|