summaryrefslogtreecommitdiffstats
path: root/public/src/app/rule-engine/action/action.component.html
blob: 38a9aa0446c84af17ce6929ee226b8e363ed292b (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<form #actionFrm="ngForm" class="conatiner" id="{{action.id}}" (mouseover)="changeStyle($event)" (mouseout)="changeStyle($event)">
  <div>

    <div class="center-content">
      <!-- type info -->
      <div class="action-info" [ngClass]="highlight">
        {{action.actionType | uppercase}}
      </div>

      <!-- from component -->
      <app-from [hidden]="action.actionType === 'log event' || action.actionType === 'log text' || action.actionType === 'hp metric' || action.actionType === 'Topology Search' ||  action.actionType === 'string transform'"
        class="center-content-item" #from [actionType]="action.actionType" (onFromChange)="updateFrom($event)"></app-from>

      <!-- target component -->
      <app-target [hidden]="action.actionType === 'clear' || action.actionType === 'clear nsf' || action.actionType === 'replace text' || action.actionType === 'log text' || action.actionType === 'log event' || action.actionType === 'hp metric' || action.actionType === 'string transform' || action.actionType === 'Topology Search' "
        #target style="width: 100%" (onTargetChange)="updateTarget($event)" [nodes]="action.nodes">
      </app-target>

      <!-- search -->
      <div *ngIf="action.actionType === 'Topology Search'" style="width: 100%;">
        <div style="display:flex; margin-bottom:10px;">
          <div class="from" style="width: 100%;">
            <div class="from-container">
              <div style="display: flex; align-items: center; width: 100%;" class="label">
                <span class="label" style="padding: 0 5px; ">
                  Field
                </span>
                <input required name="searchField" class="input-text" data-tests-id="searchField" [(ngModel)]="action.search.searchField"
                  type="text" placeholder="Search Field">
              </div>
            </div>
          </div>
          <div class="from" style="width: 100%; padding-right: 0;">
            <div class="from-container">
              <div style="display: flex; align-items: center; width: 100%;" class="label">
                <span class="label" style="padding: 0 5px;">
                  Value
                </span>
                <input required class="input-text" data-tests-id="searchValue" [(ngModel)]="action.search.searchValue" type="text" name="searchValue"
                  placeholder="Search Value">
              </div>
            </div>
          </div>
        </div>

        <div class="from" style="width: 100%; padding-right:0">
          <!-- <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">
                Filter
              </span>
              <input required class="input-text" name="searchFilter" data-tests-id="searchFilter" [(ngModel)]="action.search.searchFilter"
                type="text" placeholder="Search Filter">
            </div>
          </div> -->
          <div class="from-conatiner">
            <div style="display: flex;">
              <div class="label" style="width:100%">
                <span class="label" style="padding: 0 10px; border-left: none;">
                  Input
                </span>
                <input class="input-text" name="searchLeft" data-tests-id="searchLeft" [(ngModel)]="action.search.searchFilter.left" type="text">
              </div>

              <div style="margin: 0 1rem;">
                <select style="height: 30px; padding: 0 10px;
                border-color: #e0e0e0;" name="searchOperator" data-tests-id="searchOperator" [(ngModel)]="action.search.searchFilter.operator">
                  <option [ngValue]="null" disabled>Select operator</option>
                  <option value="contains">Contains</option>
                  <option value="endsWith">Ends with</option>
                  <option value="startsWith">Starts with</option>
                  <option value="equals">Equals</option>
                  <option value="notEqual">Not equal</option>
                  <option value="oneOf">One of</option>
                  <option value="NotOneOf">Not one of</option>
                </select>
              </div>

              <div class="label" style="width:100%">
                <span class="label" style="padding: 0 10px; border-left: none;">
                  Value
                </span>
                <input class="input-text" name="searchRight" data-tests-id="searchRight" [(ngModel)]="action.search.searchFilter.right" type="text">
              </div>
            </div>
          </div>
        </div>

        <div style="margin: 15px 0;">
          <p-radioButton name="searchRadio" label="Updates" value="updates" [ngModel]="action.search.radio" data-tests-id="radioUpdates"
            (ngModelChange)="searchRadioChange($event)"></p-radioButton>
          <span style="padding-left:15px;">
            <p-radioButton name="searchRadio" label="Enrich" value="enrich" [ngModel]="action.search.radio" data-tests-id="radioEnrich"
              (ngModelChange)="searchRadioChange($event)"></p-radioButton>
          </span>
        </div>

        <div *ngIf="action.search.radio === 'enrich'" style="display:flex; margin-bottom:10px;">
          <div>
            <div>
              <div style="display: flex; flex-direction: column; align-items: flex-start; width: 100%;">
                <div *ngFor="let input of action.search.enrich.fields; let index = index;" data-tests-id="searchFields" (mouseleave)="hoveredIndex=-1"
                  (mouseover)="hoveredIndex=index" class="from" style="margin-bottom:1rem; display: flex; flex-direction: row; align-items: flex-start;">
                  <div class="from-container" style="display: flex; flex-direction: row;">
                    <div style="display: flex; align-items: center; width: 100%;" class="label">
                      <span class="label" style="padding: 0 5px; width: 50px;">Fields</span>
                      <input class="input-text" [(ngModel)]="input.value" type="text" data-tests-id="searchFieldValue" required name="searchFeild[{{index}}]">
                    </div>

                    <button mat-icon-button class="button-remove" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" (click)="removeSearchField(index)"
                      *ngIf="action.search.enrich.fields.length > 1" style="box-shadow: none; height: 24px; width: 24px; display:flex"
                      data-tests-id="btnDelete">
                      <mat-icon class="md-24">delete</mat-icon>
                    </button>
                  </div>

                </div>
                <div style="display:flex; justify-content: space-between;">
                  <div style="display: flex; align-items: center;">
                    <button mat-mini-fab color="primary" (click)="addSearchFeild()" style="box-shadow: none; height: 16px; width: 16px; display:flex"
                      data-tests-id="btnAddSearchFeild">
                      <span style="padding-left: 2px; display: flex; justify-content: center; align-items: center" [innerHTML]="'plus' | feather:12"></span>
                    </button>
                    <span style="color: #009FDB; display: flex; justify-content: center; padding-left: 6px">Add Fields</span>
                  </div>
                </div>

              </div>
            </div>
          </div>
          <div class="from">
            <div class="from-container">
              <div style="display: flex; align-items: center; width: 100%;" class="label">
                <span class="label" style="padding: 0 5px;">
                  Prefix
                </span>
                <input required class="input-text" name="searchPrefix" data-tests-id="searchPrefix" [(ngModel)]="action.search.enrich.prefix"
                  type="text" placeholder="Search prefix">
              </div>
            </div>
          </div>
        </div>

        <div *ngIf="action.search.radio === 'updates'">
          <table style="width: 100%; margin-bottom: 1rem;">
            <thead style="background: #D2D2D2;">
              <tr style="height: 30px;">
                <th style="padding-left: 10px;">Key</th>
                <th style="padding-left: 10px;">value</th>
              </tr>
            </thead>
            <tbody ngModelGroup="searchUpdateKeyValue" #searchUpdateKeyValue="ngModelGroup">
              <tr *ngFor="let item of action.search.updates; let index = index;" (mouseleave)="hoveredIndex=-1" (mouseover)="hoveredIndex=index">
                <th style="height: 30px; border: 1px solid #F3F3F3;">
                  <input [(ngModel)]="item.key" required name="searchKey[{{index}}]" data-tests-id="updatesKey" type="text" style="width:97%; height: 100%;border: none; padding:0 5px;">
                </th>
                <th style="height: 30px; border: 1px solid #F3F3F3;">
                  <input [(ngModel)]="item.value" required name="searchValue[{{index}}]" data-tests-id="updatesValue" type="text" style="width:97%; height: 100%;border: none; padding:0 5px;">
                </th>
                <th style="height: 30px; display: flex; align-items: baseline;">
                  <button mat-icon-button data-tests-id="btn-remove-row" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}"
                    class="button-remove" (click)="removeSearchUpdatesRow(index)" *ngIf="action.search.updates.length > 1"
                    style="height: 24px; width: 24px; display:flex; box-shadow: none;">
                    <mat-icon class="md-24">delete</mat-icon>
                  </button>
                </th>
              </tr>
            </tbody>
          </table>
          <div style="display:flex; justify-content: flex-start;">
            <div style="display: flex; align-items: center;">
              <button mat-mini-fab color="primary" (click)="addSearchUpdateRow()" data-tests-id="btn-add-row" style="height: 16px; width: 16px; display:flex; box-shadow: none;">
                <span style="padding-left: 2px; display: flex; justify-content: center; align-items: center" [innerHTML]="'plus' | feather:12"></span>
              </button>
              <span style="color: #009FDB; display: flex; justify-content: center; padding-left: 6px">Add Row</span>
            </div>
          </div>
        </div>

      </div>

      <!-- Hp Metric -->
      <div *ngIf="action.actionType === 'hp metric'" class="center-content-item">
        <ng-select name="hp-metric" [items]="metrics" required [virtualScroll]="true" placeholder="Select Parser Type" [(ngModel)]="action.selectedHpMetric"
          (change)="metricChange($event)" data-tests-id="hp metric">
        </ng-select>
      </div>

      <!-- string transform -->
      <div *ngIf="action.actionType === 'string transform'" class="center-content-item">

        <div style="display:flex; margin-bottom:10px;">
          <div class="from">
            <div class="from-container">
              <div style="display: flex; align-items: center; width: 100%;" class="label">
                <span class="label" style="padding: 0 5px; width: 100px;">
                  Start Value
                </span>
                <input required class="input-text" data-tests-id="startValue" name="title" [(ngModel)]="action.stringTransform.startValue"
                  type="text" placeholder="Select start value">
              </div>
            </div>
          </div>

          <app-target [hidden]="! (action.actionType === 'string transform')" #target style="width: 100%" (onTargetChange)="updateTarget($event)"
            [nodes]="action.nodes">
          </app-target>
        </div>

        <div class="from" style="padding-right:0">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">
                Target case
              </span>
              <input required class="input-text" data-tests-id="targetCase" name="title" [(ngModel)]="action.stringTransform.targetCase"
                type="text" placeholder="Select target case">
            </div>
          </div>
        </div>

        <div class="pretty p-svg" style="margin: 1rem 0rem;">
          <input type="checkbox" name="isTrimString" data-tests-id="isTrimString" [checked]="action.stringTransform.isTrimString" (change)="action.stringTransform.isTrimString = !action.stringTransform.isTrimString"
          />
          <div class="state">
            <svg class="svg svg-icon" viewBox="0 0 20 20">
              <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                style="stroke: #009fdb; fill:#009fdb;"></path>
            </svg>
            <label>Trim String</label>
          </div>
        </div>
      </div>

      <!-- log Event -->
      <div *ngIf="action.actionType === 'log event'" class="center-content-item">
        <div class="from">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">Title</span>
              <input required class="input-text" data-tests-id="InputLogTitle" name="title" [(ngModel)]="action.logEvent.title" type="text"
                placeholder="The title for the log entry">
            </div>
          </div>
        </div>
      </div>

      <!-- log Text -->
      <div *ngIf="action.actionType === 'log text'" class="center-content-item">
        <div class="from">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">Log Text</span>
              <input required class="input-text" data-tests-id="InputLogText" name="logText" [(ngModel)]="action.logText.text" type="text"
                placeholder="Text to log">
            </div>
          </div>
        </div>
      </div>

    </div>

    <!-- dateFormatter -->
    <div *ngIf="action.actionType === 'date formatter'" style="flex-direction: column; margin-left: 163px; align-items: flex-end;">
      <div style="display: flex; margin: 0.5em 0; padding-left: 6px;">
        <div class="from" style="width:50%;">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">From Format</span>
              <input data-tests-id="InputFromFormat" class="input-text" required name="fromFormat" [(ngModel)]="action.dateFormatter.fromFormat"
                type="text">
            </div>
          </div>
        </div>
        <div class="from" style="width:50%; padding: 0;">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">To Format</span>
              <input data-tests-id="InputToFormat" class="input-text" required name="toFormat" [(ngModel)]="action.dateFormatter.toFormat"
                type="text">
            </div>
          </div>
        </div>
      </div>

      <div style="display: flex; margin: 0.5em 0; padding-left: 6px;">
        <div class="from" style="width:50%;">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 132px;">From Time-zone</span>
              <input class="input-text" data-tests-id="InputFromTimezone" required name="fromTimezone" [(ngModel)]="action.dateFormatter.fromTimezone"
                type="text">
            </div>
          </div>
        </div>
        <div class="from" style="width:50%; padding: 0;">
          <div class="from-container">
            <div style="display: flex; align-items: center; width: 100%;" class="label">
              <span class="label" style="padding: 0 5px; width: 100px;">To Time-zone</span>
              <input class="input-text" data-tests-id="InputToTimezone" required name="toTimezone" [(ngModel)]="action.dateFormatter.toTimezone"
                type="text">
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- replace text -->
    <div *ngIf="action.actionType === 'replace text'" class="action-container" style="flex-direction: row; margin-left: 160px; padding: 0 0.8em;">

      <div class="action-item">
        <div class="from" style="width:100%;">
          <div class="from-container" display="padding:0;">

            <div class="label" style="width: 100%;">
              <span class="label" style="padding: 0 5px; width: 100px;">Find what</span>
              <input data-tests-id="InputFindWhat" class="input-text" required name="findWhat" [(ngModel)]="action.replaceText.find" type="text"
                placeholder="Find text">
            </div>

          </div>
        </div>

      </div>

      <div class="action-item">
        <div class="from" style="width: 100%; padding: 0;">
          <div class="from-container">

            <div class="label" style="width: 100%;">
              <span class="label" style="padding: 0 5px; width: 100px;">Replace with</span>
              <input data-tests-id="InputReplaceWith" class="input-text" required name="replaceWith" [(ngModel)]="action.replaceText.replace"
                type="text" placeholder="Replace with text">
            </div>

          </div>
        </div>

      </div>
    </div>

    <!-- log text -->
    <div *ngIf="action.actionType === 'log text'" class="action-container" style="flex-direction: row; margin-left: 160px; padding: 0 0.8em;">

      <div class="action-item">
        <div class="from" style="width: 100%;">
          <div class="from-container" display="padding:0;">
            <div class="label" style="width: 100%;">
              <span class="label" style="padding: 0 5px; width: 100px;">Log Name</span>
              <input class="input-text" data-tests-id="InputLogName" name="logName" [(ngModel)]="action.logText.name" type="text" placeholder="Enter log name">
            </div>
          </div>
        </div>
      </div>

      <div class="action-item">
        <div class="from" style="width: 100%; padding: 0;">
          <div class="from-container">
            <div class="label" style="width: 100%;">
              <span class="label" style="padding: 0 5px; width: 100px;">Log Level</span>
              <input class="input-text" data-tests-id="InputLogLevel" required name="logLevel" [(ngModel)]="action.logText.level" type="text"
                placeholder="The title for the log entry">
            </div>
          </div>
        </div>
      </div>

    </div>

    <!-- Map -->
    <div *ngIf="action.actionType === 'map'" class="map-container">
      <!-- Default checkbox and input -->
      <div class="default" style="display: flex; align-items: center">
        <div class="pretty p-svg">
          <input type="checkbox" name="defaultCheckbox" data-tests-id="defaultCheckbox" [checked]="action.map.haveDefault" (change)="changeCheckbox()"
          />
          <div class="state">
            <!-- svg path -->
            <svg class="svg svg-icon" viewBox="0 0 20 20">
              <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                style="stroke: #009fdb; fill:#009fdb;"></path>
            </svg>
            <label>Default</label>
          </div>
        </div>
        <div *ngIf="action.map.haveDefault" class="input-wrapper">
          <input type="text" required name="defaultInput" data-tests-id="defaultInput" [(ngModel)]="action.map.default" class="input">
        </div>
      </div>

      <table style="width: 100%; margin-bottom: 1rem;">
        <thead style="background: #D2D2D2;">
          <tr style="height: 30px;">
            <th style="padding-left: 10px;">Key</th>
            <th style="padding-left: 10px;">value</th>
          </tr>
        </thead>
        <tbody ngModelGroup="mapKeyValue" #mapKeyValue="ngModelGroup">
          <tr *ngFor="let item of action.map.values; let index = index;" (mouseleave)="hoveredIndex=-1" (mouseover)="hoveredIndex=index">
            <th style="height: 30px; border: 1px solid #F3F3F3;">
              <input [(ngModel)]="item.key" required name="mapKey[{{index}}]" data-tests-id="key" type="text" style="width:97%; height: 100%;border: none; padding:0 5px;">
            </th>
            <th style="height: 30px; border: 1px solid #F3F3F3;">
              <input [(ngModel)]="item.value" required name="mapValue[{{index}}]" data-tests-id="value" type="text" style="width:97%; height: 100%;border: none; padding:0 5px;">
            </th>
            <th style="height: 30px; display: flex; align-items: baseline;">
              <button mat-icon-button data-tests-id="btn-remove-row" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}"
                class="button-remove" (click)="removeMapRow(index)" *ngIf="action.map.values.length > 1" style="height: 24px; width: 24px; display:flex; box-shadow: none;">
                <mat-icon class="md-24">delete</mat-icon>
              </button>
            </th>
          </tr>
        </tbody>
      </table>


      <div style="display:flex; justify-content: flex-start;">
        <div style="display: flex; align-items: center;">
          <button mat-mini-fab color="primary" (click)="addMapRow()" data-tests-id="btn-add-row" style="height: 16px; width: 16px; display:flex; box-shadow: none;">
            <span style="padding-left: 2px; display: flex; justify-content: center; align-items: center" [innerHTML]="'plus' | feather:12"></span>
            <!-- <mat-icon>add</mat-icon> -->
          </button>
          <span style="color: #009FDB; display: flex; justify-content: center; padding-left: 6px">Add Row</span>
        </div>
        <div class="btn-wrapper">
          <div style="width: 36px; height: 36px; cursor: pointer;">
            <span style="width: 100%;
                    color:#5a5a5a;
                    height: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;" [innerHTML]="'download' | feather:20"></span>
          </div>
          <input type="file" id="file" accept=".csv" (change)="handleFileInput($event.target.files)">
        </div>
      </div>
    </div>

  </div>
</form>