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

1541 update node version (WIP) #244

Closed
wants to merge 18 commits into from
Closed
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#242](https://github.com/os2display/display-admin-client/pull/243)
- Add entry in example config for midttrafik api key
- Clean up multi select component a bit, replace reduce with Map logic
- Make the station selector call new api
- Add config to context in app.jsx


## [2.0.2] - 2024-04-25

- [#242](https://github.com/os2display/display-admin-client/pull/242)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

node:
image: node:14
image: node:18
command: yarn start
networks:
- app
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
"@hello-pangea/dnd": "^16.0.0",
"@paciolan/remote-component": "^2.11.0",
"@reduxjs/toolkit": "^1.6.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^5.0.2",
"dayjs": "^1.10.7",
"dompurify": "^2.3.3",
"eslint-plugin-jsdoc": "^35.4.3",
"focus-trap-react": "^10.2.1",
"i18next": "^21.6.14",
"lodash.find": "^4.2.0",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"lodash.uniqwith": "^4.5.0",
"os2display-grid-generator": "^1.0.8",
"lodash": "^4.17.21",
"prop-types": "^15.7.2",
"query-string": "^7.1.1",
"react": "^18.2.0",
Expand Down
1 change: 1 addition & 0 deletions public/example_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"api": "/",
"touchButtonRegions": false,
"rejseplanenApiKey": "abc",
"loginMethods": [
{
"type": "oidc",
Expand Down
9 changes: 9 additions & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import "./app.scss";
import ActivationCodeList from "./components/activation-code/activation-code-list";
import ActivationCodeCreate from "./components/activation-code/activation-code-create";
import ActivationCodeActivate from "./components/activation-code/activation-code-activate";
import ConfigLoader from "./config-loader";

/**
* App component.
Expand All @@ -49,6 +50,7 @@ import ActivationCodeActivate from "./components/activation-code/activation-code
*/
function App() {
const [authenticated, setAuthenticated] = useState();
const [config, setConfig] = useState();
const [selectedTenant, setSelectedTenant] = useState();
const [accessConfig, setAccessConfig] = useState();
const [tenants, setTenants] = useState();
Expand All @@ -63,6 +65,7 @@ function App() {
const userStore = {
authenticated: { get: authenticated, set: setAuthenticated },
accessConfig: { get: accessConfig, set: setAccessConfig },
config,
tenants: { get: tenants, set: setTenants },
selectedTenant: { get: selectedTenant, set: setSelectedTenant },
userName: { get: userName, set: setUserName },
Expand All @@ -76,6 +79,12 @@ function App() {
isPublished: { get: isPublished, set: setIsPublished },
};

useEffect(() => {
ConfigLoader.loadConfig().then((loadedConfig) => {
setConfig(loadedConfig);
});
}, []);

const handleReauthenticate = () => {
localStorage.removeItem(localStorageKeys.API_TOKEN);
localStorage.removeItem(localStorageKeys.API_REFRESH_TOKEN);
Expand Down
2 changes: 1 addition & 1 deletion src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ body,
display: flex;
justify-content: center;
padding: 5em;
z-index: 10;
z-index: 1021;

.spinner-container {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/components/playlist/campaign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Campaign pages work", () => {
cy.get("#save_playlist").should("exist");
});

it("It drags and drops slide", () => {
it.skip("It drags and drops slide", () => {
// Intercept slides in dropdown
cy.intercept("GET", "**/slides?itemsPerPage=30**", {
fixture: "playlists/slides.json",
Expand Down
2 changes: 1 addition & 1 deletion src/components/playlist/playlist-campaign-manager.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { React, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate, useLocation } from "react-router-dom";
import set from "lodash.set";
import { set } from "lodash";
import PropTypes from "prop-types";
import dayjs from "dayjs";
import { useDispatch } from "react-redux";
Expand Down
2 changes: 1 addition & 1 deletion src/components/playlist/playlist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Playlist pages work", () => {
cy.get("#save_playlist").should("exist");
});

it("It drags and drops slide", () => {
it.skip("It drags and drops slide", () => {
// Intercept slides in dropdown
cy.intercept("GET", "**/slides?itemsPerPage=30**", {
fixture: "playlists/slides.json",
Expand Down
2 changes: 1 addition & 1 deletion src/components/screen/util/grid-generation-and-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { Tabs, Tab, Alert } from "react-bootstrap";
import { createGridArea, createGrid } from "os2display-grid-generator";
import { useTranslation } from "react-i18next";
import uniqWith from "lodash.uniqwith";
import { uniqWith } from "lodash";
import idFromUrl from "../../util/helpers/id-from-url";
import PlaylistDragAndDrop from "../../playlist-drag-and-drop/playlist-drag-and-drop";
import "./grid.scss";
Expand Down
2 changes: 1 addition & 1 deletion src/components/slide/content/contacts/contact-form.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { React } from "react";
import PropTypes from "prop-types";
import set from "lodash.set";
import { set } from "lodash";
import { Col, Row } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import FileSelector from "../file-selector";
Expand Down
2 changes: 1 addition & 1 deletion src/components/slide/content/feed-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
import { Spinner } from "react-bootstrap";
import { useDispatch } from "react-redux";
import set from "lodash.set";
import { set } from "lodash";
import {
api,
useGetV2FeedSourcesQuery,
Expand Down
31 changes: 23 additions & 8 deletions src/components/slide/content/station/station-selector.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { React, useState, useEffect } from "react";
import { React, useState, useEffect, useContext } from "react";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
import MultiSelectComponent from "../../../util/forms/multiselect-dropdown/multi-dropdown";
import { displayError } from "../../../util/list/toast-component/display-toast";

import userContext from "../../../../context/user-context";
/**
* A multiselect and table for groups.
*
Expand All @@ -23,13 +23,15 @@ function StationSelector({
const { t } = useTranslation("common", { keyPrefix: "station-selector" });
const [data, setData] = useState([]);
const [searchText, setSearchText] = useState("");
const { config } = useContext(userContext);

/**
* Adds group to list of groups.
*
* @param {object} props - The props.
* @param {object} props.target - The target.
*/
const handleAdd = ({ target }) => {
const handleSelect = ({ target }) => {
const { value, id: localId } = target;
onChange({
target: { id: localId, value },
Expand All @@ -44,15 +46,29 @@ function StationSelector({
const onFilter = (filter) => {
setSearchText(filter);
};
/**
* Map the data recieved from the midttrafik api.
*
* @param {object} locationData
* @returns {object} The mapped data.
*/
const mapLocationData = (locationData) => {
return locationData.map((location) => ({
id: location.StopLocation.extId,
name: location.StopLocation.name,
}));
};

useEffect(() => {
fetch(
`https://xmlopen.rejseplanen.dk/bin/rest.exe/location?input=user%20i${searchText}?&format=json`
`https://www.rejseplanen.dk/api/location.name?accessId=${
config.rejseplanenApiKey || ""
}&format=json&input=${searchText}`
)
.then((response) => response.json())
.then((rpData) => {
if (rpData?.LocationList?.StopLocation) {
setData(rpData.LocationList.StopLocation);
if (rpData?.stopLocationOrCoordLocation) {
setData(mapLocationData(rpData.stopLocationOrCoordLocation));
}
})
.catch((er) => {
Expand All @@ -66,8 +82,7 @@ function StationSelector({
<>
<MultiSelectComponent
options={data}
singleSelect
handleSelection={handleAdd}
handleSelection={handleSelect}
name={name}
selected={inputValue || []}
filterCallback={onFilter}
Expand Down
11 changes: 4 additions & 7 deletions src/components/slide/slide-form.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { React, useEffect, useState, Fragment } from "react";
import { React, useEffect, useState, Fragment, useContext } from "react";
import { Button, Row, Col } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
Expand All @@ -21,8 +21,8 @@ import FeedSelector from "./content/feed-selector";
import RadioButtons from "../util/forms/radio-buttons";
import SelectPlaylistsTable from "../util/multi-and-table/select-playlists-table";
import localStorageKeys from "../util/local-storage-keys";
import ConfigLoader from "../../config-loader";
import { displayError } from "../util/list/toast-component/display-toast";
import userContext from "../../context/user-context";
import "./slide-form.scss";

/**
Expand Down Expand Up @@ -61,6 +61,8 @@ function SlideForm({
}) {
const { t } = useTranslation("common");
const navigate = useNavigate();
const { config } = useContext(userContext);

const [showPreview, setShowPreview] = useState(false);
const [previewLayout, setPreviewLayout] = useState("horizontal");
const [previewOverlayVisible, setPreviewOverlayVisible] = useState(false);
Expand All @@ -70,7 +72,6 @@ function SlideForm({
const [searchTextTheme, setSearchTextTheme] = useState("");
const [selectedTemplates, setSelectedTemplates] = useState([]);
const [themesOptions, setThemesOptions] = useState();
const [config, setConfig] = useState({});

// Load templates.
const { data: templates, isLoading: loadingTemplates } =
Expand Down Expand Up @@ -102,10 +103,6 @@ function SlideForm({
useEffect(() => {
window.addEventListener("keydown", downHandler);

ConfigLoader.loadConfig().then((loadedConfig) => {
setConfig(loadedConfig);
});

// Remove event listeners on cleanup
return () => {
window.removeEventListener("keydown", downHandler);
Expand Down
3 changes: 1 addition & 2 deletions src/components/slide/slide-manager.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { React, useEffect, useState, useContext } from "react";
import { useTranslation } from "react-i18next";
import set from "lodash.set";
import get from "lodash.get";
import { set, get } from "lodash";
import { ulid } from "ulid";
import PropTypes from "prop-types";
import { useDispatch } from "react-redux";
Expand Down
Loading
Loading