dev-list.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @var yii\web\View $this
  4. */
  5. $this->title = '上线任务列表';
  6. use app\models\Task;
  7. ?>
  8. <div class="box">
  9. <div class="box-header">
  10. <!-- <h3 class="box-title">Responsive Hover Table</h3>-->
  11. <form action="/walle/index" method="POST">
  12. <div class="col-xs-12 col-sm-8" style="padding-left: 0;margin-bottom: 10px;">
  13. <div class="input-group">
  14. <input type="text" name="kw" class="form-control search-query" placeholder="上线标题、commit号">
  15. <span class="input-group-btn">
  16. <button type="submit"
  17. class="btn btn-default btn-sm">
  18. Search
  19. <i class="icon-search icon-on-right bigger-110"></i>
  20. </button>
  21. </span>
  22. </div>
  23. </div>
  24. </form>
  25. <a class="btn btn-default btn-sm" href="/walle/submit/">
  26. <i class="icon-pencil align-top bigger-125"></i>
  27. 创建上线任务
  28. </a>
  29. </div><!-- /.box-header -->
  30. <div class="box-body table-responsive no-padding">
  31. <table class="table table-striped table-bordered table-hover">
  32. <tbody><tr>
  33. <th>任务名称</th>
  34. <th>上线commit号</th>
  35. <th>当前状态</th>
  36. <th>操作</th>
  37. </tr>
  38. <?php foreach ($list as $item) { ?>
  39. <tr>
  40. <td><?= $item['title'] ?></td>
  41. <td><?= $item['commit_id'] ?></td>
  42. <td class="<?= \Yii::t('status', 'task_status_' . $item['status'] . '_color') ?>">
  43. <?= \Yii::t('status', 'task_status_' . $item['status']) ?>
  44. </td>
  45. <td>
  46. <?php if (in_array($item['status'], [Task::STATUS_PASS, Task::STATUS_FAILED])) { ?>
  47. <a class="btn btn-xs btn-success task-operation" href="/walle/deploy?taskId=<?= $item['id'] ?>">发起上线</a>
  48. <?php } elseif ($item['status'] == Task::STATUS_DONE) { ?>
  49. <button class="btn btn-xs btn-warning task-operation task-rollback" data-id="<?= $item['id'] ?>">回滚此次上线</button>
  50. <?php } ?>
  51. </td>
  52. </tr>
  53. <?php } ?>
  54. </tbody></table>
  55. </div><!-- /.box-body -->
  56. </div>
  57. <script>
  58. $('.task-rollback').click(function(e) {
  59. $this = $(this);
  60. $.post('/walle/rollback', {taskId: $this.data('id')}, function(o) {
  61. if (!o.code) {
  62. window.location.href="/walle/deploy?taskId=" + o.data.taskId;
  63. } else {
  64. alert(o.msg);
  65. }
  66. })
  67. })
  68. </script>