Skip to content

Commit 165ec2f

Browse files
feat: set server URL via env vars, and improvements to README (#280)
Co-authored-by: Erik Bjäreholt <[email protected]>
1 parent 4f2139b commit 165ec2f

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"node": true
5050
},
5151
"globals": {
52-
"PRODUCTION": false
52+
"PRODUCTION": false,
53+
"AW_SERVER_URL": false
5354
},
5455
"overrides": [
5556
{

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A web-based UI for ActivityWatch, built with Vue.js
1111
Getting started with setting up the development environment is pretty straight forward:
1212

1313
```bash
14-
# Start an instance of aw-server running in testing mode (on port 5666, with a separate database),
14+
# Start an instance of aw-server running in testing mode (on port 5666, with a separate database),
1515
# This is what the web UI will connect to by default when run in development mode.
1616
aw-qt --testing
1717
# or, to run without watchers:
@@ -26,6 +26,8 @@ npm ci
2626
npm run serve
2727
```
2828

29+
Alternatively, you can run `make dev` to install dependencies and serve the application locally.
30+
2931
You might have to configure CORS for it to work, see the CORS section below.
3032

3133
You may also want to generate fake data so you have something to test with, see: https://github.com/ActivityWatch/aw-fakedata/
@@ -53,8 +55,23 @@ The assets are stored in the following directories (relative to your installatio
5355
- aw-server-python: `activitywatch/aw-server/aw_server/static/`
5456
- aw-server-rust: `activitywatch/aw-server-rust/static/`
5557

58+
Either copy the assets manually, or run `make build` from the `aw-server` parent directory to rebuild and copy the assets for you.
59+
5660
Once you've put the files in the directories, you may have to do a hard refresh in your browser to invalidate any stale caches.
5761

62+
If you want to actively iterate on aw-webui with your local production data, you'll want to use a development build, automatically update it, and connect a aw-server running against production data. To do this, in one terminal window run:
63+
64+
```bash
65+
AW_SERVER_URL="'http://localhost:5600'" npx vue-cli-service build --watch --dest=../aw_server/static
66+
```
67+
68+
If you want to add `debugger` statements in your code and otherwise break linting rules, you'll need to add a `--skip-plugins=no-debugger` to that command. Then, in another terminal (with your venv activated, assuming you are using python aw-server) run:
69+
70+
```shell
71+
poetry install
72+
aw-server
73+
```
74+
5875
## Tests
5976

6077
Tests can be run with:

src/util/awclient.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ let baseURL = '';
55
// If running with `npm node dev`, use testing server as origin.
66
// Works since CORS is enabled by default when running `aw-server --testing`.
77
if (!PRODUCTION) {
8-
const protocol = 'http';
9-
const hostname = '127.0.0.1';
10-
const port = '5666';
11-
baseURL = protocol + '://' + hostname + ':' + port;
8+
baseURL = AW_SERVER_URL || 'http://127.0.0.1:5666';
129
}
1310

1411
const awc = new AWClient('aw-webui', { testing: !PRODUCTION, baseURL });

vue.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
plugins: [
2929
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
3030
new webpack.DefinePlugin({
31+
AW_SERVER_URL: process.env.AW_SERVER_URL,
3132
PRODUCTION: process.env.NODE_ENV === 'production',
3233
}),
3334
new CopyWebpackPlugin([{ from: 'static/', to: 'static' }]),

0 commit comments

Comments
 (0)