Skip to content

Commit a7ed48a

Browse files
marxangelsTrong. Pham Van - CMC Global DU1.19
authored andcommitted
feat[ErrorLog]: add a clear button in ErrorLog component (PanJiaChen#2065)
1 parent 59c3be1 commit a7ed48a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/components/ErrorLog/index.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
</el-button>
77
</el-badge>
88

9-
<el-dialog :visible.sync="dialogTableVisible" title="Error Log" width="80%" append-to-body>
9+
<el-dialog :visible.sync="dialogTableVisible" width="80%" append-to-body>
10+
<div slot="title">
11+
<span style="padding-right: 10px;">Error Log</span>
12+
<el-button size="mini" type="primary" icon="el-icon-delete" @click="clearAll">Clear All</el-button>
13+
</div>
1014
<el-table :data="errorLogs" border>
1115
<el-table-column label="Message">
1216
<template slot-scope="{row}">
@@ -54,6 +58,12 @@ export default {
5458
errorLogs() {
5559
return this.$store.getters.errorLogs
5660
}
61+
},
62+
methods: {
63+
clearAll() {
64+
this.dialogTableVisible = false
65+
this.$store.dispatch('errorLog/clearErrorLog')
66+
}
5767
}
5868
}
5969
</script>

src/store/modules/errorLog.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ const state = {
55
const mutations = {
66
ADD_ERROR_LOG: (state, log) => {
77
state.logs.push(log)
8+
},
9+
CLEAR_ERROR_LOG: (state) => {
10+
state.logs.splice(0)
811
}
912
}
1013

1114
const actions = {
1215
addErrorLog({ commit }, log) {
1316
commit('ADD_ERROR_LOG', log)
17+
},
18+
clearErrorLog({ commit }) {
19+
commit('CLEAR_ERROR_LOG')
1420
}
1521
}
1622

0 commit comments

Comments
 (0)