Skip to content

Commit a61a509

Browse files
author
Visagan Guruparan
committed
Update rule trigger api routing by agentId
1 parent 7a969eb commit a61a509

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/lib/services/agent-service.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ export async function getAgentRuleOptions() {
115115
return response.data;
116116
}
117117

118+
/**
119+
* Get agent rule options by agent id
120+
* @param {string} agentId
121+
* @returns {Promise<import('$agentTypes').AgentRule[]>}
122+
*/
123+
export async function getAgentRuleOptionsById(agentId) {
124+
const url = endpoints.agentRuleOptionsByIdUrl.replace("{agentId}", agentId);;
125+
const response = await axios.get(url);
126+
return response.data;
127+
}
128+
118129
/**
119130
* Get agent rule config options
120131
* @returns {Promise<any>}

src/lib/services/api-endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const endpoints = {
4040
agentCreateUrl: `${host}/agent`,
4141
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
4242
agentRuleOptionsUrl: `${host}/rule/triggers`,
43+
agentRuleOptionsByIdUrl: `${host}/rule/triggers/{agentId}`,
4344
agentRuleConfigOptionsUrl: `${host}/rule/config/options`,
4445
agentLabelsUrl: `${host}/agent/labels`,
4546

src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import { onMount } from 'svelte';
3-
import { getAgentRuleOptions, getAgentRuleConfigOptions } from '$lib/services/agent-service';
3+
import { getAgentRuleOptionsById, getAgentRuleConfigOptions } from '$lib/services/agent-service';
44
import LoadingToComplete from '$lib/common/spinners/LoadingToComplete.svelte';
55
import { scrollToBottom } from '$lib/helpers/utils/common';
66
import AgentRuleItem from './agent-rule-item.svelte';
@@ -89,7 +89,7 @@
8989
9090
function loadAgentRuleOptions() {
9191
return new Promise((resolve) => {
92-
getAgentRuleOptions().then(data => {
92+
getAgentRuleOptionsById(agent.id).then(data => {
9393
const list = data?.map(x => {
9494
return {
9595
name: x.trigger_name,

0 commit comments

Comments
 (0)