Subnet command (#17)

* Started working on subnets

* Basic version of the subnet command

* Improved subnet command

* almost done with subnets

* improve positioning
This commit is contained in:
Borys Levytskyi
2021-01-16 11:33:45 +02:00
committed by GitHub
parent 0cd9c8049b
commit 478ecbfb60
24 changed files with 659 additions and 332 deletions

View File

@@ -3,12 +3,16 @@ import hash from '../core/hash';
import AppState from './AppState';
import { Env } from './interfaces';
import appStateStore from './appStateStore';
import CommandLink from '../core/components/CommandLink';
export type StartupAppData = {
appState: AppState,
startupCommands: string[]
}
const STARTUP_COMMAND_KEY = 'StartupCommand';
const DEFAULT_COMMANDS = ['help', '127.0.0.1 192.168.0.0/8', '1|2&6','4 0b1000000 0x80'];
function bootstrapAppData() : StartupAppData {
const env = window.location.host === "bitwisecmd.com" ? 'prod' : 'stage';
@@ -35,7 +39,10 @@ function createAppState(env:string) {
function getStartupCommands(appState : AppState) : string[] {
var hashArgs = hash.getArgs(window.location.hash);
var startupCommands = ['help', '127.0.0.1 192.168.0.0/8', '1|2&6','4 0b1000000 0x80'];
var startupCommands = loadStoredCommands();
if(startupCommands.length == 0)
startupCommands = DEFAULT_COMMANDS;
if(appState.wasOldVersion) {
startupCommands = ["whatsnew"];
@@ -50,6 +57,11 @@ function getStartupCommands(appState : AppState) : string[] {
return startupCommands;
}
function loadStoredCommands() : string[] {
const json = localStorage.getItem(STARTUP_COMMAND_KEY);
return json != null ? [json] : [];
}
function setupLogger(env: Env) {
if(env != 'prod'){
log.setLevel("debug");
@@ -59,4 +71,5 @@ function setupLogger(env: Env) {
}
}
export {STARTUP_COMMAND_KEY};
export default bootstrapAppData;