Skip to content

Commit ec501e0

Browse files
committed
fix(ui): sgpgconfig default params fetching blocks dry run
1 parent c4643b6 commit ec501e0

1 file changed

Lines changed: 49 additions & 17 deletions

File tree

stackgres-k8s/src/admin-ui/src/components/forms/CreateSGPgConfigs.vue

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
v-model="pgConfigVersion"
3030
:disabled="(editMode)"
3131
required data-field="spec.postgresVersion"
32-
@change="loadingDefaults = true; dryRun = true; createPGConfig();"
32+
@change="getDefaultParams()"
3333
>
3434
<option disabled value="">Select Major Postgres Version</option>
3535
<option v-for="version in postgresVersions">{{ version }}</option>
@@ -50,7 +50,7 @@
5050
</div>
5151
</div>
5252

53-
<template v-if="Object.keys(defaultParams).length">
53+
<template v-if="Object.keys(defaultParams).length || loadingDefaults">
5454
<div class="paramDetails">
5555
<hr/>
5656
<h2>Default Parameters</h2><br/>
@@ -94,22 +94,19 @@
9494
type="button"
9595
class="btn border floatRight"
9696
title="Dry run mode helps to evaluate a request through the typical request stages without any storage persistance or resource allocation."
97-
@click="
98-
dryRun = true;
99-
createPGConfig();
100-
"
97+
@click="createPGConfig(true, true)"
10198
>
10299
Dry Run
103100
</button>
104101
</form>
105102
<CRDSummary
106103
v-if="showSummary"
107104
:crd="previewConfig"
108-
:dryRun="dryRun"
105+
:dryRun="showDryRun"
109106
kind="SGPostgresConfig"
110107
@closeSummary="
111108
showSummary = false;
112-
dryRun = false;
109+
showDryRun = false;
113110
previewConfig = {};
114111
"
115112
></CRDSummary>
@@ -139,9 +136,9 @@
139136
return {
140137
editMode: (vm.$route.name === 'EditPgConfig'),
141138
editReady: false,
142-
dryRun: false,
143139
previewConfig: {},
144140
showSummary: false,
141+
showDryRun: false,
145142
pgConfigName: vm.$route.params.hasOwnProperty('name') ? vm.$route.params.name : '',
146143
pgConfigNamespace: vm.$route.params.hasOwnProperty('namespace') ? vm.$route.params.namespace : '',
147144
pgConfigParams: '',
@@ -200,7 +197,36 @@
200197
},
201198
methods: {
202199
203-
createPGConfig(preview = false, previous) {
200+
getDefaultParams() {
201+
const vc = this;
202+
203+
vc.loadingDefaults = true;
204+
205+
let config = {
206+
"metadata": {
207+
"name": vc.pgConfigName.length ? vc.pgConfigName : 'get-default-params',
208+
"namespace": vc.pgConfigNamespace
209+
},
210+
"spec": {
211+
"postgresVersion": vc.pgConfigVersion
212+
}
213+
};
214+
215+
sgApi
216+
.create('sgpgconfigs', config, true)
217+
.then(function (response) {
218+
vc.defaultParams = response.data.status.defaultParameters;
219+
vc.pgConfigParamsObj = response.data.status['postgresql.conf'];
220+
vc.loadingDefaults = false;
221+
})
222+
.catch(function (error) {
223+
console.log(error.response);
224+
vc.notify(error.response.data,'error', 'sgpgconfigs');
225+
vc.loadingDefaults = false;
226+
});
227+
},
228+
229+
createPGConfig(preview = false, dryRun = false, previous) {
204230
const vc = this;
205231
206232
if (!vc.loadingDefaults && !vc.checkRequired()) {
@@ -213,15 +239,15 @@
213239
sgApi
214240
.getResourceDetails('sgpgconfigs', this.pgConfigNamespace, this.pgConfigName)
215241
.then(function (response) {
216-
vc.createPGConfig(preview, response.data);
242+
vc.createPGConfig(preview, dryRun, response.data);
217243
})
218244
.catch(function (error) {
219245
if (error.response.status != 404) {
220246
console.log(error.response);
221247
vc.notify(error.response.data,'error', 'sgpgconfigs');
222248
return;
223249
}
224-
vc.createPGConfig(preview, {});
250+
vc.createPGConfig(preview, dryRun, {});
225251
});
226252
return;
227253
}
@@ -247,17 +273,17 @@
247273
store.commit('loading', false);
248274
249275
} else {
276+
vc.showDryRun = dryRun;
250277
251278
if(this.editMode) {
252279
sgApi
253-
.update('sgpgconfigs', config, vc.dryRun)
280+
.update('sgpgconfigs', config, dryRun)
254281
.then(function (response) {
255-
if(vc.dryRun) {
282+
if(dryRun) {
256283
vc.showSummary = true;
257284
vc.validateDryRun(response.data);
258285
} else {
259286
vc.notify('Postgres configuration <strong>"'+config.metadata.name+'"</strong> updated successfully', 'message', 'sgpgconfigs');
260-
261287
vc.fetchAPI('sgpgconfig');
262288
router.push('/' + config.metadata.namespace + '/sgpgconfig/' + config.metadata.name);
263289
}
@@ -271,10 +297,10 @@
271297
} else {
272298
273299
sgApi
274-
.create('sgpgconfigs', config, vc.dryRun)
300+
.create('sgpgconfigs', config, dryRun)
275301
.then(function (response) {
276302
277-
if(vc.dryRun) {
303+
if(dryRun) {
278304
vc.showSummary = true;
279305
vc.validateDryRun(response.data);
280306
} else {
@@ -387,7 +413,13 @@
387413
transform: translate(20px, 15px);
388414
}
389415
416+
table.defaultParams.loading {
417+
min-height: 100px;
418+
}
419+
390420
.defaultParams.loadingContainer.loading:after {
391421
position: absolute;
422+
left: 0;
423+
width: 100%;
392424
}
393425
</style>

0 commit comments

Comments
 (0)