Skip to content

Commit

Permalink
Merge branch 'main' into analysis-task-updates
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Dickerson <sdickers@redhat.com>
  • Loading branch information
sjd78 authored Jun 20, 2024
2 parents 19bbe42 + 5b2352d commit c78405d
Show file tree
Hide file tree
Showing 37 changed files with 1,390 additions and 336 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY --chown=1001 . .
RUN npm clean-install --ignore-scripts && npm run build && npm run dist

# Runner image
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-113.1717076360
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-117

# Add ps package to allow liveness probe for k8s cluster
# Add tar package to allow copying files with kubectl scp
Expand Down
1 change: 1 addition & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
"assessmentQuestionnaires": "Assessment questionnaires",
"assessmentNotes": "Assessment notes",
"assessmentSummary": "Assessment summary",
"attachments": "Attachments",
"autoTagging": "Automated Tagging",
"binary": "Binary",
"branch": "Branch",
Expand Down
9 changes: 6 additions & 3 deletions client/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import { BrowserRouter } from "react-router-dom";
import { AppRoutes } from "./Routes";
import { DefaultLayout } from "./layout";
import { NotificationsProvider } from "./components/NotificationsContext";
import { TaskManagerProvider } from "./components/task-manager/TaskManagerContext";

import "./app.css";

const App: React.FC = () => {
return (
<BrowserRouter>
<NotificationsProvider>
<DefaultLayout>
<AppRoutes />
</DefaultLayout>
<TaskManagerProvider>
<DefaultLayout>
<AppRoutes />
</DefaultLayout>
</TaskManagerProvider>
</NotificationsProvider>
</BrowserRouter>
);
Expand Down
8 changes: 8 additions & 0 deletions client/src/app/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export const DevPaths = {
applications: "/applications",
applicationsAnalysisDetails:
"/applications/:applicationId/analysis-details/:taskId",
applicationsAnalysisDetailsAttachment:
"/applications/:applicationId/analysis-details/:taskId/attachments/:attachmentId",
applicationsAnalysisTab: "/applications/analysis-tab",
applicationsAssessmentTab: "/applications/assessment-tab",
applicationsImports: "/applications/application-imports",
Expand Down Expand Up @@ -93,3 +95,9 @@ export interface AnalysisDetailsRoute {
applicationId: string;
taskId: string;
}

export interface AnalysisDetailsAttachmentRoute {
applicationId: string;
taskId: string;
attachmentId: string;
}
5 changes: 5 additions & 0 deletions client/src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const devRoutes: IRoute<DevPathValues>[] = [
{
path: Paths.applicationsAnalysisDetails,
comp: AnalysisDetails,
exact: true,
},
{
path: Paths.applicationsAnalysisDetailsAttachment,
comp: AnalysisDetails,
exact: false,
},
{
Expand Down
85 changes: 64 additions & 21 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,62 @@ export type TaskState =

export interface Task {
id?: number;
createUser?: string;
updateUser?: string;
createTime?: string;
application: { id: number };

name: string;
kind?: string;
addon?: string;
kind: string;
addon: string;
extensions: string[];
state?: TaskState;
locator?: string;
priority?: number;
policy: TaskPolicy;
ttl: TTL;
data: TaskData;
error?: string;
image?: string;
application: Ref;
bucket?: Ref;
pod?: string;
retries?: number;
started?: string;
terminated?: string;
state?: TaskState;
job?: string;
report?: TaskReport;
events?: TaskEvent[];
errors?: TaskError[];
activity?: string[];
attached?: TaskAttachment[];
}

export interface TaskPolicy {
isolated?: boolean;
preemptEnabled?: boolean;
preemptExempt?: boolean;
}

export interface TTL {
created?: number;
pending?: number;
running?: number;
succeeded?: number;
failed?: number;
}

export interface TaskEvent {
kind: string;
count: number;
reason?: string;
last: string; // time
}

export interface TaskError {
severity: string;
description: string;
}

export interface TaskAttachment {
id: number;
name?: string;
activity?: number;
}

export interface TaskData {
Expand Down Expand Up @@ -356,19 +399,6 @@ export interface TaskData {
};
}

interface TaskReport {
activity: string[];
completed: number;
createTime: string;
createUser: string;
error: string;
id: number;
status: string;
task: number;
total: number;
updateUser: string;
}

export interface TaskgroupTask {
name: string;
data: any;
Expand All @@ -384,6 +414,19 @@ export interface Taskgroup {
tasks: TaskgroupTask[];
}

export interface TaskQueue {
/** Total number of tasks scheduled */
total: number;
/** number of tasks ready to run */
ready: number;
/** number of postponed tasks */
postponed: number;
/** number of tasks with pods created awaiting node scheduler */
pending: number;
/** number of tasks with running pods */
running: number;
}

export interface Cache {
path: string;
capacity: string;
Expand Down
73 changes: 49 additions & 24 deletions client/src/app/api/rest.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import axios, { AxiosPromise, RawAxiosRequestHeaders } from "axios";

import {
AnalysisAppDependency,
AnalysisAppReport,
AnalysisDependency,
BaseAnalysisRuleReport,
BaseAnalysisIssueReport,
AnalysisIssue,
AnalysisFileReport,
AnalysisIncident,
AnalysisIssue,
Application,
ApplicationAdoptionPlan,
ApplicationDependency,
ApplicationImport,
ApplicationImportSummary,
Archetype,
Assessment,
BaseAnalysisIssueReport,
BaseAnalysisRuleReport,
BusinessService,
Cache,
HubFile,
HubPaginatedResult,
HubRequestParams,
Identity,
InitialAssessment,
IReadFile,
Tracker,
JobFunction,
MigrationWave,
MimeType,
New,
Proxy,
Questionnaire,
Ref,
Review,
Setting,
SettingTypes,
Stakeholder,
StakeholderGroup,
Tag,
TagCategory,
Target,
Task,
Taskgroup,
MigrationWave,
TaskQueue,
Ticket,
New,
Ref,
Tracker,
TrackerProject,
TrackerProjectIssuetype,
UnstructuredFact,
AnalysisAppDependency,
AnalysisAppReport,
Target,
HubFile,
Questionnaire,
Archetype,
InitialAssessment,
MimeType,
} from "./models";
import { serializeRequestParamsForHub } from "@app/hooks/table-controls";

Expand Down Expand Up @@ -319,26 +320,40 @@ export const getApplicationImports = (
.get(`${APP_IMPORT}?importSummary.id=${importSummaryID}&isValid=${isValid}`)
.then((response) => response.data);

export function getTaskById(
export function getTaskById(id: number): Promise<Task> {
return axios
.get(`${TASKS}/${id}`, {
headers: { ...jsonHeaders },
responseType: "json",
})
.then((response) => {
return response.data;
});
}

export function getTaskByIdAndFormat(
id: number,
format: string,
format: "json" | "yaml",
merged: boolean = false
): Promise<Task | string> {
const headers = format === "yaml" ? { ...yamlHeaders } : { ...jsonHeaders };
const responseType = format === "yaml" ? "text" : "json";
): Promise<string> {
const isYaml = format === "yaml";
const headers = isYaml ? { ...yamlHeaders } : { ...jsonHeaders };
const responseType = isYaml ? "text" : "json";

let url = `${TASKS}/${id}`;
if (merged) {
url += "?merged=1";
}

return axios
.get(url, {
.get<Task | string>(url, {
headers: headers,
responseType: responseType,
})
.then((response) => {
return response.data;
return isYaml
? String(response.data ?? "")
: JSON.stringify(response.data, undefined, 2);
});
}

Expand All @@ -348,10 +363,15 @@ export const getTasks = () =>
export const getServerTasks = (params: HubRequestParams = {}) =>
getHubPaginatedResult<Task>(TASKS, params);

export const deleteTask = (id: number) => axios.delete<Task>(`${TASKS}/${id}`);
export const deleteTask = (id: number) => axios.delete<void>(`${TASKS}/${id}`);

export const cancelTask = (id: number) =>
axios.put<Task>(`${TASKS}/${id}/cancel`);
axios.put<void>(`${TASKS}/${id}/cancel`);

export const getTaskQueue = (addon?: string): Promise<TaskQueue> =>
axios
.get<TaskQueue>(`${TASKS}/report/queue`, { params: { addon } })
.then(({ data }) => data);

export const createTaskgroup = (obj: Taskgroup) =>
axios.post<Taskgroup>(TASKGROUPS, obj).then((response) => response.data);
Expand Down Expand Up @@ -439,6 +459,11 @@ export const createFile = ({
return response.data;
});

export const getTextFile = (id: number): Promise<string> =>
axios
.get(`${FILES}/${id}`, { headers: { Accept: "text/plain" } })
.then((response) => response.data);

export const getSettingById = <K extends keyof SettingTypes>(
id: K
): Promise<SettingTypes[K]> =>
Expand Down
Loading

0 comments on commit c78405d

Please sign in to comment.