@@ -60,9 +60,101 @@ blobsProfiler.RegisterSubModule("SQLite", "Schema", {
60
60
RefreshButton = " Refresh"
61
61
})
62
62
63
+ local function requestSQLiteData (luaState , tableName , pageNum )
64
+ pageNum = pageNum or 1
65
+ local schemaDataTable = blobsProfiler [luaState ].SQLite .Schema
66
+
67
+ local tableSelectorList = blobsProfiler [luaState ].SQLite .Data .tableSelectorList
68
+ local tableDataListView = blobsProfiler [luaState ].SQLite .Data .tableDataListView
69
+
70
+ if luaState == " Client" then
71
+ for k , line in ipairs ( tableDataListView :GetLines () ) do
72
+ tableDataListView :RemoveLine (k )
73
+ end
74
+
75
+ for k ,v in ipairs (tableDataListView .Columns ) do
76
+ if v and IsValid (v ) then v :Remove () end
77
+ end
78
+
79
+ tableDataListView .Columns = {}
80
+
81
+ local colList = schemaDataTable .Tables [tableName ]
82
+ if colList then
83
+ local colAmnt = table .Count (colList )
84
+ for i = 0 , colAmnt - 1 do
85
+ local colData = schemaDataTable .Tables [tableName ][tostring (i )] -- TODO: make this actual number ffs
86
+ tableDataListView :AddColumn (colData .Name )
87
+ end
88
+ end
89
+ tableDataListView :SetDirty ( true )
90
+
91
+ tableDataListView :FixColumnsLayout ()
92
+
93
+ local getSQLData = sql .Query (" SELECT * FROM " .. sql .SQLStr (tableName ) .. " LIMIT 25" )
94
+ if getSQLData == false then
95
+ -- error
96
+ elseif getSQLData == nil then
97
+ -- no data
98
+ else
99
+
100
+ local tblOrder = {}
101
+ local colList = schemaDataTable .Tables [tableName ]
102
+ if colList then
103
+ local colAmnt = table .Count (colList )
104
+ for i = 0 , colAmnt - 1 do
105
+ local colData = schemaDataTable .Tables [tableName ][tostring (i )] -- TODO: make this actual number ffs
106
+ table.insert (tblOrder , colData .Name )
107
+ end
108
+ end
109
+
110
+ for _ , record in ipairs (getSQLData ) do
111
+ local dataBuild = {}
112
+ for __ , key in ipairs (tblOrder ) do
113
+ table.insert (dataBuild , record [key ])
114
+ end
115
+ tableDataListView :AddLine (unpack (dataBuild ))
116
+ end
117
+
118
+ end
119
+ else
120
+ -- TODO
121
+ end
122
+ end
123
+
63
124
blobsProfiler .RegisterSubModule (" SQLite" , " Data" , {
64
125
Icon = " icon16/page_white_database.png" ,
65
126
OrderPriority = 2 ,
127
+ CustomPanel = function (luaState , parentPanel )
128
+ blobsProfiler [luaState ].SQLite = blobsProfiler [luaState ].SQLite or {}
129
+ blobsProfiler [luaState ].SQLite .Data = blobsProfiler [luaState ].SQLite .Data or {}
130
+
131
+ blobsProfiler [luaState ].SQLite .Schema = blobsProfiler [luaState ].SQLite .Schema or {}
132
+
133
+ local schemaDataTable = blobsProfiler [luaState ].SQLite .Schema
134
+
135
+ blobsProfiler [luaState ].SQLite .Data .tableSelectorList = vgui .Create (" DComboBox" , parentPanel )
136
+ blobsProfiler [luaState ].SQLite .Data .tableDataListView = vgui .Create (" DListView" , parentPanel )
137
+
138
+ local tableSelectorList = blobsProfiler [luaState ].SQLite .Data .tableSelectorList
139
+ local tableDataListView = blobsProfiler [luaState ].SQLite .Data .tableDataListView
140
+
141
+ tableDataListView :Dock (FILL )
142
+
143
+ tableSelectorList :Dock (TOP )
144
+ tableSelectorList :SetSortItems (false )
145
+
146
+ tableSelectorList .OnSelect = function (s , index , value )
147
+ requestSQLiteData (luaState , value )
148
+ end
149
+
150
+ for k ,v in pairs (schemaDataTable .Tables or {}) do
151
+ tableSelectorList :AddChoice (k )
152
+
153
+ if not tableSelectorList :GetSelected () then
154
+ tableSelectorList :ChooseOption (k , 1 )
155
+ end
156
+ end
157
+ end
66
158
})
67
159
68
160
blobsProfiler .RegisterSubModule (" SQLite" , " Execute" , {
0 commit comments