summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html
blob: a272b62b0cb65445b01457e08c60fc2f649585d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<div class="import-container-all">
    <div class="import-container">
        <div class="import-container-input">
            <input class="ng-pristine ng-valid ng-touched" placeholder="Enter file URL then ENTER" type="input">
            <a class="enter-link" href="#"><i class="icon-enter-link"></i></a>
        </div>
        <span tourAnchor="st-scriptsImport" class="import-container-span">Or you can also <a data-target="#scriptsModal"
                                                                                             data-toggle="modal"
                                                                                             (click)="resetTheUploadedFiles()"
                                                                                             href="#"><b>Import File</b></a></span>
        <span>
   <div class="card creat-card"></div>
   <div class="single-line-model">
      <label class="label-name">File Name
      <span _ngcontent-uew-c3="">*</span>
      </label>
      <div class="label-input">
         <input type="input" [(ngModel)]="currentFileName"
                placeholder="script name" name="scriptName" autofocus [autofocus]="true">
      </div>
      <div class="single-line">
         <label class="label-name">Script Type</label>
         <div class="label-input" (change)="changeExtension()">
            <label name="trst" id="kt">
            <input class="form-check-input" [(ngModel)]="scriptExtension" type="radio"
                   name="exampleRadios1" id="kt" value=kotlin>
            <span>
            Kotlin
            </span>
            </label>
            <label name="trst" id="py">
            <input class="form-check-input" [(ngModel)]="scriptExtension" type="radio"
                   name="exampleRadios2" id="py" value=python>
            <span>
            Jython
            </span>
            </label>
            <label id="ansible">
            <input class="form-check-input" [(ngModel)]="scriptExtension" type="radio"
                   name="exampleRadios3" id="ansible" value=ansible>
            <span>
            Ansible
            </span>
            </label>
         </div>
      </div>
   </div>
   <div id="id-script" class="collapse show">
      <div class="card-body">
         <ace-editor [(text)]="currentFileContent"
                     [mode]="currentExtension"
                     [autoUpdateContent]="true" [durationBeforeCallback]="3000" [theme]="'eclipse'"
                     #editor
                     style="height:300px;">
         </ace-editor>
      </div>
   </div>
</span>
        <button tourAnchor="tm-templateFinish" (click)="textCurrentChanges()" [disabled]="currentFileName?.length == 0 ||
this.currentFileContent?.length == 0
"
                title="Submit template and close" class="btn btn-primary">Save
        </button>
    </div>


    <div class="accordion">
        <!-- <div class="card creat-card">
            <div class="single-line">
                <label class="label-name">File</label>
            </div>
        </div> -->
        <div *ngFor="let file of scriptsFiles | keyvalue; let mapIndex = index" id="accordion-script">

            <div class="card">
                <div [id]="'head-script-'+mapIndex" class="card-header">
                    <h5 class="mb-0 d-flex justify-content-between">
                        <button (click)="changeDivShow(mapIndex)" aria-expanded="false" class="btn btn-link collapsed"
                                data-toggle="collapse">
                            <i class="icon-file-code"></i> {{file.key}}
                        </button>
                        <a data-toggle="modal" (click)="initDelete(file)" data-target="#exampleModal"
                           class="accordion-delete"><i class="icon-delete-sm"></i></a>
                        <!-- <a (click)="removeFile(file.key,mapIndex)" data-toggle="modal" data-target="#exampleModal" class="accordion-delete"><i
                                    class="icon-delete-sm"></i></a> -->
                        <!-- Delete Modal -->
                        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
                             aria-labelledby="exampleModalLabel" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLabel">Delete Script</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <img src="assets/img/icon-close.svg"/>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <p>Are you sure you want to delete script file
                                            <span>{{fileToDelete?.key?.split('/')[2]}}</span>?</p>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary"
                                                data-dismiss="modal">Cancel
                                        </button>
                                        <button type="button" (click)="removeFile(fileToDelete?.key,0)"
                                                data-dismiss="modal" class="btn btn-danger">Delete
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>


                    </h5>
                </div>
                <div [attr.aria-labelledby]="'head-script-'+mapIndex" [id]="'id-script-'+mapIndex" class="collapse"
                     data-parent="#accordion-script">
                    <div class="card-body">
                        <ace-editor [(text)]="file.value" (textChange)="textChanges($event,file.key)" [mode]="'kotlin'"
                                    [autoUpdateContent]="true" [durationBeforeCallback]="5000" [theme]="'eclipse'"
                                    #editor
                                    style="height:300px;">
                        </ace-editor>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>

<div aria-hidden="true" aria-labelledby="scriptsModalLabel" class="modal fade" id="scriptsModal" role="dialog"
     tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="scriptsModalLabel">Import File</h5>
                <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                    <img src="assets/img/icon-close.svg"/>
                </button>
            </div>
            <div class="modal-body">
                <ngx-file-drop accept=".kt,.py" (onFileDrop)="dropped($event)" (onFileLeave)="fileLeave($event)"
                               (onFileOver)="fileOver($event)" dropZoneLabel="Drop files here">
                    <ng-template let-openFileSelector="openFileSelector" ngx-file-drop-content-tmp>
                        <div class="folder-upload">
                            <img src="assets/img/folder-upload.svg"/>
                        </div>
                        <div class="folder-upload-text">
                            Drag & Drop file
                        </div>
                        <div class="folder-upload-text">or
                            <button (click)="openFileSelector()" class="btn btn-sm btn-primary" type="button">Browse
                                Files
                            </button>
                        </div>
                        <div class="folder-upload-type">Allowed file type: Kotlin(kt), Python(py)</div>
                    </ng-template>
                </ngx-file-drop>
                <div class="upload-table">
                    <table class="table">
                        <thead>
                        <tr *ngFor="let item of uploadedFiles; let i=index">
                            <th width="40"><img src="assets/img/icon-file-code.svg"/></th>
                            <th>{{ item.name }}</th>
                            <th (click)="removeInitFile(i)" width="40" class="text-right"><img
                                    src="assets/img/icon-remove-file.svg"/></th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button (click)="resetTheUploadedFiles()" class="btn btn-sm btn-secondary" data-dismiss="modal"
                        type="button">Cancel
                </button>
                <button (click)="setFilesToStore()" class="btn btn-sm btn-primary" [disabled]="uploadedFiles?.length<=0"
                        data-dismiss="modal" type="button">
                    Import
                </button>
            </div>
        </div>
    </div>
</div>