mirror of
https://github.com/KeymonSoft/Monitor-Keymon.git
synced 2026-04-17 21:06:19 +00:00
- VERSION 4.11.30
- Se quitaron librerias y permisos que no se usaban. - Se agregó la opción de monitorear mas de un servidor.
This commit is contained in:
@@ -35,8 +35,8 @@ Sub Class_Globals
|
||||
Private p_estatus As Panel
|
||||
Dim cb_conexion As CheckBox
|
||||
Dim cb_internet As CheckBox
|
||||
Dim cb_dbreqserver As CheckBox
|
||||
Dim cb_db As CheckBox
|
||||
' Dim cb_dbreqserver As CheckBox
|
||||
' Dim cb_db As CheckBox
|
||||
' Private b_intervalo As Button
|
||||
' Private b_server As Button
|
||||
Private et_server As EditText
|
||||
@@ -60,6 +60,19 @@ Sub Class_Globals
|
||||
Private l_server As Label
|
||||
Private l_info As Label
|
||||
Private b_guardaCambios As Button
|
||||
Dim servidores As List
|
||||
Dim lv_servidores As ListView
|
||||
Dim lbl, lbl2, lbl3 As B4XView
|
||||
Private p_dbreqServidores As Panel
|
||||
Private l_db As Label
|
||||
Private l_dbreqServer As Label
|
||||
Dim lv_dbs As ListView
|
||||
Private p_dbs As Panel
|
||||
Private p_servidoresActivos As Panel
|
||||
Private lv_servidoresActivos As ListView
|
||||
Dim jsn As JSONParser
|
||||
Dim jsnGnr As JSONGenerator
|
||||
DIM rp AS RuntimePermissions
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
@@ -74,9 +87,9 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
B4XPages.AddPage("Login", login)
|
||||
s.Initialize
|
||||
l_version.Text = Application.VersionName
|
||||
lv_server.AddSingleLine("http://keymon.lat:1782")
|
||||
lv_server.AddSingleLine("http://10.0.0.205:1782")
|
||||
lv_server.AddSingleLine("http://40.123.36.38:1782")
|
||||
' lv_server.AddSingleLine("http://keymon.lat:1782")
|
||||
' lv_server.AddSingleLine("http://10.0.0.205:1782")
|
||||
' lv_server.AddSingleLine("http://40.123.36.38:1782")
|
||||
|
||||
clv_server.Add(CreateListItem("http://keymon.lat:1782", clv_server.AsView.Width, 35dip), "http://keymon.lat:1782")
|
||||
clv_server.Add(CreateListItem("http://10.0.0.205:1782", clv_server.AsView.Width, 35dip), "http://10.0.0.205:1782")
|
||||
@@ -86,14 +99,53 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
logger = False
|
||||
#end if
|
||||
s.centraEtiqueta(l_info, Root.Width)
|
||||
servidores.Initialize
|
||||
' Private srv1 As Map = CreateMap("nombre": "1781", "servidor": "http://keymon.lat:1781", "intervalo": 30, "timeout": 11000)
|
||||
' Private srv2 As Map = CreateMap("nombre": "1782", "servidor": "http://keymon.lat:1782", "intervalo": 30, "timeout": 11000)
|
||||
' Private srv3 As Map = CreateMap("nombre": "1783", "servidor": "http://keymon.lat:1783", "intervalo": 30, "timeout": 11000)
|
||||
' servidores.AddAll(Array As Object (srv1, srv2, srv3))
|
||||
' Private srvrsMap As Map
|
||||
' srvrsMap.Initialize
|
||||
' srvrsMap.Put("1781", srv1)
|
||||
' srvrsMap.Put("1782", srv2)
|
||||
' srvrsMap.Put("1783", srv3)
|
||||
' Starter.skmt.ExecNonQuery($"delete from cat_variables where nombre = 'servidores'"$)
|
||||
' jsnGnr.Initialize2(servidores)
|
||||
' Starter.skmt.ExecNonQuery($"insert into cat_variables (nombre, valor) values ("servidores", '${jsnGnr.ToString}')"$)
|
||||
|
||||
|
||||
' Starter.skmt.ExecNonQuery("insert into cat_servidores (nombre, url, intervalo, timeout) values ('1781', 'http://keymon.lat:1781', '30', '11000')")
|
||||
' Starter.skmt.ExecNonQuery("insert into cat_servidores (nombre, url, intervalo, timeout) values ('1782', 'http://keymon.lat:1782', '30', '11000')")
|
||||
' Starter.skmt.ExecNonQuery("insert into cat_servidores (nombre, url, intervalo, timeout) values ('1783', 'http://keymon.lat:1783', '30', '11000')")
|
||||
lv_servidores.SingleLineLayout.ItemHeight = 22dip
|
||||
lbl = lv_servidores.SingleLineLayout.Label
|
||||
lbl.TextColor = Colors.black
|
||||
lbl.SetTextAlignment("CENTER", "CENTER")
|
||||
lbl.TextSize = 14
|
||||
lv_dbs.SingleLineLayout.ItemHeight = 22dip
|
||||
lbl2 = lv_dbs.SingleLineLayout.Label
|
||||
lbl2.TextColor = Colors.black
|
||||
lbl2.SetTextAlignment("CENTER", "CENTER")
|
||||
lbl2.TextSize = 14
|
||||
lv_servidoresActivos.SingleLineLayout.ItemHeight = 30dip
|
||||
lbl3 = lv_servidoresActivos.SingleLineLayout.Label
|
||||
lbl3.TextColor = Colors.black
|
||||
lbl3.SetTextAlignment("CENTER", "CENTER")
|
||||
lbl3.TextSize = 16
|
||||
p_dbreqServidores.Left = (p_estatus.Width / 2) - (lv_servidores.Width / 2)
|
||||
lv_servidores.Top = 10
|
||||
lv_servidores.Left = 0
|
||||
s.centraEtiqueta(l_dbreqServer, p_estatus.Width)
|
||||
s.centraEtiqueta(l_db, p_estatus.Width)
|
||||
s.borraArribaDeXXXErrores(3000)
|
||||
rp.CheckAndRequest(rp.PERMISSION_POST_NOTIFICATIONS)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) 'change to Activity_PermissionResult if non-B4XPages.
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
' reqManager.Initialize(Me, Starter.DBReqServer)
|
||||
cd1.Initialize(Colors.RGB(16, 141, 0), 10dip)
|
||||
b_ping.Background = cd1
|
||||
' bu.Initialize
|
||||
' batterystatus = bu.BatteryInformation
|
||||
b_monitorActivo.Left = (Root.Width / 2) - (b_monitorActivo.Width / 2)
|
||||
b_ping.Left = (Root.Width / 2) - (b_ping.Width / 2)
|
||||
s.centraPanel(p_estatus, Root.Width)
|
||||
@@ -101,25 +153,25 @@ Sub B4XPage_Appear
|
||||
s.centraEtiqueta(l_ultimoPing, Root.Width)
|
||||
' s.centraPanel(p_intervalo, Root.Width)
|
||||
s.centraEtiqueta(Label1, Root.Width)
|
||||
If Not(CheckNotificationAccess) Then
|
||||
Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True)
|
||||
Wait For Msgbox_Result (resultado As Int)
|
||||
If resultado = DialogResponse.POSITIVE Then
|
||||
b_notifAccess_Click
|
||||
End If
|
||||
Private cd1 As ColorDrawable
|
||||
cd1.Initialize(Colors.red, 10dip)
|
||||
b_notifAccess.Background = cd1
|
||||
b_notifAccess.TextColor = Colors.White
|
||||
b_notifAccess.Text = "Activar Permisos"
|
||||
Else
|
||||
Private cd1 As ColorDrawable
|
||||
cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
|
||||
b_notifAccess.Background = cd1
|
||||
b_notifAccess.TextColor = Colors.White
|
||||
b_notifAccess.Text = "Permisos Activos"
|
||||
End If
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
' If Not(CheckNotificationAccess) Then
|
||||
' Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True)
|
||||
' Wait For Msgbox_Result (resultado As Int)
|
||||
' If resultado = DialogResponse.POSITIVE Then
|
||||
' b_notifAccess_Click
|
||||
' End If
|
||||
' Private cd1 As ColorDrawable
|
||||
' cd1.Initialize(Colors.red, 10dip)
|
||||
' b_notifAccess.Background = cd1
|
||||
' b_notifAccess.TextColor = Colors.White
|
||||
' b_notifAccess.Text = "Activar Permisos"
|
||||
' Else
|
||||
' Private cd1 As ColorDrawable
|
||||
' cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
|
||||
' b_notifAccess.Background = cd1
|
||||
' b_notifAccess.TextColor = Colors.White
|
||||
' b_notifAccess.Text = "Permisos Activos"
|
||||
' End If
|
||||
' CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
@@ -135,11 +187,11 @@ End Sub
|
||||
|
||||
'Revisa si la aplicación tiene permiso para acceder a las notificaciones.
|
||||
Sub CheckNotificationAccess As Boolean
|
||||
Dim nstr, pstr As String
|
||||
Dim r As Reflector
|
||||
pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
|
||||
nstr = ph.GetSettings("enabled_notification_listeners")
|
||||
Return nstr.Contains(pstr)
|
||||
' Dim nstr, pstr As String
|
||||
' Dim r As Reflector
|
||||
' pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
|
||||
' nstr = ph.GetSettings("enabled_notification_listeners")
|
||||
' Return nstr.Contains(pstr)
|
||||
End Sub
|
||||
|
||||
Private Sub tb_monitorActivo_CheckedChange(Checked As Boolean)
|
||||
@@ -209,6 +261,15 @@ Private Sub i_engrane_Click
|
||||
et_timeout.Text = s.traeTimeoutDeBD
|
||||
p_engrane.Width = Root.Width
|
||||
p_engrane.Height = Root.Height
|
||||
Private sa As Cursor = Starter.skmt.ExecQuery("select * from cat_servidores")
|
||||
If sa.RowCount > 0 Then
|
||||
lv_servidoresActivos.Clear
|
||||
For i = 0 To sa.RowCount - 1
|
||||
sa.Position = i
|
||||
lv_servidoresActivos.AddSingleLine(sa.GetString("url"))
|
||||
Next
|
||||
End If
|
||||
|
||||
s.panelVisible(p_engrane, 0, 0)
|
||||
End Sub
|
||||
|
||||
@@ -221,7 +282,7 @@ Private Sub b_ping_Click
|
||||
b_ping.Background = cd1
|
||||
b_ping.Text = "Buscando ..."
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
CallSubDelayed(Monitor, "probamosConexion")
|
||||
' CallSubDelayed(Monitor, "probamosConexion")
|
||||
' Wait For (ph.ShellAsync("ping", Array As String("-c 1","-W 2", "8.8.8.8"))) Complete (Success As Boolean, ExitValue As Int, StdOut As String, StdErr As String)
|
||||
' If Success Then
|
||||
' Log("ExitValue:" & ExitValue)
|
||||
@@ -243,9 +304,9 @@ End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
Sub b_notifAccess_Click
|
||||
Dim In As Intent
|
||||
In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
|
||||
StartActivity(In)
|
||||
' Dim In As Intent
|
||||
' In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
|
||||
' StartActivity(In)
|
||||
End Sub
|
||||
|
||||
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel 'ignore
|
||||
@@ -287,7 +348,9 @@ Private Sub b_guardaCambios_Click
|
||||
Monitor.Interval = et_intervalo.text
|
||||
Starter.skmt.ExecNonQuery($"delete from cat_variables where nombre = 'intervalo'"$)
|
||||
Starter.skmt.ExecNonQuery($"insert into cat_variables (nombre, valor) values ("intervalo", '${et_intervalo.text}')"$)
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
Starter.skmt.ExecNonQuery($"delete from cat_servidores where url = '${et_server.text}'"$)
|
||||
Starter.skmt.ExecNonQuery($"insert into cat_servidores (url, intervalo, timeout) values ('${et_server.text}', '${et_intervalo.text}', '${et_timeout.text}')"$)
|
||||
' CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
p_engrane.Visible = False
|
||||
'Guardamos DBReqServer
|
||||
Starter.DBReqServer = et_server.text
|
||||
@@ -295,7 +358,7 @@ Private Sub b_guardaCambios_Click
|
||||
Starter.skmt.ExecNonQuery($"insert into cat_variables (nombre, valor) values ("servidor", '${et_server.text}')"$)
|
||||
CallSubDelayed(Monitor, "reinicializaReqManager")
|
||||
p_engrane.Visible = False
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
' CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
'Guardamos Timeout
|
||||
Monitor.timeout = et_timeout.text
|
||||
Starter.skmt.ExecNonQuery($"delete from cat_variables where nombre = 'timeout'"$)
|
||||
@@ -303,4 +366,24 @@ Private Sub b_guardaCambios_Click
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
p_engrane.Visible = False
|
||||
ToastMessageShow($"Cambios guardados"$, False)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub lv_servidoresActivos_ItemClick (Position As Int, Value As Object)
|
||||
Private sa As Cursor = Starter.skmt.ExecQuery($"select * from cat_servidores where url = '${Value}'"$)
|
||||
If sa.RowCount > 0 Then
|
||||
sa.Position = 0
|
||||
et_server.Text = sa.GetString("url")
|
||||
et_intervalo.Text = sa.GetString("intervalo")
|
||||
et_timeout.Text = sa.GetString("timeout")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub lv_servidoresActivos_ItemLongClick (Position As Int, Value As Object)
|
||||
Msgbox2Async($"Esta seguro que desea borrar el servidor ${Value}"$, "AVISO", "SI", "", "NO", Null, True)
|
||||
Wait For Msgbox_Result (Result As Int)
|
||||
If Result = DialogResponse.POSITIVE Then
|
||||
Starter.skmt.ExecNonQuery($"delete from cat_servidores where url = '${Value}'"$)
|
||||
i_engrane_Click
|
||||
End If
|
||||
End Sub
|
||||
Reference in New Issue
Block a user