Skip to content

Commit

Permalink
Merge pull request #232 from rimi-itk/feature/872-rrule-stuff
Browse files Browse the repository at this point in the history
Time zone issue in schedules
  • Loading branch information
rimi-itk authored Mar 18, 2024
2 parents bdb9f6e + a192fcf commit 36f8a5c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#232](https://github.com/os2display/display-admin-client/pull/232)
- Fixed time zone issue in playlist schedules.
- [#231](https://github.com/os2display/display-admin-client/pull/231)
- Fixed post body of activation POST request.
- [#230](https://github.com/os2display/display-admin-client/pull/230)
Expand Down Expand Up @@ -71,8 +73,8 @@ All notable changes to this project will be documented in this file.
- [#205](https://github.com/os2display/display-admin-client/pull/205)
- Setup separate image builds for itkdev and os2display
- [#204](https://github.com/os2display/display-admin-client/pull/204)
- Change docker image name from `os2display/os2display-admin-client`
to `os2display/display-admin-client` to match image name and
- Change docker image name from `os2display/os2display-admin-client`
to `os2display/display-admin-client` to match image name and
repository name
- [#200](https://github.com/os2display/display-admin-client/pull/200)
- Update docker build to publish to "os2display" org on docker hub.
Expand Down
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# OS2Display Admin

This is an admin for OS2Display.
This is based on create-react-app.
See [https://github.com/os2display/display-docs/blob/main/admin.md](https://github.com/os2display/display-docs/blob/main/admin.md) for a description of the admin.
This is an admin for OS2Display. This is based on create-react-app. See
<https://github.com/os2display/display-docs/blob/main/admin.md> for a
description of the admin.

## Docker development setup

Expand All @@ -11,7 +11,7 @@ See [https://github.com/os2display/display-docs/blob/main/admin.md](https://gith
By default the api that is requested is located at `/api/`.
This can be configured by:

```bash
```shell
cp public/example_config.json public/config.json
```

Expand All @@ -25,32 +25,36 @@ And modify the entries to suit your setup.

### Create public/access-config file

This file contains the access config. This file is only required if other access setting are required than what is default.
This file contains the access config. This file is only required if other access
setting are required than what is default.

```bash
```shell
cp public/example-access-config.json public/access-config.json
```

### Up the containers

```bash
docker-compose up -d
```shell
docker compose up --detach
```

### Install npm packages

```bash
docker-compose run node yarn
```shell
docker compose run --rm node yarn install
```

**Note**: When to `node` container is running, the JavaScript is continously
being built.

### Redux Toolkit

The communication with the API is generated from an OpenAPI
specification with Redux Toolkit.

To regenerate (when the API specification has changed):

```bash
```shell
# Action: Replace api.json with the new api.json OpenAPI specification

# Install and run scripts to generate ned Redux Api slices.
Expand All @@ -64,16 +68,16 @@ We use [cypress](https://www.cypress.io/) for testing.

To run cypress tests in the cypress container:

```bash
docker-compose run cypress run
```shell
docker compose run --rm cypress run
```

### Linting

```bash
docker-compose run node yarn check-coding-standards
```shell
docker compose run --rm node yarn check-coding-standards
```

```bash
docker-compose run node yarn apply-coding-standards
```shell
docker compose run --rm node yarn apply-coding-standards
```
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
start_period: 60s

cypress:
image: cypress/included:9.5.2
image: cypress/included:9.5.4
networks:
- app
- frontend
Expand Down
10 changes: 1 addition & 9 deletions src/components/util/schedule/schedule-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,7 @@ const createNewSchedule = () => {
id: ulid(nowTimestamp),
duration: 60 * 60 * 24, // Default one day.
freq: RRule.WEEKLY,
dtstart: new Date(
Date.UTC(
now.getFullYear(),
now.getMonth(),
now.getDate(),
now.getHours(),
now.getMinutes()
)
),
dtstart: new Date(),
until: null,
wkst: RRule.MO,
byhour: null,
Expand Down
13 changes: 3 additions & 10 deletions src/components/util/schedule/schedule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,9 @@ function Schedule({ schedules, onChange }) {
* @param {object} target - Input target.
*/
const setDateValue = (scheduleId, target) => {
const date = new Date(target.value);

const date = target.valueAsDate;
const scheduleDate = new Date(
Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes()
)
date.getTime() + 60 * 1000 * date.getTimezoneOffset()
);

changeSchedule(scheduleId, target.id, scheduleDate);
Expand All @@ -141,7 +134,7 @@ function Schedule({ schedules, onChange }) {
* @returns {string} - The date formatted for datetime-local.
*/
const getDateValue = (date) => {
return date ? dayjs(date).utc().format("YYYY-MM-DDTHH:mm") : "";
return date ? dayjs(date).format("YYYY-MM-DDTHH:mm") : "";
};

/**
Expand Down

0 comments on commit 36f8a5c

Please sign in to comment.