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