Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wavefront/client/src/api/app-user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class AppUserService {
/**
* List users with access to an app (owners only)
*/
async listAppUsers(appId: string): Promise<IApiResponse<{ users: IUser[] }>> {
return this.http.get(`/v1/apps/${appId}/users`);
async listAppUsers(): Promise<IApiResponse<{ users: IUser[] }>> {
return this.http.get(`/v1/:appId/floware/v1/users`);
}

/**
Expand Down
23 changes: 12 additions & 11 deletions wavefront/client/src/api/scheduled-job-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CreateScheduledJobResponse,
DeleteScheduledJobResponse,
ListScheduledJobsResponse,
UpdateScheduledJobRequest,
UpdateScheduledJobResponse,
} from '@app/types/scheduled-job';
import { AxiosInstance } from 'axios';
Expand All @@ -16,6 +17,7 @@ export class ScheduledJobService {

async listScheduledJobs(params: {
limit?: number;
offset?: number;
query_id?: string;
datasource_id?: string;
job_type?: string;
Expand All @@ -24,20 +26,19 @@ export class ScheduledJobService {
return this.http.get(`/v1/:appId/floware/v1/scheduled-jobs`, { params });
}

async updateScheduledJob(
jobId: string,
payload: {
cron_expr?: string;
timezone?: string;
payload?: Record<string, unknown>;
max_retries?: number;
status?: 'active' | 'paused' | 'running' | 'failed' | 'completed';
}
): Promise<UpdateScheduledJobResponse> {
return this.http.patch(`/v1/:appId/floware/v1/scheduled-jobs/${jobId}`, payload);
async updateScheduledJob(jobId: string, request: UpdateScheduledJobRequest): Promise<UpdateScheduledJobResponse> {
return this.http.patch(`/v1/:appId/floware/v1/scheduled-jobs/${jobId}`, request);
}

async deleteScheduledJob(jobId: string): Promise<DeleteScheduledJobResponse> {
return this.http.delete(`/v1/:appId/floware/v1/scheduled-jobs/${jobId}`);
}

async pauseScheduledJob(jobId: string): Promise<UpdateScheduledJobResponse> {
return this.http.post(`/v1/:appId/floware/v1/scheduled-jobs/${jobId}/pause`);
}

async resumeScheduledJob(jobId: string): Promise<UpdateScheduledJobResponse> {
return this.http.post(`/v1/:appId/floware/v1/scheduled-jobs/${jobId}/resume`);
}
}
1 change: 1 addition & 0 deletions wavefront/client/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export { default as ModelRepositoryIcon } from './model-repository-icon';
export { default as PermissionIcon } from './permission-icon';
export { PhoneActiveIcon, PhoneIcon } from './phone-icon';
export { default as RagIcon } from './rag-icon';
export { default as ScheduledJobsIcon } from './scheduled-jobs-icon';
export { default as RootfloIcon } from './rootflo-icon';
export { default as WorkflowIcon } from './workflow-icon';
13 changes: 13 additions & 0 deletions wavefront/client/src/assets/icons/scheduled-jobs-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const ScheduledJobsIcon = ({ ...props }: React.SVGProps<SVGSVGElement>) => (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16" {...props}>
<path
stroke="#585858"
strokeLinecap="round"
strokeLinejoin="round"
d="M8 2.667v2.666M8 10.667v2.666M4 8H2.667M13.333 8H12M4.343 4.343l1.886 1.886M9.771 9.771l1.886 1.886M4.343 11.657l1.886-1.886M9.771 6.229l1.886-1.886"
/>
<circle cx="8" cy="8" r="2.667" stroke="#585858" strokeLinecap="round" strokeLinejoin="round" />
</svg>
);

export default ScheduledJobsIcon;
21 changes: 17 additions & 4 deletions wavefront/client/src/hooks/data/fetch-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TelephonyConfig } from '@app/types/telephony-config';
import { ToolDetails, VoiceAgentTool, VoiceAgentToolWithAssociation } from '@app/types/tool';
import { TtsConfig } from '@app/types/tts-config';
import { VoiceAgent } from '@app/types/voice-agent';
import { ScheduledJob } from '@app/types/scheduled-job';
import { WorkflowListItem, WorkflowPipelineListItem, WorkflowRunListData } from '@app/types/workflow';
import { UseQueryResult } from '@tanstack/react-query';

Expand All @@ -28,6 +29,7 @@ import {
getApiServiceQueryFn,
getApiServicesQueryFn,
getAppByIdFn,
getAppUsersQueryFn,
getAuthenticatorQueryFn,
getAuthenticatorsQueryFn,
getCurrentUserQueryFn,
Expand All @@ -54,7 +56,7 @@ import {
getToolsQueryFn,
getTtsConfigQueryFn,
getTtsConfigsQueryFn,
getUsersQueryFn,
getConsoleUsersQueryFn,
getVoiceAgentQueryFn,
getVoiceAgentToolQueryFn,
getVoiceAgentToolsQueryFn,
Expand All @@ -64,6 +66,7 @@ import {
getWorkflowRunsQueryFn,
getWorkflowsQueryFn,
readYamlQueryFn,
getScheduledJobsQueryFn,
} from './query-functions';
import {
getAgentKey,
Expand All @@ -74,6 +77,7 @@ import {
getApiServiceKey,
getApiServicesKey,
getAppByIdKey,
getAppUsersKey,
getAuthenticatorKey,
getAuthenticatorsKey,
getCurrentUserKey,
Expand All @@ -100,7 +104,7 @@ import {
getToolsKey,
getTtsConfigKey,
getTtsConfigsKey,
getUsersKey,
getConsoleUsersKey,
getVoiceAgentKey,
getVoiceAgentToolKey,
getVoiceAgentToolsKey,
Expand All @@ -110,6 +114,7 @@ import {
getWorkflowRunsKey,
getWorkflowsKey,
readYamlKey,
getScheduledJobsKey,
} from './query-keys';

export const useGetAllApps = (enabled: boolean): UseQueryResult<App[], Error> => {
Expand Down Expand Up @@ -417,8 +422,16 @@ export const useGetAppById = (appId: string, enabled: boolean = true): UseQueryR
return useQueryInit<App | undefined>(getAppByIdKey(appId), () => getAppByIdFn(appId), enabled);
};

export const useGetUsers = (): UseQueryResult<IUser[], Error> => {
return useQueryInit(getUsersKey(), getUsersQueryFn, true);
export const useGetAppUsers = (appId: string | undefined): UseQueryResult<IUser[], Error> => {
return useQueryInit(getAppUsersKey(appId || ''), () => getAppUsersQueryFn(), !!appId);
};

export const useGetConsoleUsers = (): UseQueryResult<IUser[], Error> => {
return useQueryInit(getConsoleUsersKey(), getConsoleUsersQueryFn, true);
};

export const useGetScheduledJobs = (appId: string | undefined): UseQueryResult<ScheduledJob[], Error> => {
return useQueryInit(getScheduledJobsKey(appId || ''), getScheduledJobsQueryFn, !!appId);
};

// Voice Agent Tools Hooks
Expand Down
8 changes: 4 additions & 4 deletions wavefront/client/src/hooks/data/mutation-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryClient, useMutation, useQueryClient } from '@tanstack/react-query';
import { getAgentKey, getAgentsKey, getAppByIdKey, getUserKey, getUsersKey } from './query-keys';
import { getAgentKey, getAgentsKey, getAppByIdKey, getConsoleUsersKey, getUserKey } from './query-keys';
import {
createUserMutationFn,
deleteAgentMutationFn,
Expand Down Expand Up @@ -90,7 +90,7 @@ export const useCreateUser = () => {
mutationFn: createUserMutationFn,
onSuccess: () => {
notifySuccess('User created successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
},
onError: (error) => {
console.error('Error creating user:', error);
Expand All @@ -108,7 +108,7 @@ export const useUpdateUser = (userId: string | undefined) => {
mutationFn: updateUserMutationFn,
onSuccess: () => {
notifySuccess('User updated successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
if (userId) {
queryClient.invalidateQueries({ queryKey: getUserKey(userId) });
}
Expand All @@ -129,7 +129,7 @@ export const useDeleteUser = () => {
mutationFn: deleteUserMutationFn,
onSuccess: () => {
notifySuccess('User deleted successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
},
onError: (error) => {
console.error('Error deleting user:', error);
Expand Down
38 changes: 36 additions & 2 deletions wavefront/client/src/hooks/data/query-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ import { ToolDetails, VoiceAgentTool, VoiceAgentToolWithAssociation } from '@app
import { TtsConfig } from '@app/types/tts-config';
import { IUser } from '@app/types/user';
import { VoiceAgent } from '@app/types/voice-agent';
import { ScheduledJob } from '@app/types/scheduled-job';
import { WorkflowListItem, WorkflowPipelineListItem, WorkflowRunListData } from '@app/types/workflow';

const SCHEDULED_JOBS_PAGE_SIZE = 20;
const MAX_SCHEDULED_JOBS = 1000;

const getAllAppsQueryFn = async () => {
const {
data: { data = { apps: [] } },
Expand Down Expand Up @@ -396,14 +400,42 @@ const getAgentToolsQueryFn = async (agentId: string): Promise<VoiceAgentToolWith
return [];
};

const getUsersQueryFn = async (): Promise<IUser[]> => {
const getAppUsersQueryFn = async (): Promise<IUser[]> => {
const response = await floConsoleService.appUserService.listAppUsers();
if (response.data?.data?.users && Array.isArray(response.data.data.users)) {
return response.data.data.users;
}
return [];
};

const getConsoleUsersQueryFn = async (): Promise<IUser[]> => {
const response = await floConsoleService.userService.listUsers();
if (response.data?.data?.users && Array.isArray(response.data.data.users)) {
return response.data.data.users;
}
return [];
};

const getScheduledJobsQueryFn = async (): Promise<ScheduledJob[]> => {
const jobs: ScheduledJob[] = [];
let offset = 0;

while (jobs.length < MAX_SCHEDULED_JOBS) {
const response = await floConsoleService.scheduledJobService.listScheduledJobs({
limit: SCHEDULED_JOBS_PAGE_SIZE,
offset,
});
const page = response.data.data?.jobs ?? [];
jobs.push(...page);
if (page.length < SCHEDULED_JOBS_PAGE_SIZE) {
break;
}
offset += SCHEDULED_JOBS_PAGE_SIZE;
}

return jobs.slice(0, MAX_SCHEDULED_JOBS);
};

export {
getAgentQueryFn,
getAgentsQueryFn,
Expand All @@ -414,6 +446,7 @@ export {
getApiServiceQueryFn,
getApiServicesQueryFn,
getAppByIdFn,
getAppUsersQueryFn,
getAuthenticatorQueryFn,
getAuthenticatorsQueryFn,
getCurrentUserQueryFn,
Expand All @@ -440,7 +473,7 @@ export {
getToolsQueryFn,
getTtsConfigQueryFn,
getTtsConfigsQueryFn,
getUsersQueryFn,
getConsoleUsersQueryFn,
getVoiceAgentQueryFn,
getVoiceAgentToolQueryFn,
getVoiceAgentToolsQueryFn,
Expand All @@ -449,4 +482,5 @@ export {
getWorkflowRunsQueryFn,
getWorkflowsQueryFn,
readYamlQueryFn,
getScheduledJobsQueryFn,
};
8 changes: 6 additions & 2 deletions wavefront/client/src/hooks/data/query-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ const getPipelinesKey = (appId: string, statusFilter?: string) => {
const getPipelineKey = (appId: string, pipelineId: string) => ['pipeline', appId, pipelineId];
const getPipelineFilesKey = (appId: string, pipelineId: string) => ['pipeline-files', appId, pipelineId];
const getAppByIdKey = (appId: string) => ['app-by-id', appId];
const getUsersKey = () => ['users'];
const getAppUsersKey = (appId: string) => ['app-users', appId];
const getConsoleUsersKey = () => ['console-users'];
const getUserKey = (userId: string) => ['user', userId];
const getVoiceAgentToolsKey = (appId: string) => ['voice-agent-tools', appId];
const getVoiceAgentToolKey = (appId: string, toolId: string) => ['voice-agent-tool', appId, toolId];
const getAgentToolsKey = (appId: string, agentId: string) => ['agent-tools', appId, agentId];
const getScheduledJobsKey = (appId: string) => ['scheduled-jobs', appId];

export {
getAgentKey,
Expand Down Expand Up @@ -105,7 +107,7 @@ export {
getTtsConfigKey,
getTtsConfigsKey,
getUserKey,
getUsersKey,
getConsoleUsersKey,
getVoiceAgentKey,
getVoiceAgentToolKey,
getVoiceAgentToolsKey,
Expand All @@ -114,4 +116,6 @@ export {
getWorkflowRunsKey,
getWorkflowsKey,
getAppByIdKey,
getAppUsersKey,
getScheduledJobsKey,
};
Loading
Loading