diff --git a/app-frontend/src/containers/apps/oneclick/OneClickAppConfigPage.tsx b/app-frontend/src/containers/apps/oneclick/OneClickAppConfigPage.tsx index 899eaa2..27abe07 100644 --- a/app-frontend/src/containers/apps/oneclick/OneClickAppConfigPage.tsx +++ b/app-frontend/src/containers/apps/oneclick/OneClickAppConfigPage.tsx @@ -10,6 +10,8 @@ import OneClickAppDeployHelper, { IDeploymentState } from "./OneClickAppDeployHelper"; import OneClickAppDeployProgress from "./OneClickAppDeployProgress"; +import Utils from "../../../utils/Utils"; +import DomUtils from "../../../utils/DomUtils"; export interface IOneClickVariable { id: string; @@ -89,7 +91,9 @@ export default class OneClickAppConfigPage extends Component< if (!!this.state.deploymentState) { return ( self.setState({ deploymentState: undefined })} /> ); } @@ -114,12 +118,13 @@ export default class OneClickAppConfigPage extends Component<
+ onNextClicked={values => { self.oneClickAppDeployHelper.startDeployProcess( self.state.apiData!, values - ) - } + ); + DomUtils.scrollToTopBar(); + }} />

diff --git a/app-frontend/src/containers/apps/oneclick/OneClickAppDeployHelper.ts b/app-frontend/src/containers/apps/oneclick/OneClickAppDeployHelper.ts index fce9976..f13f9e2 100644 --- a/app-frontend/src/containers/apps/oneclick/OneClickAppDeployHelper.ts +++ b/app-frontend/src/containers/apps/oneclick/OneClickAppDeployHelper.ts @@ -1,6 +1,13 @@ import ApiManager from "../../../api/ApiManager"; import { IHashMapGeneric } from "../../../models/IHashMapGeneric"; -import { IOneClickTemplate } from "./OneClickAppConfigPage"; +import { + IOneClickTemplate, + IDockerComposeService +} from "./OneClickAppConfigPage"; + +const REGISTERING = "REGISTERING"; +const CONFIGURING = "CONFIGURING"; +const DEPLOYING = "DEPLOYING"; export interface IDeploymentState { steps: string[]; @@ -10,6 +17,7 @@ export interface IDeploymentState { export default class OneClickAppDeployHelper { private apiManager: ApiManager; + private template: IOneClickTemplate | undefined; constructor( private onDeploymentStateChanged: ( deploymentState: IDeploymentState @@ -22,18 +30,43 @@ export default class OneClickAppDeployHelper { template: IOneClickTemplate, values: IHashMapGeneric ) { - // JSON.stringfy - // Replace - // Re parse with error check - // Start deploy - // TODO - alert("Deploying"); - console.log(values); + let stringified = JSON.stringify(template); + + for (let index = 0; index < template.variables.length; index++) { + const element = template.variables[index]; + stringified = stringified + .split(element.id) + .join(values[element.id] || ""); + } + + try { + this.template = JSON.parse(stringified); + } catch (error) { + this.onDeploymentStateChanged({ + steps: ["Parsing the template"], + error: `Cannot parse: ${stringified}` + "\n\n\n\n" + error, + currentStep: 0 + }); + return; + } + + alert("TODO"); + // Dependency tree + // Create steps as promises + // Start running promises, each promise will update the progress state automatically this.onDeploymentStateChanged({ - steps: [], + steps: ["Parsing the template"], error: "", currentStep: 0 }); } + + createStep(appName: string, step: string) { + return appName + " " + step; + } + + onStepCompleted(appName: string, step: string) {} + + deployApp(appName: string, dockerComposeService: IDockerComposeService) {} } diff --git a/app-frontend/src/containers/apps/oneclick/OneClickAppDeployProgress.tsx b/app-frontend/src/containers/apps/oneclick/OneClickAppDeployProgress.tsx index 8b8ba38..6a0f16b 100644 --- a/app-frontend/src/containers/apps/oneclick/OneClickAppDeployProgress.tsx +++ b/app-frontend/src/containers/apps/oneclick/OneClickAppDeployProgress.tsx @@ -1,14 +1,62 @@ import React, { Component } from "react"; import { IDeploymentState } from "./OneClickAppDeployHelper"; +import { Row, Col, Card, Steps, Icon } from "antd"; + +const Step = Steps.Step; export default class OneClickAppDeployProgress extends Component<{ + appName: string; deploymentState: IDeploymentState; + onRestartClicked: () => void; }> { render() { return (
-

OneClickAppDeployProgress

{JSON.stringify(this.props.deploymentState, null, 2)}
+
+
+ + + +

+ This process takes a few minutes to complete. DO NOT refresh + this page and DO NOT navigate away!!! +

+
+

Progress:

+
+ + + } + title="Configuring App Name" + description="This is a description." + /> + + + + + +
+ + + +
); }