fix: 修复访问最近报告中已删除的报告报错的问题

This commit is contained in:
shiziyuan9527 2020-07-31 15:45:01 +08:00
parent 534957aa77
commit b9d48bd00e
5 changed files with 42 additions and 24 deletions

View File

@ -62,6 +62,7 @@ export default {
let url = "/api/report/get/" + this.reportId; let url = "/api/report/get/" + this.reportId;
this.$get(url, response => { this.$get(url, response => {
this.report = response.data || {}; this.report = response.data || {};
if (response.data) {
if (this.isNotRunning) { if (this.isNotRunning) {
try { try {
this.content = JSON.parse(this.report.content); this.content = JSON.parse(this.report.content);
@ -74,6 +75,10 @@ export default {
} else { } else {
setTimeout(this.getReport, 2000) setTimeout(this.getReport, 2000)
} }
} else {
this.loading = false;
this.$error(this.$t('api_report.not_exist'));
}
}); });
} }
}, },

View File

@ -43,12 +43,12 @@
</el-col> </el-col>
</el-row> </el-row>
<el-divider></el-divider> <el-divider/>
<el-tabs v-model="active" type="border-card" :stretch="true"> <el-tabs v-model="active" type="border-card" :stretch="true">
<el-tab-pane :label="$t('report.test_overview')"> <el-tab-pane :label="$t('report.test_overview')">
<!-- <ms-report-test-overview :id="reportId" :status="status"/>--> <!-- <ms-report-test-overview :id="reportId" :status="status"/>-->
<ms-report-test-overview :report="report"/> <ms-report-test-overview :report="report" ref="testOverview"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('report.test_request_statistics')"> <el-tab-pane :label="$t('report.test_request_statistics')">
<ms-report-request-statistics :report="report"/> <ms-report-request-statistics :report="report"/>
@ -63,8 +63,8 @@
</el-card> </el-card>
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%"> <el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
<p v-html="$t('report.force_stop_tips')"></p> <p v-html="$t('report.force_stop_tips')"/>
<p v-html="$t('report.stop_tips')"></p> <p v-html="$t('report.stop_tips')"/>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="danger" size="small" @click="stopTest(true)">{{$t('report.force_stop_btn')}} <el-button type="danger" size="small" @click="stopTest(true)">{{$t('report.force_stop_btn')}}
</el-button> </el-button>
@ -190,7 +190,7 @@
} else { } else {
this.report.status = 'Completed'; this.report.status = 'Completed';
} }
}) });
this.dialogFormVisible = false; this.dialogFormVisible = false;
}, },
rerun(testId) { rerun(testId) {
@ -201,7 +201,7 @@
}).then(() => { }).then(() => {
this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, (response) => { this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, (response) => {
this.reportId = response.data; this.reportId = response.data;
this.$router.push({path: '/performance/report/view/' + this.reportId}) this.$router.push({path: '/performance/report/view/' + this.reportId});
// socket // socket
this.initWebSocket(); this.initWebSocket();
}) })
@ -235,6 +235,7 @@
this.reportId = this.$route.path.split('/')[4]; this.reportId = this.$route.path.split('/')[4];
this.result = this.$get("/performance/report/" + this.reportId, res => { this.result = this.$get("/performance/report/" + this.reportId, res => {
let data = res.data; let data = res.data;
if (data) {
this.status = data.status; this.status = data.status;
this.$set(this.report, "id", this.reportId); this.$set(this.report, "id", this.reportId);
this.$set(this.report, "status", data.status); this.$set(this.report, "status", data.status);
@ -242,9 +243,13 @@
if (this.status === "Completed" || this.status === "Running") { if (this.status === "Completed" || this.status === "Running") {
this.initReportTimeInfo(); this.initReportTimeInfo();
} }
})
this.initBreadcrumb(); this.initBreadcrumb();
this.initWebSocket(); this.initWebSocket();
} else {
this.$error(this.$t('report.not_exist'))
}
});
}, },
beforeDestroy() { beforeDestroy() {
this.websocket.close() //websocket this.websocket.close() //websocket
@ -288,6 +293,8 @@
} else { } else {
this.clearData(); this.clearData();
} }
} else {
this.$error(this.$t('report.not_exist'));
} }
}); });

View File

@ -266,6 +266,7 @@ export default {
stop_tips: 'A <strong>Graceful shutdown</strong> will archive the JTL files and then stop the servers.', stop_tips: 'A <strong>Graceful shutdown</strong> will archive the JTL files and then stop the servers.',
force_stop_btn: 'Terminating', force_stop_btn: 'Terminating',
stop_btn: 'Graceful shutdown', stop_btn: 'Graceful shutdown',
not_exist: "Test report does not exist",
}, },
load_test: { load_test: {
operating: 'Operating', operating: 'Operating',
@ -476,6 +477,7 @@ export default {
detail: "Report detail", detail: "Report detail",
delete: "Delete report", delete: "Delete report",
running: "The test is running", running: "The test is running",
not_exist: "Test report does not exist",
}, },
test_track: { test_track: {
test_track: "Track", test_track: "Track",

View File

@ -264,6 +264,7 @@ export default {
stop_tips: '<strong>停止</strong>测试会结束当前测试并保留报告数据', stop_tips: '<strong>停止</strong>测试会结束当前测试并保留报告数据',
force_stop_btn: '强制停止', force_stop_btn: '强制停止',
stop_btn: '停止', stop_btn: '停止',
not_exist: "测试报告不存在",
}, },
load_test: { load_test: {
operating: '操作', operating: '操作',
@ -475,6 +476,7 @@ export default {
detail: "报告详情", detail: "报告详情",
delete: "删除报告", delete: "删除报告",
running: "测试执行中", running: "测试执行中",
not_exist: "测试报告不存在",
}, },
test_track: { test_track: {
test_track: "测试跟踪", test_track: "测试跟踪",

View File

@ -264,6 +264,7 @@ export default {
stop_tips: '<strong>停止</strong>測試會結束當前測試並保留報告數據', stop_tips: '<strong>停止</strong>測試會結束當前測試並保留報告數據',
force_stop_btn: '強制停止', force_stop_btn: '強制停止',
stop_btn: '停止', stop_btn: '停止',
not_exist: "測試報告不存在",
}, },
load_test: { load_test: {
operating: '操作', operating: '操作',
@ -475,6 +476,7 @@ export default {
detail: "報告詳情", detail: "報告詳情",
delete: "刪除報告", delete: "刪除報告",
running: "測試執行中", running: "測試執行中",
not_exist: "測試報告不存在",
}, },
test_track: { test_track: {
test_track: "測試跟踪", test_track: "測試跟踪",