Unraid traefik

Buttons that allows you to easily add traefik.enable and wanted middlewares

  1. // ==UserScript==
  2. // @name Unraid traefik
  3. // @namespace https://greasyfork.org/en/users/1388191-masapa
  4. // @version 2024-10-31
  5. // @license MIT
  6. // @description Buttons that allows you to easily add traefik.enable and wanted middlewares
  7. // @author Masapa
  8. // @match http://unraid.local/Docker/AddContainer*
  9. // @match http://unraid.local/Docker/UpdateContainer*
  10. // @match http://unraid.local/Apps/AddContainer*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16.  
  17. const middlewares = ["auth@file","local@file"];
  18.  
  19.  
  20. const addButton = (i = 0) => {
  21. const name = document.getElementsByName("contName")[0].value;
  22.  
  23. const opts = {
  24. Description: "",
  25. Name: "Enable traefik",
  26. Type: "Label",
  27. Target: "traefik.enable",
  28. Value: "true",
  29. Buttons:
  30. "<button type='button' onclick='editConfigPopup(" +
  31. confNum +
  32. ",false)'>Edit</button><button type='button' onclick='removeConfig(" +
  33. confNum +
  34. ")'>Remove</button>",
  35. Number: confNum,
  36. };
  37. $("#configLocation").append(makeConfig(opts));
  38.  
  39. const opts2 = {
  40. Description: "",
  41. Name: "Traefik auth",
  42. Type: "Label",
  43. Target: "traefik.http.routers." + name + ".middlewares",
  44. Value: i !== 2 ? middlewares[0] : middlewares.join(","),
  45. Buttons:
  46. "<button type='button' onclick='editConfigPopup(" +
  47. confNum +
  48. ",false)'>Edit</button><button type='button' onclick='removeConfig(" +
  49. confNum +
  50. ")'>Remove</button>",
  51. Number: confNum,
  52. };
  53.  
  54. $("#configLocation").append(makeConfig(opts2));
  55.  
  56. };
  57.  
  58. const button = document.createElement("button");
  59. button.addEventListener("click", () => addButton());
  60. button.innerHTML = "TRAEFIK";
  61. document.getElementsByClassName("left")[0].append(button);
  62. const button2 = document.createElement("button");
  63. button2.addEventListener("click", () => addButton(2));
  64. button2.innerHTML = "With All middlewares";
  65. document.getElementsByClassName("left")[0].append(button, button2);
  66.  
  67. })();