显示运行测试的log

This commit is contained in:
Captain.B 2020-04-22 10:30:35 +08:00
parent ad26dc0c65
commit 9cc2a9d9f1
1 changed files with 46 additions and 18 deletions

View File

@ -49,6 +49,13 @@
</el-tabs> </el-tabs>
</el-card> </el-card>
<el-dialog :title="title" :visible.sync="showTestLogging">
<el-tabs type="border-card" :stretch="true">
<el-tab-pane v-for="(item, key) in testLogging" :key="key" :label="key" class="logging-content">
{{item}}
</el-tab-pane>
</el-tabs>
</el-dialog>
</div> </div>
</div> </div>
</template> </template>
@ -79,15 +86,18 @@
startTime: '0', startTime: '0',
endTime: '0', endTime: '0',
minutes: '0', minutes: '0',
seconds: '0' seconds: '0',
title: 'Logging',
testLogging: null,
showTestLogging: false,
} }
}, },
methods: { methods: {
initBreadcrumb() { initBreadcrumb() {
if(this.reportId){ if (this.reportId) {
this.result = this.$get("/performance/report/test/pro/info/" + this.reportId, res => { this.result = this.$get("/performance/report/test/pro/info/" + this.reportId, res => {
let data = res.data; let data = res.data;
if(data){ if (data) {
this.reportName = data.name; this.reportName = data.name;
this.testName = data.testName; this.testName = data.testName;
this.projectName = data.projectName; this.projectName = data.projectName;
@ -96,10 +106,10 @@
} }
}, },
initReportTimeInfo() { initReportTimeInfo() {
if(this.reportId){ if (this.reportId) {
this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => { this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => {
let data = res.data; let data = res.data;
if(data){ if (data) {
this.startTime = data.startTime; this.startTime = data.startTime;
this.endTime = data.endTime; this.endTime = data.endTime;
let duration = data.duration; let duration = data.duration;
@ -108,6 +118,11 @@
} }
}) })
} }
},
getLog(testId) {
this.$get('/performance/log/' + testId, response => {
this.testLogging = response.data;
})
} }
}, },
mounted() { mounted() {
@ -115,16 +130,25 @@
this.$get("/performance/report/" + this.reportId, res => { this.$get("/performance/report/" + this.reportId, res => {
let data = res.data; let data = res.data;
this.status = data.status; this.status = data.status;
if (data.status === "Error") { switch (data.status) {
this.$message({ case 'Error':
type: 'warning', this.$message({
message: "报告生成错误,无法查看!" type: 'warning',
}); message: "报告生成错误,无法查看!"
} else if (data.status === "Starting") { });
this.$message({ break;
type: 'info', case 'Starting':
message: "报告生成中...." this.$message({
}); type: 'info',
message: "报告生成中...."
});
break;
case 'Running':
this.showTestLogging = true;
this.getLog(data.testId);
break;
default:
break;
} }
}) })
this.initBreadcrumb(); this.initBreadcrumb();
@ -133,10 +157,10 @@
watch: { watch: {
'$route'(to) { '$route'(to) {
let reportId = to.path.split('/')[4]; let reportId = to.path.split('/')[4];
if(reportId){ if (reportId) {
this.$get("/performance/report/test/pro/info/" + reportId, response => { this.$get("/performance/report/test/pro/info/" + reportId, response => {
let data = response.data; let data = response.data;
if(data){ if (data) {
this.reportName = data.name; this.reportName = data.name;
this.testName = data.testName; this.testName = data.testName;
this.projectName = data.projectName; this.projectName = data.projectName;
@ -144,7 +168,7 @@
}); });
this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => { this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => {
let data = res.data; let data = res.data;
if(data){ if (data) {
this.startTime = data.startTime; this.startTime = data.startTime;
this.endTime = data.endTime; this.endTime = data.endTime;
let duration = data.duration; let duration = data.duration;
@ -170,4 +194,8 @@
display: block; display: block;
color: #5C7878; color: #5C7878;
} }
.logging-content {
white-space: pre-line;
}
</style> </style>