This is Pluto, the webhook server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
5.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. {% macro checked_if(value) -%}{% if value %}checked{% endif %}{%- endmacro %}
  2. {% macro text_in(desc, name, value) -%}
  3. <p>{{desc}}: <input type="text" name="{{ name }}" value="{{ value }}"/></p>
  4. {%- endmacro %}
  5. {% macro text_in_id(desc, id, name, value) -%}
  6. <p><span id="{{ id }}">{{desc}}</span>: <input type="text" name="{{ name }}" value="{{ value }}"/></p>
  7. {%- endmacro %}
  8. {% macro textarea_in_id(desc, id, name, value) -%}
  9. <p><span id="{{ id }}">{{desc}}</span>: <textarea class="input" name="{{ name }}">{{ value }}</textarea></p>
  10. {%- endmacro %}
  11. {% macro select_in(desc, name, value, displays, options) -%}
  12. <p>{{desc}}:
  13. <select name="{{ name }}" value="{{ value }}">
  14. {% for disp in displays %}
  15. {% set opt = options[loop.index0] %}
  16. <option value="{{ opt }}">{{ disp }}</option>
  17. {% endfor %}
  18. </select>
  19. </p>
  20. {%- endmacro %}
  21. {% macro select_in_id(desc, id, name, value, displays, options) -%}
  22. <p>{{desc}}:
  23. <select name="{{ name }}" value="{{ value }}" id="{{ id }}">
  24. {% for disp in displays %}
  25. {% set opt = options[loop.index0] %}
  26. <option value="{{ opt }}">{{ disp }}</option>
  27. {% endfor %}
  28. </select>
  29. </p>
  30. {%- endmacro %}
  31. {% macro checkbox_in(desc, name, value) -%}
  32. <p><label><input type="checkbox" name="{{ name }}" value="1" {{ checked_if(value) }}/>{{ desc }}</label></p>
  33. {%- endmacro %}
  34. {% macro hook(hook) -%}
  35. {% if hook %}
  36. <a class="hook" href="/hook/{{ hook.rowid }}">hook {{ hook.name }} ({{ hook.rowid }})</a>
  37. {% else %}
  38. <span class="nodata">Bad hook</span>
  39. {% endif %}
  40. {%- endmacro %}
  41. {% macro hook_id(rowid) -%}
  42. {{ hook(safe_load('Hook', rowid)) }}
  43. {%- endmacro %}
  44. {% macro hook_params(hook) -%}
  45. {{ text_in('Name', 'name', hook.name) }}
  46. {{ checkbox_in('Disable hook', 'disabled', hook.disabled) }}
  47. {{ checkbox_in('Debug hook', 'debugged', hook.debugged) }}
  48. {%- endmacro %}
  49. {% macro cond(cond) -%}
  50. {% if cond %}
  51. <a class="cond" href="/cond/{{ cond.rowid }}">condition {{ cond.rowid }}, selector {{ cond.selector }} ({{ cond.s1 | pprint }}, {{ cond.s2 | pprint }}, {{ cond.s3 | pprint }}), test {{ cond.test }} ({{ cond.t1 | pprint }}, {{ cond.t2 | pprint }}, {{ cond.t3 | pprint}})</a>
  52. {% else %}
  53. <span class="nodata">Bad condition</span>
  54. {% endif %}
  55. {%- endmacro %}
  56. {% macro cond_id(rowid) -%}
  57. {{ cond(safe_load('Condition', rowid)) }}
  58. {%- endmacro %}
  59. {% macro cond_params(cond) -%}
  60. {{ select_in_id('Selector', 'select_selector', 'selector', cond.selector, ['header', 'JSON', 'path', 'value'], ['header', 'JSON', 'path', 'value']) }}
  61. {{ textarea_in_id('Selector parameter 1', 'label_s1', 's1', cond.s1) }}
  62. {{ textarea_in_id('Selector parameter 2', 'label_s2', 's2', cond.s2) }}
  63. {{ textarea_in_id('Selector parameter 3', 'label_s3', 's3', cond.s3) }}
  64. {{ select_in_id('Test', 'select_test', 'test', cond.test, ['equal', 'inrange', 'truthy', 'contains'], ['equal', 'inrange', 'truthy', 'contains']) }}
  65. {{ textarea_in_id('Test parameter 1', 'label_t1', 't1', cond.t1) }}
  66. {{ textarea_in_id('Test parameter 2', 'label_t2', 't2', cond.t2) }}
  67. {{ textarea_in_id('Test parameter 3', 'label_t3', 't3', cond.t3) }}
  68. {{ checkbox_in('Invert this condition', 'invert', cond.invert) }}
  69. <script type="text/javascript">
  70. reg_selector_select(
  71. document.querySelector("#select_selector"),
  72. document.querySelector("#label_s1"),
  73. document.querySelector("#label_s2"),
  74. document.querySelector("#label_s3"),
  75. "{{cond.selector}}"
  76. );
  77. reg_test_select(
  78. document.querySelector("#select_test"),
  79. document.querySelector("#label_t1"),
  80. document.querySelector("#label_t2"),
  81. document.querySelector("#label_t3"),
  82. "{{cond.test}}"
  83. );
  84. </script>
  85. {%- endmacro %}
  86. {% macro act(act) -%}
  87. {% if act %}
  88. <a class="act" href="/act/{{ act.rowid }}">action {{ act.rowid }}, action {{ act.action }} ({{ act.a1 | pprint }}, {{ act.a2 | pprint }}, {{ act.a3 | pprint }})</a>
  89. {% else %}
  90. <span class="nodata">Bad action</span>
  91. {% endif %}
  92. {%- endmacro %}
  93. {% macro act_id(rowid) -%}
  94. {{ act(safe_load('Action', rowid)) }}
  95. {%- endmacro %}
  96. {% macro act_params(act) -%}
  97. {{ select_in_id('Action', 'select_action', 'action', act.action, ['post', 'gitlab', 'system', 'udp', 'tcp', 'set_response'], ['post', 'gitlab', 'system', 'udp', 'tcp', 'set_response']) }}
  98. {{ textarea_in_id('Action parameter 1', 'label_a1', 'a1', act.a1) }}
  99. {{ textarea_in_id('Action parameter 2', 'label_a2', 'a2', act.a2) }}
  100. {{ textarea_in_id('Action parameter 3', 'label_a3', 'a3', act.a3) }}
  101. <script type="text/javascript">
  102. reg_action_select(
  103. document.querySelector("#select_action"),
  104. document.querySelector("#label_a1"),
  105. document.querySelector("#label_a2"),
  106. document.querySelector("#label_a3"),
  107. "{{act.action}}"
  108. );
  109. </script>
  110. {%- endmacro %}
  111. {% macro yesno(booly) -%}
  112. {% if booly %}<span class="positive">Yes</span>{% else %}<span class="negative">No</span>{% endif %}
  113. {%- endmacro %}