Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F reconstruct bufan #290

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions packages/client/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import { useEffect, useState } from 'react'
import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom'
import styled from 'styled-components'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { Us3rAuthWithRainbowkitProvider } from '@us3r-network/auth-with-rainbowkit'
import { ProfileStateProvider } from '@us3r-network/profile'
import { ToastContainer } from 'react-toastify'
import 'react-toastify/dist/ReactToastify.min.css'

import { useAppCtx } from './context/AppCtx'
import { DappComposite, ModelStream } from './types.d'
import { CERAMIC_TESTNET_HOST, WALLET_CONNECT_PROJECT_ID } from './constants'

import AppProvider, { useAppCtx } from './context/AppCtx'
import CeramicNodeProvider from './context/CeramicNodeCtx'

import MyDapps from './container/MyDapps'
import NoMatch from './container/NoMatch'
import CeramicProvider from './context/AppCtx'
import { CERAMIC_TESTNET_HOST, WALLET_CONNECT_PROJECT_ID } from './constants'
import DappHome from './container/DappHome'
import DappCreate from './container/DappCreate'
import Header from './components/Header'
import Nav from './components/Nav'
import DappHome from './container/DappHome'
import DappInfo from './container/DappInfo'
import ExploreModel from './container/ExploreModel'

import DappModelEditor from './container/DappModelEditor'
import DappModelPlayground from './container/DappModelPlayground'
import DappModelSdk from './container/DappModelSdk'
import DappDataStatistic from './container/DappDataStatistic'
import Components from './container/Components'

import { useEffect, useState } from 'react'
import ModelList from './components/ModelList'
import { DappComposite, ModelStream } from './types'
import { ToastContainer } from 'react-toastify'
import 'react-toastify/dist/ReactToastify.min.css'
import DappModelSdk from './container/DappModelSdk'
import CeramicNodes from './container/CeramicNodes'
import CeramicNodeProvider from './context/CeramicNodeCtx'
import ExploreModel from './container/ExploreModel'
import NoMatch from './container/NoMatch'

import Header from './components/nav/Header'
import Nav from './components/nav/Nav'
import ModelList from './components/model/ModelList'

dayjs.extend(relativeTime)

Expand Down Expand Up @@ -65,14 +64,20 @@ export default function App () {
<Us3rAuthWithRainbowkitProvider
projectId={WALLET_CONNECT_PROJECT_ID}
appName='S3 Console'
authOpts={{resources:["ceramic://*","ceramic://*?model=kh4q0ozorrgaq2mezktnrmdwleo1d"],expirationTime:''}}
authOpts={{
resources: [
'ceramic://*',
'ceramic://*?model=kh4q0ozorrgaq2mezktnrmdwleo1d'
],
expirationTime: ''
}}
>
<ProfileStateProvider ceramicHost={CERAMIC_TESTNET_HOST}>
<CeramicProvider>
<CeramicNodeProvider>
<CeramicNodeProvider>
<AppProvider>
<Routers />
</CeramicNodeProvider>
</CeramicProvider>
</AppProvider>
</CeramicNodeProvider>
</ProfileStateProvider>
</Us3rAuthWithRainbowkitProvider>
)
Expand Down
23 changes: 2 additions & 21 deletions packages/client/dashboard/src/api/ceramicNode.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
/*
* @Author: bufan [email protected]
* @Date: 2023-12-15 14:39:12
* @LastEditors: bufan [email protected]
* @LastEditTime: 2023-12-15 15:25:53
* @FilePath: /s3/packages/client/dashboard/src/api/ceramicNode.ts
* @Description:
*/

import axios, { AxiosPromise } from 'axios'
import { CERAMIC_NODE_SERVICE_API_URL } from '../constants'
import {
CeramicRequestDto,
CeramicDto,
CeramicNetwork,
} from '../types'

enum ApiRespCode {
SUCCESS = 0,
ERROR = 1,
}

type ApiResp<T> = {
code: ApiRespCode
msg: string
data: T
}
} from '../types.d'
import { ApiResp } from '.'

export function getCeramicNode(id: number): AxiosPromise<ApiResp<CeramicDto>> {
return axios({
Expand Down
68 changes: 68 additions & 0 deletions packages/client/dashboard/src/api/composite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import axios, { AxiosPromise } from 'axios'
import { APP_API_URL } from '../constants'
import {
ClientDApp,
DappComposite,
} from '../types.d'
import { ApiResp } from '.'

export function getDappComposites({
dapp: { id },
didSession,
}: {
dapp: ClientDApp
didSession?: string
}): AxiosPromise<ApiResp<DappComposite[]>> {
let host = APP_API_URL

return axios({
url: host + `/dapps/${id}/composites`,
method: 'GET',
headers: {
'did-session': didSession || '',
},
})
}

export function createDappComposites({
didSession,
dapp,
data,
name,
}: {
didSession: string
dapp: ClientDApp
data: string
name: string
}) {
let host = APP_API_URL
return axios({
url: host + `/dapps/${dapp.id}/composites`,
method: 'POST',
headers: {
'did-session': didSession,
},
data: { graphql: data, name },
})
}

export function updateDappComposites() {}

export function deleteDappComposites({
compositeId,
dapp,
didSession,
}: {
compositeId: number
dapp: ClientDApp
didSession: string
}) {
let host = APP_API_URL
return axios({
url: host + `/dapps/${dapp.id}/composites/${compositeId}`,
method: 'DELETE',
headers: {
'did-session': didSession,
},
})
}
83 changes: 83 additions & 0 deletions packages/client/dashboard/src/api/dapp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import axios, { AxiosPromise } from 'axios'
import { APP_API_URL } from '../constants'
import {
ClientDApp,
Network,
} from '../types.d'
import { ApiResp } from '.'

export const PageSize = 50

export function getDapp(appId: string) {
let host = APP_API_URL
return axios({
url: host + `/dapps/${appId}`,
method: 'GET',
})
}

export function createDapp(
dapp: ClientDApp,
didSession: string
): AxiosPromise<ApiResp<ClientDApp>> {
let host = APP_API_URL
return axios({
url: host + '/dapps',
method: 'POST',
headers: {
'did-session': didSession,
},
data: { ...dapp },
})
}

export function updateDapp(
dapp: ClientDApp,
didSession: string,
ceramicId?:number,
): AxiosPromise<ApiResp<ClientDApp>> {
if (!dapp.id) throw new Error('dapp id is required')

let host = APP_API_URL

return axios({
url: host + '/dapps',
method: 'POST',
headers: {
'did-session': didSession,
},
data: { ...dapp, ceramicId, id: Number(dapp.id) },
})
}

export function delDapp(
dapp: ClientDApp,
didSession: string
): AxiosPromise<ApiResp<undefined>> {
if (!dapp.id) throw new Error('dapp id is required')

let host = APP_API_URL

return axios({
url: host + '/dapps/' + dapp.id,
method: 'DELETE',
headers: {
'did-session': didSession,
},
})
}

export function getDappWithDid(
didSession: string,
network?: Network
): AxiosPromise<ApiResp<ClientDApp[]>> {
let host = APP_API_URL

return axios({
url: host + '/dapps',
method: 'GET',
headers: {
'did-session': didSession,
},
})
}
Loading