From 36a5993539b83ee7057ea297c430c14dc30530eb Mon Sep 17 00:00:00 2001 From: ikaluo Date: Fri, 11 Oct 2024 11:45:57 +0800 Subject: [PATCH 1/2] fix: add filters and fixed typo --- .../admin42/serializers/runtimes.py | 4 +- .../platformmgr/runtimes/buildpacks.html | 48 +++++++++++--- .../platformmgr/runtimes/slugbuilders.html | 62 ++++++++++++++++--- .../platformmgr/runtimes/slugrunners.html | 56 ++++++++++++++--- 4 files changed, 144 insertions(+), 26 deletions(-) diff --git a/apiserver/paasng/paasng/plat_admin/admin42/serializers/runtimes.py b/apiserver/paasng/paasng/plat_admin/admin42/serializers/runtimes.py index 19d0efa7af..4e80c359aa 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/serializers/runtimes.py +++ b/apiserver/paasng/paasng/plat_admin/admin42/serializers/runtimes.py @@ -187,13 +187,13 @@ class Meta: exclude = ["modules", "id", "created", "updated", "environments"] def validate_name(self, name: str) -> str: - if AppSlugBuilder.objects.filter(name=name).exists(): + if AppSlugRunner.objects.filter(name=name).exists(): raise serializers.ValidationError("name already exists") return name class AppSlugRunnerUpdateInputSLZ(AppSlugRunnerCreateInputSLZ): def validate_name(self, name: str) -> str: - if AppSlugBuilder.objects.exclude(id=self.instance.id).filter(name=name).exists(): + if AppSlugRunner.objects.exclude(id=self.instance.id).filter(name=name).exists(): raise serializers.ValidationError("name already exists") return name diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html index e3e35c728b..5aa74d0f9e 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html @@ -100,7 +100,7 @@ $[ props.row.version ] - + @@ -416,6 +416,16 @@ size: 'medium' }, typeFilters: typeFilters, + isHiddenFilters: [ + { + text: '是', + value: false, + }, + { + text: '否', + value: true, + } + ], } }, methods: { @@ -428,10 +438,6 @@ } await this.$http.get(url).then(res => { this.data = res; - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({"key": regions[i], "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})`}); - } }); } catch (e) { if (e.response.status === 400) { @@ -480,6 +486,9 @@ } if (success) { this.cancelDialog(); + if (this.dialog.type === 'create') { + this.modifyRegionCount(this.dialog.form.region, 1); + } await this.fetchBuildPackList(); } }, @@ -534,6 +543,7 @@ const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); + this.modifyRegionCount(row.region, -1); const index = this.data.findIndex(item => item.id === row.id); if (index !== -1) { this.data.splice(index, 1); @@ -674,6 +684,19 @@ this.curRegionActive = region; this.fetchBuildPackList(); }, + modifyRegionCount: function (region, delta) { + // 更新当前 region 数量 + let text = this.regionList.find(item => item.key === region).text; + // 找到字符串中的数字并修改 + let newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === region).text = text; + // 更新全部数量 + text = this.regionList.find(item => item.key === "all").text; + newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === "all").text = text; + }, handleSettingChange ({ fields, size }) { this.setting.size = size; this.setting.selectedFields = fields; @@ -683,8 +706,15 @@ return row[property] === value } }, - mounted: function () { - this.fetchBuildPackList(); + mounted: async function () { + await this.fetchBuildPackList(); + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } }, }) }) @@ -851,5 +881,9 @@ border-radius: 2px; background-color: #e6e9ea; } + + .bk-checkbox-text { + font-weight: normal; + } {% endblock %} diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html index 3afe9c0ddf..ad77fc8a37 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html @@ -66,7 +66,7 @@ - + - + - + @@ -487,6 +487,26 @@ size: 'medium' }, typeFilters: typeFilters, + isHiddenFilters: [ + { + text: '是', + value: false, + }, + { + text: '否', + value: true, + } + ], + isDefaultFilters: [ + { + text: '是', + value: true, + }, + { + text: '否', + value: false, + }, + ], } }, methods: { @@ -499,10 +519,6 @@ } await this.$http.get(url).then(res => { this.data = res; - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({"key": regions[i], "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})`}); - } }) } catch (e) { if (e.response.status === 400) { @@ -554,6 +570,9 @@ } if (success) { this.cancelDialog(); + if (this.dialog.type === 'create') { + this.modifyRegionCount(this.dialog.form.region, 1); + } await this.fetchSlugBuilderList(); } }, @@ -610,6 +629,7 @@ const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); + this.modifyRegionCount(row.region, -1); const index = this.data.findIndex(item => item.id === row.id); if (index !== -1) { this.data.splice(index, 1); @@ -750,6 +770,19 @@ this.curRegionActive = region; this.fetchSlugBuilderList(); }, + modifyRegionCount: function (region, delta) { + // 更新当前 region 数量 + let text = this.regionList.find(item => item.key === region).text; + // 找到字符串中的数字并修改 + let newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === region).text = text; + // 更新全部数量 + text = this.regionList.find(item => item.key === "all").text; + newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === "all").text = text; + }, handleSettingChange ({ fields, size }) { this.setting.size = size; this.setting.selectedFields = fields; @@ -759,8 +792,15 @@ return row[property] === value } }, - mounted: function () { - this.fetchSlugBuilderList(); + mounted: async function () { + await this.fetchSlugBuilderList(); + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } }, }) }) @@ -928,6 +968,10 @@ background-color: #e6e9ea; } + .bk-checkbox-text { + font-weight: normal; + } + .empty-text { font-size: 14px; } diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html index 057e5504cb..ef9b8500e4 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html @@ -57,12 +57,12 @@ $[ props.row.image + ':' + props.row.tag ] - + - + @@ -372,6 +372,26 @@ size: 'medium' }, typeFilters: typeFilters, + isHiddenFilters: [ + { + text: '是', + value: false, + }, + { + text: '否', + value: true, + } + ], + isDefaultFilters: [ + { + text: '是', + value: true, + }, + { + text: '否', + value: false, + }, + ], } }, methods: { @@ -384,10 +404,6 @@ } await this.$http.get(url).then(res => { this.data = res; - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({"key": regions[i], "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})`}); - } }) } catch (e) { if (e.response.status === 400) { @@ -438,6 +454,9 @@ } if (success) { this.cancelDialog(); + if (this.dialog.type === 'create') { + this.modifyRegionCount(this.dialog.form.region, 1); + } await this.fetchSlugrunnerList(); } }, @@ -494,6 +513,7 @@ const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); + this.modifyRegionCount(row.region, -1); const index = this.data.findIndex(item => item.id === row.id); if (index !== -1) { this.data.splice(index, 1); @@ -570,6 +590,19 @@ this.curRegionActive = region; this.fetchSlugBuilderList(); }, + modifyRegionCount: function (region, delta) { + // 更新当前 region 数量 + let text = this.regionList.find(item => item.key === region).text; + // 找到字符串中的数字并修改 + let newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === region).text = text; + // 更新全部数量 + text = this.regionList.find(item => item.key === "all").text; + newCount = parseInt(text.match(/\d+/)[0]) + delta; + text = text.replace(/\d+/, newCount); + this.regionList.find(item => item.key === "all").text = text; + }, handleSettingChange ({ fields, size }) { this.setting.size = size; this.setting.selectedFields = fields; @@ -579,8 +612,15 @@ return row[property] === value } }, - mounted: function () { - this.fetchSlugrunnerList(); + mounted: async function () { + await this.fetchSlugrunnerList(); + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } }, }) }) From 6b17e4fb0d4f24d42a5d512f279ef026bcd6b7ec Mon Sep 17 00:00:00 2001 From: ikaluo Date: Fri, 11 Oct 2024 14:33:14 +0800 Subject: [PATCH 2/2] fix: fixed --- .../platformmgr/runtimes/buildpacks.html | 41 +++++------------- .../platformmgr/runtimes/slugbuilders.html | 41 +++++------------- .../platformmgr/runtimes/slugrunners.html | 43 ++++++------------- 3 files changed, 34 insertions(+), 91 deletions(-) diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html index 5aa74d0f9e..c1555679a3 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/buildpacks.html @@ -439,6 +439,15 @@ await this.$http.get(url).then(res => { this.data = res; }); + if (this.curRegionActive === 'all') { + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } + } } catch (e) { if (e.response.status === 400) { this.$bkMessage({ @@ -486,10 +495,7 @@ } if (success) { this.cancelDialog(); - if (this.dialog.type === 'create') { - this.modifyRegionCount(this.dialog.form.region, 1); - } - await this.fetchBuildPackList(); + this.switchRegion("all"); } }, handleCreate: function () { @@ -542,12 +548,7 @@ deleteRow: async function (row) { const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); - - this.modifyRegionCount(row.region, -1); - const index = this.data.findIndex(item => item.id === row.id); - if (index !== -1) { - this.data.splice(index, 1); - } + this.switchRegion("all"); }, handleBind: async function (row) { try { @@ -684,19 +685,6 @@ this.curRegionActive = region; this.fetchBuildPackList(); }, - modifyRegionCount: function (region, delta) { - // 更新当前 region 数量 - let text = this.regionList.find(item => item.key === region).text; - // 找到字符串中的数字并修改 - let newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === region).text = text; - // 更新全部数量 - text = this.regionList.find(item => item.key === "all").text; - newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === "all").text = text; - }, handleSettingChange ({ fields, size }) { this.setting.size = size; this.setting.selectedFields = fields; @@ -708,13 +696,6 @@ }, mounted: async function () { await this.fetchBuildPackList(); - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({ - "key": regions[i], - "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` - }); - } }, }) }) diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html index ad77fc8a37..db62b6f1f6 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugbuilders.html @@ -520,6 +520,15 @@ await this.$http.get(url).then(res => { this.data = res; }) + if (this.curRegionActive === 'all') { + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } + } } catch (e) { if (e.response.status === 400) { this.$bkMessage({ @@ -570,10 +579,7 @@ } if (success) { this.cancelDialog(); - if (this.dialog.type === 'create') { - this.modifyRegionCount(this.dialog.form.region, 1); - } - await this.fetchSlugBuilderList(); + this.switchRegion("all"); } }, handleCreate: function () { @@ -628,12 +634,7 @@ deleteRow: async function (row) { const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); - - this.modifyRegionCount(row.region, -1); - const index = this.data.findIndex(item => item.id === row.id); - if (index !== -1) { - this.data.splice(index, 1); - } + this.switchRegion("all"); }, handleBind: async function (row) { try { @@ -770,19 +771,6 @@ this.curRegionActive = region; this.fetchSlugBuilderList(); }, - modifyRegionCount: function (region, delta) { - // 更新当前 region 数量 - let text = this.regionList.find(item => item.key === region).text; - // 找到字符串中的数字并修改 - let newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === region).text = text; - // 更新全部数量 - text = this.regionList.find(item => item.key === "all").text; - newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === "all").text = text; - }, handleSettingChange ({ fields, size }) { this.setting.size = size; this.setting.selectedFields = fields; @@ -794,13 +782,6 @@ }, mounted: async function () { await this.fetchSlugBuilderList(); - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({ - "key": regions[i], - "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` - }); - } }, }) }) diff --git a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html index ef9b8500e4..bcbf02538b 100644 --- a/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html +++ b/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/platformmgr/runtimes/slugrunners.html @@ -405,6 +405,15 @@ await this.$http.get(url).then(res => { this.data = res; }) + if (this.curRegionActive === 'all') { + this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; + for (let i = 0; i < regions.length; i++) { + this.regionList.push({ + "key": regions[i], + "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` + }); + } + } } catch (e) { if (e.response.status === 400) { this.$bkMessage({ @@ -454,10 +463,7 @@ } if (success) { this.cancelDialog(); - if (this.dialog.type === 'create') { - this.modifyRegionCount(this.dialog.form.region, 1); - } - await this.fetchSlugrunnerList(); + this.switchRegion("all"); } }, handleCreate: function () { @@ -512,12 +518,7 @@ deleteRow: async function (row) { const url = this.fillUrlTemplate(URLRouter.detail, {row}); await this.$http.delete(url); - - this.modifyRegionCount(row.region, -1); - const index = this.data.findIndex(item => item.id === row.id); - if (index !== -1) { - this.data.splice(index, 1); - } + this.switchRegion("all"); }, fillUrlTemplate: function (url_template, {row}) { if (!row) { @@ -588,20 +589,7 @@ switchRegion: function(region) { this.expandRowKeys = []; this.curRegionActive = region; - this.fetchSlugBuilderList(); - }, - modifyRegionCount: function (region, delta) { - // 更新当前 region 数量 - let text = this.regionList.find(item => item.key === region).text; - // 找到字符串中的数字并修改 - let newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === region).text = text; - // 更新全部数量 - text = this.regionList.find(item => item.key === "all").text; - newCount = parseInt(text.match(/\d+/)[0]) + delta; - text = text.replace(/\d+/, newCount); - this.regionList.find(item => item.key === "all").text = text; + this.fetchSlugrunnerList(); }, handleSettingChange ({ fields, size }) { this.setting.size = size; @@ -614,13 +602,6 @@ }, mounted: async function () { await this.fetchSlugrunnerList(); - this.regionList = [{"key": "all", "text": `全部 (${this.data.length})`}]; - for (let i = 0; i < regions.length; i++) { - this.regionList.push({ - "key": regions[i], - "text": `${regions[i]} (${this.data.filter(item => item.region === regions[i]).length})` - }); - } }, }) })