|
56 | 56 |
|
57 | 57 | func createFlowDisplay() { |
58 | 58 | focus = "inputField" |
59 | | - showCount = defaultFlowShowCount |
60 | 59 | app = tview.NewApplication(). |
61 | 60 | SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
62 | 61 | //nolint:exhaustive |
@@ -460,33 +459,28 @@ func AppendFlow(genericMap config.GenericMap) { |
460 | 459 | return |
461 | 460 | } |
462 | 461 |
|
463 | | - if errAdvancedDisplay != nil { |
464 | | - // simply print flow into logs |
465 | | - log.Printf("%v\n", genericMap) |
466 | | - } else { |
467 | | - // lock since we are updating lastFlows concurrently |
468 | | - mutex.Lock() |
469 | | - |
470 | | - // add new flow to the array |
471 | | - genericMap["Index"] = flowIndex |
472 | | - flowIndex++ |
473 | | - lastFlows = append(lastFlows, genericMap) |
474 | | - |
475 | | - // sort flows according to time |
476 | | - sort.Slice(lastFlows, func(i, j int) bool { |
477 | | - if capture == Flow { |
478 | | - return toFloat64(lastFlows[i], "TimeFlowEndMs") < toFloat64(lastFlows[j], "TimeFlowEndMs") |
479 | | - } |
480 | | - return toFloat64(lastFlows[i], "Time") < toFloat64(lastFlows[j], "Time") |
481 | | - }) |
| 462 | + // lock since we are updating lastFlows concurrently |
| 463 | + mutex.Lock() |
482 | 464 |
|
483 | | - // limit flows kept in memory |
484 | | - if len(lastFlows) > keepCount { |
485 | | - lastFlows = lastFlows[len(lastFlows)-keepCount:] |
| 465 | + // add new flow to the array |
| 466 | + genericMap["Index"] = flowIndex |
| 467 | + flowIndex++ |
| 468 | + lastFlows = append(lastFlows, genericMap) |
| 469 | + |
| 470 | + // sort flows according to time |
| 471 | + sort.Slice(lastFlows, func(i, j int) bool { |
| 472 | + if capture == Flow { |
| 473 | + return toFloat64(lastFlows[i], "TimeFlowEndMs") < toFloat64(lastFlows[j], "TimeFlowEndMs") |
486 | 474 | } |
| 475 | + return toFloat64(lastFlows[i], "Time") < toFloat64(lastFlows[j], "Time") |
| 476 | + }) |
487 | 477 |
|
488 | | - mutex.Unlock() |
| 478 | + // limit flows kept in memory |
| 479 | + if len(lastFlows) > keepCount { |
| 480 | + lastFlows = lastFlows[len(lastFlows)-keepCount:] |
489 | 481 | } |
| 482 | + |
| 483 | + mutex.Unlock() |
490 | 484 | } |
491 | 485 |
|
492 | 486 | func updateDisplayEnrichmentTexts() { |
@@ -599,6 +593,23 @@ func getFlows() []config.GenericMap { |
599 | 593 | return flows |
600 | 594 | } |
601 | 595 |
|
| 596 | +func getTableRows() []string { |
| 597 | + arr := []string{} |
| 598 | + if len(tableData.cols) == 0 || len(tableData.flows) == 0 { |
| 599 | + return arr |
| 600 | + } |
| 601 | + |
| 602 | + for i := range len(tableData.flows) + 1 { |
| 603 | + str := "" |
| 604 | + for j := range tableData.cols { |
| 605 | + str += tableData.GetCell(i, j).Text |
| 606 | + } |
| 607 | + arr = append(arr, str) |
| 608 | + } |
| 609 | + |
| 610 | + return arr |
| 611 | +} |
| 612 | + |
602 | 613 | func updateTableAndSuggestions() { |
603 | 614 | // update tableData |
604 | 615 | tableData.cols = getCols() |
|
0 commit comments