Bläddra i källkod

pre tag response

thomas 3 år sedan
förälder
incheckning
76574d4518
1 ändrade filer med 41 tillägg och 8 borttagningar
  1. 41 8
      src/components/AdminCommands.vue

+ 41 - 8
src/components/AdminCommands.vue

@@ -1,8 +1,12 @@
 <template>
   <div>
-      <h3>Admin Session</h3>
-      <div v-for="request in requestCmds" :key="request.keyword"><button @click="sendRequest(request)">{{ request.label }} </button></div>
-      <div v-for="response in responses" :key="response.cnt">{{ response.data }}</div>
+    <h3>Admin Session</h3>
+    <div v-for="request in requestCmds" :key="request.keyword">
+      <button @click="sendRequest(request)">{{ request.label }}</button>
+    </div>
+    <div v-for="response in responses" :key="response.cnt">
+      <pre>{{ response.data }}</pre>
+    </div>
   </div>
 </template>
 
@@ -19,22 +23,51 @@ export default class AdminCommands extends Vue {
 
   requestCmds = [
     { keyword: 'login', label: 'getCurrentLogins' },
-    //{ keyword: 'conn',  label: 'getCurrentConnections' },
-    //{ keyword: 'sub',   label: 'getSubscriptions' },
-    // { keyword: 'req',   label: 'getRequests' },
-    // { keyword: 'res',   label: 'getResponses' },
+    { keyword: 'conn',  label: 'getCurrentConnections' },
+    { keyword: 'sub',   label: 'getSubscriptions' },
+    { keyword: 'req',   label: 'getRequests' },
+    { keyword: 'res',   label: 'getResponses' },
   ];
   
   socket = null
   responses = []
   url = 'http://localhost:3111'
 
+  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)})
+  }
+  // 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(){
     const socket = io.connect(this.url)
     let cnt = 0;
     socket.on('admin_response', (data) => {
       cnt++;
-      this.responses.unshift({cnt, data: JSON.stringify(data,null,3)})
+      this.addResponse(cnt, data);
     })
 
     socket.on('connect', (ws) => {