From c074752b8944c0a9ba236f7f74f88343a9d32eb2 Mon Sep 17 00:00:00 2001 From: marcsello Date: Sun, 6 Dec 2020 22:36:17 +0100 Subject: [PATCH] Implemented loading of nodes --- src/views/Dashboard.vue | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 9a2f5de..cbbb2f1 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -56,6 +56,7 @@ export default { }, pendingNodeMoves: 0, // count of inflight coord modifications processingNodeChanges: false, + processingModelDownload: false, model: { centerX: 0, centerY: 0, @@ -317,6 +318,59 @@ export default { }, }, + mounted() { + this.processingModelDownload = true; + this.$api.get('objects/streamerobjects').then((resp) => { + + + resp.data.forEach((apiNode) => { + + const type_map = { + 1: "ingest", + 2: "encoder", + 3: "restreamer" + } + + let newNode = { + x: apiNode.x, + y: apiNode.y, + type: type_map[apiNode.resource_type], + apiId: apiNode.id + } + + switch (newNode.type) { + case "ingest": + newNode.data = { + url: apiNode.url, + streamkey: apiNode.stream_key + } + break; + case "encoder": + newNode.data = { + bitrate: apiNode.bitrate, + width: apiNode.width, + height: apiNode.height + } + break; + case "restreamer": + newNode.data = { + url: apiNode.url, + streamkey: apiNode.stream_key + } + break; + } + + newNode.id = this.idGenerator; + this.idGenerator++; + + this.model.nodes.push(newNode); + + }); + + + this.processingModelDownload = false; + }); + }, computed: { modelChanged() { return some(this.pendingChanges, (o) => o.length > 0);