Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readme dockerfile and JS formatting #89

Merged
merged 10 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .djlintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore": "H006"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Folders
_obj
_test
.idea/*
node_modules

# Architecture specific extensions/prefixes
*.[568vq]
Expand All @@ -31,3 +31,4 @@ eq-questionnaire-launcher

# Dev config
.vscode/
.idea/*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start from golang base image
FROM golang:1.21 as builder
FROM golang:1.21 AS builder

WORKDIR /go/src/github.com/ONSdigital/eq-questionnaire-launcher

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This project was copied from https://github.com/ONSdigital/go-launch-a-survey and should be used for v3 of runner.

### Building and Running
## Building and Running
Install Go and ensure that your `GOPATH` env variable is set (usually it's `~/go`).

```
Expand All @@ -15,7 +15,7 @@ go run launch.go (Does both the build and run cmd above)

Open http://localhost:8000/

### Docker
## Docker
The dockerfile is a multistage dockerfile which can be built using:

```
Expand All @@ -42,7 +42,7 @@ You can also run a Survey Register for launcher to load Schemas from
docker run -it -p 8080:8080 onsdigital/eq-survey-register:simple-rest-api
```

### Run Quick-Launch
## Run Quick-Launch
If the schema specifies a `schema_name` field, that will be used as the schema_name claim. If not, the filename from the URL (before `.`) will be used.

Run Questionnaire Launcher
Expand All @@ -60,7 +60,7 @@ Documentation on the `v2` structure can be found [here](https://github.com/ONSdi
e.g."http://localhost:8000/quick-launch?schema_url=http://localhost:7777/1_0001.json&version=v1"
```

### Commands for Formatting & Linting
## Commands for Formatting & Linting
Ensure you are using the correct version of node using:
``` shell
nvm install
Expand All @@ -75,8 +75,8 @@ Firstly, ensure you have Python & Poetry installed and then install djLint for f
poetry install
```

**Note**: Before being able to run `lint-go`,
you will need to install the external tool `golangci-lint`. The command to install the tool is
**Note**: Before being able to run `lint-go`,
you will need to install the external tool `golangci-lint`. The command to install the tool is
`brew install golangci-lint` and to upgrade it use `brew upgrade golangci-lint`. Visit
https://golangci-lint.run/welcome/install/#local-installation to see additional ways to install the tool.

Expand All @@ -92,18 +92,18 @@ https://golangci-lint.run/welcome/install/#local-installation to see additional
| `make lint` | Lints all files listed above |


### Design System
To update the design system version, you need to update the version within the CDN link, they are present in both template files ([layout](templates/layout.html:11) and [launch](templates/launch.html:381))
## Design System
To update the design system version, you need to update the version within the CDN link, they are present in both template files ([layout](templates/layout.html:11) and [launch](templates/launch.html:381))

### Notes
## Notes
* There are no unit tests yet
* JWT spec based on http://ons-schema-definitions.readthedocs.io/en/latest/jwt_profile.html

### Settings
## Settings

| Environment Variable | Meaning | Default |
|--------------------------------|---------------------------------------------------------------------|------------------------------------------------------------------------|
| GO_LAUNCH_A_SURVEY_LISTEN_HOST | Host address to listen on | 0.0.0.0 |
| GO_LAUNCH_A_SURVEY_LISTEN_HOST | Host address to listen on | 0.0.0.0 |
| GO_LAUNCH_A_SURVEY_LISTEN_PORT | Host port to listen on | 8000 |
| SURVEY_RUNNER_URL | URL of Questionnaire Runner to re-direct to when launching a survey | http://localhost:5000 |
| SURVEY_REGISTER_URL | URL of eq-survey-register to load schema list from | http://localhost:8080 |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ djlint = "^1.34.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
28 changes: 13 additions & 15 deletions static/javascript/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
].join("");
}
for (var t = [], i = 0; i < 256; ++i)
t[i] = (i + 256).toString(16).substr(1);
t[i] = (i + 256).toString(16).substring(1);
n.exports = o;
},
{},
Expand All @@ -90,8 +90,7 @@
function (e, n, r) {
var o =
("undefined" != typeof crypto &&
crypto.getRandomValues &&
crypto.getRandomValues.bind(crypto)) ||
crypto.getRandomValues?.bind(crypto)) ||
("undefined" != typeof msCrypto &&
"function" == typeof window.msCrypto.getRandomValues &&
msCrypto.getRandomValues.bind(msCrypto));
Expand Down Expand Up @@ -213,17 +212,17 @@ function showMetadataAccordion(type, show) {
}
}

function enableButtons(button) {
for (let i = 0; i < button.length; i++) {
button[i].classList.remove("ons-btn--disabled");
button[i].disabled = false;
function enableButtons(buttons) {
for (const button of buttons) {
button.classList.remove("ons-btn--disabled");
button.disabled = false;
}
}

function disableButtons(button) {
for (let i = 0; i < button.length; i++) {
button[i].classList.add("ons-btn--disabled");
button[i].disabled = true;
function disableButtons(buttons) {
for (const button of buttons) {
button.classList.add("ons-btn--disabled");
button.disabled = true;
}
}

Expand All @@ -250,9 +249,9 @@ function includeSurveyMetadataFields(schema_name, survey_type) {

document.querySelector("#survey_metadata_fields").innerHTML =
`<div class="ons-field ons-field--inline">
<label class="ons-label" for="form_type">form_type</label>
<input id="form_type" name="form_type" type="text" value="${formTypeValue}" class="ons-input ons-input--text ons-input-type__input">
</div>`;
<label class="ons-label" for="form_type">form_type</label>
<input id="form_type" name="form_type" type="text" value="${formTypeValue}" class="ons-input ons-input--text ons-input-type__input">
</div>`;
setTabIndex("survey_type_metadata_detail", 0);
showMetadataAccordion("sds", true);
}
Expand Down Expand Up @@ -453,7 +452,6 @@ function loadSchemaMetadata(schemaName, schemaUrl, cirInstrumentId) {
getDataAsync(survey_data_url)
.then((schema_response) => {
document.querySelector("#survey_metadata").innerHTML = "";
document.querySelector("#survey_metadata").innerHTML = "";

// We always need survey_id from top-level schema metadata for SDS retrieval
schemaSurveyId = schema_response.survey_id;
Expand Down