Skip to content

Commit

Permalink
Merge pull request #77 from Native-Planet/nallux_dev
Browse files Browse the repository at this point in the history
Beta-3.4.0
  • Loading branch information
nallux-dozryl authored Dec 9, 2022
2 parents d6de26a + 061f9ee commit c669156
Show file tree
Hide file tree
Showing 28 changed files with 376 additions and 86 deletions.
17 changes: 13 additions & 4 deletions api/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Orchestrator:
_disk = None

# GroundSeg
gs_version = 'Beta-3.3.7'
gs_version = 'Beta-3.4.0'
anchor_config = {'lease': None,'ongoing': None}
minIO_on = False
config = {}
Expand Down Expand Up @@ -666,8 +666,8 @@ def register_urbit(self, patp):

if self.anchor_config != None:
for ep in self.anchor_config['subdomains']:
if(patp in ep['url']):
self.log_groundseg(f"{patp}: Services already exists")
if patp in ep['url'] :
self.log_groundseg(f"{patp}: {ep['svc_type']} already exists")
patp_reg = True

if patp_reg == False:
Expand Down Expand Up @@ -890,7 +890,7 @@ def restart(self):
if sys.platform == "win32":
os.system("shutdown /s /t 0")
else:
os.system("shutdown /r")
os.system("reboot")
return 200

# Get list of available docker containers
Expand Down Expand Up @@ -1037,13 +1037,22 @@ def register_device(self, reg_key):
self.toggle_minios_on()
self.save_config()

time.sleep(2)

if self.wireguard.is_running() and len(self.config['piers']) > 0:
self.log_groundseg(f"Restarting Anchor")
x = self.toggle_anchor_off()
if x == 200:
self.toggle_anchor_on()

return 200

return 400

# Change Anchor endpoint URL
def change_wireguard_url(self, url):
endpoint = self.config['endpointUrl']
api_version = self.config['apiVersion']
old_url = f'https://{endpoint}/{api_version}'
self.config['endpointUrl'] = url
self.config['wgRegistered'] = False
Expand Down
1 change: 1 addition & 0 deletions release/version.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Beta-3.4.0,eb1f6f327e160ad192fde4996791758ae711538ca966b0cd1f679fd7ebee5824,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.4.0/groundseg
Beta-3.3.7,5a3df4778cc58fa60fcbd5c765fd27f3939be49bd3ae25c37ba0a5e453e6e076,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.7/groundseg
Beta-3.3.5,b2a551603d6476834bf1d97bff76c75ea14fb73116a63f3898ae9ca4969199a4,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.5/groundseg
Beta-3.3.4,4cb6f2a38ae8f92b1307d051507becece0c38c8bc616ac84b5ebd48706ea517e,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.4/groundseg
Expand Down
3 changes: 3 additions & 0 deletions release/version_edge.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Beta-3.4.0-edge,6edf1bac09c511986d2ade2f336eee4d4c24651f2fc25e386a9b071a8264b172,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.4.0-edge/groundseg
Beta-3.3.9-edge,4151e9835fdf95987ef0339a16c7f70182d3acc1e6ba45dfaa346f2d91a9981a,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.9-edge/groundseg
Beta-3.3.8-edge,82e92b1a3ff8d171956ca4e221bb7c2de95f6fe783ef76f21c5e9b62916d08c6,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.8-edge/groundseg
Beta-3.3.7-edge,ed69385f4fbc10ca0a04a0cad397d1f5b34148f168c2ea9edc166f92c51a49ce,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.7-edge/groundseg
Beta-3.3.6-edge,60080fe61a32f00291c9d8176d4751058bda7dc777b47ea64ae592e12755d320,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.6-edge/groundseg
Beta-3.3.5-edge,835ddef1ecd87726baf34bad8d7ea5e0ea416ff4db7182de8b3d90703b454fd6,https://github.com/Native-Planet/GroundSeg/releases/download/beta-3.3.5-edge/groundseg
Expand Down
26 changes: 24 additions & 2 deletions ui/src/lib/AnchorAdvanced.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { scale } from 'svelte/transition'
import { api } from '$lib/api'
import Fa from 'svelte-fa'
import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'
import { faTriangleExclamation, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'
import PrimaryButton from '$lib/PrimaryButton.svelte'
export let wgReg
Expand All @@ -14,7 +14,8 @@
epButtonStatus = 'standard',
cancelButtonStatus = 'standard',
confirmCancel = false,
regKey = '', view = false
regKey = '', view = false,
showEpInfo = false
const insertNP = () => epKey = defaultEpKey
Expand Down Expand Up @@ -99,7 +100,19 @@
{#if advanced}
<div class="ep-title" transition:scale={{duration:120, delay: 200}}>
Set Endpoint
{#if wgReg}
<button class="alert-mark" on:click={()=>showEpInfo = !showEpInfo} >
<Fa icon={faTriangleExclamation} size="1.2x" />
</button>
{/if}
</div>

{#if showEpInfo}
<div class="ep-info">
Modifying your endpoint will result in removing all StarTram related services attached to this device.
</div>
{/if}

<div class="ep-key"transition:scale={{duration:120, delay: 200}}>
<input type="text" bind:value={epKey} />
<img on:click={insertNP} width="24px" src="/nplogo.svg" alt="np logo" />
Expand Down Expand Up @@ -213,4 +226,13 @@
opacity: .8;
cursor: pointer;
}
.ep-info {
font-size: 11px;
padding-bottom: 12px;
color: orange;
}
.alert-mark {
cursor: pointer;
color: orange;
}
</style>
52 changes: 44 additions & 8 deletions ui/src/lib/AnchorButton.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
<script>
import { afterUpdate } from 'svelte'
import { onMount, afterUpdate } from 'svelte'
import { updateState, api, system, noconn } from '$lib/api'
import { page } from '$app/stores'
import Fa from 'svelte-fa'
import { faSatelliteDish } from '@fortawesome/free-solid-svg-icons'
let hide = false
let hide = true
let blur = false
let data = {anchor: {wgReg:false, wgRunning: false}}
afterUpdate(()=> {
hide = ($page.routeId == 'login')
blur = ($page.routeId == 'anchor')
blur = ($page.routeId == 'startram')
})
// updateState loop
const update = () => {
if (!$noconn) {
fetch($api + '/anchor', {credentials: "include"})
.then(raw => raw.json())
.then(res => data = res)
.catch(err => {
if ((typeof err) == 'object') {
updateState({status:'noconn'})
}
})
}
setTimeout(update, 10000)
}
// Start the update loop
onMount(()=> {
api.set("http://" + $page.url.hostname + ":27016")
update()
})
</script>

<a href='/anchor' class:hide={hide} class:blur={blur}>
<div class="img">
<Fa icon={faSatelliteDish} size="1.2x" />
</div>
</a>
{#if !hide}
<a href='/startram' class:hide={hide} class:blur={blur}>
<div
class="img"
class:connected={data.anchor.wgReg && data.anchor.wgRunning}
class:not-connected={data.anchor.wgReg && !data.anchor.wgRunning}
>
<Fa icon={faSatelliteDish} size="1.2x" />
</div>
</a>
{/if}

<style>
.blur {
Expand All @@ -35,4 +65,10 @@
top: 3px;
}
.img {height: 24px; margin: 20px; color: white}
.connected {
color: lime;
}
.not-connected {
color: red;
}
</style>
9 changes: 5 additions & 4 deletions ui/src/lib/AnchorRegisterKey.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@

<!-- If not registered -->
{#if !wgReg}
<div class="reg-title" transition:scale={{duration:120, delay: 200}}>Key Registration</div>
<div class="reg-title" transition:scale={{duration:120, delay: 200}}>StarTram Key Registration</div>
<div class="reg-key" transition:scale={{duration:120, delay: 200}}>
<input id='input' type="password" bind:value={key} />
<img on:click={toggleView} src="/eye-{view ? "closed" : "open"}.svg" alt="eye" />
</div>

<!-- if registered -->
{:else if !reRegCheck}
<div class="reg-title" transition:scale={{duration:120, delay: 200}}>Key Registration</div>
<div class="reg-title" transition:scale={{duration:120, delay: 200}}>StarTram Key Registration</div>
<div class="reg-key" transition:scale={{duration:120, delay: 200}}>
<input id='input' type="password" bind:value={key} />
<img on:click={toggleView} src="/eye-{view ? "closed" : "open"}.svg" alt="eye" />
Expand All @@ -66,8 +66,9 @@
<!-- Submit button -->
<div transition:scale={{duration:120, delay: 200}}>
<PrimaryButton
left={true}
on:click={wgReg && reRegCheck ? ()=>reRegCheck = false : registerKey }
standard="Register{wgReg && reRegCheck ? " A New Key" : ""}"
standard="Register{wgReg && reRegCheck ? " A New StarTram Key" : ""}"
success="Key registered"
failure="Registration failed"
loading="Processing..."
Expand All @@ -76,7 +77,7 @@
key == '' ? "disabled" : buttonStatus
}
top="{wgReg && reRegCheck ? "26" : "12"}"
/>
/>
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions ui/src/lib/Dropzone.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
} else {
setTimeout(()=> handleSuccess(n), 1000)
}
})
.catch(err => console.log(err))
})
.catch(err => console.log(err))
}
const onError = (e) => {
Expand Down Expand Up @@ -107,7 +107,7 @@
{#if failed}
<span style="color: red;">{failedText}</span>
{:else}
Drop pier here to upload
Drop Pier File here to Upload
{/if}
{/if}

Expand Down
109 changes: 109 additions & 0 deletions ui/src/lib/KeyDropper.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<script>
import Dropzone from "dropzone"
import { afterUpdate, createEventDispatcher } from "svelte"
import Fa from 'svelte-fa'
import { faFileArrowUp } from '@fortawesome/free-solid-svg-icons'
let key = '', viewKey = false, error = false, files
$: if (files) {
handleKey(files[0])
}
const dispatch = createEventDispatcher()
const reader = new FileReader();
const toggleViewKey = () => {
viewKey = !viewKey
document.querySelector('#key').type = viewKey ? 'text' : 'password'
}
const handleDragOver = event => {
event.preventDefault();
}
const handleDrop = event => {
event.preventDefault();
handleKey(event.dataTransfer.files[0])
}
const handleKey = file => {
if (file.name.split('.').splice(-1)[0] == 'key') {
reader.readAsText(file)
reader.onload = event => key = event.target.result
} else {
error = true
setTimeout(()=> error = false, 1000)
}
}
afterUpdate(()=> {
dispatch("change", key)
})
</script>

<div class="pass-wrapper">
<input
spellcheck="false"
id="key"
type="password"
placeholder={error ? "not valid key file" : "paste key or drop a keyfile"}
bind:value={key}
on:dragover={handleDragOver}
on:drop={handleDrop}
/>
<div class="upload-icon">
<input type="file" bind:files >
<Fa icon={faFileArrowUp} size="1.2x" />
</div>
<img on:click={toggleViewKey} src="/eye-{viewKey ? "closed" : "open"}.svg" alt="eye" />
</div>

<style>
.pass-wrapper {
display: flex;
}
input {
flex: 1;
padding: 8px;
font-size: 12px;
color: inherit;
font-weight: 700;
background: #ffffff4d;
outline: none;
border: none;
border-radius: 6px;
}
::-moz-placeholder {
color: white;
}
::-webkit-input-placeholder {
color: white;
}
.upload-icon {
position: relative;
margin: auto;
padding: 0 12px 0 12px;
cursor: pointer;
}
.upload-icon > input {
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
position: absolute;
overflow: hidden;
}
img {
cursor: pointer;
}
input[type="file"]::before {
content: "Choose File";
display: inline-block;
cursor: pointer;
}
</style>
4 changes: 2 additions & 2 deletions ui/src/lib/Logs.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { api, currentLog } from '$lib/api'
import { api, currentLog, noconn } from '$lib/api'
import { onMount, onDestroy, beforeUpdate, afterUpdate } from 'svelte'
export let container, maxHeight
Expand Down Expand Up @@ -29,7 +29,7 @@
setTimeout(getLog, 1000)
} else {
let module = 'logs'
if (shown) {
if (shown && !$noconn) {
if ($currentLog.container != container) {
currentLog.set({'container':'','log':[]})
}
Expand Down
Loading

0 comments on commit c669156

Please sign in to comment.