gitlab-ci-batch

批量上线samza任务脚本

当前为 2018-06-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name gitlab-ci-batch
  3. // @namespace undefined
  4. // @version 0.1
  5. // @description 批量上线samza任务脚本
  6. // @author songyang
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
  8. // @match https://git.yidian-inc.com:8021/cpp-streaming/cpp-samza-task-ci/pipelines/*
  9. // @match https://git.yidian-inc.com:8021/crawler/gitlab-ci-test/pipelines/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. $(document).ready(function(){
  17. var selects = []
  18. $("a[data-original-title*='manual']").click(function() {
  19. var link = this.href + "/play";
  20. console.log("you found one " + link);
  21. var index = $.inArray(link, selects);
  22. if (index == -1) {
  23. selects.push(link);
  24. $(this).css("background-color", "yellow");
  25. } else {
  26. selects.splice(index, 1);
  27. $(this).css("background-color", "white");
  28. }
  29. return false;
  30. });
  31.  
  32. $("div.content-wrapper").append('<div style="text-align: center"><button type="button" class="btn" id="submit-batch" style="width: 500px;">批量上线</button></div>');
  33. $("#submit-batch").click(function() {
  34. $.each(selects, function(index, val){
  35. console.log("index is " + index + ", val is " + val);
  36. var csrf_token = $('meta[name="csrf-token"]').attr('content');
  37. $.ajax({
  38. url: val,
  39. type: "post",
  40. headers: {
  41. 'x-csrf-token': csrf_token
  42. }
  43. });
  44. });
  45. })
  46. });
  47. })();