Skip to content

Commit

Permalink
✨ Read batch execution from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysoun committed Aug 7, 2024
1 parent d7af646 commit b19078f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
15 changes: 9 additions & 6 deletions modules/ui/src/lib/domain/execution/Execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import {Type} from 'class-transformer';
export class Execution {
id: string
@Type(() => Date)
date: Date
startDate: Date
@Type(() => Date)
endDate: Date
origin: ExecutionOrigin
type: ExecutionType
status: ExecutionStatus
duration: number


constructor(id: string, date: Date, origin: ExecutionOrigin, type: ExecutionType, status: ExecutionStatus, duration: number) {
constructor(id: string, startDate: Date, endDate: Date, origin: ExecutionOrigin, type: ExecutionType, status: ExecutionStatus, duration: number) {
this.id = id;
this.date = date;
this.startDate = startDate;
this.endDate = endDate;
this.origin = origin;
this.type = type;
this.status = status;
Expand Down Expand Up @@ -49,16 +52,16 @@ export class ExecutionForDashboard extends Execution {
export class ExecutionDetail extends Execution {
project: {name: string}
module: {name: string}
env: {name: string}
environment: {name: string}


constructor(id: string, date: Date, origin: ExecutionOrigin, type: ExecutionType, status: ExecutionStatus, duration: number, project: {
name: string
}, module: { name: string }, env: { name: string }) {
}, module: { name: string }, environment: { name: string }) {
super(id, date, origin, type, status, duration);
this.project = project;
this.module = module;
this.env = env;
this.environment = environment;
}
}

Expand Down
9 changes: 6 additions & 3 deletions modules/ui/src/lib/mocks/ExecutionMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,26 @@ export class ExecutionMock {
public static readonly executions: Execution[] = [
{
id: '1',
date: new Date(),
startDate: new Date(),
endDate: new Date(),
origin: ExecutionOrigin.SERVER,
type: ExecutionType.PLANNED,
status: ExecutionStatus.COMPLETED,
duration: 125
},
{
id: '2',
date: new Date(),
startDate: new Date(),
endDate: new Date(),
origin: ExecutionOrigin.SERVER,
type: ExecutionType.PLANNED,
status: ExecutionStatus.ERROR,
duration: 361
},
{
id: '3',
date: new Date(),
startDate: new Date(),
endDate: new Date(),
origin: ExecutionOrigin.SERVER,
type: ExecutionType.PLANNED,
status: ExecutionStatus.IN_PROGRESS,
Expand Down
7 changes: 2 additions & 5 deletions modules/ui/src/lib/services/ExecutionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ export class ExecutionService {
});
}

public static async byId(id: string): Promise<ExecutionWithReport | undefined> {
return new Promise((resolve) => {
resolve(ExecutionMock.executionsWithReport
.find(execution => execution.id === id));
});
public static async byId(id: string): Promise<ExecutionDetail> {
return Http.get<ExecutionDetail>(`/api/v1/batchExecutions/${id}`, ExecutionDetail)
}

public static async scriptEnvMatrixByProjectAndModule(projectId: string, moduleId: string): Promise<ScriptEnvMatrix> {
Expand Down
29 changes: 14 additions & 15 deletions modules/ui/src/routes/executions/[executionId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import A_icon from "$lib/components/atoms/A_icon.svelte";
import M_breadcrumbItem from "$lib/components/molecules/M_breadcrumbItem.svelte";
import {Tooltip} from "svelte-tooltip-simple";
Expand All @@ -7,11 +7,10 @@
import M_tabs from "$lib/components/molecules/M_tabs.svelte";
import O_scriptList from "$lib/components/organisms/O_scriptList.svelte";
import {page} from "$app/stores";
import {ProjectService} from "$lib/services/ProjectService.ts";
import {ExecutionMock} from "$lib/mocks/ExecutionMock.ts";
import {ExecutionService} from "$lib/services/ExecutionService.ts";
import {ExecutionService} from "$lib/services/ExecutionService";
import type {ExecutionDetail} from "$lib/domain/execution/Execution";
let executionPromise
let executionPromise: Promise<ExecutionDetail>
let tabItems = ['Script', 'Logs']
let activeTabItem = 'Script'
Expand All @@ -20,8 +19,8 @@
activeTabItem = event.detail;
}
$: if($page.params?.project) {
executionPromise = ExecutionService.byId($page.params.execution);
$: if($page.params?.executionId) {
executionPromise = ExecutionService.byId($page.params.executionId);
}
Expand Down Expand Up @@ -466,10 +465,10 @@
</Tooltip>
</div>
<div class="executionView-header-breadcrumb cell auto grid-x">
<M_breadcrumbItem nameItem="Portail Fret"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="Production"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="Module"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="Exécution PF12092022-1" isLast="true"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="{execution.project.name}"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="{execution.environment.name}"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="{execution.module.name}"></M_breadcrumbItem>
<M_breadcrumbItem nameItem="{execution.id}" isLast="{true}"></M_breadcrumbItem>
</div>
<div class="executionView-header-favorite cell shrink">
<Tooltip text="Ajouter aux favoris">
Expand All @@ -479,7 +478,7 @@
</div>

<div class="executionView-title cell shrink">
Exécution PF12092022-1
Exécution {execution.id}
</div>

<div class="executionView-content cell shrink">
Expand All @@ -488,23 +487,23 @@
Lancé le :
</div>
<div class="executionView-content-data">
12/09/2022 à 13h57
{execution.startDate.toLocaleDateString()}
</div>
</div>
<div class="executionView-content-container">
<div class="executionView-content-title">
Module :
</div>
<div class="executionView-content-data">
Module Machin
{execution.module.name}
</div>
</div>
<div class="executionView-content-container">
<div class="executionView-content-title">
Environnement :
</div>
<div class="executionView-content-data">
Production
{execution.environment.name}
</div>
</div>
</div>
Expand Down

0 comments on commit b19078f

Please sign in to comment.