Téléverser les fichiers vers "CenRa_Metabase"
This commit is contained in:
parent
839eb525e4
commit
f831f2e5a3
@ -46,9 +46,8 @@ from pg_metadata.connection_manager import (
|
||||
settings_connections_names,
|
||||
)
|
||||
'''
|
||||
from CenRa_Metabase.resources.i18n import tr
|
||||
|
||||
from CenRa_Metabase.resources.resources import (
|
||||
from .tools.resources import (
|
||||
load_ui,
|
||||
resources_path,
|
||||
login_base,
|
||||
@ -91,18 +90,18 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
||||
|
||||
# Flat table button
|
||||
self.flatten_dataset_table.setText('')
|
||||
self.flatten_dataset_table.setToolTip(tr("Add the catalog table"))
|
||||
#self.flatten_dataset_table.setToolTip(tr("Add the catalog table"))
|
||||
self.flatten_dataset_table.setIcon(QgsApplication.getThemeIcon("/mActionAddHtml.svg"))
|
||||
#self.flatten_dataset_table.clicked.connect(self.add_flatten_dataset_table)
|
||||
|
||||
# Settings menu
|
||||
self.config.setAutoRaise(True)
|
||||
self.config.setToolTip(tr("Settings"))
|
||||
#self.config.setToolTip(tr("Settings"))
|
||||
self.config.setPopupMode(QToolButton.InstantPopup)
|
||||
self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
|
||||
|
||||
self.auto_open_dock_action = QAction(
|
||||
tr('Auto open dock from locator'),
|
||||
("Dommage, cette option n'existe pas encore."),
|
||||
iface.mainWindow())
|
||||
self.auto_open_dock_action.setCheckable(True)
|
||||
self.auto_open_dock_action.setChecked(
|
||||
@ -115,21 +114,21 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
||||
|
||||
# Setting PDF/HTML menu
|
||||
self.save_button.setAutoRaise(True)
|
||||
self.save_button.setToolTip(tr("Save metadata"))
|
||||
#self.save_button.setToolTip(tr("Save metadata"))
|
||||
self.save_button.setPopupMode(QToolButton.InstantPopup)
|
||||
self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg')))
|
||||
|
||||
self.save_as_pdf = QAction(
|
||||
tr('Enregistrer en PDF') + '…',
|
||||
('Enregistrer en PDF') + '…',
|
||||
iface.mainWindow())
|
||||
self.save_as_pdf.triggered.connect(partial(self.export_dock_content, OutputFormats.PDF))
|
||||
|
||||
self.save_as_html = QAction(
|
||||
tr('Enregistrer en HTML') + '…',
|
||||
('Enregistrer en HTML') + '…',
|
||||
iface.mainWindow())
|
||||
self.save_as_html.triggered.connect(partial(self.export_dock_content, OutputFormats.HTML))
|
||||
self.save_as_dcat = QAction(
|
||||
tr('Enregistrer en DCAT') + '…',
|
||||
('Enregistrer en DCAT') + '…',
|
||||
iface.mainWindow())
|
||||
self.save_as_dcat.triggered.connect(partial(self.export_dock_content, OutputFormats.DCAT))
|
||||
|
||||
@ -160,12 +159,12 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
||||
layer_name = iface.activeLayer().name()
|
||||
|
||||
file_path = os.path.join(
|
||||
self.settings.value("UI/lastFileNameWidgetDir"),
|
||||
'{name}.{ext}'.format(name=layer_name, ext=output_format.ext)
|
||||
os.environ['USERPROFILE'],
|
||||
'Desktop\\{name}.{ext}'.format(name=layer_name, ext=output_format.ext)
|
||||
)
|
||||
output_file = QFileDialog.getSaveFileName(
|
||||
self,
|
||||
tr("Enregistrer en {format}").format(format=output_format.label),
|
||||
("Enregistrer en {format}").format(format=output_format.label),
|
||||
file_path,
|
||||
"{label} (*.{ext})".format(
|
||||
label=output_format.label,
|
||||
@ -187,8 +186,8 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
||||
printer.setOutputFileName(output_file_path)
|
||||
self.viewer.print(printer)
|
||||
iface.messageBar().pushSuccess(
|
||||
tr("Export PDF"),
|
||||
tr(
|
||||
("Export PDF"),
|
||||
(
|
||||
"The metadata has been exported as PDF successfully in "
|
||||
"<a href=\"{}\">{}</a>").format(parent_folder, output_file_path)
|
||||
)
|
||||
@ -212,8 +211,8 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
||||
with open(output_file[0], "w", encoding='utf8') as file_writer:
|
||||
file_writer.write(data_str)
|
||||
iface.messageBar().pushSuccess(
|
||||
tr("Export") + ' ' + output_format.label,
|
||||
tr(
|
||||
("Export") + ' ' + output_format.label,
|
||||
(
|
||||
"The metadata has been exported as {format} successfully in "
|
||||
"<a href=\"{folder}\">{path}</a>").format(
|
||||
format=output_format.label, folder=parent_folder, path=output_file_path)
|
||||
@ -359,7 +358,11 @@ publisher+
|
||||
uri=''
|
||||
if uri != '':
|
||||
if not uri.table():
|
||||
self.default_html_content_not_pg_layer()
|
||||
layertype = layer.providerType().lower()
|
||||
if layertype == 'wms' or layertype == 'wfs':
|
||||
self.set_html_to_wms(layer)
|
||||
else:
|
||||
self.default_html_content_not_pg_layer()
|
||||
self.save_button.setEnabled(False)
|
||||
else:
|
||||
data_count = self.sql_check(uri)
|
||||
@ -441,13 +444,16 @@ publisher+
|
||||
self.set_html_content(
|
||||
layer.name(), body)
|
||||
|
||||
def set_html_to_wms(self,layer):
|
||||
self.set_html_content(
|
||||
'CenRa Metadata',(layer.htmlMetadata()))
|
||||
def default_html_content_not_pg_layer(self):
|
||||
""" When it's not a PostgreSQL layer. """
|
||||
self.set_html_content(
|
||||
'CenRa Metadata', tr('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.'))
|
||||
'CenRa Metadata', ('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.'))
|
||||
def default_html_content_not_metadata(self):
|
||||
self.set_html_content(
|
||||
'CenRa Metadata', tr('La couche ne contien pas de métadonnée.'))
|
||||
'CenRa Metadata', ('La couche ne contien pas de métadonnée.'))
|
||||
|
||||
def sql_check(self,uri):
|
||||
cur=login_base()
|
||||
@ -479,3 +485,4 @@ publisher+
|
||||
data_contact = cur.fetchall()
|
||||
cur.close()
|
||||
return data_general[0],data_url,data_contact
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
name=CenRa_Metabase
|
||||
qgisMinimumVersion=3.0
|
||||
description=CenRa_METABASE
|
||||
version=1.2
|
||||
version=1.3
|
||||
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
|
||||
email=si_besoin@cen-rhonealpes.fr
|
||||
|
||||
@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
|
||||
|
||||
hasProcessingProvider=no
|
||||
# Uncomment the following line and add your changelog:
|
||||
changelog=<h2>CenRa_Metabase:</h2></br><p><h3>07/10/2024 - Version 1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 1.0: </h3> - Lancement du plugin CenRa_Metabase </p></br>
|
||||
changelog=<h2>CenRa_Metabase:</h2></br><p><h3>08/10/2024 - Version 1.3: </h3> - Lecture de métadonnée des flux WMS/WFS.</p></br><p><h3>07/10/2024 - Version 1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 1.0: </h3> - Lancement du plugin CenRa_Metabase </p></br>
|
||||
|
||||
# Tags are comma separated with spaces allowed
|
||||
tags=python
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user