You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2023/09/13 15:49:04 UTC
[camel-karavan] branch main updated (685158db -> 42ab5fe7)
This is an automated email from the ASF dual-hosted git repository.
marat pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
from 685158db Fix issues run in Docker for #885
new c5f9f5d4 Hide Dashboard page for #885
new 42ab5fe7 Show images on container page for #885
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/karavan/api/ContainerResource.java | 8 --
.../webui/src/containers/ContainerTableRow.tsx | 51 +++++++++--
.../src/main/webui/src/dashboard/DashboardPage.tsx | 98 ++++++++++++----------
.../karavan-app/src/main/webui/src/main/Main.tsx | 2 +-
.../src/main/webui/src/main/PageNavigation.tsx | 2 +-
.../src/main/webui/src/project/ProjectPanel.tsx | 1 +
6 files changed, 100 insertions(+), 62 deletions(-)
[camel-karavan] 01/02: Hide Dashboard page for #885
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit c5f9f5d48a630c6b361b2af552ca6520fc0de04b
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Wed Sep 13 11:26:43 2023 -0400
Hide Dashboard page for #885
---
.../webui/src/containers/ContainerTableRow.tsx | 7 +-
.../src/main/webui/src/dashboard/DashboardPage.tsx | 98 ++++++++++++----------
.../karavan-app/src/main/webui/src/main/Main.tsx | 2 +-
.../src/main/webui/src/main/PageNavigation.tsx | 2 +-
4 files changed, 60 insertions(+), 49 deletions(-)
diff --git a/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx b/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
index 9e855217..a3ea184a 100644
--- a/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
@@ -24,9 +24,8 @@ export function ContainerTableRow (props: Props) {
const container = props.container;
const commands = container.commands;
- const imageParts = container.image.split("@");
- const image = imageParts[0];
- const imageSha = imageParts[1];
+ const imageParts = container.image?.split("@");
+ const image = imageParts?.length > -1 ? imageParts[0] : "";
const ports = container.ports;
const isRunning = container.state === 'running';
const inTransit = container.inTransit;
@@ -107,7 +106,7 @@ export function ContainerTableRow (props: Props) {
<Td colSpan={2}>
<ExpandableRowContent>
<Flex direction={{default: "column"}} cellPadding={"0px"}>
- {container.containerId.substring(0, 10)+"..."}
+ {container.containerId?.substring(0, 10)+"..."}
</Flex>
</ExpandableRowContent>
</Td>
diff --git a/karavan-web/karavan-app/src/main/webui/src/dashboard/DashboardPage.tsx b/karavan-web/karavan-app/src/main/webui/src/dashboard/DashboardPage.tsx
index 0745dbaa..56fdde4a 100644
--- a/karavan-web/karavan-app/src/main/webui/src/dashboard/DashboardPage.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/dashboard/DashboardPage.tsx
@@ -13,7 +13,14 @@ import {
ToolbarItem, Tooltip, EmptyStateHeader
} from '@patternfly/react-core';
import '../designer/karavan.css';
-import {CamelStatus, ContainerStatus, DeploymentStatus, Project, ServiceStatus} from "../api/ProjectModels";
+import {
+ CamelStatus,
+ CamelStatusValue,
+ ContainerStatus,
+ DeploymentStatus,
+ Project,
+ ServiceStatus
+} from "../api/ProjectModels";
import {
TableVariant,
Tbody,
@@ -124,12 +131,17 @@ export function DashboardPage () {
});
}
- function getCamelStatusByEnvironments(name: string): [string, CamelStatus | undefined] [] {
- return selectedEnv.map(e => {
+ function getCamelStatusByEnvironments(containerName: string): [string, CamelStatusValue | undefined] [] {
+ console.log(camels)
+ console.log(selectedEnv)
+ const result = selectedEnv.map(e => {
const env: string = e as string;
- const status = camels?.find(d => d.projectId === name && d.env === env);
- return [env, status];
+ const status = camels?.find(d => d.containerName === containerName && d.env === env);
+ const statusValue = status ? status.statuses[0] : undefined;
+ return {env, statusValue};
});
+ console.log(result)
+ return [];
}
function getProject(name: string): Project | undefined {
@@ -271,67 +283,67 @@ export function DashboardPage () {
<Table aria-label="Projects" variant={TableVariant.compact}>
<Thead>
<Tr>
- <Th key='type'>Type</Th>
- <Th key='container'>Container</Th>
- <Th key='description'>Project Description</Th>
- <Th key='ports'>Ports</Th>
- <Th key='environment'>Environment</Th>
- <Th key='camel'>Camel Health</Th>
- {/*<Th key='action'></Th>*/}
+ <Th key='container' width={20}>Container</Th>
+ <Th key='description' width={30} isStickyColumn >Project Description</Th>
+ {/*{config.environments.map((e, i) =>*/}
+ {['dev', 'test', 'prod'].map((e, i) =>
+ <Th key={e} textCenter hasLeftBorder width={10} >{e}</Th>
+ )}
</Tr>
</Thead>
<Tbody>
{conts.map(container => (
<Tr key={container.containerName}>
- <Td style={{verticalAlign: "middle"}} modifier={"fitContent"}>
- <Badge className="badge">{container.type}</Badge>
- </Td>
<Td style={{verticalAlign: "middle"}}>
<Label color={container.state === 'running' ? "green" : 'grey'}>
{container.containerName}
+ <Badge isRead>{container.type}</Badge>
</Label>
</Td>
- <Td style={{verticalAlign: "middle"}}>
+ <Td isStickyColumn style={{verticalAlign: "middle"}}>
<HelperText>
<HelperTextItem>{getProject(container.containerName)?.description || "Camel project"}</HelperTextItem>
</HelperText>
</Td>
- <Td>
- <Flex direction={{default: "column"}}>
- {container.ports.map(port => (
- <FlexItem className="badge-flex-item" key={port}>
- <Badge className="badge" isRead={true}>{port}</Badge>
- </FlexItem>
- ))}
- </Flex>
- </Td>
- <Td>
- <Flex direction={{default: "column"}}>
+ {/*<Td>*/}
+ {/* <Flex direction={{default: "column"}}>*/}
+ {/* {container.ports.map(port => (*/}
+ {/* <FlexItem className="badge-flex-item" key={port}>*/}
+ {/* <Badge className="badge" isRead={true}>{port}</Badge>*/}
+ {/* </FlexItem>*/}
+ {/* ))}*/}
+ {/* </Flex>*/}
+ {/*</Td>*/}
+ <Td hasLeftBorder>
+ <Flex direction={{default: "column"}} style={{verticalAlign: "middle"}}>
{getContainerByEnvironments(container.containerName).map(value => (
<FlexItem className="badge-flex-item" key={value[0]}>
<Label color={"green"}>
{value[1] ? value[1]?.env : ""}
+ <Label color={"green"}>
+ {value[1] ? value[1]?.env : ""}
+ </Label>
</Label>
</FlexItem>
))}
</Flex>
</Td>
- <Td modifier={"fitContent"}>
- <Flex direction={{default: "column"}}>
- {getCamelStatusByEnvironments(container.containerName).map(value => {
- // const color = value[1] ? (value[1].consumerStatus === "UP" ? "green" : "red") : "grey";
- // let icon = undefined;
- // if (value[1]?.consumerStatus === "UP") icon = <UpIcon/>
- // if (value[1]?.consumerStatus === "DOWN") icon = <DownIcon/>
- // const text = value[1] && value[1]?.contextVersion ? value[1]?.contextVersion : "???";
- return <FlexItem key={value[0]}>
- {/*<LabelGroup numLabels={4} className="camel-label-group">*/}
- {/* <Label color={color} className="table-label" icon={icon}>{text}</Label>*/}
- {/*</LabelGroup>*/}
- </FlexItem>
- })}
- </Flex>
- </Td>
+ {/*<Td modifier={"fitContent"}>*/}
+ {/* <Flex direction={{default: "column"}}>*/}
+ {/* {getCamelStatusByEnvironments(container.containerName).map(value => {*/}
+ {/* // const color = value[1] ? (value[1].consumerStatus === "UP" ? "green" : "red") : "grey";*/}
+ {/* // let icon = undefined;*/}
+ {/* // if (value[1]?.consumerStatus === "UP") icon = <UpIcon/>*/}
+ {/* // if (value[1]?.consumerStatus === "DOWN") icon = <DownIcon/>*/}
+ {/* // const text = value[1] && value[1]?.contextVersion ? value[1]?.contextVersion : "???";*/}
+ {/* return <FlexItem key={value[0]}>*/}
+ {/* /!*<LabelGroup numLabels={4} className="camel-label-group">*!/*/}
+ {/* /!* <Label color={color} className="table-label" icon={icon}>{text}</Label>*!/*/}
+ {/* /!*</LabelGroup>*!/*/}
+ {/* </FlexItem>*/}
+ {/* })}*/}
+ {/* </Flex>*/}
+ {/*</Td>*/}
</Tr>
))}
{conts.length === 0 && getEmptyState()}
diff --git a/karavan-web/karavan-app/src/main/webui/src/main/Main.tsx b/karavan-web/karavan-app/src/main/webui/src/main/Main.tsx
index 4de22cd4..c7cecc80 100644
--- a/karavan-web/karavan-app/src/main/webui/src/main/Main.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/main/Main.tsx
@@ -133,7 +133,7 @@ export function Main() {
</FlexItem>
<FlexItem flex={{default: "flex_2"}} style={{height: "100%"}}>
<Routes>
- <Route path="/dashboard" element={<DashboardPage key={'dashboard'}/>}/>
+ {/*<Route path="/dashboard" element={<DashboardPage key={'dashboard'}/>}/>*/}
<Route path="/projects" element={<ProjectsPage key={'projects'}/>}/>
<Route path="/projects/:projectId" element={<ProjectPage key={'project'}/>}/>
<Route path="/templates" element={<TemplatesPage key={'templates'}/>}/>
diff --git a/karavan-web/karavan-app/src/main/webui/src/main/PageNavigation.tsx b/karavan-web/karavan-app/src/main/webui/src/main/PageNavigation.tsx
index 1eb173fa..0178c23f 100644
--- a/karavan-web/karavan-app/src/main/webui/src/main/PageNavigation.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/main/PageNavigation.tsx
@@ -43,7 +43,7 @@ export function PageNavigation () {
function getMenu() : MenuItem[] {
const pages: MenuItem[] = [
- new MenuItem("dashboard", "Dashboard", <DashboardIcon/>),
+ // new MenuItem("dashboard", "Dashboard", <DashboardIcon/>),
new MenuItem("projects", "Projects", <ProjectsIcon/>),
new MenuItem("templates", "Templates", <TemplatesIcon/>),
]
[camel-karavan] 02/02: Show images on container page for #885
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 42ab5fe70310dc8730751d47b7fb73dc160cc17e
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Wed Sep 13 11:48:44 2023 -0400
Show images on container page for #885
---
.../camel/karavan/api/ContainerResource.java | 8 ----
.../webui/src/containers/ContainerTableRow.tsx | 44 +++++++++++++++++++---
.../src/main/webui/src/project/ProjectPanel.tsx | 1 +
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ContainerResource.java b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ContainerResource.java
index febf6201..e035dbba 100644
--- a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ContainerResource.java
+++ b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ContainerResource.java
@@ -24,10 +24,8 @@ import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
-import org.apache.camel.karavan.code.CodeService;
import org.apache.camel.karavan.code.DockerComposeConverter;
import org.apache.camel.karavan.code.model.DockerComposeService;
-import org.apache.camel.karavan.docker.DockerForKaravan;
import org.apache.camel.karavan.docker.DockerService;
import org.apache.camel.karavan.infinispan.InfinispanService;
import org.apache.camel.karavan.infinispan.model.ContainerStatus;
@@ -56,18 +54,12 @@ public class ContainerResource {
@Inject
KubernetesService kubernetesService;
- @Inject
- DockerForKaravan dockerForKaravan;
-
@Inject
DockerService dockerService;
@Inject
ProjectService projectService;
- @Inject
- CodeService codeService;
-
@ConfigProperty(name = "karavan.environment")
String environment;
diff --git a/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx b/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
index a3ea184a..623afea3 100644
--- a/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/containers/ContainerTableRow.tsx
@@ -2,7 +2,7 @@ import React, {useState} from 'react';
import {
Button,
Tooltip,
- Flex, FlexItem, Label, Badge, Spinner
+ Flex, FlexItem, Label, Badge, Spinner, Modal
} from '@patternfly/react-core';
import '../designer/karavan.css';
import {ExpandableRowContent, Tbody, Td, Tr} from "@patternfly/react-table";
@@ -21,6 +21,8 @@ interface Props {
export function ContainerTableRow (props: Props) {
const [isExpanded, setIsExpanded] = useState<boolean>(false);
+ const [showConfirmation, setShowConfirmation] = useState<boolean>(false);
+ const [command, setCommand] = useState<'run' | 'pause' | 'stop' | 'delete'>();
const container = props.container;
const commands = container.commands;
@@ -30,8 +32,36 @@ export function ContainerTableRow (props: Props) {
const isRunning = container.state === 'running';
const inTransit = container.inTransit;
const color = container.state === 'running' ? "green" : "grey";
+
+ function getConfirmation() {
+ return (<Modal
+ className="modal-delete"
+ title="Confirmation"
+ isOpen={showConfirmation}
+ onClose={() => setShowConfirmation(false)}
+ actions={[
+ <Button key="confirm" variant="primary" onClick={e => {
+ if (command) {
+ KaravanApi.manageContainer(container.env, container.type, container.containerName, command, res => {});
+ setCommand(undefined);
+ setShowConfirmation(false);
+ }
+ }}>Delete
+ </Button>,
+ <Button key="cancel" variant="link"
+ onClick={e => {
+ setCommand(undefined);
+ setShowConfirmation(false);
+ }}>Cancel</Button>
+ ]}
+ onEscapePress={e => setShowConfirmation(false)}>
+ <div>{"Confirm " + commands + " container " + container.containerName + " ?"}</div>
+ </Modal>)
+ }
+
return (
<Tbody isExpanded={isExpanded}>
+ {showConfirmation && getConfirmation()}
<Tr key={container.containerName}>
<Td expand={
container.containerName
@@ -69,7 +99,8 @@ export function ContainerTableRow (props: Props) {
<Tooltip content={"Start container"} position={"bottom"}>
<Button variant={"plain"} icon={<PlayIcon/>} isDisabled={!commands.includes('run') || inTransit}
onClick={e => {
- KaravanApi.manageContainer(container.env, container.type, container.containerName, 'run', res => {});
+ setCommand('run');
+ setShowConfirmation(true);
}}></Button>
</Tooltip>
</FlexItem>
@@ -77,7 +108,8 @@ export function ContainerTableRow (props: Props) {
<Tooltip content={"Pause container"} position={"bottom"}>
<Button variant={"plain"} icon={<PauseIcon/>} isDisabled={!commands.includes('pause') || inTransit}
onClick={e => {
- KaravanApi.manageContainer(container.env, container.type, container.containerName, 'pause', res => {});
+ setCommand('pause');
+ setShowConfirmation(true);
}}></Button>
</Tooltip>
</FlexItem>
@@ -85,7 +117,8 @@ export function ContainerTableRow (props: Props) {
<Tooltip content={"Stop container"} position={"bottom"}>
<Button variant={"plain"} icon={<StopIcon/>} isDisabled={!commands.includes('stop') || inTransit}
onClick={e => {
- KaravanApi.manageContainer(container.env, container.type, container.containerName, 'stop', res => {});
+ setCommand('stop');
+ setShowConfirmation(true);
}}></Button>
</Tooltip>
</FlexItem>
@@ -93,7 +126,8 @@ export function ContainerTableRow (props: Props) {
<Tooltip content={"Delete container"} position={"bottom"}>
<Button variant={"plain"} icon={<DeleteIcon/>} isDisabled={!commands.includes('delete') || inTransit}
onClick={e => {
- KaravanApi.deleteContainer(container.env, container.type, container.containerName, res => {});
+ setCommand('delete');
+ setShowConfirmation(true);
}}></Button>
</Tooltip>
</FlexItem>
diff --git a/karavan-web/karavan-app/src/main/webui/src/project/ProjectPanel.tsx b/karavan-web/karavan-app/src/main/webui/src/project/ProjectPanel.tsx
index 5769a286..512530b1 100644
--- a/karavan-web/karavan-app/src/main/webui/src/project/ProjectPanel.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/project/ProjectPanel.tsx
@@ -48,6 +48,7 @@ export function ProjectPanel() {
{!buildIn && tab === 'build' && <FlexItem><ProjectBuildTab/></FlexItem>}
{!buildIn && tab === 'build' && config.infrastructure !== 'kubernetes' && <FlexItem><ImagesPanel/></FlexItem>}
{!buildIn && tab === 'container' && <FlexItem><ProjectContainerTab/></FlexItem>}
+ {!buildIn && tab === 'container' && config.infrastructure !== 'kubernetes' && <FlexItem><ImagesPanel/></FlexItem>}
</Flex>
</PageSection>
</PageSection>