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