main.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <div class="flow-main" :class="{dark:dark}">
  3. <div class="app-header">
  4. Flow
  5. <button @click="dark=!dark">{{ dark?'light':'dark' }}</button>
  6. </div>
  7. <div class="app-horizontal">
  8. <div class="app-flow-container">
  9. <div class="app-watermark">PROTOTYPE</div>
  10. <div class="app-info">
  11. <h4>HELP</h4>
  12. <ul>
  13. <li><b>Pan</b>: Drag with Middle Mouse or Ctrl+left mouse button</li>
  14. <li><b>Zoom</b>: Mouse wheel up and down to zoom in and out</li>
  15. <li><b>New Node</b>: Create a node by dragging a fn from left panel into area</li>
  16. <li><b>Remove Node</b>: Middle click in a node to remove a node</li>
  17. <li><b>Inspect node</b>: Double click on a node to get detailed information</li>
  18. <li><b>Move Node</b>: Mouse click and drag</li>
  19. <li><b>Links</b>: Press [shift] and Drag from a node/socket to a socket highlighted in green</li>
  20. <li><b>Links(alternative)</b>: Toggle socket visualisation in the panel and Drag from a socket to a socket highlighted in green</li>
  21. <li><b>Remove Link</b>: Simple click on the link when it turns red</li>
  22. </ul>
  23. <h4>TODO:</h4>
  24. <ul>
  25. <li>UX/UI: Undo changes</li>
  26. <li>UX/UI: Special nodes with display capabilities (images,datatables,...)</li>
  27. <li>UX/UI: Group nodes into a single box, exposing inputs and outputs</li>
  28. <li>UX/UI: Implement touch</li>
  29. <li>UX/UI: drop link in node to link to next compatible available input</li>
  30. <li>Registry: Synchronize registry with server(GET)</li>
  31. <li>Collaboration: Better concurrent editing/message passing (testing)</li>
  32. <li>Collaboration: Improve document synchronization</li>
  33. <li>FlowServer: Build the graph on the server and run</li>
  34. <li>FlowPkg: Create training mechanism</li>
  35. <li>FlowPkg: matrix pooling function example</li>
  36. </ul>
  37. <br>
  38. <small>&copy; Luis Figueiredo (luisf@hexasoftware.com)</small>
  39. </div>
  40. <!--:value="nodeData"
  41. @input="documentUpdate"-->
  42. <hx-split
  43. dir="horizontal"
  44. :resizeable="true"
  45. :split="funcsSize"
  46. @onSplitResize="funcsSizeUpdate"
  47. >
  48. <div class="flow-panel__container">
  49. <div class="flow-panel__selector">
  50. <button :class="{active:panel=='palette'}" @click="panel='palette'">Funcs</button>
  51. <button :class="{active:panel=='inspector'}" @click="panel='inspector';">Inspector</button>
  52. </div>
  53. <transition name="fade">
  54. <flow-funcs
  55. v-show="panel=='palette'"
  56. @toggleResizeable="funcsResizeable=!funcsResizeable"
  57. @toggleStickySockets="managerStickySockets=!managerStickySockets"
  58. />
  59. </transition>
  60. <transition name="fade">
  61. <flow-inspector
  62. ref="inspector"
  63. v-show="panel=='inspector'"
  64. @nodeProcess="nodeProcess($event)"
  65. />
  66. </transition>
  67. </div>
  68. <flow-editor
  69. ref="flowManager"
  70. @nodeInspect="nodeInspectStart(...arguments)"
  71. @nodeProcess="nodeProcess(...arguments)"
  72. @nodeDblClick="nodeInspectStart(...arguments,true)"
  73. @documentSave="documentSave"
  74. width="100%"
  75. height="100%"/>
  76. </hx-split>
  77. </div>
  78. <div class="app-chat">
  79. <app-chat/>
  80. </div>
  81. <flow-notifications/>
  82. </div>
  83. </div>
  84. </template>
  85. <script>
  86. import {mapGetters, mapActions} from 'vuex'
  87. import AppChat from '@/components/chat'
  88. import FlowEditor from '@/components/flow/editor'
  89. import FlowPanzoom from '@/components/flow/panzoom'
  90. import FlowNotifications from '@/components/flow/notifications'
  91. import FlowFuncs from './panel-funcs'
  92. import FlowInspector from './panel-inspector'
  93. import HxSplit from '@/components/shared/hx-split'
  94. import HxModal from '@/components/shared/hx-modal'
  95. import 'reset-css/reset.css'
  96. import '@/assets/dark-theme.css'
  97. import '@/assets/style.css'
  98. // import nodeData from './nodedata'
  99. export default {
  100. components: {
  101. FlowEditor,
  102. FlowPanzoom,
  103. FlowNotifications,
  104. FlowInspector,
  105. FlowFuncs,
  106. HxSplit,
  107. HxModal,
  108. AppChat
  109. },
  110. data () {
  111. return {
  112. panel: 'palette',
  113. funcsSize: '250px',
  114. funcsResizeable: false,
  115. dark: false
  116. }
  117. },
  118. computed: {
  119. ...mapGetters(['registry', 'activity'])
  120. },
  121. created () {
  122. /* let ctx = this.$route.params.context
  123. let urlPath = [
  124. window.location.host,
  125. ctx,
  126. 'conn'
  127. ]
  128. let targetws = 'ws://' + urlPath.join('/')
  129. if (window.location.protocol === 'https:') {
  130. targetws = 'wss://' + urlPath.join('/')
  131. }
  132. this.$flowService.connect(targetws) */
  133. // Vue.use(FlowService, {location: targetws})
  134. },
  135. mounted () {
  136. // Handle incoming things
  137. this.$flowService.on('sessionJoin', (v) => {
  138. if (v.id !== this.$route.params.sessId) {
  139. this.$router.push('/' + this.$route.params.context + '/' + v.id) // Swap to ID
  140. }
  141. })
  142. this.$flowService.on('sessionLog', (v) => {
  143. console.log(v.data) // Temporary
  144. })
  145. // Connected
  146. /* this.$flowService.connected(() => {
  147. this.NOTIFICATION_ADD('Connected')
  148. // Make this in a service
  149. if (this.$route.params.sessId === undefined) {
  150. console.log('Creating new session')
  151. this.$flowService.sessionNew()
  152. return
  153. }
  154. this.$flowService.sessionLoad(undefined, this.$route.params.sessId)
  155. }) */
  156. },
  157. methods: {
  158. ...mapActions('flow', ['NODE_INSPECT', 'NOTIFICATION_ADD']),
  159. nodeInspectStart (node, changePane) { // node
  160. this.NODE_INSPECT(node.id)
  161. if (changePane) {
  162. this.panel = 'inspector'
  163. }
  164. if (this.panel !== 'inspector') {
  165. return
  166. }
  167. // this.nodeInspect = node
  168. // if (!changePane) { return }
  169. this.$nextTick(() => {
  170. // panel input
  171. if (!this.$refs.inspector) { }
  172. const insp = this.$refs.inspector
  173. let targetInput = insp.$refs.label
  174. if (insp.$refs.inputs && insp.$refs.inputs.length > 0) {
  175. targetInput = insp.$refs.inputs[0]
  176. } else if (insp.$refs.propss && insp.$refs.props.length > 0) {
  177. targetInput = insp.$refs.props[0]
  178. }
  179. if (!targetInput) {
  180. return
  181. }
  182. targetInput.setSelectionRange(0, targetInput.value.length)
  183. targetInput.focus()
  184. })
  185. },
  186. nodeProcess (node) {
  187. this.$flowService.nodeProcess(node.id)
  188. },
  189. funcsSizeUpdate (ev, size) {
  190. this.funcsSize = size
  191. },
  192. documentSave (nodeData) {
  193. this.$flowService.documentSave(nodeData)
  194. }
  195. // Update individual nodes/links
  196. }
  197. }
  198. </script>
  199. <style>
  200. .flow-main {
  201. height:100%;
  202. display:flex;
  203. flex-direction: column;
  204. }
  205. .app-flow-container {
  206. width:100%;
  207. position:relative;
  208. flex:1;
  209. }
  210. .flow-main .flow-container {
  211. position:absolute;
  212. top:0;
  213. right:0;
  214. bottom:0;
  215. left:0;
  216. }
  217. .flow-main .app-header {
  218. padding:0 14px;
  219. height: 50px;
  220. display:flex;
  221. justify-content: space-between;
  222. align-items: center;
  223. }
  224. .app-info {
  225. opacity:0.5;
  226. color: #aaa;
  227. font-size:10px;
  228. margin:20px;
  229. padding:20px;
  230. position:absolute;
  231. right:0;
  232. bottom:3%;
  233. }
  234. .flow-main .app-watermark {
  235. position:absolute;
  236. top:40%;
  237. text-align:center;
  238. width:100%;
  239. font-size:100px;
  240. text-shadow: 1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.05);
  241. }
  242. .split .splitter{
  243. flex-basis:0;
  244. position:relative;
  245. background: rgba(208,208,208,0.9);
  246. }
  247. .split:not(.resizeable) .content:first-child {
  248. transition: all var(--transition-speed);
  249. }
  250. .split.resizeable.horizontal .splitter::after {
  251. opacity:0.4;
  252. display:flex;
  253. justify-content: center;
  254. align-items: center;
  255. z-index:100;
  256. content:" ";
  257. position:absolute;
  258. top:0%;
  259. bottom:0%;
  260. left:0;
  261. width:10px;
  262. background: rgba(0,0,0,0.5);
  263. transition: var(--transition-speed);
  264. }
  265. .app-horizontal {
  266. height:100%;
  267. max-height:100%;
  268. display:flex;
  269. position:relative;
  270. flex-flow:row;
  271. overflow:hidden;
  272. }
  273. .app-chat {
  274. position:absolute;
  275. top:0;
  276. right:0;
  277. height:100%;
  278. }
  279. .flow-panel__container {
  280. display:flex;
  281. flex-flow:column;
  282. flex:1;
  283. overflow:hidden;
  284. }
  285. .flow-panel__selector {
  286. color: var(--normal);
  287. display:flex;
  288. align-content: stretch;
  289. flex-shrink: 0;
  290. height:50px;
  291. border-bottom:solid 1px var(--primary);
  292. }
  293. .flow-panel__selector button{
  294. flex:1;
  295. }
  296. /*
  297. .flow-modal__info {
  298. padding-bottom:20px;
  299. display:flex;
  300. flex-flow:row;
  301. }
  302. .flow-modal__info > * {
  303. margin-right:10px;
  304. flex:1;
  305. }
  306. .flow-modal__body label {
  307. font-size:14px;
  308. display:flex;
  309. flex-flow:row;
  310. font-weight:bold;
  311. padding-bottom:10px;
  312. }
  313. .flow-modal__info .property {
  314. padding-left:20px;
  315. font-size:12px;
  316. }
  317. .flow-modal__properties-error .property{
  318. color: red;
  319. }
  320. .flow-modal__button-run {
  321. align-self: flex-end;
  322. width:100%;
  323. }
  324. .flow-modal__footer {
  325. }*/
  326. </style>