Skip to content

Commit

Permalink
feat(web): support dedicated database (#1730)
Browse files Browse the repository at this point in the history
* feat(web): support dedicated database

* fix(web): add key for map loop

* chore(web): diabled change database type

* fix(web): fix api type

* chore(web): change spec i18n

* feat(web): add dedicated db billing

* feat(web): add database monitor

* fix scrollbar bounce

* refactor ddb fields

* disabled reduce ddb capacity

---------

Co-authored-by: HUAHUAI23 <huahua1319873800@outlook.com>
  • Loading branch information
0fatal and HUAHUAI23 authored Jan 3, 2024
1 parent cae101b commit 6a02910
Show file tree
Hide file tree
Showing 41 changed files with 2,531 additions and 1,266 deletions.
2 changes: 1 addition & 1 deletion cli/src/action/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function init(appid: string, options: { sync: boolean; basicMode: b
policyPull()
// pull functions
funcPull({ force: true })
// pull env
// pull env
envPull()
}
console.log(`${getEmoji('🚀')} application ${app.name} init success`)
Expand Down
10 changes: 5 additions & 5 deletions cli/src/action/environment/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { environmentVariableControllerGet, environmentVariableControllerUpdateAll } from "../../api/v1/application";
import { AppSchema } from "../../schema/app";
import { EnvironmentSchema } from "../../schema/environment";
import { getEmoji } from "../../util/print";
import { environmentVariableControllerGet, environmentVariableControllerUpdateAll } from '../../api/v1/application'
import { AppSchema } from '../../schema/app'
import { EnvironmentSchema } from '../../schema/environment'
import { getEmoji } from '../../util/print'

export async function pull(): Promise<void> {
const appSchema = AppSchema.read()
Expand All @@ -15,4 +15,4 @@ export async function push(): Promise<void> {
const env = EnvironmentSchema.read()
await environmentVariableControllerUpdateAll(appSchema.appid, env)
console.log(`${getEmoji('✅')} env pushed`)
}
}
1 change: 0 additions & 1 deletion cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { command as triggerCommand } from './command/trigger'
import { command as databaseCommand } from './command/database'
import { command as environmentCommand } from './command/environment'


const program = new Command()
program.option('-v, --version', 'output version').action((options) => {
if (!options.version) {
Expand Down
8 changes: 2 additions & 6 deletions cli/src/schema/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import { ENVIRONMENT_SCHEMA_NAME } from '../common/constant'
import * as dotenv from 'dotenv'
import { exist } from '../util/file'


export class EnvironmentSchema {

variables: EnvironmentVariable[]


static read(): EnvironmentVariable[] {
const configPath = path.join(getAppPath(), ENVIRONMENT_SCHEMA_NAME)
if (!exist(configPath)) {
Expand All @@ -22,7 +19,7 @@ export class EnvironmentSchema {
for (const key in data) {
env.push({
name: key,
value: data[key]
value: data[key],
})
}
return env
Expand All @@ -36,10 +33,9 @@ export class EnvironmentSchema {
}
fs.writeFileSync(configPath, dataStr)
}

}

export interface EnvironmentVariable {
name: string
value: string
}
}
35 changes: 27 additions & 8 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@
"cpu": "CPU",
"memory": "Memory",
"databaseCapacity": "Database",
"storageCapacity": "Storage"
"storageCapacity": "Storage",
"capacity": "Capacity",
"replicas": "Replicas"
},
"LogPanel": {
"Detail": "Log Details",
Expand Down Expand Up @@ -227,15 +229,18 @@
"CostTrend": "Cost Trend",
"Balance": "Balance",
"Pause": "Pause",
"AppMonitor": "Application Monitor",
"PauseTips": "Are you sure you want to pause this application?",
"RestartTips": "Are you sure you want to restart this application?",
"CommonSetting": "Common Settings",
"ClientSetting": "Client Settings",
"EditorFont": "Editor Font",
"FontSize": "Font Size",
"FuncListDisplay": "Function List Display",
"ListDisplay": "List Display"
"ListDisplay": "List Display",
"OldLogs": "Old Logs",
"MonitorSetting": "Resource Monitor",
"DatabaseMonitor": "Database monitor",
"RuntimeMonitor": "Runtime monitor",
"ClientSetting": "Client settings"
},
"StoragePanel": {
"All": "Total Capacity",
Expand Down Expand Up @@ -365,7 +370,8 @@
"RAM": "RAM",
"Database": "Database",
"Storage": "Storage",
"NetworkTraffic": "NetworkTraffic"
"NetworkTraffic": "NetworkTraffic",
"QueryOperand": "Query operands"
},
"Price": {
"Free": "Free"
Expand Down Expand Up @@ -526,7 +532,12 @@
"ChooseSpecifications": "Choose Specifications",
"autoscaling": "AutoScaling",
"Number of Instances": "Number of Instances",
"CPU Threshold": "CPU Threshold"
"CPU Threshold": "CPU Threshold",
"DatabaseSpecification": "Database specification",
"DedicatedType": "Dedicated",
"SharedType": "Shared",
"ApplicationSecification": "Application specification",
"DatabaseCreateTip": "Once a database is created, its type and number of instances cannot be temporarily modified. The capacity can only increase, not decrease. If there are special needs, please contact our customer service."
},
"Storage Threshold": "Storage Threshold",
"Template": {
Expand Down Expand Up @@ -705,10 +716,18 @@
},
"Deprecated": "Deprecated",
"All": "All",
"DatabaseMonitor": {
"Connections": "Connections",
"DocumentOperand": "Document operands",
"PageError": "Page error(ops/s)",
"Resource": "Resource",
"Performance": "Performance",
"Capacity": "Capacity"
},
"DatabaseBundleControlTip": "Once a database is created, its type and number of instances cannot be temporarily modified, and its capacity can only increase and not decrease. If you have special needs, please contact customer service",
"MoveFunction": "Move function",
"UpgradeVersionTip": {
"Title": "Laf is ready to update!",
"Description": "Click to update"
}
}

}
34 changes: 27 additions & 7 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@
"cpu": "CPU",
"memory": "内存",
"databaseCapacity": "数据库",
"storageCapacity": "云存储"
"storageCapacity": "云存储",
"capacity": "容量",
"replicas": "实例数"
},
"LogPanel": {
"Detail": "日志详情",
Expand Down Expand Up @@ -227,15 +229,18 @@
"CostTrend": "成本趋势",
"Balance": "余额",
"Pause": "暂停应用",
"AppMonitor": "资源监控",
"PauseTips": "确定要暂停此应用吗?",
"RestartTips": "确定要重启此应用吗?",
"CommonSetting": "常用设置",
"ClientSetting": "客户端设置",
"EditorFont": "编辑器字体",
"FontSize": "字体大小",
"FuncListDisplay": "函数列表显示",
"ListDisplay": "列表显示"
"ListDisplay": "列表显示",
"OldLogs": "旧版日志",
"MonitorSetting": "资源监控",
"DatabaseMonitor": "数据库监控",
"RuntimeMonitor": "运行时监控",
"ClientSetting": "客户端设置"
},
"StoragePanel": {
"All": "总容量",
Expand Down Expand Up @@ -365,7 +370,8 @@
"RAM": "内存",
"Database": "数据库",
"Storage": "云存储",
"NetworkTraffic": "出网流量"
"NetworkTraffic": "出网流量",
"QueryOperand": "查询操作数"
},
"Price": {
"Free": "免费"
Expand Down Expand Up @@ -575,7 +581,12 @@
"ChooseSpecifications": "选择规格",
"autoscaling": "弹性伸缩",
"Number of Instances": "实例数",
"CPU Threshold": "CPU 阈值"
"CPU Threshold": "CPU 阈值",
"DatabaseSpecification": "数据库规格",
"DedicatedType": "专用型",
"SharedType": "共享型",
"ApplicationSecification": "应用规格",
"DatabaseCreateTip": "数据库一旦创建后,暂时无法修改类型和实例数,容量只增不减,如有特殊需要请联系客服"
},
"Storage Threshold": "内存阈值",
"Yesterday": "昨天",
Expand Down Expand Up @@ -705,9 +716,18 @@
},
"Deprecated": "已弃用",
"All": "全部",
"DatabaseMonitor": {
"Connections": "连接数",
"DocumentOperand": "文档操作数",
"PageError": "页错误(ops/s)",
"Resource": "资源",
"Performance": "性能",
"Capacity": "容量"
},
"DatabaseBundleControlTip": "数据库一旦创建后,暂时无法修改类型和实例数,容量只增不减,如有特殊需要请联系客服",
"MoveFunction": "移动函数",
"UpgradeVersionTip": {
"Title": "Laf 新版本已经准备好了!",
"Description": "点击立即更新"
}
}
}
35 changes: 27 additions & 8 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@
"cpu": "CPU",
"memory": "内存",
"databaseCapacity": "数据库",
"storageCapacity": "云存储"
"storageCapacity": "云存储",
"capacity": "容量",
"replicas": "实例数"
},
"LogPanel": {
"Detail": "日志详情",
Expand Down Expand Up @@ -227,15 +229,18 @@
"CostTrend": "成本趋势",
"Balance": "余额",
"Pause": "暂停应用",
"AppMonitor": "资源监控",
"PauseTips": "确定要暂停此应用吗?",
"RestartTips": "确定要重启此应用吗?",
"CommonSetting": "常用设置",
"ClientSetting": "客户端设置",
"EditorFont": "编辑器字体",
"FontSize": "字体大小",
"FuncListDisplay": "函数列表显示",
"ListDisplay": "列表显示"
"ListDisplay": "列表显示",
"OldLogs": "旧版日志",
"MonitorSetting": "资源监控",
"DatabaseMonitor": "数据库监控",
"RuntimeMonitor": "运行时监控",
"ClientSetting": "客户端设置"
},
"StoragePanel": {
"All": "总容量",
Expand Down Expand Up @@ -365,7 +370,8 @@
"RAM": "内存",
"Database": "数据库",
"Storage": "云存储",
"NetworkTraffic": "出网流量"
"NetworkTraffic": "出网流量",
"QueryOperand": "查询操作数"
},
"Price": {
"Free": "免费"
Expand Down Expand Up @@ -575,7 +581,12 @@
"ChooseSpecifications": "选择规格",
"autoscaling": "弹性伸缩",
"Number of Instances": "实例数",
"CPU Threshold": "CPU 阈值"
"CPU Threshold": "CPU 阈值",
"DatabaseSpecification": "数据库规格",
"DedicatedType": "专用型",
"SharedType": "共享型",
"ApplicationSecification": "应用规格",
"DatabaseCreateTip": "数据库一旦创建后,暂时无法修改类型和实例数,容量只增不减,如有特殊需要请联系客服"
},
"Storage Threshold": "内存阈值",
"Yesterday": "昨天",
Expand Down Expand Up @@ -705,10 +716,18 @@
},
"Deprecated": "已弃用",
"All": "全部",
"DatabaseMonitor": {
"Connections": "连接数",
"DocumentOperand": "文档操作数",
"PageError": "页错误(ops/s)",
"Resource": "资源",
"Performance": "性能",
"Capacity": "容量"
},
"DatabaseBundleControlTip": "数据库一旦创建后,暂时无法修改类型和实例数,容量只增不减,如有特殊需要请联系客服",
"MoveFunction": "移动函数",
"UpgradeVersionTip": {
"Title": "Laf 新版本已经准备好了!",
"Description": "点击立即更新"
}
}

}
29 changes: 17 additions & 12 deletions web/src/App.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* stylelint-disable at-rule-no-unknown */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* stylelint-enable at-rule-no-unknown */

:root {
--bg-color: #fafafa;
Expand All @@ -9,7 +11,7 @@
/* 设置滚动条的样式 */
::-webkit-scrollbar {
width: 4px;
height: 6px;
height: 4px;
}

body::-webkit-scrollbar {
Expand All @@ -25,7 +27,7 @@ body::-webkit-scrollbar {
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
border-radius: 4px;
background: rgba(0, 0, 0, 0.2);
background: rgb(0 0 0 / 20%);
}

html,
Expand All @@ -40,18 +42,20 @@ body {
background-position: center !important;
font-variant-numeric: lining-nums;
font-size: 12px;
/* stylelint-disable font-family-no-duplicate-names */
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", Helvetica, Arial,
"PingFang SC", "Noto Sans SC", sans-serif !important;
}

[data-theme="light"] body {
background-color: #eef0f2 !important;

/* background-image: url("/bg.png") !important; */
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
/* 滚动条滑块 */
background: rgba(21, 22, 26, 0.4);
background: rgb(21 22 26 / 40%);
}

a {
Expand Down Expand Up @@ -80,20 +84,21 @@ a {
font-weight: 400;
src: url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.eot"),
/* IE9 Compat Modes */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.eot?#iefix")
format("embedded-opentype"),
/* IE6-IE8 */ url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.woff2")
format("woff2"),
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.eot?#iefix") format("embedded-opentype"),
/* IE6-IE8 */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.woff2") format("woff2"),
/* Super Modern Browsers */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.woff") format("woff"),
/* Modern Browsers */ url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.ttf")
format("truetype"),
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.woff") format("woff"),
/* Modern Browsers */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.ttf") format("truetype"),
/* Safari, Android, iOS */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.svg#NotoSans SC") format("svg"); /* Legacy iOS */
url("//lib.baomitu.com/fonts/noto-sans-sc/noto-sans-sc-regular.svg#NotoSans SC") format("svg");

/* Legacy iOS */
}

@font-face {
font-family: "Noto Sans SC";
font-weight: 500 600;
src: url("/fonts/NotoSansSC-Medium.ttf");
}
}
Loading

0 comments on commit 6a02910

Please sign in to comment.