-
Notifications
You must be signed in to change notification settings - Fork 4
New feed source: Eventdatabasen v2 #271
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8e77f34
2927: Started work on upgrading poster component to work with v2 api
tuj 0e9f0e6
Merge branch 'develop' into feature/eventdatabasen-v2
tuj 4aae53d
2927: Created v2 of poster selector
tuj 8b041a9
2927: Code cleanup
tuj b10f6d4
2927: Started work on fixing data flow
tuj 829e8fc
2927: Fixed single
tuj 4bab571
2927: Fixes to subscription
tuj 46c3cfa
2927: Added debounce to options
tuj 58f6e72
2927: Use options endpoint
tuj d616446
2927: Fixed options endpoint
tuj d1b738c
2927: Fixed reload of options
tuj 72bc6e3
2927: Fixed multiple occurrences case
tuj 57fdd17
2927: Fixed linting issues
tuj e2dfc98
2927: Changed to upload artifact v4
tuj a703581
2927: Updated changelog
tuj cf83ea9
2927: Fixed warning
tuj b962b64
2927: Fixed occurences issue
tuj 0c19ab2
2927: Styling
tuj d9cec03
2927: Fixed styling and texts
tuj 30cac60
2927: Applied coding standards
tuj 02e15a6
2927: Fixed issues raised in code review
tuj 8dc65b0
2927: Deconstruct props
tuj 65a6eed
2927: Fixed bugs introduced by deconstruction
tuj 36fc7ba
2927: Moved options to helper
tuj 05f9ce3
2927: Moved overrides to own component
tuj bf3214f
2927: Refactored poster single component
tuj 195cbe9
2927: Split poster single up into components
tuj fabfbd4
2927: Applied coding standards
tuj aa91a52
2927: Removed url from search options
tuj 40e3d1f
2927: Added placeholder text
tuj da98eaf
2927: Refactored poster subscription
tuj 53e8abd
2927: Added alert with information
tuj 3874ef9
2927: Added placeholders
tuj ac12491
Merge branch 'develop' into feature/eventdatabasen-v2
tuj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/components/feed-sources/templates/event-database-v2-feed-type.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }; |
104 changes: 104 additions & 0 deletions
104
src/components/slide/content/poster/poster-selector-v2.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { React } from "react"; | ||
| import PropTypes from "prop-types"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { Button, Card, Row } from "react-bootstrap"; | ||
| import Col from "react-bootstrap/Col"; | ||
| import PosterSingle from "./poster-single"; | ||
| import PosterSubscription from "./poster-subscription"; | ||
|
|
||
| /** | ||
| * @param {object} props Props. | ||
| * @param {object} props.feedSource Feed source. | ||
| * @param {Function} props.getValueFromConfiguration Gets a value from the feed | ||
| * configuration. | ||
| * @param {Function} props.configurationChange Configuration onChange. | ||
| * @param {object} props.configuration Configuration. | ||
| * @returns {object} PosterSelector component. | ||
| */ | ||
| function PosterSelectorV2({ | ||
| feedSource, | ||
| getValueFromConfiguration, | ||
| configuration, | ||
| configurationChange, | ||
| }) { | ||
| const { t } = useTranslation("common", { keyPrefix: "poster-selector-v2" }); | ||
| const posterType = getValueFromConfiguration("posterType"); | ||
|
|
||
| return ( | ||
| <Card className="mb-3"> | ||
| <Card.Body> | ||
| {!posterType && ( | ||
| <Row> | ||
| <Col> | ||
| <h5>{t("select-mode")}</h5> | ||
| </Col> | ||
| <Col> | ||
| <Button | ||
| onClick={() => | ||
| configurationChange({ | ||
| target: { | ||
| id: "posterType", | ||
| value: "single", | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| {t("poster-feed-type-single")} | ||
| </Button> | ||
| </Col> | ||
| <Col> | ||
| <Button | ||
| onClick={() => | ||
| configurationChange({ | ||
| target: { | ||
| id: "posterType", | ||
| value: "subscription", | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| {t("poster-feed-type-subscription")} | ||
| </Button> | ||
| </Col> | ||
| </Row> | ||
| )} | ||
| {posterType && ( | ||
| <> | ||
| {posterType === "single" && ( | ||
| <PosterSingle | ||
| feedSource={feedSource} | ||
| configuration={configuration} | ||
| getValueFromConfiguration={getValueFromConfiguration} | ||
| configurationChange={configurationChange} | ||
| /> | ||
| )} | ||
| {posterType === "subscription" && ( | ||
| <PosterSubscription | ||
| feedSource={feedSource} | ||
| configuration={configuration} | ||
| getValueFromConfiguration={getValueFromConfiguration} | ||
| configurationChange={configurationChange} | ||
| /> | ||
| )} | ||
| </> | ||
| )} | ||
| </Card.Body> | ||
| </Card> | ||
| ); | ||
| } | ||
|
|
||
| PosterSelectorV2.propTypes = { | ||
| getValueFromConfiguration: PropTypes.func.isRequired, | ||
| configurationChange: PropTypes.func.isRequired, | ||
| configuration: PropTypes.shape({}), | ||
| feedSource: PropTypes.shape({ | ||
| admin: PropTypes.arrayOf( | ||
| PropTypes.shape({ | ||
| endpointEntity: PropTypes.string, | ||
| endpointSearch: PropTypes.string, | ||
| }) | ||
| ), | ||
| }).isRequired, | ||
| }; | ||
|
|
||
| export default PosterSelectorV2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.