Created initial UI component template.
This commit is contained in:
58
src/client/views/agents.nim
Normal file
58
src/client/views/agents.nim
Normal file
@@ -0,0 +1,58 @@
|
||||
import times
|
||||
import imguin/[cimgui, glfw_opengl, simple]
|
||||
import ../utils/appImGui
|
||||
import ../../common/[types]
|
||||
|
||||
type
|
||||
AgentsTableComponent = ref object of RootObj
|
||||
title: string
|
||||
agents: seq[Agent]
|
||||
|
||||
|
||||
let exampleAgents: seq[Agent] = @[
|
||||
Agent(
|
||||
agentId: "DEADBEEF",
|
||||
listenerId: "L1234567",
|
||||
username: "alice",
|
||||
hostname: "DESKTOP-01",
|
||||
domain: "CORP",
|
||||
ip: "192.168.1.10",
|
||||
os: "Windows 10",
|
||||
process: "explorer.exe",
|
||||
pid: 2340,
|
||||
elevated: true,
|
||||
sleep: 60,
|
||||
tasks: @[],
|
||||
firstCheckin: now() - initDuration(hours = 2),
|
||||
latestCheckin: now(),
|
||||
sessionKey: [byte 0, 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]
|
||||
),
|
||||
Agent(
|
||||
agentId: "FACEDEAD",
|
||||
listenerId: "L7654321",
|
||||
username: "bob",
|
||||
hostname: "LAPTOP-02",
|
||||
domain: "SALES",
|
||||
ip: "10.0.0.5",
|
||||
os: "Windows 11",
|
||||
process: "cmd.exe",
|
||||
pid: 4567,
|
||||
elevated: false,
|
||||
sleep: 120,
|
||||
tasks: @[],
|
||||
firstCheckin: now() - initDuration(hours = 1, minutes = 30),
|
||||
latestCheckin: now() - initDuration(minutes = 5),
|
||||
sessionKey: [byte 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
|
||||
)
|
||||
]
|
||||
|
||||
proc AgentsTable*(title: string): AgentsTableComponent =
|
||||
result = new AgentsTableComponent
|
||||
result.title = title
|
||||
result.agents = exampleAgents
|
||||
|
||||
proc draw*(component: AgentsTableComponent, showComponent: ptr bool) =
|
||||
igBegin(component.title, showComponent, 0)
|
||||
defer: igEnd()
|
||||
|
||||
igText("asd")
|
||||
59
src/client/views/dockspace.nim
Normal file
59
src/client/views/dockspace.nim
Normal file
@@ -0,0 +1,59 @@
|
||||
import tables
|
||||
import imguin/[cimgui, glfw_opengl, simple]
|
||||
import ../utils/appImGui
|
||||
|
||||
type
|
||||
DockspaceComponent* = ref object of RootObj
|
||||
windowClass: ptr ImGuiWindowClass
|
||||
dockspaceFlags: ImGuiDockNodeFlags
|
||||
windowFlags: ImGuiWindow_Flags
|
||||
|
||||
proc Dockspace*(): DockspaceComponent =
|
||||
result = new DockspaceComponent
|
||||
result.windowClass = ImGuiWindowClass_ImGuiWindowClass()
|
||||
result.dockspaceFlags = ImGuiDockNodeFlags_None.int32
|
||||
result.windowFlags = ImGuiWindowFlags_MenuBar.int32 or ImGuiWindowFlags_NoDocking.int32
|
||||
|
||||
proc draw*(component: DockspaceComponent, showComponent: ptr bool, views: Table[string, ptr bool]) =
|
||||
|
||||
var vp = igGetMainViewport()
|
||||
igSetNextWindowPos(vp.WorkPos, ImGui_Cond_None.int32, vec2(0.0f, 0.0f))
|
||||
igSetNextWindowSize(vp.WorkSize, 0)
|
||||
igSetNextWindowViewport(vp.ID)
|
||||
igPushStyleVar_Float(ImGuiStyleVar_WindowRounding.int32, 0.0f)
|
||||
igPushStyleVar_Float(ImGuiStyleVar_WindowBorderSize.int32, 0.0f)
|
||||
component.windowFlags = component.windowFlags or (
|
||||
ImGuiWindowFlags_NoTitleBar.int32 or
|
||||
ImGuiWindowFlags_NoCollapse.int32 or
|
||||
ImGuiWindowFlags_NoResize.int32 or
|
||||
ImGuiWindowFlags_NoMove.int32 or
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus.int32 or
|
||||
ImGuiWindowFlags_NoNavFocus.int32
|
||||
)
|
||||
|
||||
# Add padding
|
||||
igPushStyleVar_Vec2(ImGuiStyleVar_WindowPadding.int32, vec2(10.0f, 10.0f))
|
||||
|
||||
igBegin("Dockspace", showComponent, component.windowFlags)
|
||||
defer: igEnd()
|
||||
|
||||
igPopStyleVar(3)
|
||||
|
||||
# Create dockspace
|
||||
igDockSpace(igGetID_Str("Dockspace"), vec2(0.0f, 0.0f), component.dockspaceFlags, component.windowClass)
|
||||
|
||||
# Create menu bar
|
||||
if igBeginMenuBar():
|
||||
if igBeginMenu("Options", true):
|
||||
if igMenuItem("Exit", nil, false, (addr showComponent) != nil):
|
||||
showComponent[] = false
|
||||
igEndMenu()
|
||||
|
||||
if igBeginMenu("Views", true):
|
||||
# Create a menu item to toggle each of the main views of the application
|
||||
for view, showView in views:
|
||||
if igMenuItem(view, nil, showView[], showView != nil):
|
||||
showView[] = not showView[]
|
||||
igEndMenu()
|
||||
|
||||
igEndMenuBar()
|
||||
Reference in New Issue
Block a user