|
29 | 29 | v-model="pgConfigVersion" |
30 | 30 | :disabled="(editMode)" |
31 | 31 | required data-field="spec.postgresVersion" |
32 | | - @change="loadingDefaults = true; dryRun = true; createPGConfig();" |
| 32 | + @change="getDefaultParams()" |
33 | 33 | > |
34 | 34 | <option disabled value="">Select Major Postgres Version</option> |
35 | 35 | <option v-for="version in postgresVersions">{{ version }}</option> |
|
50 | 50 | </div> |
51 | 51 | </div> |
52 | 52 |
|
53 | | - <template v-if="Object.keys(defaultParams).length"> |
| 53 | + <template v-if="Object.keys(defaultParams).length || loadingDefaults"> |
54 | 54 | <div class="paramDetails"> |
55 | 55 | <hr/> |
56 | 56 | <h2>Default Parameters</h2><br/> |
|
94 | 94 | type="button" |
95 | 95 | class="btn border floatRight" |
96 | 96 | 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)" |
101 | 98 | > |
102 | 99 | Dry Run |
103 | 100 | </button> |
104 | 101 | </form> |
105 | 102 | <CRDSummary |
106 | 103 | v-if="showSummary" |
107 | 104 | :crd="previewConfig" |
108 | | - :dryRun="dryRun" |
| 105 | + :dryRun="showDryRun" |
109 | 106 | kind="SGPostgresConfig" |
110 | 107 | @closeSummary=" |
111 | 108 | showSummary = false; |
112 | | - dryRun = false; |
| 109 | + showDryRun = false; |
113 | 110 | previewConfig = {}; |
114 | 111 | " |
115 | 112 | ></CRDSummary> |
|
139 | 136 | return { |
140 | 137 | editMode: (vm.$route.name === 'EditPgConfig'), |
141 | 138 | editReady: false, |
142 | | - dryRun: false, |
143 | 139 | previewConfig: {}, |
144 | 140 | showSummary: false, |
| 141 | + showDryRun: false, |
145 | 142 | pgConfigName: vm.$route.params.hasOwnProperty('name') ? vm.$route.params.name : '', |
146 | 143 | pgConfigNamespace: vm.$route.params.hasOwnProperty('namespace') ? vm.$route.params.namespace : '', |
147 | 144 | pgConfigParams: '', |
|
200 | 197 | }, |
201 | 198 | methods: { |
202 | 199 |
|
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) { |
204 | 230 | const vc = this; |
205 | 231 |
|
206 | 232 | if (!vc.loadingDefaults && !vc.checkRequired()) { |
|
213 | 239 | sgApi |
214 | 240 | .getResourceDetails('sgpgconfigs', this.pgConfigNamespace, this.pgConfigName) |
215 | 241 | .then(function (response) { |
216 | | - vc.createPGConfig(preview, response.data); |
| 242 | + vc.createPGConfig(preview, dryRun, response.data); |
217 | 243 | }) |
218 | 244 | .catch(function (error) { |
219 | 245 | if (error.response.status != 404) { |
220 | 246 | console.log(error.response); |
221 | 247 | vc.notify(error.response.data,'error', 'sgpgconfigs'); |
222 | 248 | return; |
223 | 249 | } |
224 | | - vc.createPGConfig(preview, {}); |
| 250 | + vc.createPGConfig(preview, dryRun, {}); |
225 | 251 | }); |
226 | 252 | return; |
227 | 253 | } |
|
247 | 273 | store.commit('loading', false); |
248 | 274 |
|
249 | 275 | } else { |
| 276 | + vc.showDryRun = dryRun; |
250 | 277 |
|
251 | 278 | if(this.editMode) { |
252 | 279 | sgApi |
253 | | - .update('sgpgconfigs', config, vc.dryRun) |
| 280 | + .update('sgpgconfigs', config, dryRun) |
254 | 281 | .then(function (response) { |
255 | | - if(vc.dryRun) { |
| 282 | + if(dryRun) { |
256 | 283 | vc.showSummary = true; |
257 | 284 | vc.validateDryRun(response.data); |
258 | 285 | } else { |
259 | 286 | vc.notify('Postgres configuration <strong>"'+config.metadata.name+'"</strong> updated successfully', 'message', 'sgpgconfigs'); |
260 | | -
|
261 | 287 | vc.fetchAPI('sgpgconfig'); |
262 | 288 | router.push('/' + config.metadata.namespace + '/sgpgconfig/' + config.metadata.name); |
263 | 289 | } |
|
271 | 297 | } else { |
272 | 298 |
|
273 | 299 | sgApi |
274 | | - .create('sgpgconfigs', config, vc.dryRun) |
| 300 | + .create('sgpgconfigs', config, dryRun) |
275 | 301 | .then(function (response) { |
276 | 302 |
|
277 | | - if(vc.dryRun) { |
| 303 | + if(dryRun) { |
278 | 304 | vc.showSummary = true; |
279 | 305 | vc.validateDryRun(response.data); |
280 | 306 | } else { |
|
387 | 413 | transform: translate(20px, 15px); |
388 | 414 | } |
389 | 415 |
|
| 416 | + table.defaultParams.loading { |
| 417 | + min-height: 100px; |
| 418 | + } |
| 419 | +
|
390 | 420 | .defaultParams.loadingContainer.loading:after { |
391 | 421 | position: absolute; |
| 422 | + left: 0; |
| 423 | + width: 100%; |
392 | 424 | } |
393 | 425 | </style> |
0 commit comments