Skip to content

Commit e8a1eaa

Browse files
committed
htmlui: added experimental HTML-based UI
This is enabled by `kopia server --ui` and can be viewed in a browser at http://localhost:51515/ Right now it can only list snapshots and policies (barely).
1 parent 945708c commit e8a1eaa

33 files changed

+15128
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ test_service_account.json
1717
id_kopia
1818
known_hosts
1919
node_modules/
20+
*_bindata.go

.goreleaser.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# This is an example goreleaser.yaml file with some sane defaults.
22
# Make sure to check the documentation at http://goreleaser.com
3+
before:
4+
hooks:
5+
- make html-ui-bindata
36
builds:
47
- env:
58
- CGO_ENABLED=0
@@ -11,6 +14,8 @@ builds:
1114
- amd64
1215
- arm
1316
- arm64
17+
flags:
18+
- -tags=embedhtml
1419
ldflags:
1520
- -s -w -X "github.com/kopia/kopia/repo.BuildVersion={{.Version}}" -X "github.com/kopia/kopia/repo.BuildInfo={{.Commit}}"
1621
archives:

Makefile

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
COVERAGE_PACKAGES=./repo/...,./fs/...,./snapshot/...
2-
GOLANGCI_LINT_VERSION=v1.18.0
3-
LINTER_TOOL=.tools/bin/golangci-lint
4-
GOVERALLS_TOOL=.tools/bin/goveralls
52
GO_TEST=go test
6-
NODE_VERSION=12.13.0
7-
TOOLS_DIR=$(CURDIR)/.tools
8-
NPM_TOOL=$(TOOLS_DIR)/nodejs/node/bin/npm
3+
4+
include tools/tools.mk
95

106
-include ./Makefile.local.mk
117

@@ -43,19 +39,20 @@ build-linux-arm64:
4339

4440
build-all: build-linux-amd64 build-windows-amd64 build-darwin-amd64 build-linux-arm build-linux-arm64
4541

46-
$(LINTER_TOOL):
47-
mkdir -p .tools
48-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b .tools/bin/ $(GOLANGCI_LINT_VERSION)
49-
50-
$(GOVERALLS_TOOL):
51-
mkdir -p .tools
52-
GO111MODULE=off GOPATH=$(CURDIR)/.tools go get github.com/mattn/goveralls
53-
5442
travis-setup: travis-install-gpg-key travis-install-test-credentials
5543
go mod download
5644

5745
website:
58-
$(MAKE) -C site
46+
$(MAKE) -C site build
47+
48+
html-ui:
49+
$(MAKE) -C htmlui build-html
50+
51+
html-ui-bindata: html-ui $(BINDATA_TOOL)
52+
(cd htmlui/build && $(BINDATA_TOOL) -fs -tags embedhtml -o "$(CURDIR)/internal/server/htmlui_bindata.go" -pkg server -ignore '.map' . static/css static/js static/media)
53+
54+
html-ui-bindata-fallback: $(BINDATA_TOOL)
55+
(cd internal/server && $(BINDATA_TOOL) -fs -tags !embedhtml -o "$(CURDIR)/internal/server/htmlui_fallback.go" -pkg server index.html)
5956

6057
travis-release: test-with-coverage lint vet verify-release integration-tests upload-coverage website stress-test
6158

@@ -169,14 +166,4 @@ travis-create-long-term-repository:
169166

170167
endif
171168

172-
site/node_modules: install-webtools
173-
174-
install-webtools:
175-
mkdir -p $(TOOLS_DIR)/nodejs
176169

177-
ifeq ($(uname),Linux)
178-
curl -LsS https://nodejs.org/dist/v$(NODE_VERSION)/node-v$(NODE_VERSION)-linux-x64.tar.gz | tar zx -C $(TOOLS_DIR)/nodejs
179-
else
180-
curl -LsS https://nodejs.org/dist/v$(NODE_VERSION)/node-v$(NODE_VERSION)-darwin-x64.tar.gz | tar zx -C $(TOOLS_DIR)/nodejs
181-
endif
182-
mv $(TOOLS_DIR)/nodejs/node-v$(NODE_VERSION)* $(TOOLS_DIR)/nodejs/node/

cli/command_server_start.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var (
1616

1717
serverStartCommand = serverCommands.Command("start", "Start Kopia server").Default()
1818
serverStartHTMLPath = serverStartCommand.Flag("html", "Server the provided HTML at the root URL").ExistingDir()
19+
serverStartUI = serverStartCommand.Flag("ui", "Start the server with HTML UI (EXPERIMENTAL)").Bool()
1920
)
2021

2122
func init() {
@@ -36,6 +37,8 @@ func runServer(ctx context.Context, rep *repo.Repository) error {
3637
if *serverStartHTMLPath != "" {
3738
fileServer := http.FileServer(http.Dir(*serverStartHTMLPath))
3839
http.Handle("/", fileServer)
40+
} else if *serverStartUI {
41+
http.Handle("/", http.FileServer(server.AssetFile()))
3942
}
4043
return http.ListenAndServe(*serverAddress, nil)
4144
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/chmduquesne/rollinghash v4.0.0+incompatible
1313
github.com/danieljoos/wincred v1.0.2 // indirect
1414
github.com/efarrer/iothrottler v0.0.1
15+
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
1516
github.com/go-ini/ini v1.46.0 // indirect
1617
github.com/godbus/dbus v4.1.0+incompatible // indirect
1718
github.com/kylelemons/godebug v1.1.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ github.com/efarrer/iothrottler v0.0.0-20141121142253-60e7e547c7fe h1:WAx1vRufH0I
3636
github.com/efarrer/iothrottler v0.0.0-20141121142253-60e7e547c7fe/go.mod h1:zjXkUoNEq44qYz/1TlzBhN2W21rDU3HvDBiJWQAZTq8=
3737
github.com/efarrer/iothrottler v0.0.1 h1:N5uXoCpk8T1nfl8z7l4YIJUI/2/mL5pQNsOkeMuVnH8=
3838
github.com/efarrer/iothrottler v0.0.1/go.mod h1:zGWF5N0NKSCskcPFytDAFwI121DdU/NfW4XOjpTR+ys=
39+
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
40+
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
3941
github.com/go-ini/ini v1.42.0 h1:TWr1wGj35+UiWHlBA8er89seFXxzwFn11spilrrj+38=
4042
github.com/go-ini/ini v1.42.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
4143
github.com/go-ini/ini v1.46.0 h1:hDJFfs/9f75875scvqLkhNB5Jz5/DybKEOZ5MLF+ng4=

htmlui/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
build/

htmlui/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
all:
2+
3+
include ../tools/tools.mk
4+
5+
dev: node_modules
6+
PATH=$(TOOL_PATH) $(NPM_TOOL) run start
7+
8+
build-html: node_modules
9+
PATH=$(TOOL_PATH) $(NPM_TOOL) run build
10+
11+
node_modules: $(NPM_TOOL)
12+
PATH=$(TOOL_PATH) $(NPM_TOOL) install

htmlui/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `npm start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `npm test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `npm run build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `npm run eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).
45+
46+
### Code Splitting
47+
48+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49+
50+
### Analyzing the Bundle Size
51+
52+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53+
54+
### Making a Progressive Web App
55+
56+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57+
58+
### Advanced Configuration
59+
60+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61+
62+
### Deployment
63+
64+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65+
66+
### `npm run build` fails to minify
67+
68+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

htmlui/env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PATH=$(pwd)/../.tools/nodejs/node/bin:$PATH

0 commit comments

Comments
 (0)