diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 06af8793..af4db401 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -125,6 +125,8 @@ export const UserPermission = Object.freeze(userPermission); const userAction = { Edit: "edit", + Train: "train", + Evaluate: "evaluate", Chat: "chat" }; export const UserAction = Object.freeze(userAction); diff --git a/src/lib/helpers/types/roleTypes.js b/src/lib/helpers/types/roleTypes.js index 8ff08ccf..1e036b99 100644 --- a/src/lib/helpers/types/roleTypes.js +++ b/src/lib/helpers/types/roleTypes.js @@ -3,9 +3,32 @@ * @property {string} id - The user id. * @property {string} [name] - Role name * @property {string[]} permissions - Permissions. + * @property {RoleAgentAction[]} agent_actions - Agent actions * @property {string} [create_date] - The user create date. * @property {string} [update_date] - The user update date. + * @property {boolean} [open_detail] */ +/** + * @typedef {Object} RoleAgentAction + * @property {string?} [id] - The id + * @property {string} agent_id - The agent id + * @property {import('$agentTypes').AgentModel} [agent] - The agent details + * @property {string[]} actions - The actions + */ + +/** + * @typedef {Object} RoleAgentInnerAction + * @property {string?} [id] - The id + * @property {string} agent_id - The agent id + * @property {string} [agent_name] - The agent name + * @property {import('$agentTypes').AgentModel} [agent] - The agent details + * @property {{ key: string, value: string, checked: boolean }[]} actions - The actions + */ + +/** + * @typedef {Object} RoleFilter + * @property {string[]} [names] - The role names. + */ export default {}; \ No newline at end of file diff --git a/src/lib/helpers/types/userTypes.js b/src/lib/helpers/types/userTypes.js index 529afe2b..e48a8517 100644 --- a/src/lib/helpers/types/userTypes.js +++ b/src/lib/helpers/types/userTypes.js @@ -44,6 +44,7 @@ * @property {string[]} [user_ids] - The user ids. * @property {string[]} [user_names] - The user names * @property {string[]} [roles] - The roles. + * @property {string[]} [types] - The types. * @property {string[]} [sources] - The sources. * @property {string[]} [external_ids] - The external ids. */ diff --git a/src/lib/scss/app.scss b/src/lib/scss/app.scss index 7d112623..604f0c2d 100644 --- a/src/lib/scss/app.scss +++ b/src/lib/scss/app.scss @@ -94,6 +94,7 @@ File: Main Css File @import "custom/pages/agent"; @import "custom/pages/knowledgebase"; @import "custom/pages/users"; +@import "custom/pages/roles"; // Common @import "custom/common/animation"; diff --git a/src/lib/scss/custom/pages/_roles.scss b/src/lib/scss/custom/pages/_roles.scss new file mode 100644 index 00000000..076c2695 --- /dev/null +++ b/src/lib/scss/custom/pages/_roles.scss @@ -0,0 +1,119 @@ +.roles-table { + .role-plain-col { + width: 10%; + max-width: 100px; + } + + .role-permission-col { + width: 40%; + max-width: 300px; + } + + .role-detail { + padding: 2px 5px; + border-radius: 3px; + border-color: var(--#{$prefix}light) !important; + background-color: var(--#{$prefix}light) !important; + position: relative; + + ul { + li { + margin: 2px 0px; + } + } + + .wrappable { + white-space: wrap !important; + } + + .basic-info { + margin: 15px 0px 0px 0px; + display: flex; + flex-wrap: wrap; + + li { + flex: 0 0 50%; + + .inline-edit { + display: flex; + gap: 3px; + } + } + } + + .role-permission-container { + display: flex; + gap: 5px; + + .permission-wrapper { + display: flex; + flex-direction: column; + gap: 3px; + + .edit-wrapper { + display: flex; + gap: 3px; + } + + input[type="text"] { + height: 30px; + font-size: 12px; + } + } + + + .list-add { + font-size: 18px; + } + } + + .role-agent-container { + margin: 20px 0px; + padding: 0px 2rem; + + .action-row-wrapper { + overflow-y: auto; + scrollbar-width: thin; + height: fit-content; + max-height: 300px; + } + + .action-row { + display: flex; + } + + .action-col { + padding: 3px 0px; + + input[type='checkbox'] { + outline: none !important; + box-shadow: none !important; + } + } + + .action-title { + .action-title-wrapper { + display: flex; + gap: 3px; + justify-content: center; + text-transform: capitalize; + text-align: center; + border-bottom: 2px solid var(--bs-primary); + } + } + + .action-center { + display: flex; + justify-content: center; + } + } + + .edit-btn { + display: flex; + justify-content: flex-end; + font-size: 16px; + margin-top: 3px; + margin-right: 5px; + } + } +} \ No newline at end of file diff --git a/src/lib/scss/custom/pages/_users.scss b/src/lib/scss/custom/pages/_users.scss index 84ecd8a0..e948ee1b 100644 --- a/src/lib/scss/custom/pages/_users.scss +++ b/src/lib/scss/custom/pages/_users.scss @@ -8,11 +8,6 @@ width: 20%; max-width: 300px; } - - .user-agent-col { - width: 25%; - max-width: 350px; - } .user-detail { padding: 2px 5px; diff --git a/src/lib/services/api-endpoints.js b/src/lib/services/api-endpoints.js index 265d761b..7c9929c4 100644 --- a/src/lib/services/api-endpoints.js +++ b/src/lib/services/api-endpoints.js @@ -6,6 +6,7 @@ export const endpoints = { roleOptionsUrl: `${host}/role/options`, rolesUrl: `${host}/roles`, roleDetailUrl: `${host}/role/{id}/details`, + roleUpdateUrl: `${host}/role`, // user tokenUrl: `${host}/token`, diff --git a/src/lib/services/role-service.js b/src/lib/services/role-service.js index 0fa83395..15f40116 100644 --- a/src/lib/services/role-service.js +++ b/src/lib/services/role-service.js @@ -11,7 +11,15 @@ export async function getRoleOptions() { } - +/** + * Get role list + * @param {import('$roleTypes').RoleFilter?} [filter] + * @returns {Promise} + */ +export async function getRoles(filter = null) { + const response = await axios.post(endpoints.rolesUrl, filter); + return response.data; +} /** @@ -24,3 +32,14 @@ export async function getRoleDetails(id) { const response = await axios.get(url); return response.data; } + + +/** + * Update role + * @param {import('$roleTypes').RoleModel} model + * @returns {Promise} + */ +export async function updateRole(model) { + const response = await axios.put(endpoints.roleUpdateUrl, { ...model }); + return response.data; +} \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 7f42d0ed..8b8e4a3a 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -202,7 +202,7 @@ } $: { - disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id; + disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id || !agent?.chatable; } setContext('chat-window-context', { diff --git a/src/routes/page/agent/[agentId]/agent-overview.svelte b/src/routes/page/agent/[agentId]/agent-overview.svelte index 4975286d..e4a5e5c9 100644 --- a/src/routes/page/agent/[agentId]/agent-overview.svelte +++ b/src/routes/page/agent/[agentId]/agent-overview.svelte @@ -75,7 +75,7 @@ height="50" class="mx-auto d-block" /> - {#if 1} + {#if !!agent.chatable} + + + + + +{#if open} + + {#if isLoading} + + + + {:else} + +
+
+ + +
save()} + > + +
+
+
    +
  • +
    + {'Name:'} + {item.name} +
    +
  • +
+
    +
  • +
    +
    {'Permissions:'}
    +
    + {#each innerItem.permissions as permission, index} +
    + +
    + {}} + on:click={() => deletePermission(index)} + /> +
    +
    + {/each} + {#if innerItem.permissions?.length < 5} +
    + {}} + on:click={() => addPermission()} + /> +
    + {/if} +
    +
    +
  • +
+ + {#if innerActions.length > 0} +
+
+
+ {'Agent'} +
+ {#each allActions as title} +
+
{title.name}
+
+ checkAll(e, title)} + /> +
+
+ {/each} +
+
+ {#each innerActions as agentActionItem} +
+
+ {agentActionItem.agent_name} +
+ {#each agentActionItem.actions as actionItem} +
+ checkAction(e, agentActionItem, actionItem)} + /> +
+ {/each} +
+ {/each} +
+
+ {/if} +
+ + {/if} + +{/if} \ No newline at end of file diff --git a/src/routes/page/users/+page.svelte b/src/routes/page/users/+page.svelte index 8fc2034a..399330c9 100644 --- a/src/routes/page/users/+page.svelte +++ b/src/routes/page/users/+page.svelte @@ -5,8 +5,6 @@ Card, CardBody, Col, - Dropdown, - DropdownToggle, Input, Row, Table @@ -58,7 +56,7 @@ userName: '', externalId: '', role: '', - source: '', + type: '', }; onMount(async () => { @@ -149,7 +147,7 @@ const userName = searchOption.userName?.trim(); const externalId = searchOption.externalId?.trim(); const role = searchOption.role?.trim(); - const source = searchOption.source?.trim(); + const type = searchOption.type?.trim(); filter = { ...filter, @@ -157,7 +155,7 @@ user_names: !!userName ? [userName] : [], external_ids: !!externalId ? [externalId] : [], roles: !!role ? [role] : [], - sources: !!source ? [source] : [] + types: !!type ? [type] : [] }; } @@ -179,7 +177,7 @@ if (res) { isLoading = false; isComplete = true; - postUpdateUser(data); + postUpdate(data); setTimeout(() => { isComplete = false; }, duration); @@ -197,7 +195,7 @@ } /** @param {import('$userTypes').UserModel} data */ - function postUpdateUser(data) { + function postUpdate(data) { userItems = userItems?.map(x => { if (x.id === data.id) { return { ...data, open_detail: true }; @@ -219,19 +217,6 @@
{$_('User List')}
-
- - - - - - -
@@ -246,7 +231,7 @@ - +