Skip to content

Commit

Permalink
fix(web): replace gateway crd data with app domain object (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeezQ authored Jan 19, 2023
1 parent de0a86b commit 5d411bb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 56 deletions.
50 changes: 7 additions & 43 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export interface TApplication {
bundle: Bundle;
runtime: Runtime;
configuration: Configuration;
gateway: Gateway;
domain: Domain;
storage: Storage;
function_debug_token: string;
}

export interface Bundle {
id: string;
name: string;
Expand Down Expand Up @@ -64,50 +65,13 @@ export interface Environment {
value: string;
}

export interface Gateway {
apiVersion: string;
kind: string;
metadata: Metadata;
spec: Spec;
status: Status;
}

export interface Metadata {
creationTimestamp: string;
generation: number;
labels: Labels;
name: string;
namespace: string;
resourceVersion: string;
uid: string;
}

export interface Labels {
"laf.dev/appid": string;
}

export interface Spec {
export interface Domain {
id: string;
appid: string;
buckets: any[];
}

export interface Status {
appRoute: AppRoute;
conditions: Condition[];
}

export interface AppRoute {
domain: string;
domainName: string;
domainNamespace: string;
}

export interface Condition {
lastTransitionTime: string;
message: string;
reason: string;
status: string;
type: string;
state: string;
createdAt: string;
updatedAt: string;
}

export interface Storage {
Expand Down
1 change: 0 additions & 1 deletion web/src/chakraTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const Button = defineStyleConfig({
fontSize: "md",
borderRadius: "100px",
px: 6,
py: 4,
height: "32px",
},
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Editor/typesResolve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useGlobalStore from "@/pages/globalStore";

async function loadPackageTypings(packageName: string) {
const { currentApp } = useGlobalStore.getState();
const url = `//${currentApp?.gateway.status.appRoute.domain}`;
const url = `//${currentApp?.domain?.domain}`;
const res = await axios({
url: `${url}/typing/package?packageName=${packageName}`,
method: "GET",
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/app/functions/mods/DeployButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function DeployButton() {

return (
<>
<Tooltip label={`快捷键: ${displayName.toUpperCase()}`}>
<Tooltip label={`快捷键: ${displayName.toUpperCase()},调试可直接点击右侧「运行」按扭`}>
<Button
variant="text"
disabled={store.getFunctionUrl() === ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ export async function main(ctx: FunctionContext) {
console.log('Hello World')
return { data: 'hi, laf' }
}
`,
},
{
label: "database 示例",
value: `import cloud from '@lafjs/cloud'
export async function main(ctx: FunctionContext) {
const res = await cloud.database().collection('test').getOne();
const db = cloud.database()
console.log(res);
return { data: res }
export async function main(ctx: FunctionContext) {
// insert data
const insertRes = await db.collection('test').add({ name: "hello laf" })
console.log(insertRes)
if (insertRes.ok) {
// get data
const res = await db.collection('test').getOne()
console.log(res)
return res
} else {
return { data: insertRes.error }
}
}
`,
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/app/functions/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useFunctionStore = create<State>()(
const currentFunction = get().currentFunction;

return currentFunction?.name
? `http://${currentApp?.gateway.status.appRoute.domain}/${currentFunction?.name}`
? `http://${currentApp?.domain?.domain}/${currentFunction?.name}`
: "";
},

Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/app/mods/SideBar/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Icons(props: { type: "function" | "database" | "storage" | "logs" | "se
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M15.8531 3C9.30412 3 3.99976 5.65218 3.99976 8.92667V23.7433C3.99976 27.0178 9.31894 29.67 15.8531 29.67C22.3872 29.67 27.7064 27.0178 27.7064 23.7433V8.92667C27.7064 5.65218 22.4021 3 15.8531 3ZM24.7431 23.7433C24.7431 24.4842 21.5871 26.7067 15.8531 26.7067C10.119 26.7067 6.96309 24.4842 6.96309 23.7433V20.4392C9.34857 21.5949 12.4749 22.2617 15.8531 22.2617C19.2313 22.2617 22.3576 21.5949 24.7431 20.4392V23.7433ZM24.7431 17.0017C22.8169 18.4093 19.4387 19.2983 15.8531 19.2983C12.2675 19.2983 8.88926 18.4093 6.96309 17.0017V12.8383C9.14114 14.0681 12.3119 14.8533 15.8531 14.8533C19.3943 14.8533 22.565 14.0681 24.7431 12.8383V17.0017ZM15.8531 11.89C10.119 11.89 6.96309 9.6675 6.96309 8.92667C6.96309 8.18583 10.119 5.96333 15.8531 5.96333C21.5871 5.96333 24.7431 8.18583 24.7431 8.92667C24.7431 9.6675 21.5871 11.89 15.8531 11.89Z" />
<path d="M8.68733 29.67C8.04288 29.67 7.47088 29.4354 6.97133 28.9662C6.47088 28.497 6.16511 27.9043 6.05399 27.1882L4.02066 13.631C3.95399 13.1865 4.04866 12.7854 4.30466 12.4278C4.55977 12.0693 4.89844 11.89 5.32066 11.89H26.1873C26.6096 11.89 26.9482 12.0693 27.2033 12.4278C27.4593 12.7854 27.554 13.1865 27.4873 13.631L25.454 27.1882C25.3429 27.9043 25.0375 28.497 24.538 28.9662C24.0375 29.4354 23.4651 29.67 22.8207 29.67H8.68733ZM6.95399 14.8533L8.65399 26.7067H22.854L24.554 14.8533H6.95399ZM13.0873 20.78H18.4207C18.7984 20.78 19.1153 20.6378 19.3713 20.3533C19.6264 20.0698 19.754 19.7181 19.754 19.2983C19.754 18.8785 19.6264 18.5264 19.3713 18.2419C19.1153 17.9584 18.7984 17.8167 18.4207 17.8167H13.0873C12.7096 17.8167 12.3931 17.9584 12.138 18.2419C11.882 18.5264 11.754 18.8785 11.754 19.2983C11.754 19.7181 11.882 20.0698 12.138 20.3533C12.3931 20.6378 12.7096 20.78 13.0873 20.78ZM7.75399 10.4083C7.37622 10.4083 7.05933 10.2666 6.80333 9.98309C6.54822 9.69861 6.42066 9.34647 6.42066 8.92667C6.42066 8.50686 6.54822 8.15472 6.80333 7.87024C7.05933 7.58675 7.37622 7.445 7.75399 7.445H23.754C24.1318 7.445 24.4482 7.58675 24.7033 7.87024C24.9593 8.15472 25.0873 8.50686 25.0873 8.92667C25.0873 9.34647 24.9593 9.69861 24.7033 9.98309C24.4482 10.2666 24.1318 10.4083 23.754 10.4083H7.75399ZM10.4207 5.96333C10.0429 5.96333 9.726 5.82109 9.47 5.53661C9.21488 5.25312 9.08733 4.90147 9.08733 4.48167C9.08733 4.06186 9.21488 3.70972 9.47 3.42524C9.726 3.14175 10.0429 3 10.4207 3H21.0873C21.4651 3 21.7815 3.14175 22.0367 3.42524C22.2927 3.70972 22.4207 4.06186 22.4207 4.48167C22.4207 4.90147 22.2927 5.25312 22.0367 5.53661C21.7815 5.82109 21.4651 5.96333 21.0873 5.96333H10.4207ZM8.65399 26.7067H22.854H8.65399Z" />
</Icon>
);

Expand All @@ -40,7 +40,7 @@ function Icons(props: { type: "function" | "database" | "storage" | "logs" | "se
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M8.68733 29.67C8.04288 29.67 7.47088 29.4354 6.97133 28.9662C6.47088 28.497 6.16511 27.9043 6.05399 27.1882L4.02066 13.631C3.95399 13.1865 4.04866 12.7854 4.30466 12.4278C4.55977 12.0693 4.89844 11.89 5.32066 11.89H26.1873C26.6096 11.89 26.9482 12.0693 27.2033 12.4278C27.4593 12.7854 27.554 13.1865 27.4873 13.631L25.454 27.1882C25.3429 27.9043 25.0375 28.497 24.538 28.9662C24.0375 29.4354 23.4651 29.67 22.8207 29.67H8.68733ZM6.95399 14.8533L8.65399 26.7067H22.854L24.554 14.8533H6.95399ZM13.0873 20.78H18.4207C18.7984 20.78 19.1153 20.6378 19.3713 20.3533C19.6264 20.0698 19.754 19.7181 19.754 19.2983C19.754 18.8785 19.6264 18.5264 19.3713 18.2419C19.1153 17.9584 18.7984 17.8167 18.4207 17.8167H13.0873C12.7096 17.8167 12.3931 17.9584 12.138 18.2419C11.882 18.5264 11.754 18.8785 11.754 19.2983C11.754 19.7181 11.882 20.0698 12.138 20.3533C12.3931 20.6378 12.7096 20.78 13.0873 20.78ZM7.75399 10.4083C7.37622 10.4083 7.05933 10.2666 6.80333 9.98309C6.54822 9.69861 6.42066 9.34647 6.42066 8.92667C6.42066 8.50686 6.54822 8.15472 6.80333 7.87024C7.05933 7.58675 7.37622 7.445 7.75399 7.445H23.754C24.1318 7.445 24.4482 7.58675 24.7033 7.87024C24.9593 8.15472 25.0873 8.50686 25.0873 8.92667C25.0873 9.34647 24.9593 9.69861 24.7033 9.98309C24.4482 10.2666 24.1318 10.4083 23.754 10.4083H7.75399ZM10.4207 5.96333C10.0429 5.96333 9.726 5.82109 9.47 5.53661C9.21488 5.25312 9.08733 4.90147 9.08733 4.48167C9.08733 4.06186 9.21488 3.70972 9.47 3.42524C9.726 3.14175 10.0429 3 10.4207 3H21.0873C21.4651 3 21.7815 3.14175 22.0367 3.42524C22.2927 3.70972 22.4207 4.06186 22.4207 4.48167C22.4207 4.90147 22.2927 5.25312 22.0367 5.53661C21.7815 5.82109 21.4651 5.96333 21.0873 5.96333H10.4207ZM8.65399 26.7067H22.854H8.65399Z" />
<path d="M15.8531 3C9.30412 3 3.99976 5.65218 3.99976 8.92667V23.7433C3.99976 27.0178 9.31894 29.67 15.8531 29.67C22.3872 29.67 27.7064 27.0178 27.7064 23.7433V8.92667C27.7064 5.65218 22.4021 3 15.8531 3ZM24.7431 23.7433C24.7431 24.4842 21.5871 26.7067 15.8531 26.7067C10.119 26.7067 6.96309 24.4842 6.96309 23.7433V20.4392C9.34857 21.5949 12.4749 22.2617 15.8531 22.2617C19.2313 22.2617 22.3576 21.5949 24.7431 20.4392V23.7433ZM24.7431 17.0017C22.8169 18.4093 19.4387 19.2983 15.8531 19.2983C12.2675 19.2983 8.88926 18.4093 6.96309 17.0017V12.8383C9.14114 14.0681 12.3119 14.8533 15.8531 14.8533C19.3943 14.8533 22.565 14.0681 24.7431 12.8383V17.0017ZM15.8531 11.89C10.119 11.89 6.96309 9.6675 6.96309 8.92667C6.96309 8.18583 10.119 5.96333 15.8531 5.96333C21.5871 5.96333 24.7431 8.18583 24.7431 8.92667C24.7431 9.6675 21.5871 11.89 15.8531 11.89Z" />
</Icon>
);

Expand Down

0 comments on commit 5d411bb

Please sign in to comment.