Browse Source

on-event logs demand (with socket)

master
lefteris 3 years ago
parent
commit
0a0555f474
  1. 37
      src/App.vue
  2. 69
      src/components/doclive/runLlo.vue

37
src/App.vue

@ -102,45 +102,8 @@ export default {
var url = new URL(url_string);
this.token = url.searchParams.get("token");
console.log("token " + this.token);
//LEFOS === CHECK TOKEN IF VALID ELSE REDIRECT TO GET A NEW ONE
this.checktoken(this.token);
},
methods: {
//LEFOS === CHECK TOKEN IF VALID ELSE REDIRECT TO GET A NEW ONE
async checktoken(value) {
try {
var token = value;
var pipelines = {
source: "ssologin",
};
var params = {
pipeline: pipelines,
};
var options = {
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${token}`,
},
};
var pipelineApi = await axios.post(
"https://api.swarmlab.io/istokenvalidsso",
params,
options
);
return pipelineApi;
} catch (e) {
if (
e.message == "Request failed with status code 401" ||
/401/i.test(e.message)
) {
window.location.href = "https://api-login.swarmlab.io:8089";
}
console.error(e);
}
},
saveDocLive() {
this.$root.$emit("asciilive_save", "save");
},

69
src/components/doclive/runLlo.vue

@ -149,14 +149,6 @@
<div class="col-1"></div>
<!-- col -->
<vuetable
ref="vuetable"
:api-mode="false"
:data="localData"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
>
</vuetable>
</div>
<!-- row -->
<!-- <vuetable
@ -200,6 +192,15 @@
</b-row>
</div>
<!-- col -->
<div class="table">
<vuetable
ref="vuetable"
:api-mode="false"
:data="localData"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
>
</vuetable>
</div>
</div>
<!-- row -->
</div>
@ -250,6 +251,43 @@ export default {
};
},
methods: {
async getuser(token) {
var data = await this.checktoken(token);
console.log("User: " + data.user + " Token: " + data.token);
this.$socket.client.emit("onevent", data.user);
},
async checktoken(value) {
try {
var token = value;
var pipelines = {
source: "ssologin",
};
var params = {
pipeline: pipelines,
};
var options = {
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${token}`,
},
};
var res = await axios.post(
"https://api.swarmlab.io/istokenvalidsso",
params,
options
);
return res.data;
} catch (e) {
if (
e.message == "Request failed with status code 401" ||
/401/i.test(e.message)
) {
window.location.href = "https://api-login.swarmlab.io:8089";
}
console.error(e);
}
},
Hotlog() {
this.Clearlog();
var restapi = "off";
@ -392,12 +430,12 @@ export default {
* == Socket subscribe
*
* [source,javascript]
* ----
* ----
* ...
* })
* sdfsf
den to perni sdfsf
* ----
* ----
* <1> EventBus is used for parent/child component communication.
*
*/
@ -450,13 +488,16 @@ export default {
created() {
//var logintoken = new URL(location.href).searchParams.get("token");
var logintoken = new URL(
"https://api-client.swarmlab.io:8088/?token=8ee68923f567ad2fb5835f579c4d74f0cad6b1d1"
"https://api-client.swarmlab.io:8088/?token=b2758b309c8aba70588987ebd0faa99beb412ff3"
).searchParams.get("token");
this.logintoken = logintoken;
// === We get the user + check for the token if exists
this.checktoken(this.logintoken);
//console.log(" from created ", data);
var log = store.dispatch("pipelineLLO/settoken", {
token: logintoken,
});
this.socketopen();
//var tokentmp =store.getters['pipelineLLO/gettoken'];
//console.log("tokennnn "+tokentmp);
@ -488,6 +529,8 @@ export default {
this.issocket = "open";
// send to AdhocView
this.$root.$emit("SERVER_socket_status", "on");
//call to start on event logs
this.getuser(logintoken);
},
/**
*
@ -711,7 +754,7 @@ export default {
<style>
.table {
overflow: scroll;
/* overflow: scroll; */
max-height: 400px;
}
.CodeMirror {

Loading…
Cancel
Save