Skip to content

Commit

Permalink
Merge pull request #19 from iceljc/bugfix/use-axios-get
Browse files Browse the repository at this point in the history
use get
  • Loading branch information
Oceania2018 authored Jan 23, 2024
2 parents f421ee6 + 39de4f3 commit 9f2239a
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 42 deletions.
12 changes: 5 additions & 7 deletions src/lib/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ export async function getSettings() {
return response.data;
}

/**
* Get conversation list
* @param {import('$types').ConversationFilter} filter
* @returns {Promise<import('$types').PagedItems<import('$types').ConversationModel>>}
*/

/**
* Get agent list
* @param {import('$types').AgentFilter} filter
* @returns {Promise<import('$types').PagedItems<import('$types').AgentModel>>}
*/
export async function getAgents(filter) {
let url = endpoints.agentListUrl;
const response = await axios.post(url, { ...filter });
const response = await axios.get(url, { params: filter,
paramsSerializer: {
dots: true
}
});
return response.data;
}

Expand Down
6 changes: 5 additions & 1 deletion src/lib/services/conversation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export async function getConversation(id) {
*/
export async function getConversations(filter) {
let url = endpoints.conversationsUrl;
const response = await axios.post(url, { ...filter });
const response = await axios.get(url, { params: filter,
paramsSerializer: {
dots: true
}
});
return response.data;
}

Expand Down
6 changes: 5 additions & 1 deletion src/lib/services/plugin-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import axios from 'axios';
*/
export async function getPlugins(filter) {
let url = endpoints.pluginListUrl;
const response = await axios.post(url, { ...filter });
const response = await axios.get(url, { params: filter,
paramsSerializer: {
dots: true
}
});
return response.data;
}

Expand Down
24 changes: 12 additions & 12 deletions src/routes/page/agent/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
import HeadTitle from '$lib/common/HeadTitle.svelte';
import CardAgent from './card-agent.svelte';
import { getAgents } from '$lib/services/agent-service.js';
import { onMount } from 'svelte';
import { getAgents } from '$lib/services/agent-service.js';
import { onMount } from 'svelte';
import PlainPagination from '$lib/common/PlainPagination.svelte';
const firstPage = 1;
const firstPage = 1;
const pageSize = 12;
/** @type {import('$types').PagedItems<import('$types').AgentModel>} */
let agents = { items: [], count: 0 };
let agents = { items: [], count: 0 };
/** @type {import('$types').AgentFilter} */
const initFilter = {
pager: { page: firstPage, size: pageSize, count: 0 },
isEvaluator: false
isEvaluator: false
};
/** @type {import('$types').AgentFilter} */
let filter = { ... initFilter };
/** @type {import('$types').AgentFilter} */
let filter = { ... initFilter };
/** @type {import('$types').Pagination} */
let pager = filter.pager;
onMount(async () => {
await getPagedAgents();
});
onMount(async () => {
await getPagedAgents();
});
async function getPagedAgents() {
agents = await getAgents(filter);
async function getPagedAgents() {
agents = await getAgents(filter);
refresh();
}
Expand Down
18 changes: 14 additions & 4 deletions src/routes/page/agent/router/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@
let isRouterNodeSelected = false;
let isAgentNodeSelected = false;
/** @type {import('$types').AgentFilter} */
const filter = {
pager: { page: 1, size: 10, count: 0 },
isRouter: true
};
onMount(async () => {
let list = await getAgents({
isRouter: true
});
router = list[0];
await getRouter();
});
async function getRouter() {
const response = await getAgents(filter);
if (response.items?.length > 0) {
router = response.items[0];
}
};
function handleUserNodeSelected() {
isRouterNodeSelected = false;
isAgentNodeSelected = false;
Expand Down
40 changes: 23 additions & 17 deletions src/routes/page/agent/router/routing-flow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@
import { getAgents } from '$lib/services/agent-service.js';
import { onMount, createEventDispatcher } from 'svelte';
/** @type {import('$types').AgentModel[]} */
/** @type any[]} */
let agents = [];
/** @type {import('$types').AgentFilter} */
const filter = {
pager: { page: 1, size: 20, count: 0 },
isRouter: false,
isEvaluator: false,
disabled: false,
allowRouting: false
};
/** @type {import('$types').AgentModel} */
export let router;
const dispatch = createEventDispatcher();
onMount(async () => {
agents = await getAgents({
isRouter: false,
isEvaluator: false,
disabled: false,
allowRouting: true
});
const response = await getAgents(filter);
agents = response?.items || [];
// add a "New Agent" button
agents.push({
name: "New Agent",
allowRouting: true
});
name: "New Agent",
allow_routing: true
});
const container = document.getElementById("drawflow");
const editor = new Drawflow(container);
editor.reroute = true;
editor.reroute_fix_curvature = true;
editor.start();
renderRoutingFlow(editor);
if (!!container) {
const editor = new Drawflow(container);
editor.reroute = true;
editor.reroute_fix_curvature = true;
editor.start();
renderRoutingFlow(editor);
}
});
/** @param {Drawflow} editor*/
Expand Down

0 comments on commit 9f2239a

Please sign in to comment.