Consolidated api list to nested structure, moved types to separate files
This commit is contained in:
parent
5ffdb8ba27
commit
529ab95a91
15 changed files with 245 additions and 176 deletions
|
|
@ -40,8 +40,12 @@ class ApiClient {
|
|||
}
|
||||
}
|
||||
|
||||
processUrl(endpoint: string): string {
|
||||
return `${apiEndpoint}${endpoint}`
|
||||
}
|
||||
|
||||
get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.get<T>(url, this.withCsrf(config))
|
||||
return this.client.get<T>(this.processUrl(url), this.withCsrf(config))
|
||||
}
|
||||
|
||||
post<T = unknown>(
|
||||
|
|
@ -49,7 +53,7 @@ class ApiClient {
|
|||
data?: unknown,
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<AxiosResponse<T>> {
|
||||
return this.client.post<T>(url, data, this.withCsrf(config))
|
||||
return this.client.post<T>(this.processUrl(url), data, this.withCsrf(config))
|
||||
}
|
||||
|
||||
put<T = unknown>(
|
||||
|
|
@ -57,7 +61,7 @@ class ApiClient {
|
|||
data?: unknown,
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<AxiosResponse<T>> {
|
||||
return this.client.put<T>(url, data, this.withCsrf(config))
|
||||
return this.client.put<T>(this.processUrl(url), data, this.withCsrf(config))
|
||||
}
|
||||
|
||||
patch<T = unknown>(
|
||||
|
|
@ -65,64 +69,89 @@ class ApiClient {
|
|||
data?: unknown,
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<AxiosResponse<T>> {
|
||||
return this.client.patch<T>(url, data, this.withCsrf(config))
|
||||
return this.client.patch<T>(this.processUrl(url), data, this.withCsrf(config))
|
||||
}
|
||||
|
||||
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.delete<T>(url, this.withCsrf(config))
|
||||
return this.client.delete<T>(this.processUrl(url), this.withCsrf(config))
|
||||
}
|
||||
}
|
||||
|
||||
export const apiEndpoint = '/api/';
|
||||
|
||||
export const API = {
|
||||
me: () => '/api/user/me/',
|
||||
login: () => '/api/user/login/',
|
||||
logout: () => '/api/user/logout/',
|
||||
session: () => '/api/user/session/',
|
||||
signup: () => '/api/user/signup/',
|
||||
changePassword: () => '/api/user/change_password/',
|
||||
auth: {
|
||||
me: () => 'user/me/',
|
||||
login: () => 'user/login/',
|
||||
logout: () => 'user/logout/',
|
||||
session: () => 'user/session/',
|
||||
signup: () => 'user/signup/',
|
||||
changePassword: () => 'user/change_password/',
|
||||
},
|
||||
|
||||
organizations: () => '/api/organization/',
|
||||
organization: (uuid: string) => `/api/organization/${uuid}/`,
|
||||
organizationMembers: (uuid: string) => `/api/organization/${uuid}/members/`,
|
||||
organizationMemberRemove: (uuid: string, userId: number) =>
|
||||
`/api/organization/${uuid}/member/${userId}/remove/`,
|
||||
organization: {
|
||||
list: () => 'organization/',
|
||||
byId: (uuid: string) => `organization/${uuid}/`,
|
||||
members: {
|
||||
list: (uuid: string) => `organization/${uuid}/members/`,
|
||||
remove: (uuid: string, userId: number) =>
|
||||
`organization/${uuid}/member/${userId}/remove/`,
|
||||
},
|
||||
invites: {
|
||||
list: (uuid: string) => `organization/${uuid}/invite/`,
|
||||
create: (uuid: string, maxUses: number) =>
|
||||
`organization/${uuid}/create-invite/?max_uses=${maxUses}`,
|
||||
revoke: (uuid: string, inviteUuid: string) =>
|
||||
`organization/${uuid}/revoke-invite/${inviteUuid}/`,
|
||||
join: (token: string) => `organization/join/${token}/`,
|
||||
},
|
||||
leave: (uuid: string) => `organization/${uuid}/leave/`,
|
||||
roles: {
|
||||
list: (uuid: string) => `organization/${uuid}/role/`,
|
||||
mine: () => 'organization/role/mine/',
|
||||
remove: (orgUuid: string, roleUuid: string) =>
|
||||
`organization/${orgUuid}/role/${roleUuid}/`,
|
||||
join: (orgUuid: string, roleUuid: string) =>
|
||||
`organization/${orgUuid}/role/${roleUuid}/join/`,
|
||||
},
|
||||
},
|
||||
|
||||
organizationInvites: (uuid: string) => `/api/organization/${uuid}/invite/`,
|
||||
organizationCreateInvite: (uuid: string, max_uses: number) =>
|
||||
`/api/organization/${uuid}/create-invite/?max_uses=${max_uses}`,
|
||||
organizationRevokeInvite: (uuid: string, inviteUuid: string) =>
|
||||
`/api/organization/${uuid}/revoke-invite/${inviteUuid}/`,
|
||||
organizationJoin: (token: string) => `/api/organization/join/${token}/`,
|
||||
organizationLeave: (uuid: string) => `/api/organization/${uuid}/leave/`,
|
||||
knowledge: {
|
||||
trainingFiles: {
|
||||
list: () => 'training-file/',
|
||||
byId: (uuid: string) => `training-file/${uuid}/`,
|
||||
},
|
||||
roleRagDocuments: {
|
||||
list: () => 'role-rag-document/',
|
||||
byId: (uuid: string) => `role-rag-document/${uuid}/`,
|
||||
},
|
||||
},
|
||||
|
||||
organizationRoles: (uuid: string) => `/api/organization/${uuid}/role/`,
|
||||
organizationRolesMine: () => '/api/organization/role/mine/',
|
||||
organizationRoleDelete: (orgUuid: string, roleUuid: string) =>
|
||||
`/api/organization/${orgUuid}/role/${roleUuid}/`,
|
||||
organizationRoleJoin: (orgUuid: string, roleUuid: string) =>
|
||||
`/api/organization/${orgUuid}/role/${roleUuid}/join/`,
|
||||
agents: {
|
||||
configs: {
|
||||
list: () => 'agent-config/',
|
||||
byId: (uuid: string) => `agent-config/${uuid}/`,
|
||||
},
|
||||
},
|
||||
|
||||
trainingFiles: () => `/api/training-file/`,
|
||||
trainingFile: (uuid: string) => `/api/training-file/${uuid}/`,
|
||||
organizationTrainingFiles: () => `/api/training-file/`,
|
||||
organizationTrainingFile: (uuid: string) => `/api/training-file/${uuid}/`,
|
||||
roleRagDocuments: () => `/api/role-rag-document/`,
|
||||
roleRagDocument: (uuid: string) => `/api/role-rag-document/${uuid}/`,
|
||||
|
||||
agentConfigs: () => '/api/agent-config/',
|
||||
agentConfig: (uuid: string) => `/api/agent-config/${uuid}/`,
|
||||
|
||||
onboardingFlows: () => '/api/onboarding-flow/',
|
||||
onboardingFlow: (uuid: string) => `/api/onboarding-flow/${uuid}/`,
|
||||
onboardingFlowStartSession: (uuid: string) => `/api/onboarding-flow/${uuid}/start-session/`,
|
||||
|
||||
onboardingSessions: () => '/api/onboarding-session/',
|
||||
onboardingSession: (uuid: string) => `/api/onboarding-session/${uuid}/`,
|
||||
onboardingSessionInteract: (uuid: string) => `/api/onboarding-session/${uuid}/interact/`,
|
||||
onboardingSessionHistory: (uuid: string) => `/api/onboarding-session/${uuid}/history/`,
|
||||
onboardingSessionComplete: (uuid: string) => `/api/onboarding-session/${uuid}/complete/`,
|
||||
|
||||
interactionLogs: () => '/api/agent-interaction-log/',
|
||||
interactionLog: (uuid: string) => `/api/agent-interaction-log/${uuid}/`,
|
||||
onboarding: {
|
||||
flows: {
|
||||
list: () => 'onboarding-flow/',
|
||||
byId: (uuid: string) => `onboarding-flow/${uuid}/`,
|
||||
startSession: (uuid: string) => `onboarding-flow/${uuid}/start-session/`,
|
||||
},
|
||||
sessions: {
|
||||
list: () => 'onboarding-session/',
|
||||
byId: (uuid: string) => `onboarding-session/${uuid}/`,
|
||||
interact: (uuid: string) => `onboarding-session/${uuid}/interact/`,
|
||||
history: (uuid: string) => `onboarding-session/${uuid}/history/`,
|
||||
complete: (uuid: string) => `onboarding-session/${uuid}/complete/`,
|
||||
},
|
||||
logs: {
|
||||
list: () => 'agent-interaction-log/',
|
||||
byId: (uuid: string) => `agent-interaction-log/${uuid}/`,
|
||||
},
|
||||
},
|
||||
}
|
||||
export const apiClient = new ApiClient()
|
||||
export { isAxiosError } from 'axios'
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import type { AgentEvent } from '../types/agent'
|
||||
import type {
|
||||
AgentEvent,
|
||||
AgentExecutionStatus,
|
||||
AgentSocketEventPayload,
|
||||
AgentStartPayload,
|
||||
} from '../types/agent'
|
||||
|
||||
export const useAgentStore = defineStore('agent', () => {
|
||||
const isConnected = ref(false)
|
||||
const executionStatus = ref<'idle' | 'running' | 'completed' | 'failed'>('idle')
|
||||
const executionStatus = ref<AgentExecutionStatus>('idle')
|
||||
const eventLog = ref<AgentEvent[]>([])
|
||||
const lastExecutionId = ref<string | null>(null)
|
||||
const socket = ref<WebSocket | null>(null)
|
||||
|
||||
const pushEvent = (evt: {
|
||||
type: string
|
||||
message?: string
|
||||
content?: unknown
|
||||
timestamp?: string
|
||||
}) => {
|
||||
const pushEvent = (evt: AgentSocketEventPayload) => {
|
||||
eventLog.value.unshift({
|
||||
type: evt.type,
|
||||
message: evt.message,
|
||||
|
|
@ -40,7 +40,7 @@ export const useAgentStore = defineStore('agent', () => {
|
|||
|
||||
socket.value.onmessage = (event) => {
|
||||
try {
|
||||
const payload = JSON.parse(event.data)
|
||||
const payload = JSON.parse(event.data) as AgentSocketEventPayload
|
||||
const type = payload.type
|
||||
|
||||
if (payload.execution_id) {
|
||||
|
|
@ -96,7 +96,7 @@ export const useAgentStore = defineStore('agent', () => {
|
|||
executionStatus.value = 'idle'
|
||||
}
|
||||
|
||||
const startAgent = (data: { query?: string; role_uuid?: string; max_tokens?: number }) => {
|
||||
const startAgent = (data: AgentStartPayload) => {
|
||||
if (!socket.value || socket.value.readyState !== WebSocket.OPEN) return
|
||||
|
||||
executionStatus.value = 'running'
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ export const useUserStore = defineStore('user', () => {
|
|||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await apiClient.get<SessionResponse>(API.session())
|
||||
const response = await apiClient.get<SessionResponse>(API.auth.session())
|
||||
if (response.data?.isAuthenticated) {
|
||||
const userData = await apiClient.get<User>(API.me())
|
||||
const userData = await apiClient.get<User>(API.auth.me())
|
||||
setUser(userData.data)
|
||||
await fetchJoinedOrganizations()
|
||||
} else {
|
||||
|
|
@ -91,7 +91,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
const fetchJoinedOrganizations = async () => {
|
||||
if (!user.value) return
|
||||
try {
|
||||
const response = await apiClient.get<Organization[]>(API.organizations())
|
||||
const response = await apiClient.get<Organization[]>(API.organization.list())
|
||||
setJoinedOrganizations(response.data)
|
||||
return response.data
|
||||
} catch (err: unknown) {
|
||||
|
|
@ -105,7 +105,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
if (!user.value || !userSelectedOrganization.value) return
|
||||
try {
|
||||
const response = await apiClient.get<Role[]>(
|
||||
API.organizationRoles(userSelectedOrganization.value.uuid),
|
||||
API.organization.roles.list(userSelectedOrganization.value.uuid),
|
||||
)
|
||||
setJoinedRoles(response.data)
|
||||
return response.data
|
||||
|
|
@ -127,7 +127,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
const res = await apiClient.post<{
|
||||
user: User
|
||||
message?: string
|
||||
}>(API.login(), { email_address: emailAddress, password })
|
||||
}>(API.auth.login(), { email_address: emailAddress, password })
|
||||
setUser(res.data?.user ?? null)
|
||||
return res.data
|
||||
} catch (err: unknown) {
|
||||
|
|
@ -156,7 +156,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
await apiClient.post(API.signup(), payload)
|
||||
await apiClient.post(API.auth.signup(), payload)
|
||||
await login(payload.email_address, payload.password)
|
||||
} catch (err: unknown) {
|
||||
if (isAxiosError(err)) {
|
||||
|
|
@ -176,7 +176,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
await apiClient.post(API.logout())
|
||||
await apiClient.post(API.auth.logout())
|
||||
} catch (err: unknown) {
|
||||
if (isAxiosError(err)) {
|
||||
error.value = err.response?.data?.detail || err.response?.data?.error || err.message
|
||||
|
|
|
|||
|
|
@ -1,3 +1,44 @@
|
|||
import type { UuidNameRef } from './common'
|
||||
|
||||
export type AgentType = 'curriculum' | 'knowledge' | 'assessment' | 'monitor' | string
|
||||
|
||||
export type AgentExecutionStatus = 'idle' | 'running' | 'completed' | 'failed'
|
||||
|
||||
export interface LLMConfig {
|
||||
model_id?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface AgentConfig {
|
||||
uuid: string
|
||||
name: string
|
||||
agent_type: AgentType
|
||||
llm_config: LLMConfig
|
||||
organization: string | UuidNameRef
|
||||
description?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type AgentStartPayload = {
|
||||
query?: string
|
||||
role_uuid?: string
|
||||
max_tokens?: number
|
||||
}
|
||||
|
||||
export type AgentSocketEventPayload = {
|
||||
type: string
|
||||
message?: string
|
||||
thought?: string
|
||||
content?: unknown
|
||||
timestamp?: string
|
||||
execution_id?: string
|
||||
}
|
||||
|
||||
export type AgentRunResult = {
|
||||
response?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type AgentEvent = {
|
||||
type: string
|
||||
timestamp: Date
|
||||
|
|
|
|||
7
site/src/types/common.ts
Normal file
7
site/src/types/common.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export type MaybePaginated<T> = T[] | { results?: T[] }
|
||||
|
||||
export type UuidNameRef = {
|
||||
uuid?: string
|
||||
name?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
import type { Role } from './organization'
|
||||
import type { UuidNameRef } from './common'
|
||||
|
||||
export type OnboardingField = {
|
||||
uuid: string
|
||||
key: string
|
||||
|
|
@ -22,7 +25,7 @@ export type OnboardingPage = {
|
|||
|
||||
export type OnboardingFlow = {
|
||||
uuid: string
|
||||
role: string
|
||||
role: string | UuidNameRef
|
||||
agent?: string | null
|
||||
title: string
|
||||
description?: string
|
||||
|
|
@ -42,3 +45,39 @@ export type OnboardingSession = {
|
|||
export type OnboardingFeedback = {
|
||||
summary?: string
|
||||
}
|
||||
|
||||
export type OnboardingSessionStatus = 'active' | 'completed' | 'paused'
|
||||
|
||||
export type OnboardingSessionSummary = {
|
||||
uuid: string
|
||||
status: string
|
||||
role?: string | UuidNameRef
|
||||
}
|
||||
|
||||
export type OnboardingFlowSummary = {
|
||||
uuid: string
|
||||
role?: string | UuidNameRef
|
||||
}
|
||||
|
||||
export type ProgressSessionApi = {
|
||||
uuid: string
|
||||
status: OnboardingSessionStatus
|
||||
role: UuidNameRef
|
||||
updated_at?: string
|
||||
state?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type ProgressFlowApi = {
|
||||
uuid: string
|
||||
role: UuidNameRef
|
||||
title: string
|
||||
}
|
||||
|
||||
export type RoleProgressItem = {
|
||||
role: Role
|
||||
latestStatus: string
|
||||
latestSessionUuid?: string
|
||||
flowTitle?: string
|
||||
feedback?: string
|
||||
loadingFeedback: boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,22 @@ import { marked } from 'marked'
|
|||
import DOMPurify from 'dompurify'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
import { apiClient, isAxiosError, API } from '../router/api'
|
||||
import type { AgentConfig, AgentRunResult } from '../types/agent'
|
||||
|
||||
const route = useRoute()
|
||||
const agentStore = useAgentStore()
|
||||
|
||||
const agentId = route.params.id as string
|
||||
|
||||
const agent = ref<Record<string, unknown>>({
|
||||
const agent = ref<AgentConfig>({
|
||||
id: agentId,
|
||||
name: 'Loading...',
|
||||
description: '',
|
||||
status: 'idle',
|
||||
uuid: agentId,
|
||||
agent_type: 'knowledge',
|
||||
llm_config: {},
|
||||
organization: '',
|
||||
})
|
||||
const maxTokens = ref<number>(256)
|
||||
|
||||
|
|
@ -38,7 +43,7 @@ const isConnected = computed(() => agentStore.isConnected ?? false)
|
|||
const agentResponse = computed(() => {
|
||||
const completedEvent = agentStore.eventLog?.find((event) => event.type === 'completed')
|
||||
if (completedEvent?.content && typeof completedEvent.content === 'object') {
|
||||
const output = completedEvent.content as Record<string, unknown>
|
||||
const output = completedEvent.content as AgentRunResult
|
||||
|
||||
return (output.response as string) || null
|
||||
}
|
||||
|
|
@ -58,7 +63,7 @@ const statusColor = (status: string) => {
|
|||
|
||||
const fetchAgent = async () => {
|
||||
try {
|
||||
const response = await apiClient.get<Record<string, unknown>>(API.agentConfig(agentId))
|
||||
const response = await apiClient.get<AgentConfig>(API.agents.configs.byId(agentId))
|
||||
agent.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch agent:', error)
|
||||
|
|
|
|||
|
|
@ -2,37 +2,18 @@
|
|||
import { ref, onMounted } from 'vue'
|
||||
import { List, Typography, Button, Card, Spin, message, Tag, Space } from 'ant-design-vue'
|
||||
import { apiClient, API } from '../router/api'
|
||||
import type { MaybePaginated } from '../types/common'
|
||||
import type { AgentConfig } from '../types/agent'
|
||||
|
||||
interface LLMConfig {
|
||||
model_id?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface OrganizationRef {
|
||||
uuid?: string
|
||||
name?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface Agent {
|
||||
uuid: string
|
||||
name: string
|
||||
agent_type: string
|
||||
llm_config: LLMConfig
|
||||
organization: string | OrganizationRef
|
||||
}
|
||||
|
||||
const agents = ref<Agent[]>([])
|
||||
const agents = ref<AgentConfig[]>([])
|
||||
const loading = ref(false)
|
||||
const loadError = ref(false)
|
||||
|
||||
type MaybePaginated<T> = T[] | { results?: T[] }
|
||||
|
||||
const fetchAgents = async () => {
|
||||
loading.value = true
|
||||
loadError.value = false
|
||||
try {
|
||||
const response = await apiClient.get<MaybePaginated<Agent>>(API.agentConfigs())
|
||||
const response = await apiClient.get<MaybePaginated<AgentConfig>>(API.agents.configs.list())
|
||||
|
||||
const data = response.data
|
||||
agents.value = Array.isArray(data) ? data : data.results || []
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const acceptInvite = async () => {
|
|||
error.value = null
|
||||
try {
|
||||
const response = await apiClient.post<{ message: string; success: boolean; uuid: string }>(
|
||||
API.organizationJoin(token),
|
||||
API.organization.invites.join(token),
|
||||
)
|
||||
message.success(response.data?.message || 'Successfully joined organization')
|
||||
accepted.value = true
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ import {
|
|||
} from 'ant-design-vue'
|
||||
import { apiClient, API } from '../router/api'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
import type { OnboardingFlow, OnboardingPage, OnboardingSession } from '../types/onboarding'
|
||||
import type {
|
||||
OnboardingFlow,
|
||||
OnboardingPage,
|
||||
OnboardingSession,
|
||||
OnboardingSessionSummary,
|
||||
OnboardingFlowSummary,
|
||||
} from '../types/onboarding'
|
||||
|
||||
import { Marked } from 'marked'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
|
@ -53,29 +59,18 @@ const renderedBody = computed(() => {
|
|||
return DOMPurify.sanitize(marked.parse(currentPage.value.body) as string)
|
||||
})
|
||||
|
||||
type SessionSummary = {
|
||||
uuid: string
|
||||
status: string
|
||||
role?: string | { uuid?: string }
|
||||
}
|
||||
|
||||
type FlowSummary = {
|
||||
uuid: string
|
||||
role?: string | { uuid?: string }
|
||||
}
|
||||
|
||||
const getSessionRoleUuid = (sessionData: SessionSummary): string | undefined => {
|
||||
const getSessionRoleUuid = (sessionData: OnboardingSessionSummary): string | undefined => {
|
||||
if (typeof sessionData.role === 'string') return sessionData.role
|
||||
return sessionData.role?.uuid
|
||||
}
|
||||
|
||||
const getFlowRoleUuid = (flowData: FlowSummary): string | undefined => {
|
||||
const getFlowRoleUuid = (flowData: OnboardingFlowSummary): string | undefined => {
|
||||
if (typeof flowData.role === 'string') return flowData.role
|
||||
return flowData.role?.uuid
|
||||
}
|
||||
|
||||
const findCompletedSessionForRole = async (): Promise<SessionSummary | null> => {
|
||||
const sessionRes = await apiClient.get<SessionSummary[]>(API.onboardingSessions(), {
|
||||
const findCompletedSessionForRole = async (): Promise<OnboardingSessionSummary | null> => {
|
||||
const sessionRes = await apiClient.get<OnboardingSessionSummary[]>(API.onboarding.sessions.list(), {
|
||||
params: { role: roleId.value },
|
||||
})
|
||||
return (
|
||||
|
|
@ -90,13 +85,13 @@ const retryGeneration = async () => {
|
|||
generationHandled.value = false
|
||||
|
||||
try {
|
||||
const response = await apiClient.get<OnboardingFlow[]>(API.onboardingFlows(), {
|
||||
const response = await apiClient.get<OnboardingFlow[]>(API.onboarding.flows.list(), {
|
||||
params: { role: roleId.value },
|
||||
})
|
||||
|
||||
if (response.data && response.data.length > 0) {
|
||||
for (const flow of response.data) {
|
||||
await apiClient.delete(API.onboardingFlow(flow.uuid))
|
||||
await apiClient.delete(API.onboarding.flows.byId(flow.uuid))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +111,7 @@ const resetCurrentFlow = async () => {
|
|||
|
||||
deletingFlow.value = true
|
||||
try {
|
||||
await apiClient.delete(API.onboardingFlow(flowDetails.value.uuid))
|
||||
await apiClient.delete(API.onboarding.flows.byId(flowDetails.value.uuid))
|
||||
|
||||
flowDetails.value = null
|
||||
session.value = null
|
||||
|
|
@ -141,7 +136,7 @@ const initOnboarding = async () => {
|
|||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await apiClient.get<OnboardingFlow[]>(API.onboardingFlows(), {
|
||||
const response = await apiClient.get<OnboardingFlow[]>(API.onboarding.flows.list(), {
|
||||
params: { role: roleId.value },
|
||||
})
|
||||
|
||||
|
|
@ -227,10 +222,10 @@ watch(
|
|||
)
|
||||
|
||||
const loadFlow = async (flowUuid: string) => {
|
||||
const response = await apiClient.get<OnboardingFlow>(API.onboardingFlow(flowUuid))
|
||||
const response = await apiClient.get<OnboardingFlow>(API.onboarding.flows.byId(flowUuid))
|
||||
flowDetails.value = response.data
|
||||
const sessionRes = await apiClient.post<OnboardingSession>(
|
||||
API.onboardingFlowStartSession(flowUuid),
|
||||
API.onboarding.flows.startSession(flowUuid),
|
||||
)
|
||||
session.value = sessionRes.data
|
||||
|
||||
|
|
@ -253,7 +248,7 @@ const hydrateFormState = () => {
|
|||
const onSubmitPage = async () => {
|
||||
if (!currentPage.value || !session.value) return
|
||||
try {
|
||||
await apiClient.post(API.onboardingSessionInteract(session.value.uuid), {
|
||||
await apiClient.post(API.onboarding.sessions.interact(session.value.uuid), {
|
||||
page_uuid: currentPage.value.uuid,
|
||||
responses: formState,
|
||||
})
|
||||
|
|
@ -263,7 +258,7 @@ const onSubmitPage = async () => {
|
|||
hydrateFormState()
|
||||
window.scrollTo(0, 0)
|
||||
} else {
|
||||
await apiClient.post(API.onboardingSessionComplete(session.value.uuid))
|
||||
await apiClient.post(API.onboarding.sessions.complete(session.value.uuid))
|
||||
message.success('Onboarding Finished!')
|
||||
router.push('/organization')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const newDescription = ref('')
|
|||
const fetchOrganization = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await apiClient.get<Organization>(API.organization(orgId))
|
||||
const response = await apiClient.get<Organization>(API.organization.byId(orgId))
|
||||
organization.value = response.data
|
||||
newDescription.value = response.data.description
|
||||
} catch (error) {
|
||||
|
|
@ -61,7 +61,7 @@ const fetchOrganization = async () => {
|
|||
|
||||
const fetchMembers = async () => {
|
||||
try {
|
||||
const response = await apiClient.get<User[]>(API.organizationMembers(orgId))
|
||||
const response = await apiClient.get<User[]>(API.organization.members.list(orgId))
|
||||
members.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch members:', error)
|
||||
|
|
@ -70,7 +70,7 @@ const fetchMembers = async () => {
|
|||
|
||||
const fetchInvites = async () => {
|
||||
try {
|
||||
const response = await apiClient.get<InviteToken[]>(API.organizationInvites(orgId))
|
||||
const response = await apiClient.get<InviteToken[]>(API.organization.invites.list(orgId))
|
||||
invites.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch invites:', error)
|
||||
|
|
@ -79,7 +79,7 @@ const fetchInvites = async () => {
|
|||
|
||||
const fetchRoles = async () => {
|
||||
try {
|
||||
const response = await apiClient.get<Role[]>(API.organizationRoles(orgId))
|
||||
const response = await apiClient.get<Role[]>(API.organization.roles.list(orgId))
|
||||
Roles.value = response.data as unknown as Role[]
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch Roles:', error)
|
||||
|
|
@ -109,7 +109,7 @@ const createRole = async () => {
|
|||
|
||||
creatingRole.value = true
|
||||
try {
|
||||
await apiClient.post(API.organizationRoles(orgId), { name, description })
|
||||
await apiClient.post(API.organization.roles.list(orgId), { name, description })
|
||||
message.success('Role created successfully')
|
||||
roleModalVisible.value = false
|
||||
resetRoleForm()
|
||||
|
|
@ -136,7 +136,7 @@ const deleteRole = async (role: Role) => {
|
|||
onOk: async () => {
|
||||
deletingRoleUuid.value = role.uuid
|
||||
try {
|
||||
await apiClient.delete(API.organizationRoleDelete(orgId, role.uuid))
|
||||
await apiClient.delete(API.organization.roles.remove(orgId, role.uuid))
|
||||
message.success('Role deleted successfully')
|
||||
await fetchRoles()
|
||||
} catch (error) {
|
||||
|
|
@ -156,7 +156,7 @@ const deleteRole = async (role: Role) => {
|
|||
const createInvite = async () => {
|
||||
try {
|
||||
const response = await apiClient.post<InviteToken>(
|
||||
API.organizationCreateInvite(orgId, newInviteMaxUses.value),
|
||||
API.organization.invites.create(orgId, newInviteMaxUses.value),
|
||||
)
|
||||
newInviteUrl.value = response.data.invite_url
|
||||
inviteModalVisible.value = true
|
||||
|
|
@ -179,7 +179,7 @@ const copyUrl = (url: string) => {
|
|||
|
||||
const revokeInvite = async (token: string) => {
|
||||
try {
|
||||
await apiClient.delete(API.organizationRevokeInvite(orgId, token))
|
||||
await apiClient.delete(API.organization.invites.revoke(orgId, token))
|
||||
message.success('Invite revoked')
|
||||
fetchInvites()
|
||||
} catch (error) {
|
||||
|
|
@ -190,7 +190,7 @@ const revokeInvite = async (token: string) => {
|
|||
|
||||
const removeMember = async (userId: number) => {
|
||||
try {
|
||||
await apiClient.post(API.organizationMemberRemove(orgId, userId))
|
||||
await apiClient.post(API.organization.members.remove(orgId, userId))
|
||||
message.success('Member removed')
|
||||
fetchMembers()
|
||||
} catch (error) {
|
||||
|
|
@ -203,7 +203,7 @@ const removeMember = async (userId: number) => {
|
|||
|
||||
const saveDescription = async () => {
|
||||
try {
|
||||
await apiClient.patch(API.organization(orgId), {
|
||||
await apiClient.patch(API.organization.byId(orgId), {
|
||||
description: newDescription.value,
|
||||
})
|
||||
message.success('Description updated')
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const isManager = computed(() => {
|
|||
const fetchOrganization = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await apiClient.get<Organization>(API.organization(orgId))
|
||||
const response = await apiClient.get<Organization>(API.organization.byId(orgId))
|
||||
organization.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch organization:', error)
|
||||
|
|
@ -58,7 +58,7 @@ const fetchOrganization = async () => {
|
|||
const fetchRoles = async () => {
|
||||
if (!organization.value?.uuid) return
|
||||
try {
|
||||
const response = await apiClient.get<Role[]>(API.organizationRoles(organization.value.uuid))
|
||||
const response = await apiClient.get<Role[]>(API.organization.roles.list(organization.value.uuid))
|
||||
roles.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch roles:', error)
|
||||
|
|
@ -68,7 +68,7 @@ const fetchRoles = async () => {
|
|||
const fetchUserRoleMemberships = async () => {
|
||||
if (!organization.value?.uuid) return
|
||||
try {
|
||||
const response = await apiClient.get<Role[]>(API.organizationRolesMine())
|
||||
const response = await apiClient.get<Role[]>(API.organization.roles.mine())
|
||||
const mine = Array.isArray(response.data) ? response.data : []
|
||||
const orgUuid = organization.value.uuid
|
||||
const joinedRoles = mine.filter((role) => role.organization?.uuid === orgUuid)
|
||||
|
|
@ -87,7 +87,7 @@ const fetchMembers = async () => {
|
|||
if (!organization.value?.uuid) return
|
||||
try {
|
||||
const response = await apiClient.get<Array<{ user: { id: number }; role: string }>>(
|
||||
API.organizationMembers(organization.value.uuid),
|
||||
API.organization.members.list(organization.value.uuid),
|
||||
)
|
||||
members.value = response.data
|
||||
} catch (error) {
|
||||
|
|
@ -114,7 +114,7 @@ const selectRole = async (roleUuid: string) => {
|
|||
}
|
||||
|
||||
try {
|
||||
await apiClient.post(API.organizationRoleJoin(organization.value.uuid, roleUuid))
|
||||
await apiClient.post(API.organization.roles.join(organization.value.uuid, roleUuid))
|
||||
message.success('Successfully joined role')
|
||||
if (!auth.userJoinedRoles.some((role) => role.uuid === roleUuid)) {
|
||||
auth.setJoinedRoles([
|
||||
|
|
@ -133,7 +133,7 @@ const selectRole = async (roleUuid: string) => {
|
|||
const fetchTrainingFiles = async () => {
|
||||
if (!organization.value?.uuid) return
|
||||
try {
|
||||
const response = await apiClient.get<TrainingFile[]>(API.organizationTrainingFiles())
|
||||
const response = await apiClient.get<TrainingFile[]>(API.knowledge.trainingFiles.list())
|
||||
trainingFiles.value = response.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch training files:', error)
|
||||
|
|
@ -203,7 +203,7 @@ const handleFileUpload = async (file: File, description: string = '') => {
|
|||
}
|
||||
|
||||
const response = await apiClient.post<TrainingFile>(
|
||||
API.organizationTrainingFiles(),
|
||||
API.knowledge.trainingFiles.list(),
|
||||
formData,
|
||||
{
|
||||
headers: {
|
||||
|
|
@ -245,7 +245,7 @@ const deleteFile = async (uuid: string, fileName: string) => {
|
|||
cancelText: 'Cancel',
|
||||
onOk: async () => {
|
||||
try {
|
||||
await apiClient.delete(API.organizationTrainingFile(uuid))
|
||||
await apiClient.delete(API.knowledge.trainingFiles.byId(uuid))
|
||||
message.success('File deleted successfully')
|
||||
trainingFiles.value = trainingFiles.value.filter((f) => f.uuid !== uuid)
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const createOrgForm = ref({
|
|||
const fetchOrganizations = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await apiClient.get<Organization[]>(API.organizations())
|
||||
const resp = await apiClient.get<Organization[]>(API.organization.list())
|
||||
organizations.value = resp.data || []
|
||||
|
||||
if (organizations.value.length === 1 && !auth.isGeneralManager) {
|
||||
|
|
@ -71,7 +71,7 @@ const handleCreateOrganization = async () => {
|
|||
|
||||
creatingOrganization.value = true
|
||||
try {
|
||||
const response = await apiClient.post<Organization>(API.organizations(), {
|
||||
const response = await apiClient.post<Organization>(API.organization.list(), {
|
||||
name,
|
||||
description,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,14 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
|
|||
import { Card, Typography, Button, Spin, Tag, List, message } from 'ant-design-vue'
|
||||
import { apiClient, API } from '../router/api'
|
||||
import type { Role } from '../types/organization'
|
||||
|
||||
type SessionApi = {
|
||||
uuid: string
|
||||
status: 'active' | 'completed' | 'paused'
|
||||
state?: Record<string, unknown>
|
||||
role: { uuid: string; name: string }
|
||||
updated_at?: string
|
||||
}
|
||||
import type { ProgressSessionApi } from '../types/onboarding'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
|
@ -20,7 +13,7 @@ const roleId = computed(() => route.params.roleId as string)
|
|||
const loading = ref(false)
|
||||
const monitoring = ref(false)
|
||||
const role = ref<Role | null>(null)
|
||||
const sessions = ref<SessionApi[]>([])
|
||||
const sessions = ref<ProgressSessionApi[]>([])
|
||||
const feedback = ref<string>('')
|
||||
const monitorLogs = ref<string[]>([])
|
||||
|
||||
|
|
@ -93,8 +86,8 @@ const loadData = async () => {
|
|||
loading.value = true
|
||||
try {
|
||||
const [rolesRes, sessionsRes] = await Promise.all([
|
||||
apiClient.get<Role[]>(API.organizationRolesMine()),
|
||||
apiClient.get<SessionApi[]>(API.onboardingSessions()),
|
||||
apiClient.get<Role[]>(API.organization.roles.mine()),
|
||||
apiClient.get<ProgressSessionApi[]>(API.onboarding.sessions.list()),
|
||||
])
|
||||
|
||||
const roles = Array.isArray(rolesRes.data) ? rolesRes.data : []
|
||||
|
|
|
|||
|
|
@ -4,28 +4,7 @@ import { useRouter } from 'vue-router'
|
|||
import { Card, Typography, List, Tag, Button, Spin, message } from 'ant-design-vue'
|
||||
import { apiClient, API } from '../router/api'
|
||||
import type { Role } from '../types/organization'
|
||||
|
||||
type SessionApi = {
|
||||
uuid: string
|
||||
status: 'active' | 'completed' | 'paused'
|
||||
role: { uuid: string; name: string }
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
type FlowApi = {
|
||||
uuid: string
|
||||
role: { uuid: string; name: string }
|
||||
title: string
|
||||
}
|
||||
|
||||
type RoleProgressItem = {
|
||||
role: Role
|
||||
latestStatus: string
|
||||
latestSessionUuid?: string
|
||||
flowTitle?: string
|
||||
feedback?: string
|
||||
loadingFeedback: boolean
|
||||
}
|
||||
import type { ProgressSessionApi, ProgressFlowApi, RoleProgressItem } from '../types/onboarding'
|
||||
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
|
|
@ -85,9 +64,9 @@ const loadProgress = async () => {
|
|||
loading.value = true
|
||||
try {
|
||||
const [rolesRes, sessionsRes, flowsRes] = await Promise.all([
|
||||
apiClient.get<Role[]>(API.organizationRolesMine()),
|
||||
apiClient.get<SessionApi[]>(API.onboardingSessions()),
|
||||
apiClient.get<FlowApi[]>(API.onboardingFlows()),
|
||||
apiClient.get<Role[]>(API.organization.roles.mine()),
|
||||
apiClient.get<ProgressSessionApi[]>(API.onboarding.sessions.list()),
|
||||
apiClient.get<ProgressFlowApi[]>(API.onboarding.flows.list()),
|
||||
])
|
||||
|
||||
const roles = Array.isArray(rolesRes.data) ? rolesRes.data : []
|
||||
|
|
|
|||
Loading…
Reference in a new issue