Skip to content

Commit

Permalink
Merge pull request #8 from KipSigei/ui-enhancements-20250117
Browse files Browse the repository at this point in the history
Update DHIS geojson with properties
  • Loading branch information
KipSigei authored Jan 19, 2025
2 parents 0f553dc + efd24f0 commit 0428f07
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions afpolgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def fetch_dhis_org_units(self, api_url, username, password):

while hasData:
params = [
("fields", "id,name,children[id,name],dataSets[id,name],geometry"),
("fields", "id,name,lastUpdated,dimensionItemType,shortName,displayName,children[id,name],dataSets[id,name],geometry"),
("filter", f"level:eq:{cleaned_adm_lvl}"),
("filter", "children:gte:0"),
("page", page),
Expand All @@ -781,7 +781,13 @@ def fetch_dhis_org_units(self, api_url, username, password):
{
"type": "Feature",
"geometry": geometry,
"properties": {},
"properties": {
"name": datum.get("name"),
"lastUpdated": datum.get("lastUpdated"),
"dimensionItemType": datum.get("dimensionItemType"),
"shortName": datum.get("shortName"),
"displayName": datum.get("displayName")
},
}
)
elif not pager.get("nextPage"):
Expand Down Expand Up @@ -824,6 +830,7 @@ def fetch_gts_tracking_rounds_data_handler(self):

# Disable OK button
self.dlg.gtsOkButton.setEnabled(False)
self.dlg.gtsOkButton.repaint()

selected_tracking_round = self.dlg.comboGTSTrackingRounds.currentData()

Expand Down Expand Up @@ -879,18 +886,7 @@ def fetch_gts_tracking_rounds_data_handler(self):
)
else:
hasData = False
self.dlg.gtsProgressBar.setValue(100)
if (
feature_collection["features"]
and len(feature_collection["features"]) == 0
):
self.dlg.gtsProgressBar.setValue(0)
self.iface.messageBar().pushMessage(
"Notice",
"No Data Found",
level=Qgis.Warning,
duration=15,
)
self.dlg.gtsProgressBar.setValue(0)
self.dlg.gtsOkButton.setEnabled(True)
else:
hasData = False
Expand All @@ -899,7 +895,7 @@ def fetch_gts_tracking_rounds_data_handler(self):
"Error",
f"Error fetching data: {response.status_code}",
level=Qgis.Critical,
duration=15,
duration=10,
)
self.dlg.gtsOkButton.setEnabled(True)

Expand All @@ -913,6 +909,18 @@ def fetch_gts_tracking_rounds_data_handler(self):
feature_collection, "gts", "_".join(single_round_name.split(" "))
)
self.dlg.gtsProgressBar.setValue(0)
else:
self.dlg.app_logs.appendPlainText(f"No available Geo Data for Selected Tracking Round")
self.iface.messageBar().pushMessage(
"Notice",
f"No available Geo Data for Selected Tracking Round",
level=Qgis.Warning,
duration=10,
)
self.dlg.gtsOkButton.setEnabled(True)
self.dlg.gtsOkButton.repaint()

self.dlg.gtsProgressBar.setValue(0)

def handle_gts_cancel_btn(self):
self.dlg.gtsProgressBar.setValue(0)
Expand Down Expand Up @@ -1272,6 +1280,10 @@ def fetch_and_save_kobo_data(
self.load_data_to_qgis(feature_collection, cleaned_asset_name, geo_field)
self.dlg.koboPorgressBar.setValue(0)
else:
self.dlg.app_logs.appendPlainText(
"The selected geo field doesn't have geo data"
)

self.iface.messageBar().pushMessage(
"Notice",
f"The selected geo field doesn't have geo data",
Expand Down Expand Up @@ -2236,6 +2248,13 @@ def handle_data_fetched(self, data):
self.dlg.app_logs.appendPlainText(
"The selected geo field doesn't have geo data"
)

self.iface.messageBar().pushMessage(
"Notice",
f"The selected geo field doesn't have geo data",
level=Qgis.Warning,
duration=10,
)
if not self.ona_sync_timer.isActive():
self.dlg.onaOkButton.setEnabled(True)

Expand Down

0 comments on commit 0428f07

Please sign in to comment.