Browse Source

final

master
lefteris 3 years ago
parent
commit
0be25d5f03
  1. 47
      src/components/doclive/AdhocView.vue
  2. 27
      src/components/doclive/runLlo.vue

47
src/components/doclive/AdhocView.vue

@ -95,7 +95,7 @@
<div class="codemirror2"> <div class="codemirror2">
<div v-if="history" class="table3"> <div v-if="history" class="table3">
<h2>History of all app logs (redis, readmongo, dummy)</h2> <h2>History of all app logs</h2>
<vuetable <vuetable
ref="vuetable" ref="vuetable"
:api-url="api_url" :api-url="api_url"
@ -461,38 +461,25 @@ export default {
methods: { methods: {
async callback(params) { async callback(params) {
var res = await axios.get("http://localhost:3000/length"); var res = await axios.get("http://localhost:3000/length");
var mongol = res.data.mongolength; //new code
var mongoerror = res.data.mongolerror;
var appout = res.data.appout;
var apperror = res.data.apperror;
var redis = res.data.redis;
var dumout = res.data.dumout;
var dumerr = res.data.dumerr;
if (params == 1) { if (params == 1) {
this.chartOptions.series[0].data = [appout, apperror]; this.chartOptions.series.splice(0, this.chartOptions.series.length);
this.chartOptions.series[1].data = [mongol, 0]; res["data"].forEach((val) => {
this.chartOptions.series[2].data = [redis, 0]; this.chartOptions.series.push({
this.chartOptions.series[3].data = [dumout, dumerr]; name: val.name,
data: [val.lengtho, val.lengthe],
});
});
} else { } else {
this.chartOptions.series.push( console.log(res["data"]);
{ res["data"].forEach((val) => {
name: "Readmongo service", this.chartOptions.series.push({
data: [appout, apperror], name: val.name,
}, data: [val.lengtho, val.lengthe],
{ });
name: "MongoDB", });
data: [mongol, mongoerror],
},
{
name: "Redis",
data: [redis, 0],
},
{
name: "Dummy",
data: [dumout, dumerr],
}
);
} }
//new code end
}, },
socketconnect() { socketconnect() {
//asd //asd

27
src/components/doclive/runLlo.vue

@ -483,6 +483,14 @@ export default {
console.log("User: " + data.user + " Token: " + data.token); console.log("User: " + data.user + " Token: " + data.token);
this.$socket.client.emit("onevent", data.user); this.$socket.client.emit("onevent", data.user);
}, },
async IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
},
async checktoken(value) { async checktoken(value) {
try { try {
var token = value; var token = value;
@ -744,7 +752,7 @@ 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=9312e5629b22cfdc7c5ca027be3cc85f91bbdb58" "https://api-client.swarmlab.io:8088/?token=f1b58f173301b2b8d052cac205d4438d283b1e33"
).searchParams.get("token"); ).searchParams.get("token");
this.logintoken = logintoken; this.logintoken = logintoken;
// === We get the user + check for the token if exists // === We get the user + check for the token if exists
@ -995,11 +1003,6 @@ export default {
// Lefos --- socket event to add the data to the right tables // Lefos --- socket event to add the data to the right tables
async logsend(val) { async logsend(val) {
// ==== LEFOS // ==== LEFOS
// console.log(" socket message " + JSON.stringify(val));
// var log = val.log;
// console.log(" LOG: " + JSON.parse(JSON.stringify(log)));
//Check which data array to put as data to the tables //Check which data array to put as data to the tables
this.checklogs(); this.checklogs();
@ -1009,10 +1012,12 @@ export default {
val.container_id = '<div class="conid">' + val.container_id + "</div>"; val.container_id = '<div class="conid">' + val.container_id + "</div>";
// console.log("raw before.. " + val.log); // console.log("raw before.. " + val.log);
// A bit of edit to fit perfectly into the table // A bit of edit to fit perfectly into the table
val.log = val.log.replace(/,/g, ", "); val.log = val.log.replace(/,/g, ", ");
val.log = val.log.replace(/":/g, '": '); val.log = val.log.replace(/":/g, '": ');
// console.log("raw after .. " + val.log); // console.log("raw after .. " + val.log);
// Change color of source for ALL RAW table to be able to see the error logs easy // Change color of source for ALL RAW table to be able to see the error logs easy
if (val.source == "stdout") { if (val.source == "stdout") {
val.source = '<div class="outtype" >' + val.source + "</div>"; val.source = '<div class="outtype" >' + val.source + "</div>";
@ -1026,7 +1031,7 @@ export default {
this.rawdata.push(val); this.rawdata.push(val);
// Check if the log is by a node_service and change color of the type field // Check if the log is by a node_service and change color of the type field
if (val.log.includes("app_name")) { if (val.tag.includes("node") && this.IsJsonString(val.log)) {
var test = JSON.parse(val.log); var test = JSON.parse(val.log);
if (test.type == "out") { if (test.type == "out") {
test.type = '<div class="outtype" >' + test.type + "</div>"; test.type = '<div class="outtype" >' + test.type + "</div>";
@ -1037,7 +1042,7 @@ export default {
} }
this.localData.push(test); this.localData.push(test);
} //check if the log is by the mongodb and change color } //check if the log is by the mongodb and change color
else if (val.container_name == "/mongo") { else if (val.tag.includes("mongodb")) {
// ========== push data for raw table ============ // ========== push data for raw table ============
var tmp = JSON.parse(val.log); var tmp = JSON.parse(val.log);
@ -1064,13 +1069,13 @@ export default {
timestamp: time, timestamp: time,
type: "<div class= 'outtype'>out</div>", type: "<div class= 'outtype'>out</div>",
process_id: "Unknown", process_id: "Unknown",
app_name: "Mongo", app_name: val.container_name,
}; };
this.localDataOut.push(tmp); this.localDataOut.push(tmp);
this.localData.push(tmp); this.localData.push(tmp);
// console.log("HEY " + JSON.stringify(test)); // console.log("HEY " + JSON.stringify(test));
} else if (val.container_name == "/redisserver") { } else if (val.tag.includes("redis")) {
var tmplog = val; var tmplog = val;
//timestamp //timestamp
var time = tmplog.time; var time = tmplog.time;
@ -1079,7 +1084,7 @@ export default {
timestamp: time, timestamp: time,
type: "<div class= 'outtype'>out</div>", type: "<div class= 'outtype'>out</div>",
process_id: "Unknown", process_id: "Unknown",
app_name: "redis", app_name: val.container_name,
}; };
this.localDataOut.push(tmp); this.localDataOut.push(tmp);

Loading…
Cancel
Save