qwc2
Version:
QGIS Web Client
7 lines • 8.82 kB
JavaScript
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/**
* Copyright 2020-2024 Sourcepole AG
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{closeWindow,closeAllWindows,NotificationType}from"../actions/windows";import LocaleUtils from"../utils/LocaleUtils";import Icon from"./Icon";import ResizeableWindow from"./ResizeableWindow";import"./style/WindowManager.css";var WindowManager=/*#__PURE__*/function(_React$Component){function WindowManager(){var _this;_classCallCheck(this,WindowManager);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,WindowManager,[].concat(args));_defineProperty(_this,"renderIframeDialog",function(key,data){var extraControls=[];if(_this.boolVal(data.options.print,true)!==false){extraControls.push({icon:"print",callback:function callback(){return _this.printIframe(key)}})}var dockable=["left","right","top","bottom"].includes(data.options.dockable)?data.options.dockable:_this.boolVal(data.options.dockable);var docked=_this.boolVal(data.options.docked)!==false;var splitScreenWhenDocked=_this.boolVal(data.options.splitScreenWhenDocked)!==false;return/*#__PURE__*/React.createElement(ResizeableWindow,{baseZIndex:data.options.zIndex||10,dockable:dockable||docked,extraControls:extraControls,icon:data.options.icon||"",initialHeight:data.options.h||480,initialWidth:data.options.w||640,initiallyDocked:docked,key:key,onClose:function onClose(){return _this.closeWindow(key)},splitScreenWhenDocked:splitScreenWhenDocked,title:LocaleUtils.tr(data.options.title||"windows."+key)},/*#__PURE__*/React.createElement("iframe",{className:"windows-iframe-dialog-body",name:key,role:"body",src:data.url}))});_defineProperty(_this,"renderNotification",function(key,data){var className="windows-notification-info";if(data.notificationType===NotificationType.WARN){className="windows-notification-warn"}else if(data.notificationType===NotificationType.ERROR){className="windows-notification-error"}return/*#__PURE__*/React.createElement("div",{className:className,key:key},/*#__PURE__*/React.createElement("div",null,data.text),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"remove",onClick:function onClick(){return _this.closeWindow(key)},size:"large"})))});_defineProperty(_this,"closeWindow",function(key){_this.props.closeWindow(key)});_defineProperty(_this,"printIframe",function(key){if(window.frames[key]){window.frames[key].focus();window.frames[key].print()}});_defineProperty(_this,"boolVal",function(value){var delft=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(value===undefined||value===null){return delft}var textVal=(""+value).toLowerCase();if(textVal===""){return delft}return["0","false"].includes(textVal)?false:true});_defineProperty(_this,"get",function(obj,key,deflt){if(obj[key]===undefined){return deflt}return obj[key]});return _this}_inherits(WindowManager,_React$Component);return _createClass(WindowManager,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.currentTheme!==prevProps.currentTheme){this.props.closeAllWindows()}}},{key:"render",value:function render(){var _this2=this;var notificationIndex=0;return[].concat(_toConsumableArray(Object.entries(this.props.windows).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],data=_ref2[1];if(data.type==="iframedialog"){return _this2.renderIframeDialog(key,data)}return null})),[/*#__PURE__*/React.createElement("div",{className:"windows-notification-container",key:"notifications-container"},Object.entries(this.props.windows).map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],data=_ref4[1];if(data.type==="notification"){return _this2.renderNotification(key,data,notificationIndex++)}else{return null}}))])}}])}(React.Component);_defineProperty(WindowManager,"propTypes",{closeAllWindows:PropTypes.func,closeWindow:PropTypes.func,currentTheme:PropTypes.object,windows:PropTypes.object});var selector=function selector(state){return{windows:state.windows.entries,currentTheme:state.theme.current}};export default connect(selector,{closeWindow:closeWindow,closeAllWindows:closeAllWindows})(WindowManager);