mirror of
https://github.com/caprover/caprover
synced 2026-10-25 00:03:59 +00:00
Save and Update config is working
This commit is contained in:
1 parent
4cbda0eab2
commit
19fa292973
4 files changed
+55
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import HttpClient from "./HttpClient";
|
||||
import Logger from "../utils/Logger";
|
||||
import { IAppDef } from "../containers/apps/AppDefinition";
|
||||
|
||||
const URL = process.env.REACT_APP_API_URL + "/api/v2";
|
||||
Logger.dev("API URL: " + URL);
|
||||
@@ -91,6 +92,37 @@ export default class ApiManager {
|
||||
);
|
||||
}
|
||||
|
||||
updateConfigAndSave(appName: string, appDefinition: IAppDef) {
|
||||
var instanceCount = appDefinition.instanceCount;
|
||||
var envVars = appDefinition.envVars;
|
||||
var notExposeAsWebApp = appDefinition.notExposeAsWebApp;
|
||||
var forceSsl = appDefinition.forceSsl;
|
||||
var volumes = appDefinition.volumes;
|
||||
var ports = appDefinition.ports;
|
||||
var nodeId = appDefinition.nodeId;
|
||||
var appPushWebhook = appDefinition.appPushWebhook;
|
||||
var customNginxConfig = appDefinition.customNginxConfig;
|
||||
var preDeployFunction = appDefinition.preDeployFunction;
|
||||
const http = this.http;
|
||||
|
||||
return Promise.resolve() //
|
||||
.then(
|
||||
http.fetch(http.POST, "/user/apps/appDefinitions/update", {
|
||||
appName: appName,
|
||||
instanceCount: instanceCount,
|
||||
notExposeAsWebApp: notExposeAsWebApp,
|
||||
forceSsl: forceSsl,
|
||||
volumes: volumes,
|
||||
ports: ports,
|
||||
customNginxConfig: customNginxConfig,
|
||||
appPushWebhook: appPushWebhook,
|
||||
nodeId: nodeId,
|
||||
preDeployFunction: preDeployFunction,
|
||||
envVars: envVars
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
registerNewApp(appName: string, hasPersistentData: boolean) {
|
||||
const http = this.http;
|
||||
|
||||
|
||||
@@ -331,6 +331,13 @@ export default class AppConfigs extends Component<
|
||||
app.hasPersistentData &&
|
||||
!this.state.forceEditableInstanceCount
|
||||
}
|
||||
onChange={e => {
|
||||
const newApiData = Utils.copyObject(this.props.apiData);
|
||||
newApiData.appDefinition.instanceCount = Number(
|
||||
e.target.value
|
||||
);
|
||||
this.props.updateApiData(newApiData);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Col>
|
||||
|
||||
@@ -23,6 +23,7 @@ import ApiManager from "../../../api/ApiManager";
|
||||
import AppConfigs from "./AppConfigs";
|
||||
import Deployment from "./Deployment";
|
||||
import { BasicProps } from "antd/lib/layout/layout";
|
||||
import Utils from "../../../utils/Utils";
|
||||
const TabPane = Tabs.TabPane;
|
||||
|
||||
const WEB_SETTINGS = "WEB_SETTINGS";
|
||||
@@ -73,6 +74,18 @@ export default class AppDetails extends ApiComponent<
|
||||
this.props.history.push("/apps");
|
||||
}
|
||||
|
||||
onUpdateConfigAndSave() {
|
||||
const self = this;
|
||||
const appDef = Utils.copyObject(self.state.apiData!.appDefinition);
|
||||
self.setState({ isLoading: true });
|
||||
this.apiManager
|
||||
.updateConfigAndSave(appDef.appName!, appDef)
|
||||
.then(function(data: any) {
|
||||
self.reFetchData();
|
||||
})
|
||||
.catch(Toaster.createCatcher());
|
||||
}
|
||||
|
||||
render() {
|
||||
const self = this;
|
||||
|
||||
@@ -155,6 +168,7 @@ export default class AppDetails extends ApiComponent<
|
||||
/>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
<div style={{ height: 50 }} />
|
||||
|
||||
<Affix
|
||||
offsetBottom={0}
|
||||
@@ -190,6 +204,7 @@ export default class AppDetails extends ApiComponent<
|
||||
style={{ minWidth: 135 }}
|
||||
type="primary"
|
||||
size="large"
|
||||
onClick={() => self.onUpdateConfigAndSave()}
|
||||
>
|
||||
Save & Update
|
||||
</Button>
|
||||
|
||||
@@ -311,6 +311,7 @@ export default class HttpSettings extends Component<
|
||||
<br />
|
||||
|
||||
<Checkbox
|
||||
defaultChecked={this.props.apiData!.appDefinition.notExposeAsWebApp}
|
||||
onChange={(e: any) => {
|
||||
const newApiData = Utils.copyObject(this.props.apiData!);
|
||||
newApiData.appDefinition.notExposeAsWebApp = !!e.target.checked;
|
||||
|
||||
Reference in new issue
Block a user