diff --git a/backend/.sqlx/query-c4e0f3eab227a798d9cd7478db50a7c1a588e69c2c8d9a1def9276ba326453d2.json b/backend/.sqlx/query-c4e0f3eab227a798d9cd7478db50a7c1a588e69c2c8d9a1def9276ba326453d2.json
new file mode 100644
index 0000000000..bd16dab3bf
--- /dev/null
+++ b/backend/.sqlx/query-c4e0f3eab227a798d9cd7478db50a7c1a588e69c2c8d9a1def9276ba326453d2.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "INSERT INTO cloud_workspace_settings (workspace_id, threshold_alert_amount) VALUES ($1, $2) ON CONFLICT (workspace_id) DO UPDATE SET threshold_alert_amount = $2, last_alert_sent = NULL",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Varchar",
+ "Int4"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "c4e0f3eab227a798d9cd7478db50a7c1a588e69c2c8d9a1def9276ba326453d2"
+}
diff --git a/backend/.sqlx/query-f74589aaa72d0eb9f44157cc60eb121e63a7f31ed849834bb8ac9e8c726e81f1.json b/backend/.sqlx/query-f74589aaa72d0eb9f44157cc60eb121e63a7f31ed849834bb8ac9e8c726e81f1.json
new file mode 100644
index 0000000000..46fe54f755
--- /dev/null
+++ b/backend/.sqlx/query-f74589aaa72d0eb9f44157cc60eb121e63a7f31ed849834bb8ac9e8c726e81f1.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "SELECT threshold_alert_amount, last_alert_sent FROM cloud_workspace_settings WHERE workspace_id = $1",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "threshold_alert_amount",
+ "type_info": "Int4"
+ },
+ {
+ "ordinal": 1,
+ "name": "last_alert_sent",
+ "type_info": "Timestamp"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ true,
+ true
+ ]
+ },
+ "hash": "f74589aaa72d0eb9f44157cc60eb121e63a7f31ed849834bb8ac9e8c726e81f1"
+}
diff --git a/backend/.sqlx/query-49a8fe5c538d8fc26f6d8ece5b30dd02a128f571039714e61525e2bb86591d93.json b/backend/.sqlx/query-f8f893fb4f6f8c16bffb233a585df0b8c007c24993979fdc013aa57583905f50.json
similarity index 54%
rename from backend/.sqlx/query-49a8fe5c538d8fc26f6d8ece5b30dd02a128f571039714e61525e2bb86591d93.json
rename to backend/.sqlx/query-f8f893fb4f6f8c16bffb233a585df0b8c007c24993979fdc013aa57583905f50.json
index b67bf27a83..759f91c962 100644
--- a/backend/.sqlx/query-49a8fe5c538d8fc26f6d8ece5b30dd02a128f571039714e61525e2bb86591d93.json
+++ b/backend/.sqlx/query-f8f893fb4f6f8c16bffb233a585df0b8c007c24993979fdc013aa57583905f50.json
@@ -1,30 +1,35 @@
{
"db_name": "PostgreSQL",
- "query": "SELECT premium, usage.usage as \"usage?\", workspace_settings.customer_id, workspace_settings.plan, workspace_settings.automatic_billing FROM workspace LEFT JOIN workspace_settings ON workspace_settings.workspace_id = $1 LEFT JOIN usage ON usage.id = $1 AND month_ = EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date) AND usage.is_workspace IS true WHERE workspace.id = $1",
+ "query": "SELECT owner, premium, usage.usage as \"usage?\", workspace_settings.customer_id, workspace_settings.plan, workspace_settings.automatic_billing FROM workspace LEFT JOIN workspace_settings ON workspace_settings.workspace_id = $1 LEFT JOIN usage ON usage.id = $1 AND month_ = EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date) AND usage.is_workspace IS true WHERE workspace.id = $1",
"describe": {
"columns": [
{
"ordinal": 0,
+ "name": "owner",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 1,
"name": "premium",
"type_info": "Bool"
},
{
- "ordinal": 1,
+ "ordinal": 2,
"name": "usage?",
"type_info": "Int4"
},
{
- "ordinal": 2,
+ "ordinal": 3,
"name": "customer_id",
"type_info": "Varchar"
},
{
- "ordinal": 3,
+ "ordinal": 4,
"name": "plan",
"type_info": "Varchar"
},
{
- "ordinal": 4,
+ "ordinal": 5,
"name": "automatic_billing",
"type_info": "Bool"
}
@@ -35,6 +40,7 @@
]
},
"nullable": [
+ false,
false,
false,
true,
@@ -42,5 +48,5 @@
false
]
},
- "hash": "49a8fe5c538d8fc26f6d8ece5b30dd02a128f571039714e61525e2bb86591d93"
+ "hash": "f8f893fb4f6f8c16bffb233a585df0b8c007c24993979fdc013aa57583905f50"
}
diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt
index ba1714d994..2f8cf983a0 100644
--- a/backend/ee-repo-ref.txt
+++ b/backend/ee-repo-ref.txt
@@ -1 +1 @@
-fb5e285c316f10fa2188318585573c7e85999784
\ No newline at end of file
+ddcfdfc18a9833a5fc4e62ad62a265ef1e06a0aa
\ No newline at end of file
diff --git a/backend/migrations/20250116154037_cloud_team_threshold_alert.down.sql b/backend/migrations/20250116154037_cloud_team_threshold_alert.down.sql
new file mode 100644
index 0000000000..786105bfb3
--- /dev/null
+++ b/backend/migrations/20250116154037_cloud_team_threshold_alert.down.sql
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS cloud_workspace_settings;
\ No newline at end of file
diff --git a/backend/migrations/20250116154037_cloud_team_threshold_alert.up.sql b/backend/migrations/20250116154037_cloud_team_threshold_alert.up.sql
new file mode 100644
index 0000000000..430f84f233
--- /dev/null
+++ b/backend/migrations/20250116154037_cloud_team_threshold_alert.up.sql
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS cloud_workspace_settings (
+ workspace_id VARCHAR(50) NOT NULL,
+ threshold_alert_amount INT NULL,
+ last_alert_sent TIMESTAMP NULL,
+ PRIMARY KEY (workspace_id),
+ FOREIGN KEY (workspace_id) REFERENCES workspace(id) ON DELETE CASCADE
+)
\ No newline at end of file
diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml
index 5d3a980657..e515b52d4f 100644
--- a/backend/windmill-api/openapi.yaml
+++ b/backend/windmill-api/openapi.yaml
@@ -1812,10 +1812,12 @@ paths:
type: number
automatic_billing:
type: boolean
+ owner:
+ type: string
required:
- premium
- automatic_billing
-
+ - owner
/w/{workspace}/workspaces/set_automatic_billing:
post:
summary: set automatic billing
@@ -1847,6 +1849,55 @@ paths:
schema:
type: string
+
+ /w/{workspace}/workspaces/threshold_alert:
+ get:
+ summary: get threshold alert info
+ operationId: getThresholdAlert
+ tags:
+ - workspace
+ parameters:
+ - $ref: "#/components/parameters/WorkspaceId"
+
+ responses:
+ "200":
+ description: status
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ threshold_alert_amount:
+ type: number
+ last_alert_sent:
+ type: string
+ format: date-time
+ post:
+ summary: set threshold alert info
+ operationId: setThresholdAlert
+ tags:
+ - workspace
+ parameters:
+ - $ref: "#/components/parameters/WorkspaceId"
+ requestBody:
+ description: threshold alert info
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ threshold_alert_amount:
+ type: number
+
+ responses:
+ "200":
+ description: status
+ content:
+ text/plain:
+ schema:
+ type: string
+
/w/{workspace}/workspaces/edit_slack_command:
post:
summary: edit slack command
diff --git a/frontend/src/lib/components/Range.svelte b/frontend/src/lib/components/Range.svelte
index 8ffed2ea89..0e92ac72de 100644
--- a/frontend/src/lib/components/Range.svelte
+++ b/frontend/src/lib/components/Range.svelte
@@ -7,6 +7,8 @@
export let value = typeof initialValue === 'string' ? parseInt(initialValue) : initialValue
export let disabled: boolean = false
export let defaultValue: number | undefined = undefined
+ export let format: (value: number) => string = (v) => `${v}`
+ export let hideInput: boolean = false
let step: number = 1
@@ -23,10 +25,6 @@
$: axisStep = calculateAxisStep(min, max)
- const format = (v, i, p) => {
- return `${v}`
- }
-
function handleKeyDown(event: KeyboardEvent) {
if (disabled) return
@@ -85,7 +83,9 @@
{/if}
-
+ {#if !hideInput}
+
+ {/if}