import type { MFPCapabilitiesLayout, MFPCapabilitiesLayoutAttribute } from './tools/MFPTypes.js'; import GirafeHTMLElement from '../../base/GirafeHTMLElement.js'; import IGirafePanel from '../../tools/state/igirafepanel.js'; /** * Print panel component. * Read print capabilities and generate options from it. * Be able to print the content on the map, based on the layer tree and the OL map. * Have actions on the print mask and on the map (rotation). */ declare class PrintComponent extends GirafeHTMLElement implements IGirafePanel { templateUrl: null; styleUrls: null; template: () => import("uhtml").Hole; isPanelVisible: boolean; panelTitle: string; panelTogglePath: string; private readonly default_dpi; private readonly default_scale; private readonly default_resolution; private readonly default_format; private readonly eventsCallbacks; private readonly eventKeys; private printManager?; private readonly printList; private printUrl?; private capabilities?; private configAttributeNames; private printMaskManager?; private isWithCapabilitiesComponentSetup; private hasErrorFetchingCapabilities; protected showCustomScale: boolean; protected attributeNames: string[]; protected printFormats: string[]; protected layouts: MFPCapabilitiesLayout[]; protected selectedLayout?: MFPCapabilitiesLayout; protected scales: number[]; protected dpis: number[]; protected hasRestrictedLayers: boolean; constructor(); protected connectedCallback(): void; /** * Render the component regarding its visibility. * Fetch the print capabilities at first rendering, then render the print mask too and register to events. */ render(): void; /** * @returns {string} The render state. * - 'error' if there was an error fetching the capabilities. * - 'setup' if the capabilities have been set up. * - 'loading' if the capabilities are being fetched. */ getRenderState(): string; /** * Update the values relative to the layout (attributes, scales, etc.) * Set scale and print format in the state. * Renders the panel with new info. */ onLayoutChanged(event: KeyboardEvent): void; /** * Set selected scale in the state and update the mask. */ onScaleChanged(event: KeyboardEvent): void; onCustomScaleTyped(evt: KeyboardEvent): void; /** * @Returns the current print scale. */ getSelectedScale(): number | null; /** * @Returns the current print format value. */ getSelectedFormat(): string | null; /** * @Returns the current print dpi value. */ getSelectedDpi(): number | null; /** * Set selected print format. */ onFormatChanged(event: Event): void; /** * Set selected dpi format. */ onDpiChanged(event: Event): void; /** * @returns {number} The rotation angle in degrees, from the map. */ getRotation(): number; /** * Sync both rotation inputs and update the map rotation value. */ onInputRotationChanged(event: Event): void; /** * @returns The matching attribute in the selected "capabilities" layout. */ getCapabilitiesAttribute(attributeName: string): MFPCapabilitiesLayoutAttribute | undefined; /** * Used to know the matching HTML element. * @returns An arbitrary type based on the matching "capabilities" attribute. */ getAttributeInputType(attributeName: string): "number" | "text" | "textarea" | "checkbox"; /** * Legacy fix for attrName i18n. */ attrNameForI18n(attrName: string): string; /** * Prints the current map state regarding every print options. * Can add datasource (based on selection) and a legend. * The status will be tracked until finished. */ print(): void; /** * On print element clicked: * - Download it on success * - Do nothing otherwise element. */ onPrintElementClicked(itemId: string): void; /** * Removes the print element with the specified itemId from the printList array. * Cancel the print if is it not finished. */ onCancelPrintElementClicked(itemId: string): void; /** * Renders the component by calling the necessary methods. * @private */ private renderComponent; /** * Renders the component capabilities part, like the mask and the capabilities related elements. * Loads the capabilities and the initial config if not already loaded. * @private */ private renderComponentCapabilitiesPart; /** * Setup "visible" component (with capabilities) related functions. * Do not update things related to the panel itself (that would need another render()). * @private */ private setupWithCapabilitiesComponent; /** * Renders an empty component when it's not visible. * Destroy not-visibility related events. * @private */ private renderEmptyComponent; /** * Sets up the print manager if it doesn't already exist. * @private */ private setupPrintManager; /** * Listen events that must be listened if the print panel is visible. * @private */ private registerEvents; private verifyRestrictedLayers; /** * Set the visibility of the panel. * @private */ togglePanel(visible: boolean): void; /** * Update the input rotation value from the map rotation value. */ private updateInputRotationFromMap; /** * Sync both rotation inputs and update the map rotation value (except if the value is * provided, meaning the map already has the right rotation). * @private */ private setRotation; /** * @returns The URL to fetch the print capabilities. * @private */ private getCapabilitiesUrl; /** * @returns a pending or finished PrintElement by id. * @private */ private getPrintElement; /** * Load the application config and then fetch the capabilities and initialize the print. * @private */ private initComponentConfig; /** * @returns the fetched print capabilities or undefined in case of error. * @private /*/ private fetchCapabilities; /** * Init the print component default values with the print capabilities. * @private */ private initFromCapabilities; /** * Initializes the print formats and default selected format based on the configuration. * @private */ private initFormats; /** * Whitelist the available layouts with the config.print.layouts, or allows every of them. * @private */ private initLayouts; /** * @returns The capabilities layout with the specified name, or undefined if not found. */ private getCapabilitiesLayout; /** * Set the available print scales for this layout. * The available scales are whitelisted with the config.print.scales (if any). * @private */ private updateScales; /** * Updates the available DPIs and current selected dpi value based on the provided client info. * @private */ private updateDpis; /** * Updates the available print/panel attributes based on the selected layout and the wanted attribute names. * @private */ private updateAvailableAttributes; /** * @returns The ClientInfo config object from the current selected layout. * @private */ private getClientInfo; /** * @returns The capabilities attribute default value or the matching selected value in this print panel. * @private */ private getCapabilitiesAttributeValue; /** * @returns An object that contains the custom attributes to print the map. */ private getCustomAttributes; /** * @returns An object containing the configured wanted attributes to print with their corresponding attribute values. * @private */ private getAttributesAndValue; /** * @returns The encoded legend or null if empty or if encoding fails. */ private encodeLegend; /** * Set an initial print status element and track the state of the linked print task. * @private */ private trackPrintStatus; /** * On print finished update the print element with the status and the download url. * @private */ private printFinished; /** * On print errored update the print element with the status and the error info. * @private */ private printError; /** * @returns An array of MFPPrintDatasource objects representing the selected features. */ private selectedFeaturesToDatasource; /** * Get the print formats based on the configuration. * Removes formats not proposed in the available formats. * @static */ static filterValidPrintFormats(configFormats: string[] | undefined, availableFormats: string[] | undefined): string[]; /** * @returns a valid default format from an array of print formats. * @static */ static getValidDefaultFormat(printFormats: string[], defaultFormat?: string): string | undefined; /** * Whitelist the availableLayouts with the given layouts, or allows every of them. * @static */ static filterValidLayouts(availableLayouts?: MFPCapabilitiesLayout[], layouts?: string[]): MFPCapabilitiesLayout[]; /** * Whitelist the availableScales with the given scales, or allows every of them. * @static */ static filterValidScales(availableScales: number[], scales?: number[]): number[]; } export default PrintComponent;