gitlab-ci-batch

批量上线samza任务脚本

目前為 2018-06-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name         gitlab-ci-batch
// @namespace    undefined
// @version      0.1
// @description  批量上线samza任务脚本
// @author       songyang
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
// @match        https://git.yidian-inc.com:8021/cpp-streaming/cpp-samza-task-ci/pipelines/*
// @match        https://git.yidian-inc.com:8021/crawler/gitlab-ci-test/pipelines/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    $(document).ready(function(){
        var selects = []
        $("a[data-original-title*='manual']").click(function() {
            var link = this.href + "/play";
            console.log("you found one " + link);
            var index = $.inArray(link, selects);
            if (index == -1) {
                selects.push(link);
                $(this).css("background-color", "yellow");
            } else {
                selects.splice(index, 1);
                $(this).css("background-color", "white");
            }
            return false;
        });

        $("div.content-wrapper").append('<div style="text-align: center"><button type="button" class="btn" id="submit-batch" style="width: 500px;">批量上线</button></div>');
        $("#submit-batch").click(function() {
            $.each(selects, function(index, val){
                console.log("index is " + index + ", val is " + val);
                var csrf_token = $('meta[name="csrf-token"]').attr('content');
                $.ajax({
                    url: val,
                    type: "post",
                    headers: {
                        'x-csrf-token': csrf_token
                    }
                });
            });
        })
    });
})();