mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
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:
@@ -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;
|
||||
Reference in New Issue
Block a user