Skip to content

Commit 3b436dc

Browse files
authored
fix: testable and functional view manager (#1192)
* feat: local rest-on-couch instance * fix: fix fancytree regressions * chore: limit exposed network interfaces * chore: cleanup * docs: provide instructions for testing the view manager
1 parent c0380f7 commit 3b436dc

File tree

21 files changed

+184
-2
lines changed

21 files changed

+184
-2
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALLOWED_ORIGINS=http://localhost:63342

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ src/usr/config/default.json
1717

1818
.eslintcache
1919
.sass-cache
20+
.env
21+
22+
couchdb-data

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "rest-on-couch/home/visualizer"]
2+
path = rest-on-couch/home/visualizer
3+
url = https://github.com/cheminfo/roc-visualizer-config.git

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ The visualizer allows the modules to comminucate via a central repository of var
2828

2929
To install the development version of the visualizer, you need Node.js.
3030
Run `npm install` and all the dependencies will be downloaded.
31+
32+
## View manager
33+
34+
To test the view manager, run a local instance of couchdb with rest-on-couch:
35+
36+
```bash
37+
# Edit the .env file if needed, making sure the allowed origin is the dev URL serving the visualizer
38+
cp .env.example .env
39+
git submodule init
40+
docker compose up -d --build
41+
```
42+
43+
Open

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"spectrum": "101b05c1d977fbc529ae4c3b6865b1f7ab70c6e0",
4343
"sprintf": "1.1.3",
4444
"threejs": "r71",
45+
"ui-contextmenu": "1.18.1",
4546
"uri.js": "1.18.4",
4647
"web-animations-js": "2.2.2",
4748
"x2js": "1.2.0",

compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
rest-on-couch:
3+
build: ./rest-on-couch
4+
environment:
5+
COUCHDB_USER: admin
6+
COUCHDB_PASSWORD: 1234
7+
DEBUG: couch:*
8+
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:?Provide the origins in your .env file}
9+
depends_on:
10+
- couchdb
11+
restart: unless-stopped
12+
ports:
13+
- 127.0.0.1:3000:3000
14+
couchdb:
15+
image: docker.io/couchdb:3.4
16+
environment:
17+
COUCHDB_USER: admin
18+
COUCHDB_PASSWORD: 1234
19+
volumes:
20+
- ./couchdb-data:/opt/couchdb/data
21+
- ./config/couch.ini:/opt/couchdb/etc/local.d/couch.ini
22+
restart: unless-stopped

config/couch.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[couchdb]
2+
max_document_size = 4294967296 ; 4 GB
3+
js_engine = quickjs
4+
single_node=true
5+
6+
[chttpd]
7+
bind_address = 0.0.0.0
8+
9+
[uuids]
10+
algorithm = random

gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ module.exports = function (grunt) {
212212
'./sprintf/dist/**',
213213
'./x2js/xml2json*',
214214
'./jit/Jit/**/*',
215+
'./ui-contextmenu/jquery.ui-contextmenu*',
215216
'./colors/css/colors.min.css',
216217
'./uri.js/src/*.js',
217218
'./onde/src/*',

rest-on-couch/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ghcr.io/cheminfo/rest-on-couch:19
2+
3+
RUN apt-get update && \
4+
apt-get install -y jq
5+
6+
COPY /wait.sh /start.sh /create_db.sh /
7+
RUN chmod +x /wait.sh /start.sh /create_db.sh
8+
9+
# Copy config files
10+
11+
# By default /rest-on-couch is the home directory the rest-on-couch image expects.
12+
# Can be overridden by overriding the REST_ON_COUCH_HOME_DIR environment variable.
13+
COPY home /rest-on-couch/
14+
15+
RUN cd /rest-on-couch
16+
17+
WORKDIR /app
18+
19+
CMD ["/start.sh"]

rest-on-couch/create_db.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
/wait.sh
4+
5+
response=$(curl --write-out %{http_code} --silent --output /dev/null http://couchdb:5984/visualizer)
6+
7+
if [ ${response} = "404" ]
8+
then
9+
10+
echo "Database is not instantiated. Create it."
11+
12+
curl -X POST -H "Content-Type: application/json" http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/_cluster_setup -d '{"action": "finish_cluster"}'
13+
14+
# Init rest-on-couch users
15+
curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/_users \
16+
-H 'Content-Type: application/json' \
17+
-d '{ "_id": "org.couchdb.user:rest-on-couch", "name": "rest-on-couch", "type": "user", "roles": [], "password": "'${COUCHDB_PASSWORD}'" }'
18+
19+
curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/_users \
20+
-H 'Content-Type: application/json' \
21+
-d '{ "_id": "org.couchdb.user:[email protected]", "name": "[email protected]", "type": "user", "roles": [], "password": "'${COUCHDB_PASSWORD}'" }'
22+
23+
24+
# Init couchdb databases and security setup, and create rest-on-couch groups (they all can be edited later)
25+
26+
echo "Create visualizer database"
27+
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/visualizer
28+
echo "Create groups in visualizer database"
29+
curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/visualizer \
30+
-H 'Content-Type: application/json' \
31+
-d '{"$type": "group", "$owners": ["[email protected]"], "name": "anonymousRead", "users": [], "rights": ["read"], "$lastModification": "[email protected]", "$modificationDate": 0, "$creationDate": 0}';
32+
curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/visualizer \
33+
-H 'Content-Type: application/json' \
34+
-d '{"$type": "group", "$owners": ["[email protected]"], "name": "anyuserRead", "users": [], "rights": ["read"], "$lastModification": "[email protected]", "$modificationDate": 0, "$creationDate": 0}';
35+
36+
echo "Create default groups in visualizer"
37+
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/visualizer/defaultGroups \
38+
-H 'Content-Type: application/json' \
39+
-d '{"_id": "defaultGroups","$type": "db","anonymous": ["anonymousRead"],"anyuser": ["anyuserRead"]}'
40+
41+
echo "Setup visualizer database _security"
42+
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/visualizer/_security \
43+
-H 'Content-Type: application/json' \
44+
-d '{ "admins": { "names": ["rest-on-couch"], "roles": [] }, "members": { "names": ["rest-on-couch"], "roles": [] } }'
45+
46+
47+
fi

0 commit comments

Comments
 (0)