Skip to content

Commit fcac4d6

Browse files
committed
fix(import-rule): improve code readability and formatting
1 parent d427e1f commit fcac4d6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

frontend/src/app/rule-management/app-rule/components/import-rules/import-rule.component.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import {Component, OnDestroy, OnInit} from '@angular/core';
33
import {FormBuilder, FormGroup} from '@angular/forms';
44
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap';
55
import {forkJoin, from, of} from 'rxjs';
6-
import {catchError, concatMap, map, tap, toArray, finalize} from 'rxjs/operators';
6+
import {catchError, concatMap, finalize, map, tap, toArray} from 'rxjs/operators';
77
import {UtmToastService} from '../../../../shared/alert/utm-toast.service';
88
import {AddRuleStepEnum, Mode, Rule, Status} from '../../../models/rule.model';
99
import {DataTypeService} from '../../../services/data-type.service';
1010
import {RuleService} from '../../../services/rule.service';
1111
import {ImportRuleService} from './import-rule.service';
1212

1313

14-
type RuleList = {
15-
rule:Rule;
14+
interface RuleList {
15+
rule: Rule;
1616
valid: boolean;
1717
status: Status;
18-
errors:Record<string; string[]>;
19-
isLoading:boolean;
18+
errors: Record<string, string[]>;
19+
isLoading: boolean;
2020
}
2121

2222
@Component({
@@ -116,7 +116,7 @@ export class ImportRuleComponent implements OnInit, OnDestroy {
116116

117117
validRules() {
118118
if (this.files.length > 0) {
119-
this.loading = true
119+
this.loading = true;
120120
const filesWithDataTypes = this.files.map(file => {
121121
return {
122122
...file,
@@ -151,26 +151,26 @@ export class ImportRuleComponent implements OnInit, OnDestroy {
151151
}))
152152
),
153153
),
154-
).pipe(finalize(()=>(this.loading = false))).subscribe(updatedFiles => {
154+
).pipe(finalize(() => (this.loading = false))).subscribe(updatedFiles => {
155155
this.rules = updatedFiles.map(file => {
156-
let rule:Rule = {
156+
let rule: Rule = {
157157
...file,
158158
dataTypes: file.dataTypes.length > 0 ? file.dataTypes : [],
159159
};
160-
const {isValid,errors} = this.importRuleService.isValidRule(rule);
160+
const {isValid, errors} = this.importRuleService.isValidRule(rule);
161161

162-
//move null fields (required and not sended) upper than others
163-
Object.keys(rule).forEach(key=>{
164-
if(rule[key]===null){
165-
rule={[key]:null,...rule};
162+
// move null fields (required and not sended) upper than others
163+
Object.keys(rule).forEach(key => {
164+
if (rule[key] === null) {
165+
rule = {[key]: null, ...rule};
166166
}
167-
})
167+
});
168168

169169
return {
170170
rule,
171171
valid: isValid,
172172
status: isValid ? ('valid' as Status) : ('error' as Status),
173-
isLoading:false,
173+
isLoading: false,
174174
errors
175175
};
176176

0 commit comments

Comments
 (0)