From 7894480d7021d6c5db8fb4ab51760314af5294fb Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 1 Nov 2023 12:56:50 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A0=EF=B8=8Fchore:=20remove=20support=20f?= =?UTF-8?q?or=20query=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- echo_handlers.go | 28 +++++++++++----------------- views/apps/new.html | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/echo_handlers.go b/echo_handlers.go index 7b79384d..6b25848c 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -240,13 +240,13 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { appName := c.QueryParam("c") // c - for client pubkey := c.QueryParam("pubkey") returnTo := c.QueryParam("return_to") - maxAmount := c.QueryParam("max_amount") - budgetRenewal := strings.ToLower(c.QueryParam("budget_renewal")) - expiresAt := c.QueryParam("expires_at") // YYYY-MM-DD or MM/DD/YYYY or timestamp in seconds - if expiresAtTimestamp, err := strconv.Atoi(expiresAt); err == nil { - expiresAt = time.Unix(int64(expiresAtTimestamp), 0).Format(time.RFC3339) - } - disabled := c.QueryParam("editable") == "false" + // maxAmount := c.QueryParam("max_amount") + // budgetRenewal := strings.ToLower(c.QueryParam("budget_renewal")) + // expiresAt := c.QueryParam("expires_at") // YYYY-MM-DD or MM/DD/YYYY or timestamp in seconds + // if expiresAtTimestamp, err := strconv.Atoi(expiresAt); err == nil { + // expiresAt = time.Unix(int64(expiresAtTimestamp), 0).Format(time.RFC3339) + // } + // disabled := c.QueryParam("editable") == "false" requestMethods := c.QueryParam("request_methods") if requestMethods == "" { // if no request methods are given, enable them all by default @@ -257,11 +257,6 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { requestMethods = strings.Join(keys, " ") } - budgetEnabled := strings.Contains(strings.ToLower(requestMethods), NIP_47_PAY_INVOICE_METHOD) && maxAmount != "" - if !budgetEnabled { - maxAmount = "" - budgetRenewal = "" - } csrf, _ := c.Get(middleware.DefaultCSRFConfig.ContextKey).(string) user, err := svc.GetUser(c) @@ -307,13 +302,12 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { "Name": appName, "Pubkey": pubkey, "ReturnTo": returnTo, - "MaxAmount": maxAmount, - "BudgetRenewal": budgetRenewal, - "ExpiresAt": expiresAt, - "BudgetEnabled": budgetEnabled, + // "MaxAmount": maxAmount, + // "BudgetRenewal": budgetRenewal, + // "ExpiresAt": expiresAt, "RequestMethods": requestMethods, "RequestMethodHelper": requestMethodHelper, - "Disabled": disabled, + // "Disabled": disabled, "Csrf": csrf, }) } diff --git a/views/apps/new.html b/views/apps/new.html index 2a433c97..6c66dde9 100644 --- a/views/apps/new.html +++ b/views/apps/new.html @@ -12,7 +12,7 @@

-
+
@@ -20,7 +20,6 @@

Connection name Eg. name of the app or purpose of the connection.

- - + +

@@ -43,29 +42,31 @@

Authorise the new app to:

-
+
    {{range $key, $value := .RequestMethodHelper}} -
  • -
    +
  • {{ end }}
-
-

Monthly budget

-
-
10k
sats
-
50k
sats
-
100k
sats
-
1M
sats
-
Unlimited
#reckless
-
-
+ Add connection expiry time
@@ -117,11 +118,13 @@

const perms = document.getElementById("request-method-options"); const edit = document.getElementById("edit"); + const permsItems = perms.querySelectorAll("li"); const permsBoxes = perms.querySelectorAll("input[type=checkbox]"); const permsIcons = perms.querySelectorAll("img"); const permsLabels = perms.querySelectorAll("label"); const requestMethods = document.getElementById("request-methods"); const budgetAllowance = document.getElementById("budget-allowance"); + const budgetAllowanceLimits = document.getElementById("budget-allowance-limits").querySelectorAll("div"); permsBoxes.forEach(checkbox => { checkbox.addEventListener("change", function(e) { @@ -132,7 +135,8 @@

} }); if (checkbox.value == "pay_invoice") { - // Set to unlimited + let unlimited = document.querySelector('[data-limit="0"]') + unlimited.click(); budgetAllowance.classList.toggle("pointer-events-none"); budgetAllowance.classList.toggle("opacity-30") } @@ -141,6 +145,10 @@

}) edit.addEventListener("click", function(e) { + permsItems.forEach(item => { + item.classList.remove("hidden"); + }) + budgetAllowance.classList.remove("hidden"); permsLabels.forEach(label => { label.classList.toggle("select-none"); label.classList.toggle("pointer-events-none"); @@ -155,7 +163,6 @@

}) // Budget Amount - const budgetAllowanceLimits = document.getElementById("budget-allowance-limits").querySelectorAll("div"); const maxAmount = document.getElementById("max-amount"); budgetAllowanceLimits.forEach(limit => {