Skip to content

Commit

Permalink
feature(ui): added basic natworking ResponseProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
jankapunkt committed Jul 4, 2023
1 parent 3289fb5 commit 56b605d
Show file tree
Hide file tree
Showing 6 changed files with 8,430 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ResponseProcessorTypes } from '../../ResposeProcessorTypes'
import { ResponseDataTypes } from '../../../../../api/plugins/ResponseDataTypes'

export const Network = {
name: 'render',
label: 'responseProcessors.render.title',
type: ResponseProcessorTypes.aggregate.name,
dataTypes: [ResponseDataTypes.textList.name],
isResponseProcessor: true,
icon: 'cubes',
schema: {},
helpers: {},
renderer: {
template: 'rpNetwork',
load: async function load () {
return import('./renderer/network')
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template name="rpNetwork">
<div class="vis-base-container" style="height: 50vh;"></div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import './network.html'
import { Network } from '../Network'
import vis from 'vis-network/standalone/index'
import 'vis-network/dist/dist/vis-network.css'

const API = Template.rpNetwork.setDependencies({

Check failure on line 6 in src/imports/contexts/tasks/responseProcessors/aggregate/network/renderer/network.js

View workflow job for this annotation

GitHub Actions / Javascript lint

'API' is assigned a value but never used

Check failure on line 6 in src/imports/contexts/tasks/responseProcessors/aggregate/network/renderer/network.js

View workflow job for this annotation

GitHub Actions / Javascript lint

'Template' is not defined
context: [Network],
debug: true
})

Template.rpNetwork.onRendered(function () {

Check failure on line 11 in src/imports/contexts/tasks/responseProcessors/aggregate/network/renderer/network.js

View workflow job for this annotation

GitHub Actions / Javascript lint

'Template' is not defined
const instance = this

instance.autorun(function () {
const templateData = Template.currentData()

Check failure on line 15 in src/imports/contexts/tasks/responseProcessors/aggregate/network/renderer/network.js

View workflow job for this annotation

GitHub Actions / Javascript lint

'Template' is not defined
const nodeData = templateData.results
.map(resultDoc => {
return resultDoc.response.map((response, index) => {
return {
id: `${resultDoc._id}-${index}`,
label: response,
createdBy: resultDoc.createdBy,
cid: 1
}
})
})
.flat()

const nodes = new vis.DataSet(nodeData)

const container = instance.$('.vis-base-container').get(0)
// provide the data in the vis format
const data = { nodes, edges: undefined }
const options = {
autoResize: true,
width: '100%',
// Height percentual settings have only effect, if all parent height are also set to 100% - See also boocmap.css
height: '100%',
physics: {
enabled: false
},
interaction: {
keyboard: true
}
}
const net = new vis.Network(container, data, options)

Check failure on line 46 in src/imports/contexts/tasks/responseProcessors/aggregate/network/renderer/network.js

View workflow job for this annotation

GitHub Actions / Javascript lint

'net' is assigned a value but never used
setTimeout(() => {

}, 3000)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { VideoGallery } from '../../../contexts/tasks/responseProcessors/aggrega
import { AudioList } from '../../../contexts/tasks/responseProcessors/aggregate/audioList/AudioList'
import { DocumentList } from '../../../contexts/tasks/responseProcessors/aggregate/documentList/DocumentList'
import { Cluster } from '../../../contexts/tasks/responseProcessors/aggregate/cluster/Cluster'
import { Network } from '../../../contexts/tasks/responseProcessors/aggregate/network/Network'
import { Text } from '../../../contexts/tasks/responseProcessors/aggregate/text/Text'
import { GroupText } from '../../../contexts/tasks/responseProcessors/aggregate/groupText/GroupText'
import { ContextRegistry } from '../../../infrastructure/context/ContextRegistry'
Expand All @@ -28,7 +29,8 @@ import { onClientExec, onServerExec } from '../../../api/utils/archUtils'
VideoGallery,
AudioList,
DocumentList,
Cluster
Cluster,
Network
].forEach(function (context) {
try {
ResponseProcessorRegistry.register(context)
Expand Down
Loading

0 comments on commit 56b605d

Please sign in to comment.