deploy.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * @var yii\web\View $this
  4. */
  5. $this->title = '部署上线';
  6. use \app\models\Task;
  7. ?>
  8. <style>
  9. .status > span {
  10. float: left;
  11. font-size: 12px;
  12. width: 25%;
  13. text-align: right;
  14. }
  15. .btn-deploy {
  16. margin-left: 30px;
  17. }
  18. .btn-return {
  19. /*float: right;*/
  20. margin-left: 30px;
  21. }
  22. </style>
  23. <div class="box" style="height: 100%">
  24. <h4 class="box-title"><?= $task->title ?> - <?= $task->commit_id ?>
  25. <?php if (in_array($task->status, [Task::STATUS_PASS, Task::STATUS_FAILED])) { ?>
  26. <button type="submit" class="btn btn-primary btn-deploy" data-id="<?= $task->id ?>">部署</button>
  27. <?php } ?>
  28. <a class="btn btn-success btn-return" href="/walle/index">返回</a></h4>
  29. <div class="status">
  30. <span><i class="fa fa-circle-o text-yellow step-1"></i>权限、目录检查</span>
  31. <span><i class="fa fa-circle-o text-yellow step-2"></i>代码检出</span>
  32. <span><i class="fa fa-circle-o text-yellow step-3"></i>同步至服务器</span>
  33. <span><i class="fa fa-circle-o text-yellow step-4"></i>更新全量服务器</span>
  34. </div>
  35. <div style="clear:both"></div>
  36. <div class="progress progress-small progress-striped active">
  37. <div class="progress-bar progress-status progress-status" style="width: 0%;"></div>
  38. </div>
  39. <div class="alert alert-block alert-success result-success" style="<?php if ($task->status != Task::STATUS_DONE) { ?>display: none <?php } ?>">
  40. <h4>上线成功!</h4>
  41. <p>辛苦了,小主:)</p>
  42. </div>
  43. <div class="alert alert-block alert-danger result-failed" style="display: none">
  44. <h4>上线出错:(</h4>
  45. <span class="error-msg">
  46. </span>
  47. </div>
  48. </div>
  49. <script type="text/javascript">
  50. $(function() {
  51. $('.btn-deploy').click(function() {
  52. $this = $(this);
  53. $this.addClass('disabled');
  54. var task_id = $(this).data('id');
  55. $.post("/walle/start-deploy", {taskId: task_id});
  56. $('.progress-status').attr('aria-valuenow', 10).width('10%');
  57. $('.result-failed').hide();
  58. function getProcess() {
  59. $.get("/walle/get-process?taskId=" + task_id, function (ret) {
  60. data = ret.data;
  61. if (0 == data.status) {
  62. clearInterval(timer);
  63. $('.step-' + data.step).removeClass('text-yellow').addClass('text-red');
  64. $('.progress-status').removeClass('progress-bar-success').addClass('progress-bar-danger');
  65. $('.error-msg').text(data.memo);
  66. $('.result-failed').show();
  67. $this.removeClass('disabled');
  68. return;
  69. } else {
  70. $('.progress-status')
  71. .removeClass('progress-bar-danger progress-bar-striped')
  72. .addClass('progress-bar-success')
  73. }
  74. if (0 != data.percent) {
  75. $('.progress-status').attr('aria-valuenow', data.percent).width(data.percent + '%');
  76. }
  77. if (100 == data.percent) {
  78. $('.progress-status').removeClass('progress-bar-striped').addClass('progress-bar-success');
  79. $('.progress-status').parent().removeClass('progress-striped');
  80. $('.result-success').show();
  81. clearInterval(timer)
  82. }
  83. for (var i = 1; i <= data.step; i++) {
  84. $('.step-' + i).removeClass('text-yellow text-red')
  85. .addClass('text-green progress-bar-striped')
  86. }
  87. });
  88. }
  89. timer = setInterval(getProcess, 100);
  90. })
  91. function setProcessStatus() {
  92. $.get("/walle/get-process?taskId=" + task_id, function (data) {
  93. })
  94. }
  95. })
  96. </script>