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