Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Electron update #4811

Merged
merged 76 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
a3861cf
Add supprot for no authentication
nwmac Jun 20, 2020
01930b2
Merge remote-tracking branch 'origin/master' into no-auth
nwmac Jul 11, 2020
a7b89cd
Electron WIP
nwmac Jul 11, 2020
1be7906
Electron app WIP
nwmac Jul 13, 2020
99b4b99
Add packaging
nwmac Jul 13, 2020
761ca4d
Wait for backend to start
nwmac Jul 13, 2020
ea44c2f
Non-functional tidy ups
richard-cox Jul 13, 2020
2d41211
Move desktop theme into desktop-extentions
richard-cox Jul 13, 2020
b778547
Disable auto-log out when there's no auth
richard-cox Jul 13, 2020
29b7681
Add Local flag
nwmac Jul 13, 2020
b1332e5
Remove jetstream binary
nwmac Jul 13, 2020
b419d0b
Merge branch 'electron' of github.com:cloudfoundry/stratos into electron
nwmac Jul 13, 2020
811a6a7
Allow SessionExpiry to be customised
richard-cox Jul 13, 2020
3ef28ea
Add SESSION_STORE_EXPIRY customisation
richard-cox Jul 13, 2020
97ee8fa
Re-enable loggin service
richard-cox Jul 13, 2020
8b47057
Logging change
richard-cox Jul 13, 2020
51265ed
Disable edit of local endpoints
richard-cox Jul 14, 2020
a8478f6
Add local endpoint indication
richard-cox Jul 14, 2020
76acb76
Allow packages to only supply routing module
richard-cox Jul 14, 2020
11c5eab
Split out profile settings into it's own component
richard-cox Jul 14, 2020
b48fe03
Add back in dark mode
richard-cox Jul 14, 2020
8d386bd
Add desktop settings page accessible via menu
richard-cox Jul 14, 2020
18629e6
Fix SESSION_STORE_EXPIRY
richard-cox Jul 14, 2020
50e2fa4
Add icon
richard-cox Jul 14, 2020
99609c5
Add correct icon
richard-cox Jul 15, 2020
caf0aa9
Add blank login page
richard-cox Jul 15, 2020
d7f4aaa
Add basic snackbar integration
richard-cox Jul 15, 2020
3c6a531
Add a 'install' nav item into desktop-extensions
richard-cox Jul 15, 2020
52dbc98
Tweaks
nwmac Jul 14, 2020
c4891ef
Tweak endpoint card
nwmac Jul 16, 2020
b9099c3
Remove unused loadsh
nwmac Jul 16, 2020
0250689
A fwe tweaks. Better about page
nwmac Jul 16, 2020
3b6de35
Add file watch
nwmac Jul 16, 2020
5fe6ba1
Add auto-update support
nwmac Jul 17, 2020
84d47ed
Bug fixes for cf
nwmac Jul 17, 2020
f41b405
Only listen for endpointsChanged when running with eletron
richard-cox Jul 17, 2020
e7ba5f0
Mirror CF Disconnect/Unregister in config
richard-cox Jul 17, 2020
39b0392
Add warning when disconnecting/unregistering local endpoints
richard-cox Jul 17, 2020
ebf4324
Improve look of DMG
nwmac Jul 17, 2020
ee7f547
Merge branch 'electron' of github.com:cloudfoundry/stratos into electron
nwmac Jul 17, 2020
9f6cb4a
Tweak alert badge. Remove copyright icon
nwmac Jul 17, 2020
7b9aed7
Remove info logging that was debug
nwmac Jul 17, 2020
ab577d1
Tweaks
nwmac Jul 17, 2020
45595c4
Persist last location, start from location
richard-cox Jul 17, 2020
700048d
Fix path
richard-cox Jul 17, 2020
e9f46d2
Minor tweaks
nwmac Jul 17, 2020
0231efa
Merge branch 'electron' of github.com:cloudfoundry/stratos into electron
nwmac Jul 17, 2020
aa0eeb7
Tweaks
nwmac Nov 27, 2020
69ceb3f
Merge remote-tracking branch 'origin/master' into electron
nwmac Nov 27, 2020
12501e1
Fix lint issues
nwmac Nov 27, 2020
dedb9a8
Fix compilation issues
nwmac Nov 27, 2020
649b5d5
Fix backend test compilation
nwmac Nov 27, 2020
b3bdf8f
Fix front-end unit tests
nwmac Nov 27, 2020
318788c
Add test coverage file
nwmac Nov 27, 2020
f4377ef
Fix build issue
nwmac Nov 30, 2020
048427f
Fix merge issue
nwmac Nov 30, 2020
d47e06b
Fix backend unit tests
nwmac Nov 30, 2020
3c0164e
Fix setting bug and read version from file
nwmac Dec 1, 2020
257f88f
Exclude desktop extension by default
nwmac Dec 1, 2020
e57b57e
More improvements
nwmac Dec 1, 2020
ab6160d
Improvements for initial checkout
nwmac Dec 1, 2020
d916829
Tweak to clean checkout experience
nwmac Dec 1, 2020
8eac32b
Tidy up
nwmac Dec 1, 2020
2a6d907
Bump version number to 4.4.0
nwmac Dec 1, 2020
a8fa21d
Merge remote-tracking branch 'origin/master' into electron-update
nwmac Dec 2, 2020
4384c00
Fix bug that broke id on user menu button
nwmac Dec 3, 2020
528b634
Merge remote-tracking branch 'origin/master' into electron-update
richard-cox Dec 9, 2020
9bb5162
Fixes following merge
richard-cox Dec 9, 2020
3bd7960
Fix deploy app snack bar
richard-cox Dec 9, 2020
9313f8d
Ensure backend plugin is included
nwmac Dec 9, 2020
00ba0ae
Add kube desktop support
nwmac Dec 9, 2020
8f134ef
Fix unit tests
richard-cox Dec 9, 2020
085f247
Merge remote-tracking branch 'origin/master' into electron-update
nwmac Dec 9, 2020
9aa808e
Fix backend build issue
nwmac Dec 10, 2020
ee48bc5
A few minor fixes
nwmac Dec 10, 2020
8d30436
Fix issue reading version file
nwmac Dec 10, 2020
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
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ build/dev_config.json
e2e-reports/
.stratos-git-metadata.json
src/jetstream/jetstream
src/jetstream/console-database.db
console-database.db
src/jetstream/config.properties
src/jetstream/db/dbconf.yml
src/jetstream/plugins/monocular/chart-repo/chartrepo
src/jetstream/plugins/analysis/container/analyzers
src/jetstream/.helm-cache
src/jetstream/coverage.txt

# Automatically generated OpenAPI docs
src/jetstream/docs/
Expand Down Expand Up @@ -139,3 +140,11 @@ website/versions.json
website/versions-repo

/scan_tmp

# Desktop app using Electron
/electron/dist
/electron/node_modules
/electron/out
/electron/dev-ssl
/electron/jetstream
/electron/version
19 changes: 19 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,23 @@
"replace": "src/frontend/packages/core/src/environments/environment.ts",
"with": "src/frontend/packages/core/src/environments/environment.prod.ts"
}]
},
"desktop": {
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [{
"replace": "src/frontend/packages/core/src/environments/environment.ts",
"with": "src/frontend/packages/core/src/environments/environment.desktop.ts"
}]
}

}
},
"serve": {
Expand All @@ -89,6 +105,9 @@
"configurations": {
"production": {
"browserTarget": "stratos:build:production"
},
"desktop": {
"browserTarget": "stratos:build:desktop"
}
}
},
Expand Down
21 changes: 21 additions & 0 deletions electron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Stratos Desktop

From the top-level Stratos folder:

- Install dependencies with `npm install`
- Change to the `electron folder` with `cd electron`
- Install dependencies for the electron UI with `npm install`
- Run the Electron app with `./run.sh all`

> Note this builds both the frontend and backend and run the app

- To build only the front end before running, use `./run.sh fe`
- To build only the back end before running, use `./run.sh be`
- To run without building either the the back end or front end, use `./run.sh`


You can also run the UI with `ng serve` from the top-level folder and then start electron with:

`./run.sh dev`

to load the UI from `https://127.0.0.1:4200`
Binary file added electron/VolumeIcon.icns
Binary file not shown.
76 changes: 76 additions & 0 deletions electron/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<html>
<body>
<head>
<style>
body {
font-family: "Lato", "Helvetica", "Arial";
margin: 0;
}
.about {
padding: 10px;
text-align: right;
}
.panel {
align-items: center;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
margin: 10px;
}
.title {
align-items: center;
display: flex;
font-family: "Lato", "Helvetica", "Arial";
}
img {
height: 64px;
width: 64px;
}
h1 {
margin: 0;
padding-left: 10px;
}
h2 {
font-size: 16px;
margin-top: 20px;
text-align: center;
}
P {
margin-top: 40px;
}
button {
position: absolute;
right: 10px;
bottom: 10px;
}
</style>
</head>
</body>
<div class="about">
<div class="panel">
<div class="title">
<img src="logo.png" />
<h1>STRATOS</h1>
</div>
<div>
<h2>Version: <span id="version"></span></h2>
<p>Lovingly designed & created in Bristol</p>
</div>
</div>
<button id="cancel-btn">Close</button>
</div>
<script>
const electron = require('electron');
const remote = electron.remote;
document.getElementById("cancel-btn").addEventListener("click", function (e) {
var window = remote.getCurrentWindow();
window.close();
});

// Set version number
const version = remote.getCurrentWindow().stratosVersion || 'dev';
const elm = document.getElementById('version');
elm.innerText = version;
</script>
</html>
Binary file added electron/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions electron/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Database connectivity environment variables
DATABASE_PROVIDER=sqlite
HTTP_CONNECTION_TIMEOUT_IN_SECS=10
HTTP_CLIENT_TIMEOUT_IN_SECS=30
HTTP_CLIENT_TIMEOUT_MUTATING_IN_SECS=120
HTTP_CLIENT_TIMEOUT_LONGRUNNING_IN_SECS=600
SKIP_SSL_VALIDATION=true
CONSOLE_PROXY_TLS_ADDRESS=:5443
CONSOLE_CLIENT=console
CF_CLIENT=cf
UAA_ENDPOINT=
CONSOLE_ADMIN_SCOPE=stratos.admin
CF_ADMIN_ROLE=cloud_controller.admin
ALLOWED_ORIGINS=http://nginx
SESSION_STORE_SECRET=wheeee!
CONSOLE_PROXY_CERT_PATH=./dev-ssl/server.crt
CONSOLE_PROXY_CERT_KEY_PATH=./dev-ssl/server.key
ENCRYPTION_KEY=B374A26A71490437AA024E4FADD5B497FDFF1A8EA6FF12F6FB65AF2720B59CCF
#VCAP_APPLICATION={"cf_api": "https://api.10.4.21.240.nip.io:8443"}
# Keep the sql lite database file
SQLITE_KEEP_DB=true

# UI code in the parent folder
UI_PATH=./dist

LOG_TO_JSON=false
LOG_API_REQUESTS=true

SSO_LOGIN=false
# Whitelist for the SSO redirect url. Paths can contain wildcard `*`
SSO_WHITELIST=

# Enable feature in tech preview
ENABLE_TECH_PREVIEW=true
# Override the default max list size. When hit we won't fetch all results for the given list
#UI_LIST_MAX_SIZE=600
# If the max list size is hit allow the user to load all results anyway. Defaults to false
#UI_LIST_ALLOW_LOAD_MAXED=false

# User Invites
SMTP_FROM_ADDRESS=Stratos<invite@stratos.com>
SMTP_HOST=127.0.0.1
SMTP_PASSWORD=
SMTP_PORT=1025
SMTP_USER=
TEMPLATE_DIR=./templates
INVITE_USER_CLIENT_ID=
INVITE_USER_CLIENT_SECRET=

# Use local admin user rather than UAA users
AUTH_ENDPOINT_TYPE=none
LOCAL_USER=admin
LOCAL_USER_PASSWORD=admin
LOCAL_USER_SCOPE=stratos.admin

# MariaDB database for local dev
# DATABASE_PROVIDER=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_USER=stratos
# DB_PASSWORD=strat0s
# DB_DATABASE_NAME=stratosdb

# Postgresql database for local dev
# DATABASE_PROVIDER=pgsql
# DB_HOST=127.0.0.1
# DB_PORT=5432
# DB_USER=stratos
# DB_PASSWORD=strat0s
# DB_DATABASE_NAME=stratosdb
# DB_SSL_MODE=disable
48 changes: 48 additions & 0 deletions electron/electron-store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// const electron = require('electron');
const path = require('path');
const fs = require('fs');
const homeDir = require('os').homedir();

class ElectronStore {
constructor(opts) {
// Renderer process has to get `app` module via `remote`, whereas the main process can get it directly
// app.getPath('userData') will return a string of the user's app data directory path.
// Causes `EISDIR: illegal operation on a directory, open '/Users/<user>/Library/Application Support/Stratos/settings.json'`
// this.path = (electron.app || electron.remote.app).getPath('userData');
this.path = path.join(homeDir, '.config', 'stratos');

// We'll use the `configName` property to set the file name and path.join to bring it all together as a string
this.filePath = path.join(this.path, opts.configName + '.json');

this.data = parseDataFile(this.filePath, opts.defaults);
}

// This will just return the property on the `data` object
get(key) {
return this.data[key];
}

// ...and this will set it
set(key, val) {
this.data[key] = val;
// Wait, I thought using the node.js' synchronous APIs was bad form?
// We're not writing a server so there's not nearly the same IO demand on the process
// Also if we used an async API and our app was quit before the asynchronous write had a chance to complete,
// we might lose that data. Note that in a real app, we would try/catch this.
fs.writeFileSync(this.filePath, JSON.stringify(this.data));
}
}

function parseDataFile(filePath, defaults) {
// We'll try/catch it in case the file doesn't exist yet, which will be the case on the first application run.
// `fs.readFileSync` will return a JSON string which we then parse into a Javascript object
try {
return JSON.parse(fs.readFileSync(filePath));
} catch (error) {
// if there was some kind of error, return the passed in defaults instead.
return defaults;
}
}

// expose the class
module.exports = ElectronStore;
59 changes: 59 additions & 0 deletions electron/freeport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const net = require("net");

// call method 1: (port, cb(err, freePort))
// call method 2: (portBeg, portEnd, cb(err, freePort))
// call method 3: (portBeg, host, cb(err, freePort))
// call method 4: (portBeg, portEnd, host, cb(err, freePort))
// call method 5: (portBeg, portEnd, host, howmany, cb(err, freePort1, freePort2, ...))

function findFreePort(beg, ...rest){
const p = rest.slice(0, rest.length - 1), cb = rest[rest.length - 1];
let [end, ip, cnt] = Array.from(p);
if (!ip && end && !/^\d+$/.test(end)) { // deal with method 3
ip = end;
end = 65534;
} else {
if (end == null) { end = 65534; }
}
if (cnt == null) { cnt = 1; }

const retcb = cb;
const res = [];
const probe = function(ip, port, cb){
const s = net.createConnection({port: port, host: ip})
s.on('connect', function(){ s.end(); cb(null, port + 1); });
s.on('error', err=> { cb(port); }); // can't connect, port is available
};
var onprobe = function(port, nextPort){
if (port) {
res.push(port);
if (res.length >= cnt) {
retcb(null, ...res)
} else {
setImmediate(()=> probe(ip, port+1, onprobe));
}
} else {
if (nextPort>=end) {
retcb(new Error("No available ports"));
} else {
setImmediate(()=> probe(ip, nextPort, onprobe));
}
}
};
return probe(ip, beg, onprobe);
};

function findFreePortPmfy(beg, ...rest) {
const last = rest[rest.length - 1];
if (typeof last === 'function') {
findFreePort(beg, ...rest);
} else {
return new Promise((resolve, reject) => {
findFreePort(beg, ...rest, (err, ...ports) => {
if (err) reject(err)
else resolve(ports);
})
})
}
}
module.exports = findFreePortPmfy
Binary file added electron/icon.icns
Binary file not shown.
Binary file added electron/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading