From 0e438e02448f25565dba2c7497530a6b8770635b Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 26 Jan 2022 21:38:41 +0000 Subject: [PATCH] Implement clear --- http/http.go | 8 +++----- web/src/pages/Settings.vue | 7 ++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/http/http.go b/http/http.go index 4ec3ee2..105a23b 100644 --- a/http/http.go +++ b/http/http.go @@ -50,7 +50,6 @@ func (h *Handler) Serve() { withBudget.Use(h.verifyLoginWithForbidden) withBudget.GET("/budget/:budgetid/:year/:month", h.budgeting) withBudget.GET("/budget/:budgetid/all-accounts", h.allAccounts) - withBudget.GET("/budget/:budgetid/settings/clear", h.clearBudget) withBudget.GET("/budget/:budgetid/settings/clean-negative", h.cleanNegativeBudget) withBudget.GET("/budget/:budgetid/transaction/:transactionid", h.transaction) @@ -66,10 +65,9 @@ func (h *Handler) Serve() { authenticated.GET("/dashboard", h.dashboard) authenticated.GET("/account/:accountid/transactions", h.transactionsForAccount) authenticated.GET("/admin/clear-database", h.clearDatabase) - - withBudget2 := authenticated.Group("") - withBudget2.GET("/budget/:budgetid", h.budgeting) - withBudget2.POST("/budget/:budgetid/import/ynab", h.importYNAB) + authenticated.GET("/budget/:budgetid", h.budgeting) + authenticated.POST("/budget/:budgetid/import/ynab", h.importYNAB) + authenticated.POST("/budget/:budgetid/settings/clear", h.clearBudget) budget := authenticated.Group("/budget") budget.POST("/new", h.newBudget) diff --git a/web/src/pages/Settings.vue b/web/src/pages/Settings.vue index b21b6c6..b6bb4dd 100644 --- a/web/src/pages/Settings.vue +++ b/web/src/pages/Settings.vue @@ -24,7 +24,12 @@ export default { this.$data.transactionsFile = e.target.files[0]; }, clearBudget() { - // Clear budget + fetch("/api/v1/budget/" + this.$store.getters.CurrentBudget.ID + "/settings/clear", { + method: "POST", + headers: { + 'Authorization': 'Bearer ' + this.$store.state.Session.Token + }, + }) }, cleanNegative() { // Fix all historic negative category-balances