diff --git a/go.sum b/go.sum index cb9c53b5..4549f32b 100644 --- a/go.sum +++ b/go.sum @@ -392,6 +392,7 @@ github.com/gojek/heimdall/v7 v7.0.3/go.mod h1:Z43HtMid7ysSjmsedPTXAki6jcdcNVnjn5 github.com/gojek/valkyrie v0.0.0-20180215180059-6aee720afcdf h1:5xRGbUdOmZKoDXkGx5evVLehuCMpuO1hl701bEQqXOM= github.com/gojek/valkyrie v0.0.0-20180215180059-6aee720afcdf/go.mod h1:QzhUKaYKJmcbTnCYCAVQrroCOY7vOOI8cSQ4NbuhYf0= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= @@ -697,6 +698,8 @@ github.com/pocketbase/dbx v1.11.0 h1:LpZezioMfT3K4tLrqA55wWFw1EtH1pM4tzSVa7kgszU github.com/pocketbase/dbx v1.11.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs= github.com/pocketbase/pocketbase v0.22.21 h1:DGPCxn6co8VuTV0mton4NFO/ON49XiFMszRr+Mysy48= github.com/pocketbase/pocketbase v0.22.21/go.mod h1:Cw5E4uoGhKItBIE2lJL3NfmiUr9Syk2xaNJ2G7Dssow= +github.com/pocketbase/pocketbase v0.23.12 h1:HB4THFbzaliF0C3wvpx+kNOZxIwCEMDqN3/17gn5N7E= +github.com/pocketbase/pocketbase v0.23.12/go.mod h1:OcFJNMO0Vzt3f9+lweMbup6iL7V13ckxu1pdEY6FeM0= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= diff --git a/internal/app/schedule.go b/internal/app/scheduler.go similarity index 100% rename from internal/app/schedule.go rename to internal/app/scheduler.go index dd0d1ef5..6b274302 100644 --- a/internal/app/schedule.go +++ b/internal/app/scheduler.go @@ -7,10 +7,10 @@ import ( "github.com/pocketbase/pocketbase/tools/cron" ) -var schedulerOnce sync.Once - var scheduler *cron.Cron +var schedulerOnce sync.Once + func GetScheduler() *cron.Cron { schedulerOnce.Do(func() { scheduler = cron.New() diff --git a/ui/src/api/notify.ts b/ui/src/api/notify.ts index 98a579c8..b51f22d9 100644 --- a/ui/src/api/notify.ts +++ b/ui/src/api/notify.ts @@ -1,3 +1,5 @@ +import { ClientResponseError } from "pocketbase"; + import { getPocketBase } from "@/repository/pocketbase"; export const notifyTest = async (channel: string) => { @@ -13,8 +15,8 @@ export const notifyTest = async (channel: string) => { }, }); - if (resp.code != 0) { - throw new Error(resp.msg); + if (resp.status != 0 && resp.status !== 200) { + throw new ClientResponseError({ status: resp.status, response: resp, data: {} }); } return resp; diff --git a/ui/src/api/statistics.ts b/ui/src/api/statistics.ts index fb5e8b94..98e77c2a 100644 --- a/ui/src/api/statistics.ts +++ b/ui/src/api/statistics.ts @@ -1,4 +1,6 @@ -import { Statistics } from "@/domain/statistics"; +import { ClientResponseError } from "pocketbase"; + +import { type Statistics } from "@/domain/statistics"; import { getPocketBase } from "@/repository/pocketbase"; export const get = async () => { @@ -8,8 +10,8 @@ export const get = async () => { method: "GET", }); - if (resp.code !== 0) { - throw new Error(resp.msg); + if (resp.status != 0 && resp.status !== 200) { + throw new ClientResponseError({ status: resp.status, response: resp, data: {} }); } return resp.data as Statistics; diff --git a/ui/src/api/workflow.ts b/ui/src/api/workflow.ts index 9fcf94a4..473d0e25 100644 --- a/ui/src/api/workflow.ts +++ b/ui/src/api/workflow.ts @@ -1,3 +1,5 @@ +import { ClientResponseError } from "pocketbase"; + import { getPocketBase } from "@/repository/pocketbase"; export const run = async (id: string) => { @@ -13,8 +15,8 @@ export const run = async (id: string) => { }, }); - if (resp.code != 0) { - throw new Error(resp.msg); + if (resp.status != 0 && resp.status !== 200) { + throw new ClientResponseError({ status: resp.status, response: resp, data: {} }); } return resp; diff --git a/ui/src/i18n/index.ts b/ui/src/i18n/index.ts index 0d89e0b9..4d7708d2 100644 --- a/ui/src/i18n/index.ts +++ b/ui/src/i18n/index.ts @@ -17,6 +17,9 @@ i18n backend: { loadPath: "/locales/{{lng}}.json", }, + detection: { + lookupLocalStorage: "certimate-ui-lang", + }, }); export const localeNames = {