Skip to content

Commit 6a13012

Browse files
author
Jicheng Lu
committed
add rule config
1 parent 6bf25ee commit 6a13012

8 files changed

Lines changed: 235 additions & 161 deletions

File tree

src/lib/common/modals/PlainModal.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { Modal, ModalBody, ModalHeader } from "@sveltestrap/sveltestrap";
2+
import { Modal, ModalBody } from "@sveltestrap/sveltestrap";
33
44
/** @type {boolean} */
55
export let isOpen;
@@ -16,6 +16,9 @@
1616
/** @type {string} */
1717
export let containerStyles = '';
1818
19+
/** @type {string} */
20+
export let bodyStyles = '';
21+
1922
/** @type {() => void} */
2023
export let toggleModal;
2124
</script>
@@ -30,7 +33,7 @@
3033
toggle={() => toggleModal()}
3134
unmountOnClose
3235
>
33-
<ModalBody>
36+
<ModalBody style={bodyStyles}>
3437
<slot />
3538
</ModalBody>
3639
</Modal>

src/lib/helpers/types/agentTypes.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,12 @@
231231
* @property {string} trigger_name
232232
* @property {string?} [displayName]
233233
* @property {boolean} disabled
234-
* @property {AgentRuleCriteria?} [rule_criteria]
235234
* @property {any?} [output_args]
236235
* @property {string?} [json_args]
237236
* @property {string?} [statement]
238237
* @property {boolean} [expanded]
239238
*/
240239

241-
/**
242-
* @typedef {Object} AgentRuleCriteria
243-
* @property {string?} [name]
244-
* @property {string?} [criteria_text]
245-
* @property {boolean} disabled
246-
* @property {any} [config]
247-
*/
248-
249-
250240
/**
251241
* @typedef {Object} AgentTaskSearchOption
252242
* @property {string?} [agentId]

src/lib/scss/custom/pages/_agent.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@
338338
max-height: 200px;
339339
}
340340

341+
.rule-config-modal {
342+
.modal-content {
343+
width: 1400px;
344+
max-width: calc(100vw - 2rem);
345+
height: 80vh;
346+
margin: 0 auto;
347+
}
348+
349+
.modal-body {
350+
height: 100%;
351+
box-sizing: border-box;
352+
}
353+
}
354+
341355
.code-editor {
342356
max-height: 500px;
343357
overflow-y: auto;

src/lib/services/agent-service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ export async function getAgentRuleOptions() {
117117

118118
/**
119119
* Get agent rule criteria providers
120-
* @returns {Promise<import('$commonTypes').KeyValuePair[]>}
120+
* @returns {Promise<any[]>}
121121
*/
122-
export async function getAgentRuleCriteriaProviders() {
123-
const url = endpoints.agentRuleCriteriaProvidersUrl;
122+
export async function getAgentRuleConfigOptions() {
123+
const url = endpoints.agentRuleConfigOptionsUrl;
124124
const response = await axios.get(url);
125125
return response.data;
126126
}

src/lib/services/api-endpoints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const endpoints = {
4040
agentCreateUrl: `${host}/agent`,
4141
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
4242
agentRuleOptionsUrl: `${host}/rule/triggers`,
43-
agentRuleCriteriaProvidersUrl: `${host}/rule/criteria-providers`,
43+
agentRuleConfigOptionsUrl: `${host}/rule/config/options`,
4444
agentLabelsUrl: `${host}/agent/labels`,
4545

4646
// agent code script:

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
/** @type {any[]} */
2828
export let ruleOptions = [];
2929
30-
/** @type {any[]} */
31-
export let criteriaOptions = [];
30+
/** @type {any} */
31+
export let configOptions = {};
3232
3333
/** @type {number} */
3434
export let windowWidth;
@@ -80,6 +80,12 @@
8080
rule: rule
8181
});
8282
}
83+
84+
function toggleConfig() {
85+
svelteDispatch('config', {
86+
ruleIdx: ruleIndex
87+
});
88+
}
8389
</script>
8490
8591
<div class="utility-wrapper">
@@ -133,6 +139,22 @@
133139
</BotsharpTooltip>
134140
</div>
135141
{/if}
142+
143+
{#if ADMIN_ROLES.includes(user?.role || '') && !!rule.trigger_name && Object.keys(configOptions || {}).length > 0}
144+
<!-- svelte-ignore a11y-no-static-element-interactions -->
145+
<div class="line-align-center">
146+
<!-- svelte-ignore a11y-click-events-have-key-events -->
147+
<i
148+
class="bx bx-cog text-primary fs-6 clickable"
149+
style="padding-top: 2px;"
150+
id={`rule-config-${ruleIndex}`}
151+
data-bs-toggle="tooltip"
152+
data-bs-placement="top"
153+
title="Rule config"
154+
on:click={() => toggleConfig()}
155+
/>
156+
</div>
157+
{/if}
136158
</div>
137159
</div>
138160
<div class="utility-value">
@@ -164,7 +186,7 @@
164186
{#if !collapsed}
165187
<div class="utility-row utility-row-secondary" transition:slide={{ duration: duration }}>
166188
<div class="utility-content">
167-
<div class="utility-list-item">
189+
<!-- <div class="utility-list-item">
168190
<div class="utility-label line-align-center">
169191
<div class="d-flex gap-1">
170192
<div class="line-align-center">
@@ -286,7 +308,7 @@
286308
<div class="utility-delete line-align-center"></div>
287309
</div>
288310
</div>
289-
{/if}
311+
{/if} -->
290312
</div>
291313
</div>
292314
{/if}

0 commit comments

Comments
 (0)