Skip to content

Commit ac1f3f7

Browse files
committed
#422753 - Code refactoring
1 parent a12e7f9 commit ac1f3f7

File tree

2 files changed

+28
-67
lines changed

2 files changed

+28
-67
lines changed

src/app/pages/assets/asset-editor-dialog/asset-editor-dialog.component.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,94 +35,94 @@
3535
<div *ngIf="storageTypeId === 'HttpData'">
3636
<mat-form-field class="form-field" color="accent">
3737
<mat-label>Name</mat-label>
38-
<input [(ngModel)]="httpDataName" matInput>
38+
<input [(ngModel)]="httpDataAddress.name" matInput>
3939
</mat-form-field>
4040

4141
<mat-form-field class="form-field" color="accent">
4242
<mat-label>Path</mat-label>
43-
<input [(ngModel)]="path" matInput>
43+
<input [(ngModel)]="httpDataAddress.path" matInput>
4444
</mat-form-field>
4545

4646
<mat-form-field class="form-field" color="accent">
4747
<mat-label>Base URL</mat-label>
48-
<input [(ngModel)]="baseUrl" matInput>
48+
<input [(ngModel)]="httpDataAddress.baseUrl" matInput>
4949
</mat-form-field>
5050

5151
<mat-form-field class="form-field" color="accent">
5252
<mat-label>Auth Key</mat-label>
53-
<input [(ngModel)]="authKey" matInput>
53+
<input [(ngModel)]="httpDataAddress.authKey" matInput>
5454
</mat-form-field>
5555

5656
<mat-form-field class="form-field" color="accent">
5757
<mat-label>Auth Code</mat-label>
58-
<input [(ngModel)]="authCode" matInput>
58+
<input [(ngModel)]="httpDataAddress.authCode" matInput>
5959
</mat-form-field>
6060

6161
<mat-form-field class="form-field" color="accent">
6262
<mat-label>Secret Name</mat-label>
63-
<input [(ngModel)]="secretName" matInput>
63+
<input [(ngModel)]="httpDataAddress.secretName" matInput>
6464
</mat-form-field>
6565

6666
<mat-form-field class="form-field" color="accent">
6767
<mat-label>Proxy Body</mat-label>
68-
<input [(ngModel)]="proxyBody" matInput>
68+
<input [(ngModel)]="httpDataAddress.proxyBody" matInput>
6969
</mat-form-field>
7070

7171
<mat-form-field class="form-field" color="accent">
7272
<mat-label>Proxy Path</mat-label>
73-
<input [(ngModel)]="proxyPath" matInput>
73+
<input [(ngModel)]="httpDataAddress.proxyPath" matInput>
7474
</mat-form-field>
7575

7676
<mat-form-field class="form-field" color="accent">
7777
<mat-label>Proxy Query Params</mat-label>
78-
<input [(ngModel)]="proxyQueryParams" matInput>
78+
<input [(ngModel)]="httpDataAddress.proxyQueryParams" matInput>
7979
</mat-form-field>
8080

8181
<mat-form-field class="form-field" color="accent">
8282
<mat-label>Proxy Method</mat-label>
83-
<input [(ngModel)]="proxyMethod" matInput>
83+
<input [(ngModel)]="httpDataAddress.roxyMethod" matInput>
8484
</mat-form-field>
8585

8686
<mat-form-field class="form-field" color="accent">
8787
<mat-label>Content Type</mat-label>
88-
<input [(ngModel)]="contentType" matInput>
88+
<input [(ngModel)]="httpDataAddress.contentType" matInput>
8989
</mat-form-field>
9090
</div>
9191

9292
<div *ngIf="storageTypeId === 'AmazonS3'">
9393
<mat-form-field class="form-field" color="accent">
9494
<mat-label>Region</mat-label>
95-
<input required [(ngModel)]="region" matInput>
95+
<input required [(ngModel)]="amazonS3DataAddress.region" matInput>
9696
</mat-form-field>
9797

9898
<mat-form-field class="form-field" color="accent">
9999
<mat-label>Bucket Name</mat-label>
100-
<input [(ngModel)]="bucketName" matInput>
100+
<input [(ngModel)]="amazonS3DataAddress.bucketName" matInput>
101101
</mat-form-field>
102102

103103
<mat-form-field class="form-field" color="accent">
104104
<mat-label>Key Prefix</mat-label>
105-
<input [(ngModel)]="keyPrefix" matInput>
105+
<input [(ngModel)]="amazonS3DataAddress.keyPrefix" matInput>
106106
</mat-form-field>
107107

108108
<mat-form-field class="form-field" color="accent">
109109
<mat-label>Folder Name</mat-label>
110-
<input [(ngModel)]="folderName" matInput>
110+
<input [(ngModel)]="amazonS3DataAddress.folderName" matInput>
111111
</mat-form-field>
112112

113113
<mat-form-field class="form-field" color="accent">
114114
<mat-label>Access Key Id</mat-label>
115-
<input [(ngModel)]="accessKeyId" matInput>
115+
<input [(ngModel)]="amazonS3DataAddress.accessKeyId" matInput>
116116
</mat-form-field>
117117

118118
<mat-form-field class="form-field" color="accent">
119119
<mat-label>Secret Access Key</mat-label>
120-
<input [(ngModel)]="secretAccessKey" matInput>
120+
<input [(ngModel)]="amazonS3DataAddress.secretAccessKey" matInput>
121121
</mat-form-field>
122122

123123
<mat-form-field class="form-field" color="accent">
124124
<mat-label>Endpoint Override</mat-label>
125-
<input [(ngModel)]="endpointOverride" matInput>
125+
<input [(ngModel)]="amazonS3DataAddress.endpointOverride" matInput>
126126
</mat-form-field>
127127
</div>
128128

src/app/pages/assets/asset-editor-dialog/asset-editor-dialog.component.ts

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,14 @@ export class AssetEditorDialog {
2020
contenttype: string = '';
2121
storageTypeId: string = '';
2222

23-
// AmazonS3 dataAddress attributes
24-
region: string = '';
25-
bucketName?: string;
26-
keyPrefix?: string;
27-
folderName?: string;
28-
accessKeyId?: string;
29-
secretAccessKey?: string;
30-
endpointOverride?: string;
23+
amazonS3DataAddress: AmazonS3DataAddress = {
24+
type: 'AmazonS3',
25+
region: ''
26+
};
3127

32-
// HttpData dataAddress attributes
33-
httpDataName?: string;
34-
path?: string;
35-
method?: string;
36-
baseUrl?: string;
37-
authKey?: string;
38-
authCode?: string;
39-
secretName?: string;
40-
proxyBody?: string;
41-
proxyPath?: string;
42-
proxyQueryParams?: string;
43-
proxyMethod?: string;
44-
contentType?: string;
28+
httpDataAddress: HttpDataAddress = {
29+
type: 'HttpData'
30+
};
4531

4632

4733
constructor(private dialogRef: MatDialogRef<AssetEditorDialog>,
@@ -58,34 +44,9 @@ export class AssetEditorDialog {
5844
let dataAddress: DataAddress;
5945

6046
if (this.storageTypeId === DATA_ADDRESS_TYPES.amazonS3) {
61-
const amazonS3DataAddress: AmazonS3DataAddress = {
62-
type: 'AmazonS3',
63-
region: this.region,
64-
bucketName: this.bucketName,
65-
keyPrefix: this.keyPrefix,
66-
folderName: this.folderName,
67-
accessKeyId: this.accessKeyId,
68-
secretAccessKey: this.secretAccessKey,
69-
endpointOverride: this.endpointOverride
70-
};
71-
dataAddress = amazonS3DataAddress;
47+
dataAddress = this.amazonS3DataAddress;
7248
} else if (this.storageTypeId === DATA_ADDRESS_TYPES.httpData) {
73-
const httpDataAddress: HttpDataAddress = {
74-
type: 'HttpData',
75-
name: this.httpDataName,
76-
path: this.path,
77-
method: this.method,
78-
baseUrl: this.baseUrl,
79-
authKey: this.authKey,
80-
authCode: this.authCode,
81-
secretName: this.secretName,
82-
proxyBody: this.proxyBody,
83-
proxyPath: this.proxyPath,
84-
proxyQueryParams: this.proxyQueryParams,
85-
proxyMethod: this.proxyMethod,
86-
contentType: this.contentType,
87-
};
88-
dataAddress = httpDataAddress;
49+
dataAddress = this.httpDataAddress;
8950
} else {
9051
this.notificationService.showError("Incorrect destination value");
9152
return;
@@ -113,7 +74,7 @@ export class AssetEditorDialog {
11374
if (!this.id || !this.storageTypeId){
11475
return false;
11576
} else {
116-
if (this.storageTypeId === DATA_ADDRESS_TYPES.amazonS3 && !this.region) {
77+
if (this.storageTypeId === DATA_ADDRESS_TYPES.amazonS3 && !this.amazonS3DataAddress.region) {
11778
return false;
11879
} else {
11980
return true;

0 commit comments

Comments
 (0)