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.

macros.html 4.9KB

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