This commit is contained in:
sokol
2026-02-18 11:38:25 +03:00
commit 83a5bb87c1
40 changed files with 5803 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { Env } from "../models/Env";
import { ConfigReader } from "../models/ConfigReader";
import { Config } from "../models/Config";
export function FileChooser(props: { onSelected: (x: Config) => void }) {
async function handleFile(x: React.ChangeEvent<HTMLInputElement>) {
let file = x.target.files![0];
console.log(file.name, file.type, file.size, "supported:", ConfigReader.isSupportedFormat(file));
let reader = new ConfigReader();
let cfg = await reader.parseFromFile(file);
if (cfg !== null) {
props.onSelected(cfg);
}
}
function handleNew(){
let cfg = new Config();
cfg.addEnvs([new Env(0,"DEFAULT", [])]);
props.onSelected(cfg);
}
return (
<>
<div className="col-2">
<button className="btn btn-primary" onClick={handleNew} >Create new</button>
</div>
<div className="col-1">or</div>
<div className="col">
<input className="form-control" type="file" id="formFile" onChange={handleFile} />
</div >
</>
);
}