diff --git a/tabby/admin/Home.py b/tabby/admin/Home.py index c88130a..04db98b 100644 --- a/tabby/admin/Home.py +++ b/tabby/admin/Home.py @@ -16,5 +16,37 @@ st.set_page_config(page_title="Tabby Admin - Home") st.markdown("## Tabby") st.markdown(" ".join(map(make_badge_markdown, SERVICES))) +st.markdown("---") -monaco.st_monaco() +SNIPPETS = { + "Clear": "# Write some code ...", + "Fibonacci": "def fib(n):", + "Parse JSON": """def parse_json_lines(filename: str) -> List[Any]: + output = [] + with open(filename, "r", encoding="utf-8") as f: +""", + "Data ORM": """import birdchirp + +from birdchirp.model.chirp import chirp +from birdchirp.db.mysql import MysqlDb + +class User: + def __init__(self, user_id): + self.user_id = user_id + self.db = MysqlDb() + + def get_avatar""", +} + + +def code_editor(): + code = "" + cols = st.columns(len(SNIPPETS)) + for col, (k, v) in zip(cols, SNIPPETS.items()): + with col: + if st.button(k): + code = v + monaco.st_monaco(key="default", code=code) + + +code_editor() diff --git a/tabby/admin/components/monaco/__init__.py b/tabby/admin/components/monaco/__init__.py index 069d68c..f191080 100644 --- a/tabby/admin/components/monaco/__init__.py +++ b/tabby/admin/components/monaco/__init__.py @@ -30,8 +30,8 @@ else: # `declare_component` and call it done. The wrapper allows us to customize # our component's API: we can pre-process its input args, post-process its # output value, and add a docstring for users. -def st_monaco(tabby_server_url="http://localhost:5000", key=None): - _editor_func(tabby_server_url=tabby_server_url, key=key) +def st_monaco(key, tabby_server_url=None, code=None): + _editor_func(tabby_server_url=tabby_server_url, code=code, key=key) # Add some test code to play with the component while it's in development. @@ -40,5 +40,9 @@ def st_monaco(tabby_server_url="http://localhost:5000", key=None): if not _RELEASE: import streamlit as st - tabby_server_url = st.text_input("Tabby Server URL", value="http://localhost:5000") - st_monaco(tabby_server_url) + code = st.text_input("code") + set_code = st.button("Set code") + if set_code: + st_monaco(code=code, key="1") + else: + st_monaco(key="1") diff --git a/tabby/admin/components/monaco/frontend/build/asset-manifest.json b/tabby/admin/components/monaco/frontend/build/asset-manifest.json index dc397c1..65084e0 100644 --- a/tabby/admin/components/monaco/frontend/build/asset-manifest.json +++ b/tabby/admin/components/monaco/frontend/build/asset-manifest.json @@ -1,9 +1,9 @@ { "files": { - "main.js": "./static/js/main.15818978.js", + "main.js": "./static/js/main.c14dfe27.js", "index.html": "./index.html" }, "entrypoints": [ - "static/js/main.15818978.js" + "static/js/main.c14dfe27.js" ] } diff --git a/tabby/admin/components/monaco/frontend/build/index.html b/tabby/admin/components/monaco/frontend/build/index.html index 0d0d4ec..d31a3ad 100644 --- a/tabby/admin/components/monaco/frontend/build/index.html +++ b/tabby/admin/components/monaco/frontend/build/index.html @@ -1 +1 @@ -