|
1 | 1 | # datalog-console
|
| 2 | + |
2 | 3 | Administration UI for Datascript, Datahike, and other Datalog databases
|
| 4 | + |
| 5 | +## Integrations |
| 6 | + |
| 7 | +- [homebase-react](https://github.com/homebaseio/homebase-react) `>=0.7.0` |
| 8 | + |
| 9 | +## Installation and Usage |
| 10 | + |
| 11 | +Install the extension and visit a url with an Datalog db that has the `datalog-console` integration (such as the `homebase-react` [demo](https://homebaseio.github.io/homebase-react/#!/dev.example.todo)). You will see a green dot appear next to the icon with the following pop up message upon clicking the extension. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +Open the Chrome console and look for the Datalog DB tab. Load the database with the button in the top right of the panel and you are ready to go. |
| 16 | + |
| 17 | + |
| 18 | +### Features |
| 19 | + |
| 20 | +You will find 3 views in the Datalog DB panel. |
| 21 | +- [Schema](#schema) |
| 22 | +- [Entities](#entities) |
| 23 | +- [Entity](#entity) |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +#### Schema |
| 28 | + |
| 29 | +If a schema exists in the database it will use this and in the case of schema on read it will also infer the schema based on contents of the database. |
| 30 | + |
| 31 | +_An example of Schema inference_. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +#### Entities |
| 36 | + |
| 37 | +Renders a list of entities found in the database. Clicking on any of these entities renders them in the Entity view. |
| 38 | + |
| 39 | +#### Entity |
| 40 | + |
| 41 | +Directly look up an entity by `id` or `unique attribute`. This renders a tree view of an entity where you can also traverse it's reverse references. |
| 42 | + |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Development |
| 47 | + |
| 48 | +Make sure you have Java and the Clojure CLI [installed](https://clojure.org/guides/getting_started). There are ways to get by without these given this project mostly relies on Javascript, but using the Clojure JVM CLI allows us to resolve dependencies in a more flexible way, which comes in really handy when developing across dependencies. |
| 49 | + |
| 50 | +```bash |
| 51 | +yarn install |
| 52 | +yarn dev |
| 53 | +``` |
| 54 | +When running for the first time you will want to run Tailwind to generate the styles. |
| 55 | + |
| 56 | +```bash |
| 57 | +yarn build:tailwind:dev |
| 58 | +``` |
| 59 | + |
| 60 | +### Load the dev extension into the Chrome browser |
| 61 | + |
| 62 | +1. Go to `chrome://extensions/` |
| 63 | +2. Turn on **developer mode** in top right |
| 64 | +3. Load unpacked `your-file-path-to/datalog_console/shells/chrome` |
| 65 | + |
| 66 | +To view the datalog panel open the Chrome console with either of these options. |
| 67 | +- Right click anywhere on the page -> Inspect |
| 68 | +- **Option + ⌘ + J** (on macOS) |
| 69 | +- **Shift + CTRL + J** (on Windows/Linux) |
| 70 | + |
| 71 | +### Connect the REPL |
| 72 | + |
| 73 | +You can connect a repl to each process by opening new windows in your terminal and doing the following. |
| 74 | + |
| 75 | + |
| 76 | +- `yarn repl-background` - for the background page |
| 77 | +- `yarn repl-panel` - for the devtool panel console |
| 78 | + |
| 79 | +You can also connect your editor connected repl. Selecting build `chrome` gets you background and `chrome-devtool` gets you the panel. |
| 80 | + |
| 81 | +### Runtime environments |
| 82 | + |
| 83 | +There is **3 runtime environments** and 4 environments which both send and receive messages. |
| 84 | +- Application environment |
| 85 | +- **Content script** |
| 86 | +- **Background script** |
| 87 | +- **Chrome panel** |
| 88 | + |
| 89 | +The first one you only have access to via postMessage to the window. You also get read and write access to the DOM (used to signal from the external Application environment that a Datalog DB is available). This is all done through `Content script`. Messages between the `Chrome panel` and `Content script` must go through `Background script`. |
| 90 | + |
| 91 | +#### How to find the console of these environments |
| 92 | + |
| 93 | +- Content script is executed in the standard browser Console |
| 94 | +- Background is executed in the background. Found in figure (Fig: 1) below 👇 |
| 95 | +- Chrome panel is available by opening up the chrome console inside of _Datalog DB_ panel tab |
| 96 | + |
| 97 | + |
| 98 | +(Fig: 1) - To view the background page go to `chrome://extensions/` and click here: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +## Load the dev extension into Firefox |
| 104 | + |
| 105 | +1. Go to `about:debugging#/runtime/this-firefox` |
| 106 | +2. Click **Load Temporary Add-on...** towards the top right |
| 107 | +3. Select any file in `your-file-path-to/datalog_console/shells/chrome` |
| 108 | + |
| 109 | +[Refer to runtime evironments](#runtime-environments) to find where code is executed. |
| 110 | + |
| 111 | + |
| 112 | +(Fig: 2) - To view the background page go to `about:debugging#/runtime/this-firefox` and click here: |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +### Quirks |
| 118 | + |
| 119 | +Execution of code inside of `content-script` will not run on `www.google.com` |
0 commit comments