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