Skip to content

Commit 1889f9f

Browse files
committed
Merge branch 'pr-237': support del log of task
原本是清除所有日志,现在支持只清除部分日志 ouqiang#237
2 parents 960fc98 + 61dec69 commit 1889f9f

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/klauspost/cpuid v1.2.1 // indirect
2323
github.com/lib/pq v1.1.1
2424
github.com/ouqiang/goutil v1.1.1
25-
github.com/rakyll/statik v0.1.6
25+
github.com/rakyll/statik v0.1.7
2626
github.com/sirupsen/logrus v1.4.2
2727
github.com/urfave/cli v1.20.0
2828
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
8383
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8484
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
8585
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
86+
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
87+
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
8688
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
8789
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
8890
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE=

internal/routers/routers.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ func Register(m *macaron.Macaron) {
5454
ctx.WriteHeader(http.StatusInternalServerError)
5555
return
5656
}
57-
5857
io.Copy(ctx.Resp, file)
59-
6058
})
6159
// 系统安装
6260
m.Group("/install", func() {
@@ -232,7 +230,6 @@ func userAuth(ctx *macaron.Context) {
232230
jsonResp := utils.JsonResponse{}
233231
data := jsonResp.Failure(utils.AuthError, "认证失败")
234232
ctx.Write([]byte(data))
235-
236233
}
237234

238235
// URL权限验证

internal/routers/tasklog/task_log.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ func Index(ctx *macaron.Context) string {
3232

3333
// 清空日志
3434
func Clear(ctx *macaron.Context) string {
35+
taskId := ctx.QueryInt("task_id")
3536
taskLogModel := new(models.TaskLog)
37+
if taskId > 0 {
38+
taskLogModel.TaskId = taskId
39+
}
3640
_, err := taskLogModel.Clear()
3741
json := utils.JsonResponse{}
3842
if err != nil {
3943
return json.CommonFailure(utils.FailureContent)
4044
}
41-
4245
return json.Success(utils.SuccessContent, nil)
4346
}
4447

internal/statik/statik.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/vue/src/api/taskLog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export default {
55
httpClient.get('/task/log', query, callback)
66
},
77

8-
clear (callback) {
9-
httpClient.post('/task/log/clear', {}, callback)
8+
clear (taskId, callback) {
9+
httpClient.post('/task/log/clear', { task_id: taskId }, callback)
1010
},
1111

1212
stop (id, taskId, callback) {

web/vue/src/pages/taskLog/list.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
</el-form-item>
3434
</el-form>
3535
<el-row type="flex" justify="end">
36-
<el-col :span="3">
37-
<el-button type="danger" v-if="this.$store.getters.user.isAdmin" @click="clearLog">清空日志</el-button>
36+
<el-col :span="4">
37+
<el-button type="danger" v-if="this.$store.getters.user.isAdmin" @click="clearLog">清空{{ searchParams.task_id == '' ? "所有": "当前"}}任务日志</el-button>
3838
</el-col>
3939
<el-col :span="2">
4040
<el-button type="info" @click="refresh">刷新</el-button>
@@ -237,7 +237,7 @@ export default {
237237
},
238238
clearLog () {
239239
this.$appConfirm(() => {
240-
taskLogService.clear(() => {
240+
taskLogService.clear(this.searchParams.task_id, () => {
241241
this.searchParams.page = 1
242242
this.search()
243243
})

0 commit comments

Comments
 (0)