summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html
blob: de97a46793e5c60bedb2aa2039c8fdee56a85d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<div class="row template-mapping-action">
    <div class="col">
        <h6 [hidden]="edit" class="create-title">Create Template</h6>
        <button (click)="openListView()" [hidden]="!edit" class="btn btn-outline-secondary"><i
                class="fa fa-chevron-left mr-2"></i>Template List</button>
    </div>
    <div class="col text-right">
        <button (click)="cancel()" [hidden]="!templatesExist || edit" class="btn btn-outline-danger"
            title="Delete Template">Cancel</button>
        <button data-toggle="modal" [hidden]="!edit" data-target="#templateDeletionModal2"
            class="btn btn-outline-danger" title="Delete Template">Delete</button>
        <button (click)="clear()" [hidden]="fileName?.length <=0 || edit"
            class="btn btn-outline-secondary">Clear</button>
        <button tourAnchor="tm-templateFinish" (click)="saveToStore()" [disabled]="fileName?.length <=0"
            title="Submit template and close" class="btn btn-primary">Finish</button>
    </div>
</div>
<div class="card creat-card">
    <div class="single-line-model">
        <label class="label-name">Name
            <span _ngcontent-uew-c3="">*</span>
        </label>

        <div class="label-input">
            <input tourAnchor="tm-templateName" type="input" [disabled]="edit" [(ngModel)]="fileName"
                placeholder="Template name" name="templateName" autofocus [autofocus]="true">
        </div>
    </div>
</div>

<div class="template-mapping-accordion">
    <div class="accordion" id="accordion">
        <div class="card">
            <div class="card-header" id="headingOne">
                <h5 class="mb-0 d-flex justify-content-between">
                    <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" id="templateTab"
                        aria-expanded="true" aria-controls="collapseOne">
                        1. Template <span class="accordian-title">{{currentTemplate?.fileName?.split('/')[1]}}</span>
                    </button>

                </h5>
            </div>

            <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
                <div class="card-body">
                    <div tourAnchor="tm-templateType" class="single-line">
                        <label class="label-name">Template Type</label>
                        <div class="label-input">
                            <label name="trst" (click)="allowedExt=['.vtl'];templateExt='vtl'">
                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
                                    name="exampleRadios" id="exampleRadios1" value=vtl>
                                <span>
                                    Velocity
                                </span>
                            </label>
                            <label name="trst" (click)="allowedExt=['.j2','.jinja2'];templateExt='j2'">
                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
                                    name="exampleRadios" id="exampleRadios1" value=j2>

                                <span>
                                    Jinja
                                </span>
                            </label>
                            <label tourAnchor="tm-templateContent" name="trst"
                                (click)="allowedExt=['.kt'];templateExt='kt'">
                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
                                    name="exampleRadios" id="exampleRadios1" value=kt>

                                <span>
                                    Kotlin
                                </span>
                            </label>
                        </div>
                    </div>
                    <div class="create-template-import">Use the editor to add parameters or you can also
                        <a href="#" data-toggle="modal" (click)="allowedExt=['.'+templateExt]"
                            data-target="#templateModal"><b>Import
                                File</b></a>. <br /> <span class="templateNote"><i class="icon-info"
                                aria-hidden="true"></i> When you import new file, the new attributes will replace
                            current attributes.</span></div>
                    <div class="editor-container mb-4">
                        <app-source-editor [lang]="'velocity'" (textChange)="textChanges($event,templateInfo.fileName)"
                            [(text)]="templateFileContent">
                        </app-source-editor>
                    </div>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header" id="headingTwo">
                <h5 class="mb-0">
                    <button tourAnchor="tm-mappingContent" class="btn btn-link collapsed" id="mappingTab"
                        data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false"
                        aria-controls="collapseTwo">
                        2. Manage Mapping <span
                            class="accordian-title">{{currentMapping?.fileName?.split('/')[1]}}</span>
                    </button>
                </h5>
            </div>
            <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
                <div class="card-body">
                    <p class="text-center"><b>Select a source to load config parameters</b></p>
                    <div class="text-center">
                        <button [disabled]="!(templateFileContent?.trim()?.length > 0)"
                            (click)="getMappingTableFromTemplate($event)" class="mapping-source-load" [ngClass]="templateFileContent?.trim()?.length > 0
                            ?'hover-enable':'hover-disable'">
                            <i class="icon-use-attributes"></i>
                            <br />
                            <span>Use Current Template Instance</span>
                        </button>
                        <a href="#" (click)="allowedExt=['.csv','.xml']" data-toggle="modal"
                            data-target="#templateModal" class="mapping-source-load">
                            <i class="icon-upload-attributes"></i>
                            <br />
                            <div>Upload Attributes List</div>
                            <div class="source-load-note">CSV or XML files</div>
                        </a>
                        <!-- <a href="#" class="mapping-source-load">
                            <i class="icon-import-cds"></i>
                        <br/>
                            <span>Import from SDC Model</span>
                        </a> -->
                    </div>

                    <div class="table-container">


                    </div>

                </div>

                <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mapping-table mx-4 my-2">
                    <div class="btn-group mapping-editBar" role="group">
                        <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
                            <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
                                id="customCheck1"
                                [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
                            <label class="custom-control-label" for="customCheck1"></label>
                        </div>
                        <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
                            tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
                        <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="removeProps()"
                            tooltip="Remove" placement="bottom"><i class="icon-delete-sm"></i></button>
                        <div style="line-height: 35px;font-size: 10px;">
                            <span>{{selectedProps.size}} selected </span>
                            <span>({{resourceDictionaryRes.length}} attributes in total)</span>
                        </div>
                    </div>
                    <table datatable [dtOptions]="initDtOptions" [dtTrigger]="dtTrigger" class="row-border hover">
                        <thead>
                            <tr>
                                <th></th>
                                <th>Required</th>
                                <th>Template Input</th>
                                <th>Parameter Name</th>
                                <th>Dictionary Name</th>
                                <th>Dictionary Source</th>
                                <th>Dependancies</th>
                                <th>Default</th>
                                <th>Velocity</th>
                                <th>Data Type</th>
                                <th>Entry Schema</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr *ngFor="let dict of resourceDictionaryRes;let i=index;trackBy: identify">
                                <td>
                                    <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
                                        <input type="checkbox" class="custom-control-input"
                                            id="customCheck-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
                                            (click)="selectProp(dict.name)">
                                        <label class="custom-control-label" for="customCheck-{{dict.name}}"></label>
                                    </div>
                                    <!-- <input type="checkbox" [checked]="selectedProps.has(dict.name)"
                                        (click)="selectProp(dict.name)"></td> -->
                                </td>
                                <td>
                                    <div class="custom-control custom-checkbox reuiredInput">
                                        <input type="checkbox" class="custom-control-input" #requiredInput
                                            (click)="setProp(requiredInput,'required',i)"
                                            id="requiredCheck-{{dict.name}}">
                                        <label class="custom-control-label" for="requiredCheck-{{dict.name}}"></label>
                                    </div>
                                </td>
                                <td>
                                    <div class="custom-control custom-checkbox reuiredInput">
                                        <input type="checkbox" class="custom-control-input" #tempInput
                                            (click)="setProp(tempInput,'input-param',i)" id="inputCheck-{{dict.name}}">
                                        <label class="custom-control-label" for="inputCheck-{{dict.name}}"></label>
                                    </div>
                                </td>
                                <td>{{ dict.name }}</td>
                                <td>{{ dict.name }}</td>
                                <td>
                                    <select class="custom-select" (click)="selectSource(dict,$event)">
                                        <option *ngFor="let val of dict.definition.sources | keyvalue">
                                            {{initMap(dict.name,val)}}
                                        </option>

                                    </select>
                                </td>
                                <td>
                                    <!-- <select class="custom-select">
                                        <option *ngFor="let val of getKeys(dependancies)">
                                            {{ getValue(dict.name)}}</option>
                                    </select> -->
                                    <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
                                    <!-- {{ dict.definition.sources }} -->
                                </td>
                                <td>{{ dict.definition?.property?.default }}</td>
                                <td><input type="text" class="form-control" #velocity
                                        (input)="setVelocity(i,velocity.value)"></td>
                                <td>{{ dict.definition?.property?.type }}</td>
                                <td>{{ dict.definition?.property['entry_schema'] }}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
                    <!-- <div class="btn-group mapping-editBar" role="group">
                        <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
                            <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
                                id="customCheck2"
                                [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
                            <label class="custom-control-label" for="customCheck2"></label>
                        </div>
                        <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
                            tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
                        <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="removeProps()"
                            tooltip="Remove" placement="bottom"><i class="icon-delete-sm"></i></button>
                    </div> -->
                    <table datatable [dtOptions]="dtOptions" [dtTrigger]="resTableDtTrigger" class="row-border hover">
                        <thead>
                            <tr>
                                <!-- <th></th> -->
                                <th>Required</th>
                                <th>Template Input</th>
                                <th>Parameter Name</th>
                                <th>Dictionary Name</th>
                                <th>Dictionary Source</th>
                                <th>Dependancies</th>
                                <th>Default</th>
                                <th>Velocity</th>
                                <th>Data Type</th>
                                <th>Entry Schema</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr *ngFor="let dict of mappingRes">
                                <!-- <td>
                                    <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
                                        <input type="checkbox" class="custom-control-input"
                                            id="customCheck2-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
                                            (click)="selectProp(dict.name)">
                                        <label class="custom-control-label" for="customCheck2-{{dict.name}}"></label>
                                    </div>
                                </td> -->
                                <td>
                                    <img *ngIf="dict?.property?.required" src="/assets/img/icon-required-yes.svg">
                                    <img *ngIf="!dict?.property?.required" src="/assets/img/icon-required-no.svg">
                                </td>
                                <td>
                                    <img *ngIf="dict['input-param']" src="/assets/img/icon-required-yes.svg">
                                    <img *ngIf="!dict['input-param']" src="/assets/img/icon-required-no.svg">
                                </td>
                                <td>{{ dict['name'] }}</td>
                                <td>{{ dict['name'] }}</td>
                                <td>
                                    <input type="text" class="form-control" [value]="dict['dictionary-source']"
                                        disabled>

                                </td>
                                <td>
                                    <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
                                    <!-- {{ dict.definition.sources }} -->
                                </td>
                                <td>{{ dict['property']['default'] }}</td>
                                <td *ngIf="dict?.property?.metadata">
                                    {{dict?.property?.metadata['transform-template']}}
                                </td>
                                <td *ngIf="!dict?.property?.metadata"></td>
                                <td>{{ dict['property']['type'] }}</td>
                                <td>{{ dict['property']['entry_schema'] }}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>


            </div>


        </div>

    </div>
</div>


<div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
    aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="templateModalLabel">Import File</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <img src="assets/img/icon-close.svg" />
                </button>
            </div>
            <div class="modal-body">
                <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
                    (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
                    <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
                        <div class="folder-upload">
                            <img src="assets/img/folder-upload.svg" />
                        </div>
                        <div class="folder-upload-text">
                            Drag & Drop file
                        </div>
                        <div class="folder-upload-text">or
                            <button type="button" class="btn btn-sm btn-primary" (click)="openFileSelector()">Browse
                                Files
                            </button>
                        </div>
                        <div class="folder-upload-type">Allowed file type:
                            {{allowedExt}}
                        </div>
                    </ng-template>
                </ngx-file-drop>
                <div class="upload-table">
                    <table class="table">
                        <thead>
                            <tr *ngFor="let item of uploadedFiles; let i=index">
                                <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
                                <th>{{ item.name }}</th>
                                <th (click)="removeFile(i)" width="40" class="text-right"><img
                                        src="assets/img/icon-remove-file.svg" class="btn-modal-remove-file" /></th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
                    (click)="resetTheUploadedFiles()">Cancel
                </button>

                <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
                    Import
                </button>
            </div>
        </div>
    </div>
</div>

<!-- Delete Modal -->
<div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
    aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <img src="assets/img/icon-close.svg" />
                </button>
            </div>
            <div class="modal-body">
                <p>Are you sure you want to delete Template file
                    <span>{{fileToDelete}}</span>?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                <button type="button" (click)="confirmDelete()" data-dismiss="modal"
                    class="btn btn-primary">Delete</button>
            </div>
        </div>
    </div>
</div>