forked from CEN-RA/Plugin_QGIS
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,
|
settings_connections_names,
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
from CenRa_Metabase.resources.i18n import tr
|
|
||||||
|
|
||||||
from CenRa_Metabase.resources.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
resources_path,
|
||||||
login_base,
|
login_base,
|
||||||
@ -91,18 +90,18 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
|
|
||||||
# Flat table button
|
# Flat table button
|
||||||
self.flatten_dataset_table.setText('')
|
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.setIcon(QgsApplication.getThemeIcon("/mActionAddHtml.svg"))
|
||||||
#self.flatten_dataset_table.clicked.connect(self.add_flatten_dataset_table)
|
#self.flatten_dataset_table.clicked.connect(self.add_flatten_dataset_table)
|
||||||
|
|
||||||
# Settings menu
|
# Settings menu
|
||||||
self.config.setAutoRaise(True)
|
self.config.setAutoRaise(True)
|
||||||
self.config.setToolTip(tr("Settings"))
|
#self.config.setToolTip(tr("Settings"))
|
||||||
self.config.setPopupMode(QToolButton.InstantPopup)
|
self.config.setPopupMode(QToolButton.InstantPopup)
|
||||||
self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
|
self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
|
||||||
|
|
||||||
self.auto_open_dock_action = QAction(
|
self.auto_open_dock_action = QAction(
|
||||||
tr('Auto open dock from locator'),
|
("Dommage, cette option n'existe pas encore."),
|
||||||
iface.mainWindow())
|
iface.mainWindow())
|
||||||
self.auto_open_dock_action.setCheckable(True)
|
self.auto_open_dock_action.setCheckable(True)
|
||||||
self.auto_open_dock_action.setChecked(
|
self.auto_open_dock_action.setChecked(
|
||||||
@ -115,21 +114,21 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
|
|
||||||
# Setting PDF/HTML menu
|
# Setting PDF/HTML menu
|
||||||
self.save_button.setAutoRaise(True)
|
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.setPopupMode(QToolButton.InstantPopup)
|
||||||
self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg')))
|
self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg')))
|
||||||
|
|
||||||
self.save_as_pdf = QAction(
|
self.save_as_pdf = QAction(
|
||||||
tr('Enregistrer en PDF') + '…',
|
('Enregistrer en PDF') + '…',
|
||||||
iface.mainWindow())
|
iface.mainWindow())
|
||||||
self.save_as_pdf.triggered.connect(partial(self.export_dock_content, OutputFormats.PDF))
|
self.save_as_pdf.triggered.connect(partial(self.export_dock_content, OutputFormats.PDF))
|
||||||
|
|
||||||
self.save_as_html = QAction(
|
self.save_as_html = QAction(
|
||||||
tr('Enregistrer en HTML') + '…',
|
('Enregistrer en HTML') + '…',
|
||||||
iface.mainWindow())
|
iface.mainWindow())
|
||||||
self.save_as_html.triggered.connect(partial(self.export_dock_content, OutputFormats.HTML))
|
self.save_as_html.triggered.connect(partial(self.export_dock_content, OutputFormats.HTML))
|
||||||
self.save_as_dcat = QAction(
|
self.save_as_dcat = QAction(
|
||||||
tr('Enregistrer en DCAT') + '…',
|
('Enregistrer en DCAT') + '…',
|
||||||
iface.mainWindow())
|
iface.mainWindow())
|
||||||
self.save_as_dcat.triggered.connect(partial(self.export_dock_content, OutputFormats.DCAT))
|
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()
|
layer_name = iface.activeLayer().name()
|
||||||
|
|
||||||
file_path = os.path.join(
|
file_path = os.path.join(
|
||||||
self.settings.value("UI/lastFileNameWidgetDir"),
|
os.environ['USERPROFILE'],
|
||||||
'{name}.{ext}'.format(name=layer_name, ext=output_format.ext)
|
'Desktop\\{name}.{ext}'.format(name=layer_name, ext=output_format.ext)
|
||||||
)
|
)
|
||||||
output_file = QFileDialog.getSaveFileName(
|
output_file = QFileDialog.getSaveFileName(
|
||||||
self,
|
self,
|
||||||
tr("Enregistrer en {format}").format(format=output_format.label),
|
("Enregistrer en {format}").format(format=output_format.label),
|
||||||
file_path,
|
file_path,
|
||||||
"{label} (*.{ext})".format(
|
"{label} (*.{ext})".format(
|
||||||
label=output_format.label,
|
label=output_format.label,
|
||||||
@ -187,8 +186,8 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
printer.setOutputFileName(output_file_path)
|
printer.setOutputFileName(output_file_path)
|
||||||
self.viewer.print(printer)
|
self.viewer.print(printer)
|
||||||
iface.messageBar().pushSuccess(
|
iface.messageBar().pushSuccess(
|
||||||
tr("Export PDF"),
|
("Export PDF"),
|
||||||
tr(
|
(
|
||||||
"The metadata has been exported as PDF successfully in "
|
"The metadata has been exported as PDF successfully in "
|
||||||
"<a href=\"{}\">{}</a>").format(parent_folder, output_file_path)
|
"<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:
|
with open(output_file[0], "w", encoding='utf8') as file_writer:
|
||||||
file_writer.write(data_str)
|
file_writer.write(data_str)
|
||||||
iface.messageBar().pushSuccess(
|
iface.messageBar().pushSuccess(
|
||||||
tr("Export") + ' ' + output_format.label,
|
("Export") + ' ' + output_format.label,
|
||||||
tr(
|
(
|
||||||
"The metadata has been exported as {format} successfully in "
|
"The metadata has been exported as {format} successfully in "
|
||||||
"<a href=\"{folder}\">{path}</a>").format(
|
"<a href=\"{folder}\">{path}</a>").format(
|
||||||
format=output_format.label, folder=parent_folder, path=output_file_path)
|
format=output_format.label, folder=parent_folder, path=output_file_path)
|
||||||
@ -359,6 +358,10 @@ publisher+
|
|||||||
uri=''
|
uri=''
|
||||||
if uri != '':
|
if uri != '':
|
||||||
if not uri.table():
|
if not uri.table():
|
||||||
|
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.default_html_content_not_pg_layer()
|
||||||
self.save_button.setEnabled(False)
|
self.save_button.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
@ -441,13 +444,16 @@ publisher+
|
|||||||
self.set_html_content(
|
self.set_html_content(
|
||||||
layer.name(), body)
|
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):
|
def default_html_content_not_pg_layer(self):
|
||||||
""" When it's not a PostgreSQL layer. """
|
""" When it's not a PostgreSQL layer. """
|
||||||
self.set_html_content(
|
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):
|
def default_html_content_not_metadata(self):
|
||||||
self.set_html_content(
|
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):
|
def sql_check(self,uri):
|
||||||
cur=login_base()
|
cur=login_base()
|
||||||
@ -479,3 +485,4 @@ publisher+
|
|||||||
data_contact = cur.fetchall()
|
data_contact = cur.fetchall()
|
||||||
cur.close()
|
cur.close()
|
||||||
return data_general[0],data_url,data_contact
|
return data_general[0],data_url,data_contact
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
name=CenRa_Metabase
|
name=CenRa_Metabase
|
||||||
qgisMinimumVersion=3.0
|
qgisMinimumVersion=3.0
|
||||||
description=CenRa_METABASE
|
description=CenRa_METABASE
|
||||||
version=1.2
|
version=1.3
|
||||||
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
|
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
|
||||||
email=si_besoin@cen-rhonealpes.fr
|
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
|
hasProcessingProvider=no
|
||||||
# Uncomment the following line and add your changelog:
|
# 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 are comma separated with spaces allowed
|
||||||
tags=python
|
tags=python
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user