Browse Source

on-event logs demand (with socket)

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

37
src/App.vue

@ -102,45 +102,8 @@ export default {
var url = new URL(url_string); var url = new URL(url_string);
this.token = url.searchParams.get("token"); this.token = url.searchParams.get("token");
console.log("token " + this.token); console.log("token " + this.token);
//LEFOS === CHECK TOKEN IF VALID ELSE REDIRECT TO GET A NEW ONE
this.checktoken(this.token);
}, },
methods: { 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() { saveDocLive() {
this.$root.$emit("asciilive_save", "save"); this.$root.$emit("asciilive_save", "save");
}, },

65
src/components/doclive/runLlo.vue

@ -149,14 +149,6 @@
<div class="col-1"></div> <div class="col-1"></div>
<!-- col --> <!-- col -->
<vuetable
ref="vuetable"
:api-mode="false"
:data="localData"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
>
</vuetable>
</div> </div>
<!-- row --> <!-- row -->
<!-- <vuetable <!-- <vuetable
@ -200,6 +192,15 @@
</b-row> </b-row>
</div> </div>
<!-- col --> <!-- col -->
<div class="table">
<vuetable
ref="vuetable"
:api-mode="false"
:data="localData"
:fields="['message', 'timestamp', 'type', 'process_id', 'app_name']"
>
</vuetable>
</div>
</div> </div>
<!-- row --> <!-- row -->
</div> </div>
@ -250,6 +251,43 @@ export default {
}; };
}, },
methods: { 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() { Hotlog() {
this.Clearlog(); this.Clearlog();
var restapi = "off"; var restapi = "off";
@ -450,13 +488,16 @@ export default {
created() { created() {
//var logintoken = new URL(location.href).searchParams.get("token"); //var logintoken = new URL(location.href).searchParams.get("token");
var logintoken = new URL( var logintoken = new URL(
"https://api-client.swarmlab.io:8088/?token=8ee68923f567ad2fb5835f579c4d74f0cad6b1d1" "https://api-client.swarmlab.io:8088/?token=b2758b309c8aba70588987ebd0faa99beb412ff3"
).searchParams.get("token"); ).searchParams.get("token");
this.logintoken = logintoken; 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", { var log = store.dispatch("pipelineLLO/settoken", {
token: logintoken, token: logintoken,
}); });
this.socketopen(); this.socketopen();
//var tokentmp =store.getters['pipelineLLO/gettoken']; //var tokentmp =store.getters['pipelineLLO/gettoken'];
//console.log("tokennnn "+tokentmp); //console.log("tokennnn "+tokentmp);
@ -488,6 +529,8 @@ export default {
this.issocket = "open"; this.issocket = "open";
// send to AdhocView // send to AdhocView
this.$root.$emit("SERVER_socket_status", "on"); this.$root.$emit("SERVER_socket_status", "on");
//call to start on event logs
this.getuser(logintoken);
}, },
/** /**
* *
@ -711,7 +754,7 @@ export default {
<style> <style>
.table { .table {
overflow: scroll; /* overflow: scroll; */
max-height: 400px; max-height: 400px;
} }
.CodeMirror { .CodeMirror {

Loading…
Cancel
Save