Skip to content

Commit

Permalink
fix: Env name is not allowed to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Feb 22, 2022
1 parent e454527 commit 66c9ef4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/app/pages/env/env.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ export class EnvComponent implements OnInit, OnDestroy {

handleSaveEnv() {
// * update list after call save api
const { parameters, ...other } = this.envInfo;
const { parameters, name, ...other } = this.envInfo;
if (!name) {
this.message.error('Name is not allowed to be empty.');
return;
}
const data = parameters.filter((it) => it.name && it.value);
this.envService.create({ ...other, parameters: data }).subscribe((result: Environment) => {
this.envService.create({ ...other, name, parameters: data }).subscribe((result: Environment) => {
this.envInfo = result;
this.activeUuid = Number(result.uuid);
this.handleSwitchEnv(result.uuid);
Expand All @@ -116,9 +120,13 @@ export class EnvComponent implements OnInit, OnDestroy {

handleUpdateEnv(uuid: string | number) {
// * update env
const { parameters, ...other } = this.envInfo;
const { parameters, name, ...other } = this.envInfo;
if (!name) {
this.message.error('Name is not allowed to be empty.');
return;
}
const data = parameters.filter((it) => it.name && it.value);
this.envService.update({ ...other, parameters: data }, uuid).subscribe((result: Environment) => {
this.envService.update({ ...other, name, parameters: data }, uuid).subscribe((result: Environment) => {
this.message.success('Save suceess');
this.getAllEnv();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class ParamsImportComponent {
if (this.contentType === 'json') {
try {
paramCode = JSON.parse(this.paramCode);
console.log('lll', paramCode);
} catch (error) {
this.message.error('JSON格式不合法');
return;
Expand Down Expand Up @@ -86,7 +85,6 @@ export class ParamsImportComponent {
console.warn('The code that you input is no-equal to the root type.');
}
// if (whatType(paramCode) === 'object') {
// console.log('kk', paramCode);
// * transform to array of table format.
// }
if (this.rootType === 'array' && whatType(paramCode) === 'array') {
Expand All @@ -96,6 +94,7 @@ export class ParamsImportComponent {
}
// * tree to array for table render
const cacheData = flatData(Object.keys(paramCode).map((it) => parseTree(it, paramCode[it])));

// TODO delete useless attribute in cacheData
switch (type) {
case 'mixin': {
Expand Down
1 change: 0 additions & 1 deletion src/app/utils/data-transfer/data-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ interface uiData {
}
export const xml2UiData = (text) => {
const data: any[] = xml2json(text);
console.log('=>', data);
const result = {};
const mapAttr = (obj: any) => {
const { tagName, attr, children, content } = obj;
Expand Down

0 comments on commit 66c9ef4

Please sign in to comment.