-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from devppratik/sop-alerts
OSD-16136 : In-built SOP Feature Added
- Loading branch information
Showing
14 changed files
with
471 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ui | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/gdamore/tcell/v2" | ||
"github.com/openshift/pagerduty-short-circuiter/pkg/utils" | ||
"github.com/rivo/tview" | ||
) | ||
|
||
// App Setup | ||
func ViewAlertSOP(tui *TUI, URL string) { | ||
textView := tview.NewTextView(). | ||
SetDynamicColors(true). | ||
SetRegions(true). | ||
SetChangedFunc(func() { | ||
tui.App.Draw() | ||
}) | ||
utils.FetchHTMLContent(URL, textView) | ||
name := "SOP - " + utils.GetReadmePath(URL) | ||
textView.Highlight("0").SetBorder(true).SetTitle(name) | ||
AddSOPSlide(name, textView, tui) | ||
// Input Handling | ||
textView.SetDoneFunc(func(key tcell.Key) { | ||
currentSelection := textView.GetHighlights() | ||
if len(currentSelection) > 0 { | ||
index, _ := strconv.Atoi(currentSelection[0]) | ||
if key == tcell.KeyEnter { | ||
// TODO: Update with the Link | ||
url := textView.GetRegionText(currentSelection[0]) | ||
utils.FetchHTMLContent(url, textView) | ||
fmt.Println(url) | ||
} | ||
if key == tcell.KeyTab { | ||
index = (index + 1) % tui.NumLinks | ||
} else if key == tcell.KeyBacktab { | ||
index = (index - 1 + tui.NumLinks) % tui.NumLinks | ||
} else { | ||
return | ||
} | ||
textView.Highlight(strconv.Itoa(index)).ScrollToHighlight() | ||
} | ||
}) | ||
|
||
} |
Oops, something went wrong.