diff --git a/apps/web/src/components/SchemaItem/index.tsx b/apps/web/src/components/SchemaItem/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..60500df32dcb5903184460ff959fb7f4ed5cbd8b --- /dev/null +++ b/apps/web/src/components/SchemaItem/index.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { observer } from "mobx-react"; +import {Button} from "antd"; +import s from './styles.module.scss'; + +interface SchemaItemProps { + item: any; + onClick?: () => void; +} + +const SchemaItem = observer(({ item, onClick }: SchemaItemProps) => { + const query = encodeURIComponent(item.id); + return ( + <div className={s.item} onClick={onClick}> + <a href={`http://ledger.didgram.pro/browse/domain?page=1&query=${query}&txn_type=`} target="_blank"> + <Button> + See {item.id} on ledger + </Button> + </a> + <pre> + {JSON.stringify(item, null, 2)} + </pre> + </div> + ); +}); + +export default SchemaItem; + diff --git a/apps/web/src/components/SchemaItem/styles.module.scss b/apps/web/src/components/SchemaItem/styles.module.scss new file mode 100644 index 0000000000000000000000000000000000000000..388a3ad936f635eedb6d5599eb017c9fdea78295 --- /dev/null +++ b/apps/web/src/components/SchemaItem/styles.module.scss @@ -0,0 +1,38 @@ +.item { + display: flex; + flex-direction: column; + + margin: 4px 0; + border: 1px solid rgba(0, 0, 0, 0.1); + border-radius: 8px; + background: rgba(255, 255, 255, 0.12); + padding: 8px; + cursor: pointer; +} + +.row { + display: flex; + margin-bottom: 4px; +} + + +.pair { + display: flex; +} + +.pair + .pair { + margin-left: 16px; +} + +.label { + display: flex; + align-items: flex-end; + font-size: 13px; + color: gray; +} +.value { + display: flex; + align-items: flex-end; + font-size: 14px; + margin-left: 4px; +} diff --git a/apps/web/src/components/Sidebar/index.tsx b/apps/web/src/components/Sidebar/index.tsx index 468f03e2931f71cd6202d4814f1773844fec2a65..3072db958118cbfbbb3990af6f33088a876f8c6d 100644 --- a/apps/web/src/components/Sidebar/index.tsx +++ b/apps/web/src/components/Sidebar/index.tsx @@ -1,7 +1,7 @@ import React from "react"; -// import { Link } from "react-router-dom"; +import { Link } from "react-router-dom"; // import SidebarMenuItem from "./SidebarMenuItem"; -// import config from "@routes/config"; +import config from "../../routes/config"; // import { Button } from "antd"; // import appStore from "@store/appStore"; import s from "./styles.module.scss"; @@ -9,23 +9,13 @@ import s from "./styles.module.scss"; const Sidebar = () => { return ( <div className={s.sidebar}> - {/*<div className={s.wrapper}>*/} - {/* <div className={s.scroll}>*/} - {/* <div className={s.content}>*/} - {/* <h2 style={{ textAlign: 'center' }}>*/} - {/* {appStore.subDomain}*/} - {/* </h2>*/} - {/* <a href="https://app.didgram.pro" className={s.link}>*/} - {/* <Button>*/} - {/* Manage agents*/} - {/* </Button>*/} - {/* </a>*/} - {/* <Link className={s.link} to={config.connection_list.getLink()}>*/} - {/* <SidebarMenuItem name="Connection List" />*/} - {/* </Link>*/} - {/* /!*<Link className={s.link} to={config.schema_list.getLink()}>*!/*/} - {/* /!* <SidebarMenuItem name="Schema List" />*!/*/} - {/* /!*</Link>*!/*/} + <Link className={s.link} to={config.schema_list.getLink()}> + Schema List + </Link> + <Link className={s.link} to={config.connection_list.getLink()}> + Connection List + </Link> + {/* <Link className={s.link} to={config.cred_def_list.getLink()}>*/} {/* <SidebarMenuItem name="Credential Definition List" />*/} {/* </Link>*/} @@ -41,9 +31,6 @@ const Sidebar = () => { {/* <Link className={s.link} to={config.proof_list.getLink()}>*/} {/* <SidebarMenuItem name="Proof List" />*/} {/* </Link>*/} - {/* </div>*/} - {/* </div>*/} - {/*</div>*/} </div> ); }; diff --git a/apps/web/src/components/Sidebar/styles.module.scss b/apps/web/src/components/Sidebar/styles.module.scss index 05f231a76704db412d6bca8f7b84644c9bc7350f..892f2b9fcaec937cdcb50b3d8c871cb8d464d523 100644 --- a/apps/web/src/components/Sidebar/styles.module.scss +++ b/apps/web/src/components/Sidebar/styles.module.scss @@ -1,6 +1,11 @@ .sidebar { display: flex; - width: 250px; + flex-direction: column; + width: 200px; flex-shrink: 0; position: relative; } + +.link { + margin: 14px 8px; +} diff --git a/apps/web/src/routes/config.ts b/apps/web/src/routes/config.ts index fd43165cdfbc315617a00e2f88ec1fde543b50b3..e1e68551cb4957081749101f10ca29bc87e679df 100644 --- a/apps/web/src/routes/config.ts +++ b/apps/web/src/routes/config.ts @@ -2,7 +2,7 @@ import ConnectionListPage from "./pages/ConnectionListPage"; import ConnectionCreatePage from "./pages/ConnectionCreatePage"; import ConnectionViewPage from "./pages/EmptyPage"; // import ConnectionOfferCredentialPage from "./pages/EmptyPage"; -// import SchemaListPage from "./pages/EmptyPage"; +import SchemaListPage from "./pages/SchemaListPage"; // import CredentialDefListPage from "./pages/CredentialDefListPage"; // import CredentialListPage from "./pages/CredentialListPage"; // import CredentialViewPage from "./pages/CredentialViewPage"; @@ -37,11 +37,11 @@ const routes = { // getLink: (id: string) => `/connection/${id}/offer-credential`, // }, // - // schema_list: { - // Component: SchemaListPage, - // route: "/schema/list", - // getLink: () => "/schema/list", - // }, + schema_list: { + Component: SchemaListPage, + route: "/schema/list", + getLink: () => "/schema/list", + }, // // cred_def_list: { // Component: CredentialDefListPage, diff --git a/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/index.tsx b/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..f5c7280528f1f7a4871770604ce88dbbec5ea3c0 --- /dev/null +++ b/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/index.tsx @@ -0,0 +1,105 @@ +import React, { useEffect, useState } from "react"; +import { observer } from "mobx-react"; +import {Form, Input, Button, Modal, Select} from 'antd'; +import api from "../../../../api"; +import {toast} from "react-toastify"; +import s from "./styles.module.scss"; + + +export interface NewSchemaDialogProps { + onSchemaCreated: (schema: any) => void; + onClose: () => void; +} + +const NewSchemaDialog = observer( + ({ onClose, onSchemaCreated }: NewSchemaDialogProps) => { + const [open, setOpen] = useState(false); + useEffect(() => { + setOpen(true); + }, []); + const [loading, setLoading] = useState(false); + + const onFinish = async (values: any) => { + try { + setLoading(true); + const schema = await api.schema.attestationControllerCreateSchema(values); + toast(`New schema ${schema.id} created`); + onSchemaCreated(schema); + } catch (e: any) { + console.error(e); + toast(e.message); + } + setLoading(false); + }; + + return ( + <Modal + style={{ top: 60 }} + open={open} + title="Add new schema" + onCancel={onClose} + footer={[]} + > + <div> + Creating schema not supported at the moment + </div> + <div className={s.body}> + <Form + layout="vertical" + labelCol={{ span: 8 }} + wrapperCol={{ span: 16 }} + style={{ maxWidth: 600 }} + initialValues={{ + name: '', + version: '', + attributes: [] + }} + onFinish={onFinish} + autoComplete="off" + > + <Form.Item + label="Name" + name="name" + rules={[{ required: true, message: 'Please enter name!' }]} + > + <Input /> + </Form.Item> + <Form.Item + label="Version" + name="version" + rules={[{ required: true, message: 'Please enter version!' }]} + > + <Input /> + </Form.Item> + <Form.Item + label="Attributes" + name="attributes" + rules={[{ required: true, message: 'Please enter attributes!' }]} + > + <Select + mode="tags" + style={{ width: '100%' }} + /> + </Form.Item> + + <div className={s.footerActions}> + <Button type="primary" htmlType="submit" disabled={loading}> + Create + </Button> + <Button + className={s.cancelButton} + onClick={onClose} + disabled={loading} + > + Close + </Button> + </div> + </Form> + + </div> + </Modal> + ); + } +); + +export default NewSchemaDialog; diff --git a/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/styles.module.scss b/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/styles.module.scss new file mode 100644 index 0000000000000000000000000000000000000000..5cc463b56978bf734f1fb44f64ead3f85dccfaa8 --- /dev/null +++ b/apps/web/src/routes/pages/SchemaListPage/NewSchemaDialog/styles.module.scss @@ -0,0 +1,4 @@ +.footerActions { + display: flex; + justify-content: space-around; +} diff --git a/apps/web/src/routes/pages/SchemaListPage/SchemaListPageStore.ts b/apps/web/src/routes/pages/SchemaListPage/SchemaListPageStore.ts new file mode 100644 index 0000000000000000000000000000000000000000..b427e36c12ab8dd0e8fca9e039218f044b7f36fd --- /dev/null +++ b/apps/web/src/routes/pages/SchemaListPage/SchemaListPageStore.ts @@ -0,0 +1,30 @@ +import {makeAutoObservable, runInAction} from "mobx"; +import api from "../../../api"; +import {toast} from "react-toastify"; + +class SchemaListPageStore { + public loading = false; + public list: any[] = []; + constructor() { + makeAutoObservable(this); + } + + public async loadAll() { + runInAction(() => this.loading = true); + try { + const schemas = await api.schema.attestationControllerListSchema() as any; + runInAction(() => { + this.list = schemas + this.loading = false; + }); + } catch (e: any) { + toast(e.message); + console.error(e); + runInAction(() => this.loading = false); + } + } +} + +export type { SchemaListPageStore }; + +export default SchemaListPageStore; diff --git a/apps/web/src/routes/pages/SchemaListPage/index.tsx b/apps/web/src/routes/pages/SchemaListPage/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..cc24fb6303d477ece69847b1fb3688f5e58659b5 --- /dev/null +++ b/apps/web/src/routes/pages/SchemaListPage/index.tsx @@ -0,0 +1,48 @@ +import React, {useEffect, useState} from "react"; +import { observer } from "mobx-react"; +import {Button, Spin} from 'antd'; +import SchemaListPageStore from './SchemaListPageStore'; +import SchemaItem from "../../../components/SchemaItem"; +import NewSchemaDialog from "./NewSchemaDialog"; +import s from './styles.module.scss'; + +const ConnectionListPage = observer(() => { + const [store] = useState(() => new SchemaListPageStore()); + const [newSchemaDialog, setNewSchemaDialog] = useState(false); + + useEffect(() => { + store.loadAll() + }, []) + return ( + <div> + <h2> + Actions + </h2> + <div> + <Button onClick={() => setNewSchemaDialog(true)}> + Create new schema + </Button> + </div> + <h2>Schema List</h2> + <div> + {store.list.map(p => ( + <SchemaItem key={p.id} item={p} /> + ))} + {store.loading && ( + <Spin /> + )} + </div> + {newSchemaDialog && ( + <NewSchemaDialog + onSchemaCreated={() => { + store.loadAll(); + setNewSchemaDialog(false) + }} + onClose={() => setNewSchemaDialog(false)} + /> + )} + </div> + ); +}); + +export default ConnectionListPage; diff --git a/apps/web/src/routes/pages/SchemaListPage/styles.module.scss b/apps/web/src/routes/pages/SchemaListPage/styles.module.scss new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/libs/ledgers/src/didgram-test/didgram-test.provider.ts b/libs/ledgers/src/didgram-test/didgram-test.provider.ts index 39da899bfe194d850c17aa7971c294ce89719afa..30d12de7437d6d21c6e36a3269af36ab788bae8e 100644 --- a/libs/ledgers/src/didgram-test/didgram-test.provider.ts +++ b/libs/ledgers/src/didgram-test/didgram-test.provider.ts @@ -20,7 +20,7 @@ export class DidgramTestProvider implements IRegistrator { unqualifiedIndyDid: string, verkey: string, ): Promise<string> => { - const did = `did:indy:didgram:test:${unqualifiedIndyDid}`; + const did = `did:indy:${unqualifiedIndyDid}`; this.logger.log(`Trying to register ${did} to didram test`); try { @@ -46,7 +46,7 @@ export class DidgramTestProvider implements IRegistrator { getNetworkConf = (): IndyVdrPoolConfig => { return { genesisTransactions: genesisFile, - indyNamespace: "didgram:test", + indyNamespace: "", isProduction: false, connectOnStartup: true, };