mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-05 07:28:01 +00:00
update single + small fixes
This commit is contained in:
@@ -13,6 +13,8 @@ export default function EventBlock(props) {
|
||||
const { data, selected, next, delay, index, eventsHandler } = props;
|
||||
|
||||
const [more, setMore] = useState(false);
|
||||
// NOTE: cheating to add responsiveness
|
||||
const [visible, setVisible] = useState(data.isPublic || false);
|
||||
|
||||
const updateValues = (field, value) => {
|
||||
// validate field
|
||||
@@ -52,9 +54,10 @@ export default function EventBlock(props) {
|
||||
updateValues('presenter', v);
|
||||
};
|
||||
|
||||
const handleVisibleToggle = (v) => {
|
||||
// setVisible(previousState => !previousState);
|
||||
updateValues('isPublic', !data.isPublic);
|
||||
const handleVisibleToggle = () => {
|
||||
let viz = !data.isPublic || !visible;
|
||||
setVisible(viz);
|
||||
updateValues('isPublic', viz);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -113,10 +116,7 @@ export default function EventBlock(props) {
|
||||
</div>
|
||||
</div>
|
||||
<div className={style.actionOverlay}>
|
||||
<VisibleIconBtn
|
||||
clickhandler={handleVisibleToggle}
|
||||
active={data.isPublic}
|
||||
/>
|
||||
<VisibleIconBtn clickhandler={handleVisibleToggle} active={visible} />
|
||||
<DeleteIconBtn clickhandler={deleteHandler} />
|
||||
<ActionButtons
|
||||
showAdd
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function StageManager(props) {
|
||||
},
|
||||
};
|
||||
|
||||
console.log('debug', events)
|
||||
return (
|
||||
<div className={style.container__gray}>
|
||||
<NavLogo />
|
||||
|
||||
@@ -373,9 +373,28 @@ class EventTimer extends Timer {
|
||||
// Reload data if running
|
||||
let type = this._startedAt != null ? 'reload' : 'load';
|
||||
this.loadEvent(eventIndex, type);
|
||||
|
||||
this.broadcastState();
|
||||
}
|
||||
this.broadcastState();
|
||||
}
|
||||
|
||||
updateSingleEvent(id, entry) {
|
||||
// find object in events
|
||||
const eventIndex = this._eventList.findIndex((e) => e.id === id);
|
||||
if (eventIndex === -1) return;
|
||||
|
||||
// update events
|
||||
const e = this._eventList[eventIndex];
|
||||
this._eventList[eventIndex] = { ...e, ...entry };
|
||||
|
||||
// handle reload selected
|
||||
// Reload data if running
|
||||
let type =
|
||||
this.selectedEventId === id && this._startedAt != null
|
||||
? 'reload'
|
||||
: 'load';
|
||||
this.loadEvent(this.selectedEvent, type);
|
||||
|
||||
this.broadcastState();
|
||||
}
|
||||
|
||||
// Loads a given event
|
||||
@@ -434,7 +453,7 @@ class EventTimer extends Timer {
|
||||
if (eventIndex === 0) return;
|
||||
|
||||
// iterate backwards to find it
|
||||
for (let i = eventIndex - 1; i >= 0; i--) {
|
||||
for (let i = eventIndex; i >= 0; i--) {
|
||||
if (
|
||||
this._eventList[i].type === 'event' &&
|
||||
this._eventList[i].isPublic
|
||||
@@ -443,6 +462,7 @@ class EventTimer extends Timer {
|
||||
this.titlesPublic.subtitleNow = this._eventList[i].subtitle;
|
||||
this.titlesPublic.presenterNow = this._eventList[i].presenter;
|
||||
this.selectedPublicEventId = this._eventList[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ function _updateTimers() {
|
||||
global.timer.updateEventList(results);
|
||||
}
|
||||
|
||||
// Updates timer object single event
|
||||
function _updateTimersSingle(id, entry) {
|
||||
global.timer.updateSingleEvent(id, entry);
|
||||
}
|
||||
|
||||
// Create controller for GET request to '/events'
|
||||
// Returns -
|
||||
exports.eventsGetAll = async (req, res) => {
|
||||
@@ -129,7 +134,9 @@ exports.eventsPut = async (req, res) => {
|
||||
.find({ id: req.body.id })
|
||||
.assign({ ...req.body })
|
||||
.write();
|
||||
_updateTimers();
|
||||
|
||||
// update timer
|
||||
_updateTimersSingle(req.body.id, req.body);
|
||||
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
@@ -159,8 +166,7 @@ exports.eventsPatch = async (req, res) => {
|
||||
.write();
|
||||
|
||||
// update timer
|
||||
// TODO: update single values when possible
|
||||
_updateTimers();
|
||||
_updateTimersSingle(req.body.id, req.body);
|
||||
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
@@ -175,6 +181,7 @@ exports.eventsDelete = async (req, res) => {
|
||||
if (!req.params.eventId) {
|
||||
res.status(400).send(`No id found in request`);
|
||||
return;
|
||||
console.log('debug: No id found in request');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -197,6 +204,8 @@ exports.eventsDelete = async (req, res) => {
|
||||
|
||||
res.sendStatus(201);
|
||||
} catch (error) {
|
||||
console.log('debug:', error);
|
||||
|
||||
res.status(400).send(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user