Skip to content

Commit

Permalink
Merge branch 'main' into pfs-117-upload-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholassully authored Sep 10, 2024
2 parents 4eb01e6 + c9c119b commit 9372d98
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
13 changes: 7 additions & 6 deletions internal/api/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ func (e ClientError) Error() string {
return string(e)
}

func NewClient(httpClient HTTPClient, siriusURL string, backendURL string) (*Client, error) {

func NewClient(httpClient HTTPClient, siriusUrl string, backendUrl string) (*Client, error) {
return &Client{
http: httpClient,
siriusURL: siriusURL,
backendURL: backendURL,
siriusUrl: siriusUrl,
backendUrl: backendUrl,
}, nil
}

Expand All @@ -35,8 +36,8 @@ type HTTPClient interface {

type Client struct {
http HTTPClient
siriusURL string
backendURL string
siriusUrl string
backendUrl string
}

type StatusError struct {
Expand All @@ -54,7 +55,7 @@ func (e StatusError) Data() interface{} {
}

func (c *Client) newBackendRequest(ctx Context, method, path string, body io.Reader) (*http.Request, error) {
req, err := http.NewRequestWithContext(ctx.Context, method, c.backendURL+path, body)
req, err := http.NewRequestWithContext(ctx.Context, method, c.backendUrl+path, body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/server/environment_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type EnvironmentVars struct {
WebDir string
SiriusURL string
SiriusPublicURL string
BackendURL string
BackendUrl string
Prefix string
}

Expand All @@ -20,7 +20,7 @@ func NewEnvironmentVars() EnvironmentVars {
SiriusURL: getEnv("SIRIUS_URL", "http://host.docker.internal:8080"),
SiriusPublicURL: getEnv("SIRIUS_PUBLIC_URL", ""),
Prefix: getEnv("PREFIX", ""),
BackendURL: getEnv("BACKEND_URL", ""),
BackendUrl: getEnv("BACKEND_URL", ""),
}
}

Expand Down
2 changes: 2 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func New(logger *slog.Logger, client ApiClient, templates map[string]*template.T

handleMux("POST /uploads", &UploadHandler{&route{client: client, tmpl: templates["uploads.gotmpl"], partial: "error-summary"}})

handleMux("GET /download", &GetDownloadHandler{&route{client: client, tmpl: templates["downloads.gotmpl"], partial: "error-summary"}})

mux.Handle("/health-check", healthCheck())

static := http.FileServer(http.Dir(envVars.WebDir + "/static"))
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func run(ctx context.Context, logger *slog.Logger) error {
}

envVars := server.NewEnvironmentVars()
client, err := api.NewClient(http.DefaultClient, envVars.SiriusURL, envVars.BackendURL)
client, err := api.NewClient(http.DefaultClient, envVars.SiriusURL, envVars.BackendUrl)
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions web/assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ window.htmx = htmx
htmx.logAll();
htmx.config.responseHandling = [{code:".*", swap: true}]

function disableDownloadFormInputs() {
function disableFormInputs() {
document.querySelector('#report-journal-type').setAttribute("disabled", "true")
document.querySelector('#report-schedule-type').setAttribute("disabled", "true")
document.querySelector('#report-account-type').setAttribute("disabled", "true")
Expand Down Expand Up @@ -38,7 +38,9 @@ htmx.onLoad(content => {
elements.forEach(element => {
htmx.addClass(element, 'hide');
});
disableDownloadFormInputs();

disableFormInputs();

const form = document.querySelector('form');
const reportTypeSelect = document.getElementById('reports-type');
const reportTypeSelectValue = reportTypeSelect.value
Expand Down Expand Up @@ -78,7 +80,9 @@ htmx.onLoad(content => {
const reportTypeSelect = document.getElementById('reports-type');
const reportTypeSelectValue = reportTypeSelect.value
const reportAccountTypeSelectValue = this.value
disableDownloadFormInputs();

disableFormInputs();

document.querySelector('#report-account-type').removeAttribute("disabled");

form.reset();
Expand Down

0 comments on commit 9372d98

Please sign in to comment.