Skip to content

Commit

Permalink
Update AWOC. Add Sentinel Health Check, MD icons - issue #69
Browse files Browse the repository at this point in the history
  • Loading branch information
freQniK committed Dec 20, 2023
1 parent c8bd1f5 commit 76f6478
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/awoc/datum/world.json
Original file line number Diff line number Diff line change
Expand Up @@ -3960,7 +3960,7 @@
"Area KM2": "780580"
},
{
"Country Name": "Türkiye",
"Country Name": "T\u00FCrkiye",
"ISO2": "TR",
"ISO3": "TUR",
"TLD": "tr",
Expand Down
27 changes: 27 additions & 0 deletions src/cli/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NodeTreeData():
NodeScores = {}
NodeLocations = {}
NodeTypes = {}
NodeHealth = {}

def __init__(self, node_tree):
if not node_tree:
Expand Down Expand Up @@ -117,6 +118,32 @@ def get_nodes(self, latency, *kwargs):
self.GetNodeScores()
self.GetNodeLocations()
self.GetNodeTypes()
self.GetHealthCheckData()


def GetHealthCheckData(self):
Request = HTTPRequests.MakeRequest(TIMEOUT=2)
http = Request.hadapter()
try:
r = http.get(HTTParams.HEALTH_CHECK) #specify a constant in konstants.py
data = r.json()

for nodehealthdata in data['result']:
# integrity check
if nodehealthdata['status'] != 1:
self.NodeHealth[nodehealthdata['addr']] = False
elif "info_fetch_error " in nodehealthdata:
self.NodeHealth[nodehealthdata['addr']] = False
elif "config_exchange_error" in nodehealthdata:
self.NodeHealth[nodehealthdata['addr']] = False
elif "location_fetch_error" in nodehealthdata:
self.NodeHealth[nodehealthdata['addr']] = False
else:
self.NodeHealth[nodehealthdata['addr']] = True


except Exception as e:
print(str(e))

def GetNodeScores(self):
Request = HTTPRequests.MakeRequest(TIMEOUT=3)
Expand Down
1 change: 1 addition & 0 deletions src/geography/continents.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class OurWorld():
'Tajikistan': [38.6281733, 70.8156541],
'Thailand': [14.8971921, 100.83273],
'Turkey': [38.9597594, 34.9249653],
'Türkiye': [38.9597594, 34.9249653],
'United Arab Emirates': [24.0002488, 53.9994829],
'Uzbekistan': [41.32373, 63.9528098],
'Vietnam': [15.9266657, 107.9650855],
Expand Down
19 changes: 14 additions & 5 deletions src/kv/meile.kv
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ WindowManager:
size: "180dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
orientation: "vertical"
padding: 10,10
#padding: 10,10
border_radius: 20
radius: [10]
md_bg_color: get_color_from_hex("#121212")
Expand All @@ -600,6 +600,8 @@ WindowManager:
city: " "
icon: ""
tooltip: ""
healthcheck: ""
healthchecktooltip: ""
ripple_behavior: True
on_press: root.subscribe_to_node(root.price_text, root.hourly_price_text, root.address_text, root.moniker_text)
MDGridLayout:
Expand All @@ -624,10 +626,7 @@ WindowManager:
font_size: "10sp"
text_color: (0/255.0,141/255.0,155/255.0,255/255.0)
pos_hint: {"x" : 0, "top" : 1.125}
TooltipMDIconButton:
icon: root.icon
tooltip_text: root.tooltip
pos_hint: {"x" : .265, "top" : .80}

MDLabel:
text: root.type_text
theme_text_color: "Custom"
Expand Down Expand Up @@ -710,6 +709,16 @@ WindowManager:
pos_hint: {"x" : .44 , "top": .95 }
size_hint: None, .525

TooltipMDIconButton:
icon: root.icon
tooltip_text: root.tooltip
pos_hint: {"x" : .445, "top" : .40}
TooltipMDIconButton:
icon: root.healthcheck
tooltip_text: root.healthchecktooltip
pos_hint: {"x" : .475, "top" : .40 }
size_hint: None, None

MDLabel:
text: root.country_text
theme_text_color: "Custom"
Expand Down
3 changes: 3 additions & 0 deletions src/typedef/konstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HTTParams():
'https://rpc-sentinel-ia.cosmosia.notional.ventures:443']
GRPC = "grpc+http://aimokoivunen.mathnodes.com:9090/"
#GRPC = "grpc+http://128.199.90.172:9090/"
HEALTH_CHECK = "https://api.health.sentinel.co/v1/records"
NODE_SCORE_ENDPOINT = "/api/nodescores"
NODE_LOCATION_ENDPOINT = "/api/nodelocations"
NODE_TYPE_ENDPOINT = "/api/nodetypes"
Expand Down Expand Up @@ -74,6 +75,8 @@ class MeileColors():
INACTIVE_DIALOG_BG_COLOR = "#50507c"
FONT_FACE = "fonts/mplus-2c-bold.ttf"
MAP_MARKER = "imgs/location_pin.png"
HEALTH_ICON = "shield-plus"
SICK_ICON = "emoticon-sick"


class NodeKeys():
Expand Down
14 changes: 14 additions & 0 deletions src/ui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,18 @@ def add_rv_data(self, node, flagloc):
IconButton = "alpha-r-circle"
ToolTipText = "Residential"

if node[NodeKeys.NodesInfoKeys[1]].lstrip().rstrip() in self.NodeTree.NodeHealth:
if self.NodeTree.NodeHealth[node[NodeKeys.NodesInfoKeys[1]].lstrip().rstrip()]:
HealthButton = MeileColors.HEALTH_ICON
HealthToolTip = "Passed Sentinel Health Check"
else:
HealthButton = MeileColors.SICK_ICON
HealthToolTip = "Failed Sentinel Health Check"

else:
HealthButton = MeileColors.SICK_ICON
HealthToolTip = "Failed Sentinel Health Check"

self.ids.rv.data.append(
{
"viewclass" : "RecycleViewRow",
Expand All @@ -1451,6 +1463,8 @@ def add_rv_data(self, node, flagloc):
"city" : city,
"icon" : IconButton,
"tooltip" : ToolTipText,
"healthcheck" : HealthButton,
"healthchecktooltip" : HealthToolTip,
"speed_image" : self.MeileConfig.resource_path(speedimage),
"source_image" : self.MeileConfig.resource_path(flagloc)

Expand Down

0 comments on commit 76f6478

Please sign in to comment.