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

Feature/2314 save playlist and regions in screen manager #259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8a3cfad
2314: screen manager clean up and save groups and playlists with screen
sinejespersen Sep 26, 2024
2a71308
2314: col-md-8->col-md-12 to give space to grid generator
sinejespersen Sep 26, 2024
b7f53d1
2314: remove unused strings
sinejespersen Sep 26, 2024
3294420
2314: changelog
sinejespersen Sep 26, 2024
b0de951
2314: method to add empty playlist array to regions
sinejespersen Oct 7, 2024
3be3cdf
2314: fix css spinner
sinejespersen Oct 7, 2024
d207a33
2314: add regionIdForInitializeCallback prop
sinejespersen Oct 7, 2024
afaee9b
2314: callback to add regions to formstateobject
sinejespersen Oct 7, 2024
5e4124c
2414: add key to login map to avoid console errors
sinejespersen Oct 7, 2024
12a8aed
2314: update api.json/api.generated.ts
sinejespersen Oct 7, 2024
d330dbe
2314: add @rtk-incubator/rtk-query-codegen-openapi to package.json
sinejespersen Oct 7, 2024
ed4bec5
2314: add comments
sinejespersen Oct 7, 2024
3422ca8
2314: update changelog
sinejespersen Oct 7, 2024
dc0e6d0
2314: more changelog
sinejespersen Oct 7, 2024
539d5a0
2314: Proptypes updated
sinejespersen Oct 8, 2024
61a7714
2314: update mapgroups and remove check before mapping playlists
sinejespersen Oct 8, 2024
b5e2b63
2314: initialize selected groups
sinejespersen Oct 8, 2024
6e1d78b
2314: check if inScreenGroups exists on mapgroups
sinejespersen Oct 9, 2024
00340c0
2314: update changelog
sinejespersen Oct 9, 2024
374b9e9
2314: revert login.jsx
sinejespersen Oct 9, 2024
11bbeb1
2314: remove login.jsx-fix from changelog
sinejespersen Oct 9, 2024
f10897b
2314: sort playlists based on weight (or else drag and drop does not …
sinejespersen Oct 16, 2024
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
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]

- [#259](https://github.com/os2display/display-admin-client/pull/259)
- Add saving of playlists/groups with screen (as opposed to _after_)
- Clean up `screen-manager.jsx`
- Change bootstrap column class from `col-md-8` -> `col-md-12`
- update api.generated.ts to match [related pr](https://github.com/os2display/display-api-service/pull/213)
- Add @rtk-incubator/rtk-query-codegen-openapi to package.json in `src/redux/api`
- Sort playlists based on weight in drag/drop component

## [2.1.0] - 2024-10-23

- [#258](https://github.com/os2display/display-admin-client/pull/258)
Expand Down
9 changes: 2 additions & 7 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ body,
padding: 5em;
z-index: 1021;

.spinner-container {
display: flex;
position: fixed;

.loading-spinner {
margin-right: 1em;
}
.loading-spinner {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-10-02 at 20 03 11

margin-right: 0.6em;
}
}

Expand Down
38 changes: 33 additions & 5 deletions src/components/playlist-drag-and-drop/playlist-drag-and-drop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ import ScreenGanttChart from "../screen/util/screen-gantt-chart";
* @param {string} props.name - The id of the form element
* @param {string} props.screenId - The screen id for get request
* @param {string} props.regionId - The region id for get request
* @param {string} props.regionIdForInitializeCallback - The region id to add
* regions to formstateobject.
* @returns {object} A drag and drop component
*/
function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
function PlaylistDragAndDrop({
handleChange,
name,
screenId,
regionId,
regionIdForInitializeCallback,
}) {
const { t } = useTranslation("common", {
keyPrefix: "playlist-drag-and-drop",
});
Expand All @@ -49,16 +57,35 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
sharedWithMe: onlySharedPlaylists,
});

/**
* @param regionsAndPlaylists This method initializes playlists, so the
* initial formstate object in screen manager is not empty
*/
function callbackToinitializePlaylists(regionsAndPlaylists) {
handleChange({
target: {
id: regionIdForInitializeCallback,
value: regionsAndPlaylists["hydra:member"].map(
({ playlist }) => playlist
),
},
});
}

/** Set loaded data into form state. */
useEffect(() => {
if (selectedPlaylistsByRegion) {
setTotalItems(selectedPlaylistsByRegion["hydra:totalItems"]);
const newPlaylists = selectedPlaylistsByRegion["hydra:member"].map(
({ playlist }) => {
return playlist;
}
({ playlist, weight }) => ({ ...playlist, weight })
);

const selected = [...selectedData, ...newPlaylists].sort(
(a, b) => a.weight - b.weight
);
setSelectedData([...selectedData, ...newPlaylists]);

setSelectedData(selected);
callbackToinitializePlaylists(selectedPlaylistsByRegion);
}
}, [selectedPlaylistsByRegion]);

Expand Down Expand Up @@ -157,6 +184,7 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
PlaylistDragAndDrop.propTypes = {
name: PropTypes.string.isRequired,
screenId: PropTypes.string.isRequired,
regionIdForInitializeCallback: PropTypes.string.isRequired,
regionId: PropTypes.string.isRequired,
handleChange: PropTypes.func.isRequired,
};
Expand Down
16 changes: 13 additions & 3 deletions src/components/screen/screen-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ function ScreenForm({
);
if (localSelectedLayout) {
setSelectedLayout(localSelectedLayout);
// Initialize regions in the formstate object of screenmanager. used to save "empty" playlists, in the situation
// we are deleting all playlists from a screen region
handleInput({
target: { id: "regions", value: localSelectedLayout.regions },
});
}
}
}, [screen.layout, layoutOptions]);
Expand All @@ -84,6 +89,7 @@ function ScreenForm({
*/
const handleAdd = ({ target }) => {
const { value, id } = target;

setSelectedLayout(value);
handleInput({
target: { id, value: value.map((item) => item["@id"]).shift() },
Expand Down Expand Up @@ -250,7 +256,7 @@ function ScreenForm({
noSelectedString={t("nothing-selected-resolution")}
handleSelection={handleInput}
options={resolutionOptions}
selected={screen.resolution || ""}
selected={screen.resolution || []}
name="resolution"
singleSelect
/>
Expand All @@ -259,7 +265,7 @@ function ScreenForm({
noSelectedString={t("nothing-selected-orientation")}
handleSelection={handleInput}
options={orientationOptions}
selected={screen.orientation || ""}
selected={screen.orientation || []}
name="orientation"
singleSelect
/>
Expand Down Expand Up @@ -340,7 +346,11 @@ ScreenForm.propTypes = {
enableColorSchemeChange: PropTypes.bool,
layout: PropTypes.string,
location: PropTypes.string,
regions: PropTypes.arrayOf(PropTypes.string),
regions: PropTypes.arrayOf(
PropTypes.shape({
"@id": PropTypes.string,
})
),
screenUser: PropTypes.string,
size: PropTypes.string,
title: PropTypes.string,
Expand Down
Loading
Loading