diff --git a/app/src/App.tsx b/app/src/App.tsx
index 772aa8614..7eda46795 100644
--- a/app/src/App.tsx
+++ b/app/src/App.tsx
@@ -162,7 +162,7 @@ export default function App() {
simulation_box: true,
vectorfield: true,
controls: "OrbitControls",
- vectors: "",
+ vectors: [],
vector_scale: 1.0,
selection_color: "#ffa500",
camera: "PerspectiveCamera",
@@ -804,18 +804,20 @@ export default function App() {
hoveredId={hoveredId}
setHoveredId={setHoveredId}
/>
- {roomConfig["scene"].vectors != "" && (
-
- )}
+ {roomConfig["scene"].vectors[0] &&
+ roomConfig["scene"].vectors.map((vector) => (
+
+ ))}
)}
diff --git a/app/src/components/sidebar.tsx b/app/src/components/sidebar.tsx
index 194e3264d..9f3d493de 100644
--- a/app/src/components/sidebar.tsx
+++ b/app/src/components/sidebar.tsx
@@ -29,78 +29,20 @@ JSONEditor.defaults.options.keep_oneof_values = false;
JSONEditor.defaults.editors.object.options.titleHidden = true;
interface SidebarMenuProps {
- schema: any;
- onSubmit: any;
- queuePosition: number;
- trigger?: boolean; // Mark trigger as optional
- setTrigger?: (value: boolean) => void; // Mark setTrigger as optional
visible: boolean;
- useSubmit?: boolean; // provide a submit button or trigger on change
- closeMenu?: () => void;
+ closeMenu: () => void;
+ token: string;
+ name: string;
+ sendImmediately: boolean;
}
-const useJSONEditor = (
- schema: any,
- setUserInput: (value: any) => void,
- useSubmit: boolean,
-) => {
- const editorRef = useRef(null);
- const JSONEditorRef = useRef(null);
-
- useEffect(() => {
- if (Object.keys(schema).length === 0) {
- return;
- }
-
- if (editorRef.current) {
- JSONEditorRef.current = new JSONEditor(editorRef.current, {
- schema: schema,
- });
- let created_trigger = false;
-
- // on ready, validate and set user input
- JSONEditorRef.current.on("ready", () => {
- if (useSubmit) {
- // when using the submit button, we need to set the user input on ready
- // otherwise, it could be None.
- if (JSONEditorRef.current.validate()) {
- const editorValue = JSONEditorRef.current.getValue();
- setUserInput(editorValue);
- }
- }
- });
-
- JSONEditorRef.current.on("change", () => {
- if (JSONEditorRef.current.ready) {
- if (created_trigger) {
- if (JSONEditorRef.current.validate()) {
- const editorValue = JSONEditorRef.current.getValue();
- setUserInput(editorValue);
- }
- } else {
- // skip first trigger
- created_trigger = true;
- }
- }
- });
- }
- return () => {
- if (JSONEditorRef.current) {
- JSONEditorRef.current.destroy();
- }
- };
- }, [schema]);
-
- return editorRef;
-};
-
-const SidebarMenu2: any = ({
+const SidebarMenu = ({
visible,
closeMenu,
token,
name,
sendImmediately,
-}) => {
+}: SidebarMenuProps) => {
const [userInput, setUserInput] = useState(undefined);
const [schema, setSchema] = useState({});
const [sharedSchema, setSharedSchema] = useState({});
@@ -423,35 +365,35 @@ function SideBar({ token }: { token: string }) {
- setVisibleOption("")}
sendImmediately={false}
/>
- setVisibleOption("")}
sendImmediately={false}
/>
- setVisibleOption("")}
sendImmediately={true}
/>
- setVisibleOption("")}
sendImmediately={false}
/>
- dict:
schema = cls.model_json_schema()
- array_props = [""]
+ array_props = []
if atoms.calc is not None:
for key in atoms.calc.results.keys():
if (
@@ -106,8 +106,10 @@ def model_json_schema_from_atoms(cls, atoms: ase.Atoms) -> dict:
and np.array(atoms.arrays[key]).shape[1] == 3
):
array_props.append(key)
- schema["properties"]["vectors"]["enum"] = array_props
- schema["properties"]["vectors"]["default"] = ""
+ # remove "positions" from the list
+ array_props = [x for x in array_props if x != "positions"]
+ schema["properties"]["vectors"]["items"] = {"type": "string", "enum": array_props}
+ schema["properties"]["vectors"]["uniqueItems"] = True
# schema["properties"]["wireframe"]["format"] = "checkbox"
schema["properties"]["animation_loop"]["format"] = "checkbox"
@@ -131,6 +133,7 @@ def model_json_schema_from_atoms(cls, atoms: ase.Atoms) -> dict:
schema["properties"]["camera_near"]["step"] = 0.1
schema["properties"]["camera_far"]["format"] = "range"
schema["properties"]["camera_far"]["step"] = 1
+
# schema["properties"]["bonds"]["format"] = "checkbox"
# schema["properties"]["line_label"]["format"] = "checkbox"