|
301 | 301 | </div> |
302 | 302 | </div> |
303 | 303 |
|
| 304 | + <el-divider /> |
| 305 | + |
| 306 | + <!-- min replica --> |
| 307 | + <div class="flex xl:flex-col gap-8"> |
| 308 | + <div class="w-[380px] sm:w-full flex flex-col"> |
| 309 | + <div class="text-sm text-gray-700 leading-5 font-medium"> |
| 310 | + {{ $t('endpoints.settings.minReplica') }} |
| 311 | + </div> |
| 312 | + </div> |
| 313 | + <div class="flex flex-col gap-1.5"> |
| 314 | + <p class="text-gray-700 text-sm"> |
| 315 | + {{ $t('endpoints.settings.currentMinReplica') }} |
| 316 | + </p> |
| 317 | + <el-select |
| 318 | + v-model="theMinReplica" |
| 319 | + :placeholder="$t('all.select')" |
| 320 | + size="large" |
| 321 | + class="!w-[512px] sm:!w-full" |
| 322 | + :disabled="!isSpaceStopped" |
| 323 | + > |
| 324 | + <el-option |
| 325 | + :key="0" |
| 326 | + :label="0" |
| 327 | + :value="0" |
| 328 | + /> |
| 329 | + <el-option |
| 330 | + :key="1" |
| 331 | + :label="1" |
| 332 | + :value="1" |
| 333 | + /> |
| 334 | + </el-select> |
| 335 | + <CsgButton |
| 336 | + v-if="hasMinReplicaChanged" |
| 337 | + @click="updateMinReplica" |
| 338 | + class="btn btn-secondary-gray btn-sm w-fit" |
| 339 | + :name="$t('all.update')" |
| 340 | + :disabled="!isSpaceStopped" |
| 341 | + /> |
| 342 | + </div> |
| 343 | + </div> |
| 344 | + |
304 | 345 | <!-- docker space variables --> |
305 | 346 | <el-divider v-if="theVariables && Object.keys(theVariables).length > 0"/> |
306 | 347 | <div v-if="theVariables && Object.keys(theVariables).length > 0"> |
|
541 | 582 | cloudResource: String, |
542 | 583 | coverImage: String, |
543 | 584 | variables: Object, |
544 | | - tags: { type: Object, default: () => ({}) } |
| 585 | + tags: { type: Object, default: () => ({}) }, |
| 586 | + minReplica: Number |
545 | 587 | }, |
546 | 588 |
|
547 | 589 | components: { ApplicationSpaceEnvEditor }, |
|
555 | 597 | theVariables: this.variables || {}, |
556 | 598 | theClusterId: this.clusterId || '', |
557 | 599 | theCloudResource: this.cloudResource != null ? String(this.cloudResource) : '', |
| 600 | + theMinReplica: this.minReplica != null ? this.minReplica : 0, |
558 | 601 | originalApplicationSpaceNickname: this.applicationSpaceNickname || '', |
559 | 602 | originalApplicationSpaceDesc: this.applicationSpaceDesc || '', |
560 | 603 | originalVariables: JSON.stringify(this.variables || {}), |
561 | 604 | originalClusterId: this.clusterId || '', |
562 | 605 | originalCloudResource: this.cloudResource != null ? String(this.cloudResource) : '', |
| 606 | + originalMinReplica: this.minReplica != null ? this.minReplica : 0, |
563 | 607 | options: [ |
564 | 608 | { value: 'Private', label: this.$t('all.private') }, |
565 | 609 | { value: 'Public', label: this.$t('all.public') } |
|
656 | 700 | const originalTagIds = this.originalTags.map(tag => tag.uid).sort() |
657 | 701 | const currentTagIds = this.selectedTags.map(tag => tag.uid).sort() |
658 | 702 | return JSON.stringify(originalTagIds) !== JSON.stringify(currentTagIds) |
| 703 | + }, |
| 704 | + hasMinReplicaChanged() { |
| 705 | + return this.theMinReplica !== this.originalMinReplica |
659 | 706 | } |
660 | 707 | }, |
661 | 708 |
|
|
1103 | 1150 | this.updateApplicationSpace(payload,this.$t('application_spaces.edit.spaceVariables')) |
1104 | 1151 | }, |
1105 | 1152 |
|
| 1153 | + updateMinReplica() { |
| 1154 | + const payload = { min_replica: this.theMinReplica } |
| 1155 | + this.updateApplicationSpace(payload, this.$t('endpoints.settings.minReplica')) |
| 1156 | + }, |
| 1157 | +
|
1106 | 1158 | async updateApplicationSpace(payload,field) { |
1107 | 1159 | const applicationSpaceUpdateEndpoint = `/spaces/${this.path}` |
1108 | 1160 | const options = { |
|
1168 | 1220 | } |
1169 | 1221 | }, |
1170 | 1222 | immediate: true |
| 1223 | + }, |
| 1224 | + minReplica: { |
| 1225 | + handler(newVal) { |
| 1226 | + if (newVal != null) { |
| 1227 | + this.theMinReplica = newVal |
| 1228 | + if (this.originalMinReplica === (this.minReplica != null ? this.minReplica : 0)) { |
| 1229 | + this.originalMinReplica = newVal |
| 1230 | + } |
| 1231 | + } |
| 1232 | + }, |
| 1233 | + immediate: true |
1171 | 1234 | } |
1172 | 1235 | } |
1173 | 1236 | } |
|
0 commit comments