Implemented move event pusher
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-12-06 03:08:02 +01:00
parent 969ffcfb0c
commit f7b5dc41ca
3 changed files with 63 additions and 9 deletions

View File

@@ -2,12 +2,15 @@
<div class="page-container md-layout-column" id="dashboard-container">
<!-- toolbar -->
<toolbar @showDrawerClicked="showDrawer = true" @applyClicked="performApply" :processing="false"
:model-changed="modelChanged"/>
<toolbar @showDrawerClicked="showDrawer = true"
@applyClicked="performApply"
:processing="anyPendingNodeMoves"
:model-changed="modelChanged"
/>
<!-- drawer -->
<md-drawer :md-active.sync="showDrawer" md-swipeable>
<workspace-drawer-content/>
<workspace-drawer-content :pending-changes="pendingChanges"/>
</md-drawer>
<!-- workspace -->
@@ -51,6 +54,7 @@ export default {
updated: [],
deleted: [] // Stores apiId instead of localId
},
pendingNodeMoves: 0, // count of inflight coord modifications
model: {
centerX: 0,
centerY: 0,
@@ -132,8 +136,24 @@ export default {
this.pendingChanges.created = Array.from(pending_creations);
},
// --- end of magic hack
handleNodeMove() {
// TODO
handleNodeMove(id) {
console.log(id);
const moved_node = this.model.nodes.find((node) => node.id === id);
console.log(moved_node);
if ((!moved_node) || (!moved_node.apiId)) {
return;
}
console.log("Anyád")
this.pendingNodeMoves++;
this.$api.put(`objects/streamerobjects/coordmodify/${moved_node.apiId}`, {
x: moved_node.x,
y: moved_node.y
}).then(() => {
this.pendingNodeMoves--;
}).catch(() => {
this.pendingNodeMoves--;
});
},
handleLinkBreak({from, to}) {
this.enqueuePendingNodeUpdate(from);
@@ -157,6 +177,9 @@ export default {
computed: {
modelChanged() {
return some(this.pendingChanges, (o) => o.length > 0);
},
anyPendingNodeMoves() {
return this.pendingNodeMoves > 0;
}
}