Skip to content

Commit

Permalink
Add Node Screen Carousel UI. Add MathNodes Node Formula API request. …
Browse files Browse the repository at this point in the history
…Some clean-up
  • Loading branch information
freQniK committed Mar 22, 2024
1 parent e4bda9b commit 1fae74a
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 21 deletions.
18 changes: 18 additions & 0 deletions src/cli/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class NodeTreeData():
NodeLocations = {}
NodeTypes = {}
NodeHealth = {}
NodeFormula = {}

def __init__(self, node_tree):
if not node_tree:
Expand Down Expand Up @@ -122,6 +123,9 @@ def get_nodes(self, latency, *kwargs):
# Not loading all the data here is a 2x improvement on loadtime
#self.GetHealthCheckData()

# Get MathNodes NodeFormula
self.GetNodeFormula()

def GetHealthCheckData(self):
Request = HTTPRequests.MakeRequest(TIMEOUT=4)
http = Request.hadapter()
Expand Down Expand Up @@ -172,6 +176,20 @@ def GetNodeLocations(self):

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

def GetNodeFormula(self):
Request = HTTPRequests.MakeRequest(TIMEOUT=4)
http = Request.hadapter()
try:
r = http.get(HTTParams.SERVER_URL + HTTParams.NODE_FORMULA_ENDPOINT)
data = r.json()

for nlist in data['data']:
#k=0
self.NodeFormula[nlist[0]] = nlist[6]

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

def GetNodeTypes(self):
Request = HTTPRequests.MakeRequest(TIMEOUT=2)
Expand Down
237 changes: 236 additions & 1 deletion src/kv/meile.kv
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,238 @@ WindowManager:
height: 50
adaptive_height: True

<NodeCarousel>:
name: "node_carousel"
MDBoxLayout:
orientation: "vertical"
MDGridLayout:
rows: 3
cols: 2
orientation: 'lr-tb'
size_hint_y: .15
MDLabel:
text: root.moniker
#size_hint_x: .9
theme_text_color: "Custom"
text_color: get_color_from_hex("#fcb711")
font_size: sp(25)
font_name: "../../src/fonts/arial-unicode-ms.ttf"
AnchorLayout:
anchor_x: "right"
TooltipMDIconButton:
icon: "spider-web"
tooltip_text: "Map"
#size_hint_x: .01
theme_text_color: "Custom"
text_color: get_color_from_hex("#fcb711")
on_press: root.switch_carousel()
HSeparator:
HSeparator:
MDLabel:
text: root.address
size_hint_x: .95
font_size: sp(11)
MDFloatLayout
size_hint_y: 1

MDBoxLayout:
orientation: "vertical"
size_hint_x: .6
size_hint_y: .95
spacing: 30
MDBoxLayout:
size_hint_y: .125
MDGridLayout
cols: 2

MDLabel:
text: "[b]Gigabyte Prices[/b]"
halign: "center"
markup: True

MDLabel:
text: "[b]Hourly Prices[/b]"
halign: "center"
markup: True

MDLabel:
text: root.gb_prices
halign: "center"
font_size: sp(12)

MDLabel:
text: root.hr_prices
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]Bandwidth Down[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Bandwidth Up[/b]"
halign: "center"
markup: True
MDLabel:
text: root.download
halign: "center"
font_size: sp(12)
MDLabel:
text: root.upload
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]Connected Peers[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Max Peers[/b]"
halign: "center"
markup: True
MDLabel:
text: root.connected_peers
halign: "center"
font_size: sp(12)
MDLabel:
text: root.max_peers
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]Protocol[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Version[/b]"
halign: "center"
markup: True
MDLabel:
text: root.protocol
halign: "center"
font_size: sp(12)
MDLabel:
text: root.version
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]Handshake[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Health Check[/b]"
halign: "center"
markup: True
MDLabel:
text: root.handshake
halign: "center"
font_size: sp(12)
MDLabel:
text: root.health_check
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]ISP Type[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Formula[/b]"
halign: "center"
markup: True
MDLabel:
text: root.isp_type
halign: "center"
font_size: sp(12)
MDLabel:
text: root.node_formula
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .03
MDGridLayout
cols: 2
rows: 2
MDLabel:
text: "[b]Votes[/b]"
halign: "center"
markup: True
MDLabel:
text: "[b]Score[/b]"
halign: "center"
markup: True
MDLabel:
text: root.votes
halign: "center"
font_size: sp(12)
MDLabel:
text: root.score
halign: "center"
font_size: sp(12)
MDBoxLayout:
size_hint_y: .1

MapView:
id: mapview
lat: 48.849943
lon: 2.279793
zoom: 8
size_hint: .4, .6
pos_hint: {"x": .575, "y": .4}

MDLabel:
text: root.location
pos_hint: {"x" : .7, "y": -.125}
markup: True

MDFlatButton:
md_bg_color: get_color_from_hex("#121212")
pos_hint: {'x' : .67, 'y': .275}
Image:
id: subscribe_button
size_hint: 3,3
source: "../../src/imgs/SubscribeButton.png"

MDFlatButton:
md_bg_color: get_color_from_hex("#121212")
pos_hint: {'x' : .87, 'y': .275}
Image:
id: subscribe_button
size_hint: 3,3
source: "../../src/imgs/GetInfoButton.png"
<Separator@Widget>:
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
<HSeparator@Separator>:
size_hint_y: None
height: dp(2)


<RecycleViewRow>:
size_hint_y: None
#size: "180dp", "180dp"
Expand Down Expand Up @@ -925,8 +1156,12 @@ WindowManager:
tooltip: ""
healthcheck: ""
healthchecktooltip: ""
node_data: ""
node_types: ""
node_scores: ""
ripple_behavior: True
on_press: root.subscribe_to_node(root.price_text, root.hourly_price_text, root.address_text, root.moniker_text)
#on_press: root.subscribe_to_node(root.price_text, root.hourly_price_text, root.address_text, root.moniker_text)
on_press: root.switch_to_node_carousel(root.node_data, root.node_types, root.node_scores, root.node_formula)
MDGridLayout:
cols: 5

Expand Down
4 changes: 3 additions & 1 deletion src/typedef/konstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class HTTParams():
'https://rpc.sentinel.quokkastake.io:443', 'https://rpc-sentinel.whispernode.com: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"
HEALTH_CHECK = "https://api.health.sentinel.co/v1/records/%s"
NODE_SCORE_ENDPOINT = "/api/nodescores"
NODE_LOCATION_ENDPOINT = "/api/nodelocations"
NODE_TYPE_ENDPOINT = "/api/nodetypes"
NODE_FORMULA_ENDPOINT = "/api/nodeformula"
API_PING_ENDPOINT = "/api/ping"
API_RATING_ENDPOINT = "/api/rating"
SESSIONS_API_URL = '/sentinel/accounts/%s/sessions'
Expand Down Expand Up @@ -90,6 +91,7 @@ class MeileColors():
HEALTH_ICON = "shield-plus"
SICK_ICON = "emoticon-sick"
ARCGIS_MAP = "https://server.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}.png"
ARCGIS_MAP2 = "https://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}.png"

class NodeKeys():
'''v1.8.0
Expand Down
1 change: 1 addition & 0 deletions src/typedef/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class WindowNames():
FIAT = "fiatgateway"
SUBSCRIPTIONS = "subscriptions"
SETTINGS = "settings"
NODE_CAROUSEL = "node_carousel"


class CoinsList():
Expand Down
Loading

0 comments on commit 1fae74a

Please sign in to comment.