Commit a13d7941 authored by Qianwen's avatar Qianwen
Browse files

add download function

parent 09282d11
Pipeline #527081 passed with stages
in 3 minutes and 17 seconds
...@@ -161,10 +161,14 @@ ...@@ -161,10 +161,14 @@
</mat-form-field> </mat-form-field>
</div> </div>
<i class="fas fa-search fa-2x" (click)="onClickSearchButton()"></i> <i class="fas fa-search fa-2x mt-3 mr-5" (click)="onClickSearchButton()"></i>
<!--download for log and log series -->
<button *ngIf="currState ==='log' || currState ==='logSeries' " class="btn btn-outline-primary download ml-5 mt-2" (click)="onDownloadLogs()"> download
</button>
</div> </div>
<!--agent selection for log anpopContentd logSeries conditions --> <!--agent selection for log and log series conditions -->
<div *ngIf="currState ==='log' || currState ==='logSeries'" class= "d-flex align-content-end"> <div *ngIf="currState ==='log' || currState ==='logSeries'" class= "d-flex align-content-end">
<div class="agent-title ml-5">agents</div> <div class="agent-title ml-5">agents</div>
<div class="agents"> <div class="agents">
......
...@@ -13,11 +13,6 @@ ...@@ -13,11 +13,6 @@
padding-bottom: 5rem; padding-bottom: 5rem;
} }
.fa-search {
margin-top: 1.5rem;
margin-left: 2rem;
cursor: pointer;
}
/* agent selection board */ /* agent selection board */
...@@ -80,8 +75,6 @@ ...@@ -80,8 +75,6 @@
} }
} }
.more { .more {
height: 4rem; height: 4rem;
width: 8rem; width: 8rem;
...@@ -97,12 +90,7 @@ ...@@ -97,12 +90,7 @@
cursor: pointer; cursor: pointer;
} }
.table {
td, th {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}
}
/*topic selection board */ /*topic selection board */
...@@ -161,6 +149,18 @@ ...@@ -161,6 +149,18 @@
} }
/* others in selection board */
.fa-search {
margin-left: 2rem;
cursor: pointer;
}
.download {
height: 4rem;
font-size: 1.6rem;
}
/* svg graph */ /* svg graph */
/* log */ /* log */
...@@ -279,6 +279,13 @@ ngx-charts-bubble-chart { ...@@ -279,6 +279,13 @@ ngx-charts-bubble-chart {
} }
.table {
td, th {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}
}
/* heatmap */ /* heatmap */
.heatmap-legend{ .heatmap-legend{
background-color: red; background-color: red;
......
...@@ -195,6 +195,8 @@ export class LoggerComponent implements OnInit { ...@@ -195,6 +195,8 @@ export class LoggerComponent implements OnInit {
} }
} }
updateSelectedID() { updateSelectedID() {
this.selectedID = []; this.selectedID = [];
this.notSelectedID = []; this.notSelectedID = [];
...@@ -264,7 +266,69 @@ export class LoggerComponent implements OnInit { ...@@ -264,7 +266,69 @@ export class LoggerComponent implements OnInit {
} }
} }
downloadData(blobConfig: Blob, filename: string) {
// Convert Blob to URL
const blobUrl = URL.createObjectURL(blobConfig);
// Create an a element with blobl URL
const anchor = document.createElement('a');
anchor.href = blobUrl;
anchor.target = "_blank";
anchor.download = filename;
// Auto click on a element, trigger the file download
anchor.click();
URL.revokeObjectURL(blobUrl);
}
onDownloadLogs() {
if (this.currState === "log") {
// configs object
this.multiLogs().subscribe( logss => {
let config: LogMessage[] = [];
for (let logs of logss) {
if (logs !== null) {
for (let log of logs) {
config.push(log);
}
}
}
// Convert object to Blob
const blobConfig = new Blob(
[ JSON.stringify(config) ],
{ type: 'text/json;charset=utf-8' }
)
this.downloadData(blobConfig, "log.json")
})
}
if (this.currState === "logSeries") {
// configs object
let config: LogSeries[] = [];
this.multiSeries().subscribe( logss => {
for (let logs of logss) {
if (logs !== null) {
for (let log of logs) {
config.push(log);
}
}
}
let configStr: string = config.map(log => {
return [log.masid, log.agentid, log.name, log.timestamp, log.value].join(",")
}).join("\n");
// Convert object to Blob
const blobConfig = new Blob(
[configStr],
{ type: 'text/csv;charset=utf-8' }
)
this.downloadData(blobConfig, "log_series.csv")
})
}
}
convertDate(date: Date): string { convertDate(date: Date): string {
let res: string = date.getFullYear().toString(); let res: string = date.getFullYear().toString();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment