Skip to content

Commit

Permalink
works in dev mode at least
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Feb 29, 2024
1 parent 50774c1 commit 3754364
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
9 changes: 8 additions & 1 deletion pmb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# SECURITY WARNING: don't run with debug turned on in production!
if os.environ.get("DEBUG"):
DEBUG = True
VITE_DEV = True
else:
DEBUG = False
VITE_DEV = False

ALLOWED_HOSTS = ["*"]
FIXTURE_DIRS = [os.path.join(BASE_DIR, "fixtures")]
Expand Down Expand Up @@ -300,4 +302,9 @@
},
}

DJANGO_VITE = {"default": {"dev_mode": True}}
DJANGO_VITE = {
"default": {
"dev_mode": VITE_DEV,
"manifest_path": "static/dist/manifest.info"
}
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ django-crispy-forms
django-extensions
django-model-utils
django-tables2
django-vite>=3.0.3,<4
djangorestframework
pandas
pylobid
Expand Down
10 changes: 8 additions & 2 deletions static/src/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cosmograph } from '@cosmograph/cosmograph'
import { Cosmograph, CosmographSearch } from '@cosmograph/cosmograph'
import * as d3 from 'd3';

const edge_csv = "http://127.0.0.1:8000/static/src/edges.csv";
Expand All @@ -24,12 +24,18 @@ Promise.all([edge_promis, node_promis]).then(([edge_data, node_data]) => {
const canvas = document.createElement("div");
canvas.style.height = "800px"
appNode.appendChild(canvas);
const searchContainer = document.createElement('div')
appNode.appendChild(searchContainer);
const config = {
nodeColor: d => d.color,
nodeLabelAccessor: d => d.label,
nodeLabelColor: "white",
hoveredNodeLabelColor: "white",
linkWidth: 2
}
const cosmograph = new Cosmograph(canvas, config)
const search = new CosmographSearch(cosmograph, searchContainer)
cosmograph.setData(nodes, links)
console.log(cosmograph)
search.setData(nodes)
})

5 changes: 1 addition & 4 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ module.exports = {
build: {
outDir: resolve('./static/dist'),
assetsDir: '',
manifest: true,
manifest: "manifest.info",
emptyOutDir: true,
target: 'es2015',
rollupOptions: {
input: {
main: resolve('./static/src/js/main.js'),
},
output: {
chunkFileNames: undefined,
},
},
},
};

0 comments on commit 3754364

Please sign in to comment.