Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
974a0c5
Refresh UI
ktg Sep 26, 2018
06eb089
Tweaks
ktg Sep 27, 2018
aa1f298
Merge remote-tracking branch 'origin/master'
ktg Oct 16, 2018
e171d51
Support Mobile
ktg Oct 16, 2018
ab00b24
Merge remote-tracking branch 'origin/master'
ktg Oct 22, 2018
bc5052d
Lots of improvements/bug fixes
ktg Nov 1, 2018
7896d2b
Simplify dockerfile
ktg Nov 8, 2018
3ea994d
Install driver for app
ktg Nov 8, 2018
2a4e3ad
Fix bug with login host
ktg Nov 9, 2018
68677ad
Fix view path
ktg Nov 9, 2018
327b40f
Add link to app-store
ktg Nov 9, 2018
4ecae1b
Fix path
ktg Nov 9, 2018
b230e94
New databox UI (#2)
Toshbrown Nov 9, 2018
528876b
Fix app install
Toshbrown Nov 10, 2018
f47f874
Remove appAsDriver hack
Toshbrown Nov 12, 2018
6336779
Update lib-go-databox version
Toshbrown Nov 12, 2018
14a4150
remove unused file
Toshbrown Nov 13, 2018
9e25c1b
Move to FUNC based API calls for
Toshbrown Nov 13, 2018
53be03b
Reduce poll time on the Home.vue
Toshbrown Nov 13, 2018
513c110
Show installed apps in app store
ktg Nov 19, 2018
e0a0e9a
Merge
ktg Nov 20, 2018
d494de2
Login error feedback
ktg Nov 20, 2018
808b8ce
Fix me-box/core-ui#3
ktg Nov 21, 2018
2a25a20
Fix me-box/core-ui#5 & other stories
ktg Nov 22, 2018
86c277d
Many changes for app support
ktg Dec 6, 2018
b8e0974
iOS Fixes
ktg Dec 17, 2018
49063cc
More bug fixes
ktg Jan 21, 2019
82f0af9
Improved QR scanning
ktg Jan 21, 2019
58698ba
Merge remote-tracking branch 'origin/master'
ktg Mar 27, 2019
bbacc06
Update build
ktg Oct 3, 2019
998266a
Merge
ktg Oct 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.5-alpine3.8 as gobuild
FROM golang:alpine as gobuild
WORKDIR /
ENV GOPATH="/go"
RUN apk update && apk add build-base git zeromq-dev
Expand All @@ -12,7 +12,7 @@ COPY ./src ./src
RUN addgroup -S databox && adduser -S -g databox databox
RUN GGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -w' -o app /src/*.go

FROM amd64/alpine:3.8
FROM amd64/alpine
COPY --from=gobuild /etc/passwd /etc/passwd
RUN apk update && apk add libzmq
USER databox
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-arm64v8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM arm64v8/golang:1.11.5-alpine3.8 as gobuild
FROM arm64v8/golang:alpine as gobuild
WORKDIR /
ENV GOPATH="/go"
RUN apk update && apk add build-base git zeromq-dev
Expand All @@ -11,7 +11,7 @@ COPY ./src ./src
RUN addgroup -S databox && adduser -S -g databox databox
RUN GGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -w' -o app /src/*.go

FROM arm64v8/alpine:3.8
FROM arm64v8/alpine
COPY --from=gobuild /etc/passwd /etc/passwd
RUN apk update && apk add libzmq
USER databox
Expand Down
3 changes: 2 additions & 1 deletion src/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func main() {

//HTTPS API
router.HandleFunc("/status", statusEndpoint).Methods("GET")
router.HandleFunc("/ui/api/connect", connect).Methods("GET")
router.HandleFunc("/ui/api/appStore", getApps(&cfg)).Methods("GET")
router.HandleFunc("/ui/api/containerStatus", containerStatus(&cfg)).Methods("GET")
//router.HandleFunc("/ui/api/containerStatus2", containerStatus2(&cfg)).Methods("GET")
router.HandleFunc("/ui/api/dataSources", dataSources(&cfg)).Methods("GET")
router.HandleFunc("/ui/api/drivers/{name}", getDrivers(&cfg)).Methods("GET")
router.HandleFunc("/ui/api/manifest/{name}", getManifest(&cfg)).Methods("GET")
Expand All @@ -70,6 +70,7 @@ func main() {
router.HandleFunc("/ui/cert.pem", certPub(&cfg)).Methods("GET")
router.HandleFunc("/ui/cert.der", certPubDer(&cfg)).Methods("GET")
router.PathPrefix("/ui/{type:css|icons|js}/").Handler(http.StripPrefix("/ui", http.FileServer(http.Dir("./www")))).Methods("GET")
router.PathPrefix("/ui/{type:manifest.json|cordova.js|service-worker.js|precache-manifest.|robots.txt}").Handler(http.StripPrefix("/ui", http.FileServer(http.Dir("./www")))).Methods("GET")
router.PathPrefix("/ui/").Handler(http.HandlerFunc(serveIndex)).Methods("GET")

//router.Use(loggingMiddleware)
Expand Down
4 changes: 4 additions & 0 deletions src/end_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func statusEndpoint(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("active\n"))
}

func connect(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("success\n"))
}

func qrcode(config *config) func(w http.ResponseWriter, r *http.Request) {
cfg := config

Expand Down
2 changes: 2 additions & 0 deletions ui/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VUE_APP_BASE_URL=/core-ui/ui/
NODE_ENV=production
2 changes: 2 additions & 0 deletions ui/.env.mobile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VUE_APP_BASE_URL=
NODE_ENV=production
14,538 changes: 7,177 additions & 7,361 deletions ui/package-lock.json

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
"private": true,
"scripts": {
"build": "vue-cli-service build --modern",
"build.app": "vue-cli-service build --dest '../../databox-app/www' 'src/app.js'"
"watch": "vue-cli-service build --modern --watch",
"build.app": "vue-cli-service build --mode mobile --dest '../../databox-app/www' 'src/app.js'",
"watch.app": "vue-cli-service build --watch --mode mobile --dest '../../databox-app/www' 'src/app.js'",
"run.android": "vue-cli-service build --mode mobile --dest '../../databox-app/www' 'src/app.js' && cd ../../databox-app && cordova run android"
},
"dependencies": {
"material-components-web": "^0.41.1",
"material-components-web": "^0.44.1",
"node-sass": "^4.12.0",
"npm": "^6.11.3",
"register-service-worker": "^1.5.2",
"sass-loader": "^7.1.0",
"vue": "^2.5.17",
"vue-async-computed": "^3.5.0",
"vue-router": "^3.0.1"
"register-service-worker": "^1.6.2",
"sass-loader": "^8.0.0",
"vue": "^2.6.10",
"vue-async-computed": "^3.7.0",
"vue-router": "^3.1.3",
"vue-template-compiler": "^2.6.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.1.1",
"@vue/cli-plugin-eslint": "^3.1.5",
"@vue/cli-plugin-pwa": "^3.1.2",
"@vue/cli-service": "^3.1.4",
"vue-template-compiler": "^2.5.17"
"@vue/cli-plugin-babel": "^3.3.0",
"@vue/cli-plugin-eslint": "^3.3.0",
"@vue/cli-plugin-pwa": "^3.3.0",
"@vue/cli-service": "^3.3.0"
},
"eslintConfig": {
"root": true,
Expand Down
Empty file added ui/public/cordova.js
Empty file.
1 change: 1 addition & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" >
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono:300,400,500">
<script src="cordova.js"></script>
</head>
<body>
<noscript>
Expand Down
111 changes: 75 additions & 36 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<div id="app">
<header class="mdc-top-app-bar" v-if="authenticated">
<header class="mdc-top-app-bar" v-if="title !== null">
<div class="mdc-top-app-bar__row">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
<a v-if="backRoute" v-on:click="back" class="material-icons mdc-top-app-bar__navigation-icon">
arrow_back
</a>
<span class="mdc-top-app-bar__title">{{ title }}</span>
</section>
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" v-if="authenticated">
<router-view name="toolbar" style="display: flex"></router-view>
<div class="mdc-menu-surface--anchor">
<div class="material-icons mdc-top-app-bar__action-item" @click="openNotifications">
Expand All @@ -30,10 +30,10 @@

<div class="mdc-top-app-bar--fixed-adjust">
<div v-if="connecting" id="content">
<Spinner />
<Spinner/>
</div>
<div v-else id="content">
<router-view />
<router-view/>
</div>
</div>
</div>
Expand All @@ -42,6 +42,9 @@
<script>
import {MDCMenuSurface} from '@material/menu-surface';
import Spinner from "./components/Spinner";
import testdata from './testData/status.json'

const DATABOX_URL = "databoxURL";

export default {
name: 'app',
Expand All @@ -50,23 +53,32 @@
return {
title: 'Databox Dashboard',
backRoute: null,
databoxUrl: "localhost",
databoxUrl: '',
connecting: true,
authenticated: false,
notifications: [],
notificationMenu: null,
}
},
created() {
if (localStorage.getItem("databoxUrl") !== null) {
this.databoxUrl = localStorage.getItem("databoxUrl");
const storedUrl = localStorage.getItem(DATABOX_URL);
if (storedUrl !== null) {
this.databoxUrl = storedUrl;
} else if (!this.isMobile) {
this.databoxUrl = window.location.hostname;
}
this.apiRequest('/core-ui/ui/api/containerStatus', {})
.then(() => {
this.connecting = false;
this.authenticated = true;
//this.$router.replace("/");
})
.catch((error) => {
console.log("Connect Failed");
console.log(error);
this.connecting = false;
this.authenticated = false;
this.$router.replace("/login");
})
},
updated() {
Expand All @@ -78,11 +90,15 @@
},
watch: {
title(val) {
document.title = val
if (val) {
document.title = val
} else {
document.title = "Databox Dashboard"
}
}
},
methods: {
apiRequest: function (url, cannedData, opts = {}) {
request(url, opts = {}) {
opts.credentials = 'include';
opts.mode = 'cors';
return fetch('https://' + this.databoxUrl + url, opts)
Expand All @@ -93,61 +109,83 @@
return response;
}
})
.then((response) => {
return response.json()
})
.catch((err) => {
this.connecting = false;
if (err.status === 401 || err.status === 404) {
if (err.status === 401) {
this.authenticated = false;
this.$router.replace("/login");
throw err;
} else if (this.isDev) {
return cannedData
} else {
throw err;
}
});
},
apiRequest(url, cannedData, opts = {}) {
opts.credentials = 'include';
opts.mode = 'cors';
return this.request(url, opts)
.then((response) => {
return response.json()
})
.catch((error) => {
if (this.isDev) {
return cannedData
} else {
throw error
}
});
},
async installAndWait(manifest) {
await this.apiRequest('/core-ui/ui/api/install', {}, {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
manifest: manifest,
}),
});
await this.waitForInstall(manifest.name);
},
async waitForInstall(appName) {
while (true) {
let json = await this.apiRequest('/core-ui/ui/api/containerStatus', testdata);
for (const app of json) {
if (app.name === appName) {
return;
}
}
await new Promise((resolve) => {
setTimeout(() => resolve(), 2000)
});
}
},
logout() {
this.authenticated = false;
this.$router.replace("/login");
},
login(url, password) {
this.databoxUrl = url;
localStorage.setItem('databoxURL', url);
return fetch('https://' + url + '/core-ui/ui/api/connect', {
localStorage.setItem(DATABOX_URL, url);
return this.request('/core-ui/ui/api/connect', {
method: "GET",
credentials: "include",
mode: "cors",
headers: {
'Authorization': "Token " + password,
},
})
.then((response) => {
if (!response.ok) {
throw {message: response.statusText, status: response.status};
} else {
return response;
}
})
.then((response) => {
return response.text()
})
.then((body) => {
if (body === "connected") {
this.authenticated = true;
localStorage.setItem('databoxAuthenticated', 'true');
this.$router.replace("/")
} else {
return Promise.reject("Auth failed")
}
.then(() => {
this.authenticated = true;
this.$router.replace("/")
})
.catch((error) => {
if (this.isDev) {
this.authenticated = true;
this.$router.replace("/")
} else {
console.log(error);
this.authenticated = false;
throw error;
}
Expand All @@ -157,7 +195,7 @@
this.$router.push(this.backRoute);
},
openNotifications() {
if(this.notificationMenu != null && this.notifications.length > 0) {
if (this.notificationMenu != null && this.notifications.length > 0) {
this.notificationMenu.open = true;
}
}
Expand All @@ -177,6 +215,7 @@
@import "~@material/menu-surface/mdc-menu-surface";
@import "~@material/select/mdc-select";
@import "~@material/textfield/mdc-text-field";
@import "~@material/typography/mdc-typography";
@import "~@material/theme/mdc-theme";
@import "~@material/top-app-bar/mdc-top-app-bar";

Expand Down
Loading