stuffs
This commit is contained in:
parent
ff1ed77907
commit
6ea50532cc
@ -15,7 +15,8 @@ import {
|
|||||||
MdList,
|
MdList,
|
||||||
MdAvatar,
|
MdAvatar,
|
||||||
MdRipple,
|
MdRipple,
|
||||||
MdDialog
|
MdDialog,
|
||||||
|
MdSpeedDial,
|
||||||
} from 'vue-material/dist/components'
|
} from 'vue-material/dist/components'
|
||||||
|
|
||||||
import 'vue-material/dist/vue-material.min.css'
|
import 'vue-material/dist/vue-material.min.css'
|
||||||
@ -36,6 +37,7 @@ Vue.use(MdList);
|
|||||||
Vue.use(MdAvatar);
|
Vue.use(MdAvatar);
|
||||||
Vue.use(MdRipple);
|
Vue.use(MdRipple);
|
||||||
Vue.use(MdDialog);
|
Vue.use(MdDialog);
|
||||||
|
Vue.use(MdSpeedDial);
|
||||||
|
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
<g @mouseover="handleMouseOver"
|
<g @mouseover="handleMouseOver"
|
||||||
@mouseleave="handleMouseLeave">
|
@mouseleave="handleMouseLeave">
|
||||||
<path :d="dAttr" :style="pathStyle"></path>
|
<path :d="dAttr" :style="pathStyle"></path>
|
||||||
<a v-if="show.delete" @click="deleteLink">
|
<a v-if="show.delete" @click="deleteLink" class="link-delete">
|
||||||
<text
|
<text
|
||||||
text-anchor="middle"
|
text-anchor="middle"
|
||||||
|
alignment-baseline="middle"
|
||||||
:transform="arrowTransform"
|
:transform="arrowTransform"
|
||||||
font-size="22">×</text>
|
>×</text>
|
||||||
</a>
|
</a>
|
||||||
<path v-else d="M -1 -1 L 0 1 L 1 -1 z"
|
<path v-else d="M -1 -1 L 0 1 L 1 -1 z"
|
||||||
:style="arrowStyle"
|
:style="arrowStyle"
|
||||||
|
|
||||||
:transform="arrowTransform"></path>
|
:transform="arrowTransform"></path>
|
||||||
</g>
|
</g>
|
||||||
</template>
|
</template>
|
||||||
@ -99,4 +101,14 @@ export default {
|
|||||||
g {
|
g {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link-delete {
|
||||||
|
font-size: 3em;
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -1,15 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flowchart-node" :style="nodeStyle"
|
<div class="flowchart-node" :style="nodeStyle"
|
||||||
@mousedown="handleMousedown"
|
@mousedown.prevent="handleMousedown"
|
||||||
@mouseover="handleMouseOver"
|
@mouseover.prevent="handleMouseOver"
|
||||||
@mouseleave="handleMouseLeave"
|
@mouseleave.prevent="handleMouseLeave"
|
||||||
|
@dblclick.prevent="editProperties"
|
||||||
v-bind:class="{selected: options.selected === id}">
|
v-bind:class="{selected: options.selected === id}">
|
||||||
|
|
||||||
<!--- Input port --->
|
<!--- Input port --->
|
||||||
<div class="node-port node-input"
|
<div class="node-port node-input"
|
||||||
v-if="haveInput"
|
v-if="haveInput"
|
||||||
@mousedown="inputMouseDown"
|
@mousedown.prevent
|
||||||
@mouseup="inputMouseUp">
|
@mouseup.prevent="inputMouseUp">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--- The box itself --->
|
<!--- The box itself --->
|
||||||
@ -21,7 +22,7 @@
|
|||||||
<!--- Output port --->
|
<!--- Output port --->
|
||||||
<div class="node-port node-output"
|
<div class="node-port node-output"
|
||||||
v-if="haveOutput"
|
v-if="haveOutput"
|
||||||
@mousedown="outputMouseDown">
|
@mousedown.prevent="outputMouseDown">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-show="show.delete" class="node-delete">×</div>
|
<div v-show="show.delete" class="node-delete">×</div>
|
||||||
@ -67,19 +68,11 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default() {
|
||||||
return {
|
return {
|
||||||
centerX: 1024,
|
centerX: 0,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
centerY: 140,
|
centerY: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
haveInput: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
haveOutput: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -98,6 +91,12 @@ export default {
|
|||||||
left: this.options.centerX + this.x * this.options.scale + 'px', // remove: this.options.offsetLeft +
|
left: this.options.centerX + this.x * this.options.scale + 'px', // remove: this.options.offsetLeft +
|
||||||
transform: `scale(${this.options.scale})`,
|
transform: `scale(${this.options.scale})`,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
haveInput() {
|
||||||
|
return this.type !== "ingest"
|
||||||
|
},
|
||||||
|
haveOutput() {
|
||||||
|
return this.type !== "restreamer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -115,30 +114,28 @@ export default {
|
|||||||
handleMouseLeave() {
|
handleMouseLeave() {
|
||||||
this.show.delete = false;
|
this.show.delete = false;
|
||||||
},
|
},
|
||||||
outputMouseDown(e) {
|
outputMouseDown() {
|
||||||
this.$emit('linkingStart')
|
this.$emit('linkingStart')
|
||||||
e.preventDefault();
|
|
||||||
},
|
},
|
||||||
inputMouseDown(e) {
|
inputMouseUp() {
|
||||||
e.preventDefault();
|
|
||||||
},
|
|
||||||
inputMouseUp(e) {
|
|
||||||
this.$emit('linkingStop')
|
this.$emit('linkingStop')
|
||||||
e.preventDefault();
|
|
||||||
},
|
},
|
||||||
|
editProperties() {
|
||||||
|
this.$emit('update:data', {"text": "asd"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
$themeColor: rgb(85, 108, 255);
|
$themeColor: rgb(0, 0, 0);
|
||||||
$portSize: 12;
|
$portSize: 14;
|
||||||
|
|
||||||
.flowchart-node {
|
.flowchart-node {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 80px;
|
width: 200px;
|
||||||
height: 80px;
|
height: 150px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: none;
|
border: none;
|
||||||
@ -189,17 +186,18 @@ $portSize: 12;
|
|||||||
|
|
||||||
.node-delete {
|
.node-delete {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -6px;
|
right: -8px;
|
||||||
top: -6px;
|
top: -8px;
|
||||||
font-size: 12px;
|
font-size: 14px;
|
||||||
width: 12px;
|
width: 16px;
|
||||||
height: 12px;
|
height: 16px;
|
||||||
color: $themeColor;
|
color: $themeColor;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid $themeColor;
|
border: 1px solid $themeColor;
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
line-height: 16px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: $themeColor;
|
background: $themeColor;
|
||||||
|
@ -36,9 +36,9 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default() {
|
||||||
return {
|
return {
|
||||||
centerX: 1024,
|
centerX: 0,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
centerY: 140,
|
centerY: 0,
|
||||||
nodes: [],
|
nodes: [],
|
||||||
links: [],
|
links: [],
|
||||||
}
|
}
|
||||||
@ -125,19 +125,23 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPortPosition(type, x, y) {
|
getPortPosition(type, x, y) {
|
||||||
|
// Line start and end points set here
|
||||||
if (type === 'top') {
|
if (type === 'top') {
|
||||||
return [x + 40, y];
|
return [x + 100, y];
|
||||||
}
|
}
|
||||||
else if (type === 'bottom') {
|
else if (type === 'bottom') {
|
||||||
return [x + 40, y + 80];
|
return [x + 100, y + 150];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
linkingStart(index) {
|
linkingStart(index) {
|
||||||
this.action.linking = true;
|
this.action.linking = true;
|
||||||
|
// Dirty fix, so that links won't glitch when being created
|
||||||
|
const node = this.findNodeWithID(index);
|
||||||
|
const [x,y] = this.getPortPosition('bottom',node.x + this.scene.centerX,node.y + this.scene.centerY);
|
||||||
this.draggingLink = {
|
this.draggingLink = {
|
||||||
from: index,
|
from: index,
|
||||||
mx: 0,
|
mx: x, // Yes, those are magic numbers
|
||||||
my: 0,
|
my: y,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
linkingStop(index) {
|
linkingStop(index) {
|
||||||
|
@ -3,9 +3,17 @@
|
|||||||
|
|
||||||
<md-dialog :md-active.sync="showNewElementChooser">
|
<md-dialog :md-active.sync="showNewElementChooser">
|
||||||
<md-dialog-title>Select the type of the new element</md-dialog-title>
|
<md-dialog-title>Select the type of the new element</md-dialog-title>
|
||||||
<md-button @click="newElement('ingest')">Ingest</md-button>
|
|
||||||
<md-button @click="newElement('encoder')">Encoder</md-button>
|
|
||||||
<md-button @click="newElement('restreamer')">Restreamer</md-button>
|
<md-button @click="newElement('ingest')"><md-icon>vertical_align_bottom</md-icon> Ingest</md-button>
|
||||||
|
<i></i> <!-- This is to prevent margin collapse -->
|
||||||
|
|
||||||
|
<md-button @click="newElement('encoder')"><md-icon>gradient</md-icon> Encoder</md-button>
|
||||||
|
<i></i>
|
||||||
|
|
||||||
|
<md-button @click="newElement('restreamer')"><md-icon>publish</md-icon> Restreamer</md-button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</md-dialog>
|
</md-dialog>
|
||||||
|
|
||||||
@ -44,13 +52,28 @@
|
|||||||
</md-drawer>
|
</md-drawer>
|
||||||
|
|
||||||
<md-content id="diagram-container">
|
<md-content id="diagram-container">
|
||||||
|
|
||||||
<simple-flowchart :scene.sync="diagram"></simple-flowchart>
|
<simple-flowchart :scene.sync="diagram"></simple-flowchart>
|
||||||
<div id="fab-holder">
|
|
||||||
<md-button class="md-fab" @click="performAddElement">
|
<md-speed-dial class="md-bottom-right">
|
||||||
|
<md-speed-dial-target @click="performAddElement">
|
||||||
<md-icon>add</md-icon>
|
<md-icon>add</md-icon>
|
||||||
</md-button>
|
</md-speed-dial-target>
|
||||||
</div>
|
|
||||||
|
<md-speed-dial-content>
|
||||||
|
<md-button @click="newElement('restreamer')" class="md-icon-button">
|
||||||
|
<md-icon>publish</md-icon>
|
||||||
|
</md-button>
|
||||||
|
|
||||||
|
<md-button @click="newElement('encoder')" class="md-icon-button">
|
||||||
|
<md-icon>gradient</md-icon>
|
||||||
|
</md-button>
|
||||||
|
|
||||||
|
<md-button @click="newElement('ingest')" class="md-icon-button">
|
||||||
|
<md-icon>vertical_align_bottom</md-icon>
|
||||||
|
</md-button>
|
||||||
|
|
||||||
|
</md-speed-dial-content>
|
||||||
|
</md-speed-dial>
|
||||||
|
|
||||||
</md-content>
|
</md-content>
|
||||||
|
|
||||||
@ -69,37 +92,35 @@ export default {
|
|||||||
showNavigation: false,
|
showNavigation: false,
|
||||||
showNewElementChooser: false,
|
showNewElementChooser: false,
|
||||||
diagram: {
|
diagram: {
|
||||||
centerX: 1024,
|
centerX: 0,
|
||||||
centerY: 140,
|
centerY: 0,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
nodes: [
|
nodes: [
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
x: -700,
|
x: 100,
|
||||||
y: -69,
|
y: 110,
|
||||||
type: 'Action',
|
type: 'ingest',
|
||||||
data: {"text" : "lofasz"},
|
data: {"text": "as"},
|
||||||
haveInput: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
x: -357,
|
x: 357,
|
||||||
y: 80,
|
y: 80,
|
||||||
type: 'Script',
|
type: 'restreamer',
|
||||||
label: 'test2',
|
data: {"text": "asd"},
|
||||||
haveOutput: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
x: -557,
|
x: 557,
|
||||||
y: 80,
|
y: 80,
|
||||||
type: 'Rule',
|
type: 'encoder',
|
||||||
label: 'test3',
|
data: {"text": "asdasd"}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 1,
|
||||||
from: 2, // node id the link start
|
from: 2, // node id the link start
|
||||||
to: 4, // node id the link end
|
to: 4, // node id the link end
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user