Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8e77f34
2927: Started work on upgrading poster component to work with v2 api
tuj Nov 22, 2024
0e9f0e6
Merge branch 'develop' into feature/eventdatabasen-v2
tuj Jan 23, 2025
4aae53d
2927: Created v2 of poster selector
tuj Jan 27, 2025
8b041a9
2927: Code cleanup
tuj Jan 27, 2025
b10f6d4
2927: Started work on fixing data flow
tuj Jan 28, 2025
829e8fc
2927: Fixed single
tuj Jan 28, 2025
4bab571
2927: Fixes to subscription
tuj Jan 28, 2025
46c3cfa
2927: Added debounce to options
tuj Jan 29, 2025
58f6e72
2927: Use options endpoint
tuj Jan 31, 2025
d616446
2927: Fixed options endpoint
tuj Feb 1, 2025
d1b738c
2927: Fixed reload of options
tuj Feb 1, 2025
72bc6e3
2927: Fixed multiple occurrences case
tuj Feb 3, 2025
57fdd17
2927: Fixed linting issues
tuj Feb 3, 2025
e2dfc98
2927: Changed to upload artifact v4
tuj Feb 3, 2025
a703581
2927: Updated changelog
tuj Feb 3, 2025
cf83ea9
2927: Fixed warning
tuj Feb 3, 2025
b962b64
2927: Fixed occurences issue
tuj Feb 3, 2025
0c19ab2
2927: Styling
tuj Feb 3, 2025
d9cec03
2927: Fixed styling and texts
tuj Feb 3, 2025
30cac60
2927: Applied coding standards
tuj Feb 3, 2025
02e15a6
2927: Fixed issues raised in code review
tuj Feb 4, 2025
8dc65b0
2927: Deconstruct props
tuj Feb 4, 2025
65a6eed
2927: Fixed bugs introduced by deconstruction
tuj Feb 4, 2025
36fc7ba
2927: Moved options to helper
tuj Feb 4, 2025
05f9ce3
2927: Moved overrides to own component
tuj Feb 5, 2025
bf3214f
2927: Refactored poster single component
tuj Feb 5, 2025
195cbe9
2927: Split poster single up into components
tuj Feb 5, 2025
fabfbd4
2927: Applied coding standards
tuj Feb 5, 2025
aa91a52
2927: Removed url from search options
tuj Feb 5, 2025
40e3d1f
2927: Added placeholder text
tuj Feb 5, 2025
da98eaf
2927: Refactored poster subscription
tuj Feb 5, 2025
53e8abd
2927: Added alert with information
tuj Feb 5, 2025
3874ef9
2927: Added placeholders
tuj Feb 5, 2025
bf9af67
Merge branch 'main' into develop
tuj Mar 17, 2025
ac12491
Merge branch 'develop' into feature/eventdatabasen-v2
tuj Mar 18, 2025
a233ee8
Merge pull request #271 from os2display/feature/eventdatabasen-v2
tuj Mar 18, 2025
16eac74
2927: Changed subscription endpoint
tuj Mar 19, 2025
1c39e13
2927: Changed options widget
tuj Mar 20, 2025
c2cba72
2927: Added helptext
tuj Mar 20, 2025
196b332
2927: Changed how poster feed single source search is handled
tuj Mar 21, 2025
9738589
2927: Fixed default value
tuj Mar 21, 2025
c05764d
2927: Fixed array query parameters
tuj Mar 21, 2025
26805ff
2927: Removed duplicate message
tuj Mar 21, 2025
8fedc87
2927: Fixed removed message
tuj Mar 21, 2025
4f6dee7
2927: Fixed labelledby
tuj Mar 24, 2025
fbffc51
Merge pull request #279 from os2display/feature/2927-fixes
tuj Mar 24, 2025
f618eb7
4084: Updated changelog
tuj Mar 24, 2025
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
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
docker compose run --rm playwright npx playwright install --with-deps
docker compose run --rm playwright npx playwright test --retries 3


- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [2.3.0] - 2025-03-24

- [#279](https://github.com/os2display/display-admin-client/pull/279)
- Eventdatabase v2 feed source - Change subscription endpoint.
- Eventdatabase v2 feed source - Fixed options load.
- [#271](https://github.com/os2display/display-admin-client/pull/271)
- Added new feed source: Eventdatabasen v2.

## [2.2.0] - 2025-03-17

- [#273](https://github.com/os2display/display-admin-client/pull/273)
Expand Down
8 changes: 8 additions & 0 deletions src/components/feed-sources/feed-source-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import FormInput from "../util/forms/form-input";
import CalendarApiFeedType from "./templates/calendar-api-feed-type";
import NotifiedFeedType from "./templates/notified-feed-type";
import EventDatabaseApiFeedType from "./templates/event-database-feed-type";
import EventDatabaseApiV2FeedType from "./templates/event-database-v2-feed-type";

/**
* The feed-source form component.
Expand Down Expand Up @@ -97,6 +98,13 @@ function FeedSourceForm({
mode={mode}
/>
)}
{feedSource?.feedType === "App\\Feed\\EventDatabaseApiV2FeedType" && (
<EventDatabaseApiV2FeedType
handleInput={handleSecretInput}
formStateObject={feedSource.secrets}
mode={mode}
/>
)}
{feedSource?.feedType === "App\\Feed\\NotifiedFeedType" && (
<NotifiedFeedType
handleInput={handleSecretInput}
Expand Down
9 changes: 9 additions & 0 deletions src/components/feed-sources/feed-source-manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ function FeedSourceManager({
host: "",
},
},
{
value: "App\\Feed\\EventDatabaseApiV2FeedType",
title: t("event-database-api-v2-feed-type.title"),
key: "7",
secretsDefault: {
host: "",
apikey: "",
},
},
{
value: "App\\Feed\\NotifiedFeedType",
title: t("dynamic-fields.notified-feed-type.title"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { React } from "react";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
import FormInput from "../../util/forms/form-input";

const EventDatabaseApiV2FeedType = ({ handleInput, formStateObject, mode }) => {
const { t } = useTranslation("common", {
keyPrefix: "event-database-api-v2-feed-type",
});
return (
<>
<FormInput
name="host"
type="text"
className="mb-2"
label={t("host")}
onChange={handleInput}
value={formStateObject?.host}
/>
<FormInput
name="apikey"
type="text"
label={t("apikey")}
onChange={handleInput}
placeholder={
mode === "PUT" ? t("redacted-value-input-placeholder") : ""
}
value={formStateObject?.apikey}
/>
</>
);
};

EventDatabaseApiV2FeedType.propTypes = {
handleInput: PropTypes.func,
formStateObject: PropTypes.shape({
host: PropTypes.string.isRequired,
apikey: PropTypes.string,
}),
mode: PropTypes.string,
};

export default EventDatabaseApiV2FeedType;
30 changes: 26 additions & 4 deletions src/components/slide/content/feed-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import MultiSelectComponent from "../../util/forms/multiselect-dropdown/multi-dr
import idFromUrl from "../../util/helpers/id-from-url";
import ContentForm from "./content-form";
import MultiselectFromEndpoint from "./multiselect-from-endpoint";
import PosterSelector from "./poster-selector";
import PosterSelectorV1 from "./poster/poster-selector-v1";
import PosterSelectorV2 from "./poster/poster-selector-v2";

/**
* Feed selector.
Expand Down Expand Up @@ -96,9 +97,19 @@ function FeedSelector({
onChange(newValue);
};

const configurationChange = ({ target }) => {
const configurationChange = ({ target = null, targets = null }) => {
const configuration = { ...value.configuration };
set(configuration, target.id, target.value);

if (target !== null) {
set(configuration, target.id, target.value);
}

if (targets !== null) {
targets.forEach(({ id, value: targetValue }) => {
set(configuration, id, targetValue);
});
}

const newValue = { ...value, configuration };
onChange(newValue);
};
Expand Down Expand Up @@ -129,10 +140,21 @@ function FeedSelector({
}
if (element?.input === "poster-selector") {
return (
<PosterSelector
<PosterSelectorV1
key={element.key}
feedSource={feedSourceData}
configurationChange={configurationChange}
getValueFromConfiguration={getValueFromConfiguration}
/>
);
}
if (element?.input === "poster-selector-v2") {
return (
<PosterSelectorV2
key={element.key}
feedSource={feedSourceData}
configurationChange={configurationChange}
configuration={value.configuration}
getValueFromConfiguration={getValueFromConfiguration}
/>
);
Expand Down
89 changes: 89 additions & 0 deletions src/components/slide/content/poster/poster-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import dayjs from "dayjs";
import localeDa from "dayjs/locale/da";
import localStorageKeys from "../../../util/local-storage-keys";

const capitalize = (s) => {
return s.charAt(0).toUpperCase() + s.slice(1);
};

const formatDate = (date, format) => {
if (!date) return "";
return capitalize(
dayjs(date)
.locale(localeDa)
.format(format ?? "LLLL")
);
};

const loadDropdownOptions = (url, headers, inputValue, callback, type) => {
const params = {
type,
display: "options",
};

if (inputValue) {
params.name = inputValue;
}

const query = new URLSearchParams(params);

fetch(`${url}?${query}`, {
headers,
})
.then((response) => response.json())
.then((data) => {
callback(data);
})
.catch(() => {
callback([]);
});
};

const loadDropdownOptionsPromise = (url, headers, inputValue, type) => {
return new Promise((resolve, reject) => {
const params = {
entityType: type,
};

if (inputValue) {
params.search = inputValue;
}

const query = new URLSearchParams(params);
fetch(`${url}?${query}`, {
headers,
})
.then((response) => response.json())
.then((data) => {
resolve(data);
})
.catch((reason) => {
reject(reason);
});
});
};

const getHeaders = () => {
const apiToken = localStorage.getItem(localStorageKeys.API_TOKEN);
const tenantKey = JSON.parse(
localStorage.getItem(localStorageKeys.SELECTED_TENANT)
);

const headers = {
authorization: `Bearer ${apiToken ?? ""}`,
};

if (tenantKey) {
headers["Authorization-Tenant-Key"] = tenantKey.tenantKey;
}

return headers;
};

export {
formatDate,
capitalize,
loadDropdownOptions,
getHeaders,
loadDropdownOptionsPromise,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import AsyncSelect from "react-select/async";
import Col from "react-bootstrap/Col";
import dayjs from "dayjs";
import localeDa from "dayjs/locale/da";
import Select from "../../util/forms/select";
import FormInput from "../../util/forms/form-input";
import FormCheckbox from "../../util/forms/form-checkbox";
import localStorageKeys from "../../util/local-storage-keys";
import Select from "../../../util/forms/select";
import FormInput from "../../../util/forms/form-input";
import FormCheckbox from "../../../util/forms/form-checkbox";
import localStorageKeys from "../../../util/local-storage-keys";

/**
* @param {object} props Props.
Expand All @@ -19,7 +19,7 @@ import localStorageKeys from "../../util/local-storage-keys";
* @param {Function} props.configurationChange Configuration onChange.
* @returns {object} PosterSelector component.
*/
function PosterSelector({
function PosterSelectorV1({
feedSource,
getValueFromConfiguration,
configurationChange,
Expand Down Expand Up @@ -650,7 +650,7 @@ function PosterSelector({
<th scope="col">
{t("poster-selector.table-price")}
</th>
<th scope="col"> </th>
<th scope="col" />
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -890,7 +890,7 @@ function PosterSelector({
/* eslint-enable jsx-a11y/control-has-associated-label */
}

PosterSelector.propTypes = {
PosterSelectorV1.propTypes = {
getValueFromConfiguration: PropTypes.func.isRequired,
configurationChange: PropTypes.func.isRequired,
feedSource: PropTypes.shape({
Expand All @@ -903,4 +903,4 @@ PosterSelector.propTypes = {
}).isRequired,
};

export default PosterSelector;
export default PosterSelectorV1;
Loading