Skip to content

Commit

Permalink
增加任务描述
Browse files Browse the repository at this point in the history
  • Loading branch information
lisijie committed Dec 30, 2015
1 parent 4288bfa commit 733d458
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
webcron*
bin/
3 changes: 3 additions & 0 deletions app/controllers/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (this *TaskController) List() {
row["name"] = v.TaskName
row["cron_spec"] = v.CronSpec
row["status"] = v.Status
row["description"] = v.Description

e := jobs.GetEntryById(v.Id)
if e != nil {
Expand Down Expand Up @@ -77,6 +78,7 @@ func (this *TaskController) Add() {
task.UserId = this.userId
task.GroupId, _ = this.GetInt("group_id")
task.TaskName = strings.TrimSpace(this.GetString("task_name"))
task.Description = strings.TrimSpace(this.GetString("description"))
task.Concurrent, _ = this.GetInt("concurrent")
task.CronSpec = strings.TrimSpace(this.GetString("cron_spec"))
task.Command = strings.TrimSpace(this.GetString("command"))
Expand Down Expand Up @@ -128,6 +130,7 @@ func (this *TaskController) Edit() {

if this.isPost() {
task.TaskName = strings.TrimSpace(this.GetString("task_name"))
task.Description = strings.TrimSpace(this.GetString("description"))
task.GroupId, _ = this.GetInt("group_id")
task.Concurrent, _ = this.GetInt("concurrent")
task.CronSpec = strings.TrimSpace(this.GetString("cron_spec"))
Expand Down
2 changes: 2 additions & 0 deletions app/models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Task struct {
UserId int
GroupId int
TaskName string
TaskType int
Description string
CronSpec string
Concurrent int
Command string
Expand Down
7 changes: 4 additions & 3 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ CREATE TABLE `t_task` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
`group_id` int(11) NOT NULL DEFAULT '0' COMMENT '分组ID',
`task_name` varchar(50) NOT NULL DEFAULT '''''' COMMENT '任务名称',
`task_name` varchar(50) NOT NULL DEFAULT '' COMMENT '任务名称',
`task_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型',
`cron_spec` varchar(100) NOT NULL DEFAULT '''''' COMMENT '时间表达式',
`description` varchar(200) NOT NULL DEFAULT '' COMMENT '任务描述',
`cron_spec` varchar(100) NOT NULL DEFAULT '' COMMENT '时间表达式',
`concurrent` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否只允许一个实例',
`command` text NOT NULL COMMENT '命令详情',
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0停用 1启用',
Expand All @@ -23,7 +24,7 @@ CREATE TABLE `t_task_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
`group_name` varchar(50) NOT NULL DEFAULT '' COMMENT '组名',
`description` varchar(255) NOT NULL DEFAULT '''''' COMMENT '说明',
`description` varchar(255) NOT NULL DEFAULT '' COMMENT '说明',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `idx_user_id` (`user_id`)
Expand Down
9 changes: 8 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ case $1 in
echo "服务已停止..."
sleep 1
;;
restart)
killall webcron
sleep 1
nohup ./webcron 2>&1 >> info.log 2>&1 /dev/null &
echo "服务已重启..."
sleep 1
;;
*)
echo "$0 {start|stop}"
echo "$0 {start|stop|restart}"
exit 4
;;
esac
Expand Down
7 changes: 7 additions & 0 deletions views/task/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ <h3>添加任务</h3>
<input type="text" name="task_name" class="span6" id="task_name">
</div>
</div>

<div class="control-group">
<label class="control-label" for="description">任务说明</label>
<div class="controls">
<textarea name="description" class="span6" id="description" rows="3"></textarea>
</div> <!-- /controls -->
</div> <!-- /control-group -->

<div class="control-group">
<label class="control-label" for="group_id">分组</label>
Expand Down
7 changes: 7 additions & 0 deletions views/task/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ <h3>编辑任务</h3>
</div>
</div>

<div class="control-group">
<label class="control-label" for="description">任务说明</label>
<div class="controls">
<textarea name="description" class="span6" id="description" rows="3">{{.task.Description}}</textarea>
</div> <!-- /controls -->
</div> <!-- /control-group -->

<div class="control-group">
<label class="control-label" for="group_id">分组</label>
<div class="controls">
Expand Down
15 changes: 9 additions & 6 deletions views/task/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,32 @@ <h3>任务列表</h3>
<td class="center">{{$v.id}}</td>
<td>
{{if eq $v.running 0}}
<i class="icon-ban-circle" style="color:red"></i>
<span class="icon-ban-circle" style="color:red"></span>
{{else}}
<i class="icon-play-circle" style="color:green"></i>
<span class="icon-play-circle" style="color:green"></span>
{{end}}
<span data-toggle="tooltip" data-placement="bottom" title="{{$v.description}}">
{{$v.name}}
</span>
</td>
<td>{{$v.cron_spec}}</td>
<td>{{$v.prev_time}}</td>
<td>{{$v.next_time}}</td>
<td>
{{if eq $v.status 0}}
<a class="btn btn-danger" href="{{urlfor "TaskController.Start"}}?id={{$v.id}}">
<i class="icon-play-circle icon-white"></i> 激活
<span class="icon-play-circle icon-white"></span> 激活
</a>
{{else}}
<a class="btn btn-success" href="{{urlfor "TaskController.Pause"}}?id={{$v.id}}">
<i class="icon-ban-circle icon-white"></i> 暂停
<span class="icon-ban-circle icon-white"></span> 暂停
</a>
{{end}}
<a class="btn btn-info" href="{{urlfor "TaskController.Edit"}}?id={{$v.id}}">
<i class="icon-pencil icon-white"></i> 编辑
<span class="icon-pencil icon-white"></span> 编辑
</a>
<a class="btn btn-info" href="{{urlfor "TaskController.Logs"}}?id={{$v.id}}">
<i class="icon-comment"></i> 日志
<span class="icon-comment"></span> 日志
</a>
</td>
</tr>
Expand All @@ -103,6 +105,7 @@ <h3>任务列表</h3>

<script>
$(function() {
$('[data-toggle="tooltip"]').tooltip()
$("input[name='chkall']").click(function () {
$("input[name='ids']").attr("checked", $(this).attr("checked") == "checked");
});
Expand Down

0 comments on commit 733d458

Please sign in to comment.