cdc73f1b9cc05a8411445f54b7a36117eae9757d
[ccsdk/cds.git] / cds-ui / designer-client / src / app / modules / feature-modules / packages / package-creation / template-mapping / templ-mapp-creation / templ-mapp-creation.component.html
1 <div class="row template-mapping-action">
2     <div class="col">
3         <h6 [hidden]="edit" class="create-title">Create Template</h6>
4         <button (click)="closeCreationForm()" [hidden]="!edit" class="btn btn-outline-secondary"><i
5                 class="fa fa-chevron-left mr-2"></i>Template List</button>
6     </div>
7     <div class="col text-right">
8
9         <button data-toggle="modal" [hidden]="!edit" (click)="initDelete()" data-target="#templateDeletionModal2"
10             class="btn btn-outline-danger" title="Delete Template">Delete</button>
11
12
13         <button (click)="cancel()" [hidden]="fileName?.length <=0 || edit"
14             class="btn btn-outline-secondary">Clear</button>
15         <button (click)="saveToStore()" [disabled]="fileName?.length <=0" class="btn btn-primary">Finish</button>
16     </div>
17 </div>
18 <div class="card creat-card">
19     <div class="single-line-model">
20         <label class="label-name">Name
21             <span _ngcontent-uew-c3="">*</span>
22         </label>
23
24         <div class="label-input">
25             <input type="input" [disabled]="edit" [(ngModel)]="fileName" placeholder="Template name" name="templateName"
26                 autofocus [autofocus]="true">
27         </div>
28     </div>
29 </div>
30
31 <div class="template-mapping-accordion">
32     <div class="accordion" id="accordion">
33         <div class="card">
34             <div class="card-header" id="headingOne">
35                 <h5 class="mb-0 d-flex justify-content-between">
36                     <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true"
37                         aria-controls="collapseOne">
38                         1. Template <span class="accordian-title">{{currentTemplate?.fileName?.split('/')[1]}}</span>
39                     </button>
40
41                 </h5>
42             </div>
43
44             <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
45                 <div class="card-body">
46                     <div class="single-line">
47                         <label class="label-name">Template Type</label>
48                         <div class="label-input">
49                             <label name="trst" (click)="allowedExt=['.vtl']">
50                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
51                                     name="exampleRadios" id="exampleRadios1" value=Velcoity>
52                                 <span>
53                                     Velcoity
54                                 </span>
55                             </label>
56                             <label name="trst" (click)="allowedExt=['.j2','.jinja2']">
57                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
58                                     name="exampleRadios" id="exampleRadios1" value=Jinja>
59
60                                 <span>
61                                     Jinja
62                                 </span>
63                             </label>
64                             <label name="trst" (click)="allowedExt=['.kt']">
65                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
66                                     name="exampleRadios" id="exampleRadios1" value=Kotlin>
67
68                                 <span>
69                                     Kotlin
70                                 </span>
71                             </label>
72                         </div>
73                     </div>
74                     <div class="create-template-import">Use the editor to add parameters or you can also
75                         <a href="#" data-toggle="modal" (click)="allowedExt=[getFileExtension()]"
76                             data-target="#templateModal"><b>Import
77                                 File</b></a></div>
78                     <div class="editor-container mb-4">
79                         <app-source-editor [lang]="'velocity'" (textChange)="textChanges($event,templateInfo.fileName)"
80                             [(text)]="templateFileContent"></app-source-editor>
81                     </div>
82                 </div>
83             </div>
84         </div>
85         <div class="card">
86             <div class="card-header" id="headingTwo">
87                 <h5 class="mb-0">
88                     <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"
89                         aria-expanded="false" aria-controls="collapseTwo">
90                         2. Manage Mapping <span
91                             class="accordian-title">{{currentMapping?.fileName?.split('/')[1]}}</span>
92                     </button>
93                 </h5>
94             </div>
95             <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
96                 <div class="card-body">
97                     <p class="text-center"><b>Select a source to load config parameters</b></p>
98                     <div class="text-center">
99                         <button [disabled]="!(variables?.length>0 && templateFileContent?.trim()?.length > 0)"
100                             (click)="getMappingTableFromTemplate($event)" class="mapping-source-load" [ngClass]="variables?.length>0 && templateFileContent?.trim()?.length > 0
101                             ?'hover-enable':'hover-disable'">
102                             <i class="icon-use-attributes"></i>
103                             <br />
104                             <span>Use Current Template Instance</span>
105                         </button>
106                         <a href="#" (click)="allowedExt=['.csv']" data-toggle="modal" data-target="#templateModal"
107                             class="mapping-source-load">
108                             <i class="icon-upload-attributes"></i>
109                             <br />
110                             <div>Upload Attributes List</div>
111                             <div class="source-load-note">(Should be comma delimited file)</div>
112                         </a>
113                         <!-- <a href="#" class="mapping-source-load">
114                             <i class="icon-import-cds"></i>
115                         <br/>
116                             <span>Import from SDC Model</span>
117                         </a> -->
118                     </div>
119
120                     <div class="table-container">
121
122
123                     </div>
124                 </div>
125                 <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mapping-table mx-4 my-2">
126                     <table datatable [dtOptions]="initDtOptions" [dtTrigger]="dtTrigger" class="row-border hover">
127                         <thead>
128                             <tr>
129                                 <th>Required</th>
130                                 <th>Parameter Name</th>
131                                 <th>Dictionary Name</th>
132                                 <th>Dictionary Source</th>
133                                 <th>Dependancies</th>
134                                 <th>Default</th>
135                                 <th>Data Type</th>
136                                 <th>Entry Schema</th>
137                             </tr>
138                         </thead>
139                         <tbody>
140                             <tr *ngFor="let dict of resourceDictionaryRes">
141                                 <td>
142                                     <img *ngIf="dict.definition?.property?.required"
143                                         src="/assets/img/icon-required-yes.svg">
144                                     <img *ngIf="!dict.definition?.property?.required"
145                                         src="/assets/img/icon-required-no.svg">
146                                 </td>
147                                 <td>{{ dict.name }}</td>
148                                 <td>{{ dict.name }}</td>
149                                 <td>
150                                     <select class="custom-select" (click)="selectSource(dict,$event)">
151                                         <option *ngFor="let val of dict.definition.sources | keyvalue">
152                                             {{initMap(dict.name,val)}}
153                                         </option>
154
155                                     </select>
156                                 </td>
157                                 <td>
158                                     <!-- <select class="custom-select">
159                                         <option *ngFor="let val of getKeys(dependancies)">
160                                             {{ getValue(dict.name)}}</option>
161
162                                     </select> -->
163                                     <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
164                                     <!-- {{ dict.definition.sources }} -->
165                                 </td>
166                                 <td>{{ dict.definition?.property?.default }}</td>
167                                 <td>{{ dict.definition?.property?.type }}</td>
168                                 <td>{{ dict.definition?.property['entry_schema'] }}</td>
169                             </tr>
170                         </tbody>
171                     </table>
172                 </div>
173
174                 <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
175                     <table datatable [dtOptions]="dtOptions" [dtTrigger]="resTableDtTrigger" class="row-border hover">
176                         <thead>
177                             <tr>
178                                 <th>Required</th>
179                                 <th>Parameter Name</th>
180                                 <th>Dictionary Name</th>
181                                 <th>Dictionary Source</th>
182                                 <th>Dependancies</th>
183                                 <th>Default</th>
184                                 <th>Data Type</th>
185                                 <th>Entry Schema</th>
186                             </tr>
187                         </thead>
188                         <tbody>
189                             <tr *ngFor="let dict of mappingRes">
190                                 <td>
191                                     <img *ngIf="dict.definition?.property?.required"
192                                         src="/assets/img/icon-required-yes.svg">
193                                     <img *ngIf="!dict.definition?.property?.required"
194                                         src="/assets/img/icon-required-no.svg">
195                                 </td>
196                                 <td>{{ dict['name'] }}</td>
197                                 <td>{{ dict['name'] }}</td>
198                                 <td>
199                                     <input type="text" class="form-control" [value]="dict['dictionary-source']"
200                                         disabled>
201
202                                 </td>
203                                 <td>
204                                     <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
205                                     <!-- {{ dict.definition.sources }} -->
206                                 </td>
207                                 <td>{{ dict['property']['default'] }}</td>
208                                 <td>{{ dict['property']['type'] }}</td>
209                                 <td>{{ dict['property']['entry_schema'] }}</td>
210                             </tr>
211                         </tbody>
212                     </table>
213                 </div>
214
215
216             </div>
217
218
219         </div>
220
221     </div>
222 </div>
223
224
225 <div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
226     aria-hidden="true">
227     <div class="modal-dialog" role="document">
228         <div class="modal-content">
229             <div class="modal-header">
230                 <h5 class="modal-title" id="templateModalLabel">Import File</h5>
231                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
232                     <img src="assets/img/icon-close.svg" />
233                 </button>
234             </div>
235             <div class="modal-body">
236                 <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
237                     (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
238                     <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
239                         <div class="folder-upload">
240                             <img src="assets/img/folder-upload.svg" />
241                         </div>
242                         <div class="folder-upload-text">
243                             Drag & Drop file
244                         </div>
245                         <div class="folder-upload-text">or
246                             <button type="button" class="btn btn-sm btn-primary" (click)="openFileSelector()">Browse
247                                 Files
248                             </button>
249                         </div>
250                         <div class="folder-upload-type">Allowed file type:
251                             {{allowedExt}}
252                         </div>
253                     </ng-template>
254                 </ngx-file-drop>
255                 <div class="upload-table">
256                     <table class="table">
257                         <thead>
258                             <tr *ngFor="let item of uploadedFiles; let i=index">
259                                 <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
260                                 <th>{{ item.name }}</th>
261                                 <th (click)="removeFile(i)" width="40" class="text-right"><img
262                                         src="assets/img/icon-remove-file.svg" /></th>
263                             </tr>
264                         </thead>
265                     </table>
266                 </div>
267             </div>
268
269             <div class="modal-footer">
270                 <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
271                     (click)="resetTheUploadedFiles()">Cancel
272                 </button>
273
274                 <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
275                     Import
276                 </button>
277             </div>
278         </div>
279     </div>
280 </div>
281
282 <!-- Delete Modal -->
283 <div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
284     aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
285     <div class="modal-dialog" role="document">
286         <div class="modal-content">
287             <div class="modal-header">
288                 <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
289                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
290                     <span aria-hidden="true">&times;</span>
291                 </button>
292             </div>
293             <div class="modal-body">
294                 <p>Are you sure you want to delete Template file
295                     <span>{{fileToDelete}}</span>?</p>
296             </div>
297             <div class="modal-footer">
298                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
299                 <button type="button" (click)="confirmDelete()" data-dismiss="modal"
300                     class="btn btn-primary">Delete</button>
301             </div>
302         </div>
303     </div>
304 </div>