Skip to content

Commit

Permalink
任务列表增加字段时间,项目,美化前端,以及管理员界面
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuiyong committed Sep 18, 2015
1 parent a1ab6a0 commit 157c91a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
3 changes: 2 additions & 1 deletion controllers/WalleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function actionIndex($kw = null, $page = 1, $size = 10) {
$size = $this->getParam('per-page') ?: $size;
$user = User::findOne(\Yii::$app->user->id);
$list = Task::find()
->with('user')
->with('conf');
if ($user->role != User::ROLE_ADMIN) {
$list->where(['user_id' => \Yii::$app->user->id]);
Expand Down Expand Up @@ -99,7 +100,7 @@ public function actionStartDeploy() {
$this->_task->ex_link_id = $dbConf->version;
}
$this->_task->status = Task::STATUS_DONE;
$this->_task->created_time = time();
$this->_task->created_at = time();
$this->_task->save();

// 记录当前线上版本(软链)回滚则是回滚的版本,上线为新版本
Expand Down
15 changes: 15 additions & 0 deletions models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace app\models;

use app\models\User;
use Yii;
use app\models\Conf;
/**
Expand Down Expand Up @@ -75,6 +76,20 @@ public function attributeLabels()
];
}

/**
* width('user')
*
* @return \yii\db\ActiveQuery
*/
public function getUser() {
return $this->hasOne(User::className(), ['id' => 'user_id']);
}

/**
* with('conf')
*
* @return \yii\db\ActiveQuery
*/
public function getConf() {
return $this->hasOne(Conf::className(), ['id' => 'project_id']);
}
Expand Down
2 changes: 1 addition & 1 deletion views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<li class="light-blue">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
<span class="user-info"><?= $userName ?></span>
<span class="user-info" style="top:12px"><?= $userName ?></span>
<i class="icon-caret-down"></i>
</a>

Expand Down
36 changes: 27 additions & 9 deletions views/walle/admin-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
?>
<div class="box">
<div class="box-header">
<!-- <h3 class="box-title">Responsive Hover Table</h3>-->
<form action="/logger/search" method="POST">
<div class="box-tools">
<div class="input-group" style="width: 150px;">
<input type="text" name="kw" class="form-control input-sm pull-right" placeholder="Search" value="">
<div class="input-group-btn">
<input class="btn btn-sm btn-default" type="submit" value="搜索"><i class="fa fa-search"></i></input>
</div>
<form action="/walle/index" method="POST">
<div class="col-xs-12 col-sm-8" style="padding-left: 0;margin-bottom: 10px;">
<div class="input-group">
<input type="text" name="kw" class="form-control search-query" placeholder="上线标题、commit号">
<span class="input-group-btn">
<button type="submit"
class="btn btn-default btn-sm">
Search
<i class="icon-search icon-on-right bigger-110"></i>
</button>
</span>
</div>
</div>
</form>
Expand All @@ -24,17 +27,22 @@
<tbody><tr>
<th>开发者</th>
<th>任务名称</th>
<th>项目</th>
<th>上线commit号</th>
<th>当前状态</th>
<th>操作</th>
</tr>
<?php foreach ($list as $item) { ?>
<tr>
<td><?= $item['username'] ?></td>
<td><?= $item['user']['realname'] ?></td>
<td><?= $item['title'] ?></td>
<td><?= $item['conf']['name'] ?></td>
<td><?= $item['commit_id'] ?></td>
<td><?= \Yii::t('status', 'task_status_' . $item['status']) ?></td>
<td class="<?= \Yii::t('status', 'task_status_' . $item['status'] . '_color') ?>">
<?php if ($item['user_id'] == \Yii::$app->user->id) { ?>
<a class="btn btn-xs btn-success task-operation <?= $item['status'] == Task::STATUS_PASS ? '' : 'disabled' ?> " href="/walle/deploy?taskId=<?= $item['id'] ?>">发起上线</a>
<?php } ?>
<?php if (!in_array($item['status'],[Task::STATUS_DONE, Task::STATUS_FAILED])) { ?>
<button class="btn btn-xs btn-success task-operation" data-id="<?= $item['id'] ?>" data-action="pass">通过</button>
<button class="btn btn-xs btn-danger task-operation" data-id="<?= $item['id'] ?>" data-action="refuse">拒绝</button>
Expand All @@ -56,6 +64,16 @@
$.get("/walle/task-operation", {id: $(this).data('id'), operation: $(this).data('action')},
function(data) {
$this.parent().prev().text(data.data.status);
$this.addClass('disabled')
if ($this.data('action') == 'pass') {
$this.parent().children('a').removeClass('disabled')
} else {
console.log($this.data('action'));
$this.parent().children('a').addClass('disabled')
console.log($this.parent().children('a'))

}
$this.siblings().removeClass('disabled');
}
);
})
Expand Down
2 changes: 1 addition & 1 deletion views/walle/deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getProcess() {
}
});
}
timer = setInterval(getProcess, 100);
timer = setInterval(getProcess, 600);
})
})

Expand Down
3 changes: 0 additions & 3 deletions web/dist/js/jquery-2.0.3.min.js

Large diffs are not rendered by default.

0 comments on commit 157c91a

Please sign in to comment.