Unraid traefik

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

目前為 2024-10-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Unraid traefik
// @namespace    https://greasyfork.org/en/users/1388191-masapa
// @version      2024-10-29_2
// @license       MIT
// @description  Buttons that allows you to easily add traefik.enable and wanted middlewares
// @author       Masapa
// @match        http://unraid.local/Docker/AddContainer*
// @match        http://unraid.local/Docker/UpdateContainer*
// @match        http://unraid.local/Apps/AddContainer*
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  const middlewares = ["auth@file","local@file"];


  const addButton = (i = 0) => {
    const name = document.getElementsByName("contName")[0].value;

    let opts = {
      Description: "",
      Name: "Enable traefik",
      Type: "Label",
      Target: "traefik.enable",
      Value: "true",
      Buttons:
        "<button type='button' onclick='editConfigPopup(" +
        confNum +
        ",false)'>Edit</button><button type='button' onclick='removeConfig(" +
        confNum +
        ")'>Remove</button>",
      Number: confNum,
    };

    let opts2 = {
      Description: "",
      Name: "Traefik auth",
      Type: "Label",
      Target: "traefik.http.routers." + name + ".middlewares",
      Value: middlewares[0],
      Buttons:
        "<button type='button' onclick='editConfigPopup(" +
        confNum +
        ",false)'>Edit</button><button type='button' onclick='removeConfig(" +
        confNum +
        ")'>Remove</button>",
      Number: confNum,
    };
    $("#configLocation").append(makeConfig(opts));

    if (i === 2) {
      opts2 = {
        Description: "",
        Name: "Traefik auth",
        Type: "Label",
        Target: "traefik.http.routers." + name + ".middlewares",
        Value: middlewares.join(","),
        Buttons:
          "<button type='button' onclick='editConfigPopup(" +
          confNum +
          ",false)'>Edit</button><button type='button' onclick='removeConfig(" +
          confNum +
          ")'>Remove</button>",
        Number: confNum,
      };
      reloadTriggers();
      $('input[name="contName"]').trigger("change"); // signal change
    }

    $("#configLocation").append(makeConfig(opts2));
    reloadTriggers();
    $('input[name="contName"]').trigger("change"); // signal change
  };

  const button = document.createElement("button");
  button.addEventListener("click", () => addButton());
  button.innerHTML = "TRAEFIK";
  document.getElementsByClassName("left")[0].append(button);
  const button2 = document.createElement("button");
  button2.addEventListener("click", () => addButton(2));
  button2.innerHTML = "Local only";
  document.getElementsByClassName("left")[0].append(button, button2);

})();