diff --git a/wtss_plugin/controller/assets/save-icon.png b/wtss_plugin/controller/assets/save-icon.png new file mode 100644 index 0000000..bbc5e74 Binary files /dev/null and b/wtss_plugin/controller/assets/save-icon.png differ diff --git a/wtss_plugin/controller/files_export/files_export.py b/wtss_plugin/controller/files_export/files_export.py index d1649b3..91a5163 100644 --- a/wtss_plugin/controller/files_export/files_export.py +++ b/wtss_plugin/controller/files_export/files_export.py @@ -145,6 +145,10 @@ def __init__(self): """Set the default values for files format.""" self.files_format = FilesFormat() + def getExportOptions(self): + """Set options to export result.""" + return ["CSV", "JSON", "Python"] + def generateCode(self, file_name, attributes): """Generate a python code file filling WTSS blank spaces. diff --git a/wtss_plugin/wtss_qgis.py b/wtss_plugin/wtss_qgis.py index acd7109..afa86a9 100644 --- a/wtss_plugin/wtss_qgis.py +++ b/wtss_plugin/wtss_qgis.py @@ -217,6 +217,7 @@ def initControls(self): self.addCanvasControlPoint(self.enabled_click) self.dlg.input_longitude.valueChanged.connect(self.checkFilters) self.dlg.input_latitude.valueChanged.connect(self.checkFilters) + self.selectCoverage() def initLoadingControls(self): """Enable loading label.""" @@ -244,22 +245,25 @@ def initIcons(self): self.dlg.search_button.setIcon(icon) icon = QIcon(str(Path(Config.BASE_DIR) / 'assets' / 'zoom-icon.png')) self.dlg.zoom_selected_point.setIcon(icon) + icon = QIcon(str(Path(Config.BASE_DIR) / 'assets' / 'save-icon.png')) + self.dlg.export_result.setIcon(icon) self.points_layer_icon_path = str(Path(Config.BASE_DIR) / 'assets' / 'marker-icon.png') def initButtons(self): """Init the main buttons to manage services and the results.""" self.dlg.show_help_button.clicked.connect(self.showHelp) self.dlg.show_coverage_description.clicked.connect(self.showCoverageDescription) - self.dlg.export_as_json.clicked.connect(self.exportJSON) - self.dlg.export_as_json.setEnabled(False) - self.dlg.export_as_csv.clicked.connect(self.exportCSV) - self.dlg.export_as_csv.setEnabled(False) - self.dlg.export_as_python.clicked.connect(self.exportPython) - self.dlg.export_as_python.setEnabled(False) + self.dlg.export_result.clicked.connect(self.exportAsType) self.dlg.zoom_selected_point.clicked.connect(self.zoom_to_selected_point) self.dlg.zoom_selected_point.setEnabled(True) self.dlg.search_button.clicked.connect(self.getTimeSeriesButton) self.dlg.search_button.setEnabled(False) + self.initExportOptions() + self.enabledSearchButtons(False) + + def initExportOptions(self): + """Init the combo box select option to export""" + self.dlg.export_result_as_type.addItems(self.files_controls.getExportOptions()) def initHistory(self): """Init and update location history.""" @@ -279,28 +283,6 @@ def initRasterHistory(self): """Add a event listener when a layer is added to check the history of vrt layers.""" QgsProject.instance().layersAdded.connect(self.updateRasterHistory) - def initServices(self): - """Load the wtss server.""" - self.wtss_server_edit = False - self.dlg.wtss_server_label.setText(self.wtss_controls.getService()) - self.dlg.wtss_server_label.setEnabled(self.wtss_server_edit) - self.dlg.wtss_server_label_update.clicked.connect(self.updateService) - self.selectCoverage() - - def updateService(self): - """Edit the selected service.""" - self.wtss_server_edit = not self.wtss_server_edit - self.dlg.wtss_server_label.setEnabled(self.wtss_server_edit) - if self.wtss_server_edit: - self.dlg.coverage_selection.clear() - self.dlg.coverage_selection.setEnabled(False) - self.dlg.bands_scroll.setWidget(QWidget()) - self.dlg.search_button.setEnabled(False) - else: - self.wtss_controls.setService(self.dlg.wtss_server_label.text()) - self.dlg.coverage_selection.setEnabled(True) - self.selectCoverage() - def initRasterPathControls(self): """Init raster path location controls.""" self.enabled_output_path_raster_edit = False @@ -562,6 +544,16 @@ def plotTimeSeries(self): else: self.basic_controls.alert("error", "AttributeError", "The times series service returns empty, no data to show!") + def exportAsType(self): + """Export result based on combo box selection.""" + ext = self.dlg.export_result_as_type.currentText() + if ext == "CSV": + self.exportCSV() + elif ext == "JSON": + self.exportJSON() + elif ext == "Python": + self.exportPython() + def getLayers(self): """Storage the layers in QGIS project.""" self.layers = QgsProject.instance().layerTreeRoot().children() @@ -709,9 +701,8 @@ def addCanvasControlPoint(self, enable): def enabledSearchButtons(self, enable): """Enable the buttons to load time series.""" self.dlg.search_button.setEnabled(enable) - self.dlg.export_as_python.setEnabled(enable) - self.dlg.export_as_csv.setEnabled(enable) - self.dlg.export_as_json.setEnabled(enable) + self.dlg.export_result_as_type.setEnabled(enable) + self.dlg.export_result.setEnabled(enable) def checkFilters(self): """Check if lat lng are selected.""" @@ -755,8 +746,6 @@ def run(self): self.dlg = wtss_qgisDialog() # Init Controls self.initControls() - # Services - self.initServices() # Virtual Raster History self.initRasterHistory() # Output vrt path diff --git a/wtss_plugin/wtss_qgis_dialog_base.ui b/wtss_plugin/wtss_qgis_dialog_base.ui index a043496..1d672d4 100644 --- a/wtss_plugin/wtss_qgis_dialog_base.ui +++ b/wtss_plugin/wtss_qgis_dialog_base.ui @@ -6,8 +6,8 @@ 0 0 - 741 - 510 + 732 + 492 @@ -24,8 +24,8 @@ 0 0 - 741 - 511 + 731 + 491 @@ -45,7 +45,7 @@ 10 - 80 + 10 451 61 @@ -77,60 +77,24 @@ - - - - 10 - 10 - 451 - 61 - - - - Active Service - - - - - 10 - 30 - 331 - 27 - - - - - - - 350 - 30 - 91 - 25 - - - - Update - - - 480 - 410 - 251 + 390 + 241 61 Export result as - + - 90 + 200 30 - 71 + 31 25 @@ -140,44 +104,18 @@ - CSV + - + 10 30 - 71 - 25 - - - - - 9 - - - - JSON - - - - - - 170 - 30 - 71 - 25 + 181 + 27 - - - 9 - - - - Python - @@ -185,8 +123,8 @@ 480 10 - 251 - 391 + 241 + 371 @@ -197,8 +135,8 @@ 10 30 - 231 - 351 + 221 + 331 @@ -210,7 +148,7 @@ 20 - 300 + 280 201 51 @@ -246,9 +184,9 @@ 10 - 150 + 80 451 - 141 + 191 @@ -260,7 +198,7 @@ 10 30 431 - 101 + 151 @@ -272,7 +210,7 @@ 0 0 429 - 99 + 149 @@ -284,8 +222,8 @@ - 100 - 440 + 90 + 420 231 25 @@ -304,7 +242,7 @@ 10 - 360 + 340 451 71 @@ -379,8 +317,8 @@ - 340 - 440 + 330 + 420 31 25 @@ -393,7 +331,7 @@ 250 - 300 + 280 201 51 @@ -576,10 +514,10 @@ - -1 + 5 0 - 741 - 511 + 731 + 491