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

27
src/components/doclive/runLlo.vue

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

Loading…
Cancel
Save