Allow updating replicas of service to zero

This commit is contained in:
cuigh 2017-10-16 20:24:11 +08:00
parent 42f3ad8b23
commit 260bf8313b
14 changed files with 14 additions and 14 deletions

View File

@ -1535,7 +1535,7 @@ var Swirl;
if (this.$mode.val() == "global") {
return { ok: true };
}
const regex = /^[1-9]\d*$/;
const regex = /^(0|[1-9]\d*)$/;
return { ok: regex.test($.trim($input.val())) };
}
}
@ -1712,7 +1712,7 @@ var Swirl;
new PreferenceTable("#table-preferences");
this.secret = new ConfigTable("#table-secrets");
this.config = new ConfigTable("#table-configs");
Validator.register("service-mode", new ServiceModeRule(this.$mode), "Please input a positive integer.");
Validator.register("service-mode", new ServiceModeRule(this.$mode), "Please input a valid integer.");
this.$mode.change(e => this.$replicas.toggle(this.$mode.val() != "global"));
$("#btn-add-secret").click(() => EditPage.addConfig(this.secret));
$("#btn-add-config").click(() => EditPage.addConfig(this.config));

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ namespace Swirl.Service {
return { ok: true }
}
const regex = /^[1-9]\d*$/;
const regex = /^(0|[1-9]\d*)$/;
return { ok: regex.test($.trim($input.val())) };
}
}
@ -217,7 +217,7 @@ namespace Swirl.Service {
this.config = new ConfigTable("#table-configs");
// register custom validators
Validator.register("service-mode", new ServiceModeRule(this.$mode), "Please input a positive integer.");
Validator.register("service-mode", new ServiceModeRule(this.$mode), "Please input a valid integer.");
// bind events
this.$mode.change(e => this.$replicas.toggle(this.$mode.val() != "global"))

View File

@ -13,7 +13,7 @@
</span>
</div>
<div class="control is-expanded">
<input id="txt-replicas" name="replicas" class="input" placeholder="" data-type="integer" data-v-rule="service-mode" {{if .Service.Mode == "global"}}style="display: none"{{else}}value="{{ trimZero(.Service.Replicas) }}"{{end}}>
<input id="txt-replicas" name="replicas" class="input" placeholder="" data-type="integer" data-v-rule="service-mode" {{if .Service.Mode == "global"}}style="display: none"{{else}}value="{{ .Service.Replicas }}"{{end}}>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../_modules/detail" }}
{{ block body_content() }}

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../_modules/service" }}
{{ block script() }}

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../_modules/pager" }}
{{ block script() }}

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ block body_content() }}
<div class="container">

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../_modules/service" }}
{{ block script() }}

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ block style() }}
<link rel="stylesheet" href="/highlight/highlight.css?v=9.12">

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../../_modules/service" }}
{{ block script() }}

View File

@ -1,4 +1,4 @@
{{ extends "base" }}
{{ extends "_base" }}
{{ import "../../_modules/pager" }}
{{ block script() }}