Skip to content

Commit ff15f30

Browse files
authored
feat(web): add recharge bonus & autoscaling (#1263)
* feat(web): add recharge bonus & autoscaling
1 parent 6c01d95 commit ff15f30

File tree

11 files changed

+530
-179
lines changed

11 files changed

+530
-179
lines changed

web/public/locales/en/translation.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -444,5 +444,16 @@
444444
"AIWelcomeMessage": "Hello, I am Laf AI Development Assistant, how can I help you?",
445445
"Send": "Send",
446446
"Stop": "Stop",
447-
"SendMessagePlaceHolder": "Send a message"
447+
"SendMessagePlaceHolder": "Send a message",
448+
"application": {
449+
"bonus": "bonus",
450+
"Recharge": "Recharge",
451+
"RecommendedSpecifications": "Recommended Specifications: ",
452+
"ChooseSpecifications": "Choose Specifications",
453+
"autoscaling": "AutoScaling",
454+
"Number of Instances": "Number of Instances",
455+
"targetCPUUtilization": "CPU Utilization",
456+
"CPU Threshold": "CPU Threshold"
457+
},
458+
"Storage Threshold": "Storage Threshold"
448459
}

web/public/locales/zh-CN/translation.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -443,5 +443,15 @@
443443
"AIWelcomeMessage": "你好,我是 Laf AI 开发助理,请问有什么可以帮助您的吗?",
444444
"Send": "发送",
445445
"Stop": "停止",
446-
"SendMessagePlaceHolder": "提问"
446+
"SendMessagePlaceHolder": "提问",
447+
"application": {
448+
"bonus": "",
449+
"Recharge": "输入金额",
450+
"RecommendedSpecifications": "推荐规格",
451+
"ChooseSpecifications": "选择规格",
452+
"autoscaling": "弹性伸缩",
453+
"Number of Instances": "实例数",
454+
"CPU Threshold": "CPU 阈值"
455+
},
456+
"Storage Threshold": "存储阈值"
447457
}

web/public/locales/zh/translation.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -444,5 +444,15 @@
444444
"AIWelcomeMessage": "你好,我是 Laf AI 开发助理,请问有什么可以帮助您的吗?",
445445
"Send": "发送",
446446
"Stop": "停止",
447-
"SendMessagePlaceHolder": "提问"
447+
"SendMessagePlaceHolder": "提问",
448+
"application": {
449+
"bonus": "",
450+
"Recharge": "输入金额",
451+
"RecommendedSpecifications": "推荐规格",
452+
"ChooseSpecifications": "选择规格",
453+
"autoscaling": "弹性伸缩",
454+
"Number of Instances": "实例数",
455+
"CPU Threshold": "CPU 阈值"
456+
},
457+
"Storage Threshold": "存储阈值"
448458
}

web/src/apis/typing.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ export type TApplicationItem = {
323323
limitStorageTPS: number;
324324
reservedTimeAfterExpired: number;
325325
};
326+
autoscaling: {
327+
enable: boolean;
328+
minReplicas: number;
329+
maxReplicas: number;
330+
targetCPUUtilizationPercentage: number | null;
331+
targetMemoryUtilizationPercentage: number | null;
332+
};
326333
createdAt: string;
327334
updatedAt: string;
328335
};

web/src/apis/v1/accounts.ts

+20
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ export async function AccountControllerCharge(params: Definitions.CreateChargeOr
6868
});
6969
}
7070

71+
/**
72+
* Get charge reward list
73+
*/
74+
export async function AccountControllerGetChargeRewardList(
75+
params: Paths.AccountControllerGetChargeRewardList.BodyParameters,
76+
): Promise<{
77+
error: string;
78+
data: Paths.AccountControllerGetChargeRewardList.Responses;
79+
}> {
80+
// /v1/accounts/charge-reward
81+
let _params: { [key: string]: any } = {
82+
appid: useGlobalStore.getState().currentApp?.appid || "",
83+
...params,
84+
};
85+
return request(`/v1/accounts/charge-reward`, {
86+
method: "GET",
87+
params: params,
88+
});
89+
}
90+
7191
/**
7292
*
7393
*/

web/src/apis/v1/api-auto.d.ts

+54-55
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,6 @@ declare namespace Definitions {
207207
domain?: string;
208208
};
209209

210-
export type Pat2TokenDto = {
211-
pat?: string /* PAT */;
212-
};
213-
214-
export type UserWithProfile = {
215-
_id?: string;
216-
username?: string;
217-
email?: string;
218-
phone?: string;
219-
createdAt?: string;
220-
updatedAt?: string;
221-
profile?: Definitions.UserProfile;
222-
};
223-
224210
export type PasswdSignupDto = {
225211
username?: string /* username, 3-64 characters */;
226212
password?: string /* password, 8-64 characters */;
@@ -270,6 +256,20 @@ declare namespace Definitions {
270256
code?: string /* sms verify code */;
271257
};
272258

259+
export type Pat2TokenDto = {
260+
pat?: string /* PAT */;
261+
};
262+
263+
export type UserWithProfile = {
264+
_id?: string;
265+
username?: string;
266+
email?: string;
267+
phone?: string;
268+
createdAt?: string;
269+
updatedAt?: string;
270+
profile?: Definitions.UserProfile;
271+
};
272+
273273
export type CreatePATDto = {
274274
name?: string;
275275
expiresIn?: number;
@@ -285,18 +285,6 @@ declare namespace Definitions {
285285
name?: string;
286286
};
287287

288-
export type ApplicationBilling = {
289-
_id?: string;
290-
appid?: string;
291-
state?: string;
292-
amount?: number;
293-
detail?: Definitions.ApplicationBillingDetail;
294-
startAt?: string;
295-
endAt?: string;
296-
createdAt?: string;
297-
updatedAt?: string;
298-
};
299-
300288
export type CalculatePriceDto = {
301289
cpu?: number;
302290
memory?: number;
@@ -389,19 +377,6 @@ declare namespace Definitions {
389377
createdAt?: string;
390378
updatedAt?: string;
391379
};
392-
393-
export type ApplicationBillingDetail = {
394-
cpu?: Definitions.ApplicationBillingDetailItem;
395-
memory?: Definitions.ApplicationBillingDetailItem;
396-
databaseCapacity?: Definitions.ApplicationBillingDetailItem;
397-
storageCapacity?: Definitions.ApplicationBillingDetailItem;
398-
networkTraffic?: Definitions.ApplicationBillingDetailItem;
399-
};
400-
401-
export type ApplicationBillingDetailItem = {
402-
usage?: number;
403-
amount?: number;
404-
};
405380
}
406381

407382
declare namespace Paths {
@@ -413,6 +388,22 @@ declare namespace Paths {
413388
export type Responses = any;
414389
}
415390

391+
namespace AuthControllerPat2token {
392+
export type QueryParameters = any;
393+
394+
export type BodyParameters = any;
395+
396+
export type Responses = any;
397+
}
398+
399+
namespace AuthControllerGetProfile {
400+
export type QueryParameters = any;
401+
402+
export type BodyParameters = any;
403+
404+
export type Responses = any;
405+
}
406+
416407
namespace FunctionControllerCreate {
417408
export type QueryParameters = any;
418409

@@ -725,6 +716,14 @@ declare namespace Paths {
725716
export type Responses = any;
726717
}
727718

719+
namespace AccountControllerGetChargeRewardList {
720+
export type QueryParameters = any;
721+
722+
export type BodyParameters = any;
723+
724+
export type Responses = any;
725+
}
726+
728727
namespace AccountControllerWechatNotify {
729728
export type QueryParameters = any;
730729

@@ -781,22 +780,6 @@ declare namespace Paths {
781780
export type Responses = any;
782781
}
783782

784-
namespace AuthControllerPat2token {
785-
export type QueryParameters = any;
786-
787-
export type BodyParameters = Definitions.Pat2TokenDto;
788-
789-
export type Responses = any;
790-
}
791-
792-
namespace AuthControllerGetProfile {
793-
export type QueryParameters = any;
794-
795-
export type BodyParameters = any;
796-
797-
export type Responses = any;
798-
}
799-
800783
namespace UserPasswordControllerSignup {
801784
export type QueryParameters = any;
802785

@@ -869,6 +852,22 @@ declare namespace Paths {
869852
export type Responses = any;
870853
}
871854

855+
namespace AuthenticationControllerPat2token {
856+
export type QueryParameters = any;
857+
858+
export type BodyParameters = Definitions.Pat2TokenDto;
859+
860+
export type Responses = any;
861+
}
862+
863+
namespace AuthenticationControllerGetProfile {
864+
export type QueryParameters = any;
865+
866+
export type BodyParameters = any;
867+
868+
export type Responses = any;
869+
}
870+
872871
namespace PatControllerCreate {
873872
export type QueryParameters = any;
874873

web/src/apis/v1/auth.ts

+38
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,41 @@ export async function AuthenticationControllerBindUsername(
175175
data: params,
176176
});
177177
}
178+
179+
/**
180+
* Get user token by PAT
181+
*/
182+
export async function AuthenticationControllerPat2token(params: Definitions.Pat2TokenDto): Promise<{
183+
error: string;
184+
data: Paths.AuthenticationControllerPat2token.Responses;
185+
}> {
186+
// /v1/auth/pat2token
187+
let _params: { [key: string]: any } = {
188+
appid: useGlobalStore.getState().currentApp?.appid || "",
189+
...params,
190+
};
191+
return request(`/v1/auth/pat2token`, {
192+
method: "POST",
193+
data: params,
194+
});
195+
}
196+
197+
/**
198+
* Get current user profile
199+
*/
200+
export async function AuthenticationControllerGetProfile(
201+
params: Paths.AuthenticationControllerGetProfile.BodyParameters,
202+
): Promise<{
203+
error: string;
204+
data: Definitions.UserWithProfile;
205+
}> {
206+
// /v1/auth/profile
207+
let _params: { [key: string]: any } = {
208+
appid: useGlobalStore.getState().currentApp?.appid || "",
209+
...params,
210+
};
211+
return request(`/v1/auth/profile`, {
212+
method: "GET",
213+
params: params,
214+
});
215+
}

0 commit comments

Comments
 (0)