Bläddra i källkod

added wfs links in Storage tableList

Piotr Labudda 9 år sedan
förälder
incheckning
9325e2c116
2 ändrade filer med 137 tillägg och 7 borttagningar
  1. 44 7
      SE/se-lib/Route/Storage.php
  2. 93 0
      SE/se-lib/tmpl/_layout_gora.php

+ 44 - 7
SE/se-lib/Route/Storage.php

@@ -559,6 +559,30 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 				UI::alert('info', "Lista obiketów zaktualizowana");
 			}
 
+			{
+				echo UI::h('style', ['type' => "text/css"], "
+					.p5UI__dropdown-content { padding:8px; background-color: #f6f6f6; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2) }
+					.p5UI__dropdown-content a { display:block; color:#000; padding:8px; text-decoration:none }
+					.p5UI__dropdown-content a:hover { background-color:#ebebeb }
+				");
+				echo UI::h('script', [], "
+					function p5_Storage_actions_filterInput(n) {
+						var input, filter, ul, li, a, i, div;
+						input = n // .id-myInput
+						filter = input.value.toUpperCase()
+						div = n.parentNode // .id-myDropdown
+						a = div.getElementsByTagName('a')
+						for (i = 0; i < a.length; i++) {
+							if (a[i].innerHTML.toUpperCase().indexOf(filter) > -1) {
+								a[i].style.display = ''
+							} else {
+								a[i].style.display = 'none'
+							}
+						}
+					}
+				");
+			}
+
 			UI::table([
 				'caption' => "Obiekty w bazie '{$sourceItem['name']}' " .
 					UI::hButtonPost('<i class="glyphicon glyphicon-refresh"></i>' . " odśwież", [
@@ -569,6 +593,7 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 					]),
 				'rows' => array_map(function ($item) use ($idStorage) {
 					$addToZasobyLink = $this->getLink('addAclObjectToZasoby', ['idStorage' => $idStorage, 'namespace' => $item['namespace']]);
+					$typeName = Api_WfsNs::typeName($item['namespace']);
 					return [
 						'namespace' => '<span style="color:#888">' . substr($item['namespace'], 0, strlen($item['namespace']) - strlen($item['name'])) . '</span>' .
 							'<span>' . $item['name'] . '</span>',
@@ -581,13 +606,25 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 							], "Dodaj do Zasobów"),
 						// 'opis' => $item['description'],
 						'active?' => ($item['isActive']) ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
-						'struktura' => UI::h('a', [ 'href' => $this->getLink('tableStruct', [ 'idStorage' => $idStorage, 'table' => $item['name'] ]) ], "struktura"),
-						'struktura OBJ' => UI::h('a', [ 'href' => $this->getLink('objectStruct', [ 'idStorage' => $idStorage, 'namespace' => $item['namespace'] ]) ], "obj struct"),
-						'raw info' => UI::h('a', [ 'href' => $this->getLink('rawInfo', [ 'idStorage' => $idStorage, 'table' => $item['name'] ]) ], "raw info"),
-						'reinstall' => UI::h('a', [ 'href' => $item['reinstallLink'] ], "reinstall"),
-						'view table' => UI::h('a', [ 'href' => Router::getRoute('ViewTableAjax')->getLink('', ['namespace' => $item['namespace']]) ], "view table"),
-						'view object' => UI::h('a', [ 'href' => Router::getRoute('ViewObject')->getLink('', ['namespace' => $item['namespace']]) ], "view object"),
-						// 'xsd' => UI::h('a', [ 'href' => $this->getLink('xsd', [ 'idStorage' => $idStorage ]) ], "xsd"),
+						'installed' => $item['isStructInstalled'] ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
+						'menu' => UI::h('div', ['class'=>"p5UI__dropdown-wrap"], [
+							UI::h('button', ['onClick' => "p5UI__dropdown(event, this, 'left bottom')", 'class' => "btn btn-xs btn-default p5UI__dropdown-btn"], [
+								'<i class="glyphicon glyphicon-menu-hamburger"></i>',
+								" menu"
+							]),
+							UI::h('div', ['class' => "p5UI__dropdown-content"], [
+								UI::h('input', ['type' => "text", 'placeholder' => "Search..", 'class' => "p5UI__dropdown-input", 'onkeyup' => "p5_Storage_actions_filterInput(this)"], null),
+								UI::h('a', [ 'href' => $item['reinstallLink'] ], "reinstall"),
+								UI::h('a', [ 'href' => $this->getLink('tableStruct', [ 'idStorage' => $idStorage, 'table' => $item['name'] ]) ], "struktura"),
+								UI::h('a', [ 'href' => $this->getLink('objectStruct', [ 'idStorage' => $idStorage, 'namespace' => $item['namespace'] ]) ], "obj struct"),
+								UI::h('a', [ 'href' => $this->getLink('rawInfo', [ 'idStorage' => $idStorage, 'table' => $item['name'] ]) ], "raw info"),
+								UI::h('a', [ 'href' => Router::getRoute('ViewTableAjax')->getLink('', ['namespace' => $item['namespace']]) ], "view table"),
+								UI::h('a', [ 'href' => Router::getRoute('ViewObject')->getLink('', ['namespace' => $item['namespace']]) ], "view object"),
+								// 'xsd' => UI::h('a', [ 'href' => $this->getLink('xsd', [ 'idStorage' => $idStorage ]) ], "xsd"),
+								UI::h('a', [ 'href' => "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&REQUEST=DescribeFeatureType&TYPENAME={$typeName}" ], "wfs DescribeFeatureType"),
+								UI::h('a', [ 'href' => "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&REQUEST=GetFeature&TYPENAME={$typeName}&MAXFEATURES=10" ], "wfs GetFeature (max: 10)"),
+							])
+						]),
 					];
 				}, $objectStorage->getItems([
 					'#refFrom' => [

+ 93 - 0
SE/se-lib/tmpl/_layout_gora.php

@@ -148,6 +148,88 @@ if (typeof Object.assign != 'function') {
 	})();
 }
 </script>
+<style type="text/css">
+	.p5UI__dropdown-wrap { display:inline-block; position:relative }
+	.p5UI__dropdown-btn { position:relative }
+	.p5UI__dropdown-btn:hover {  }
+	.p5UI__dropdown-content { display:none; position:absolute; overflow:auto; min-width:230px; z-index: 1 }
+	.p5UI__dropdown-show { display:block }
+	.p5UI__dropdown-input { border-box:box-sizing; width:100% }
+</style>
+<script>
+function p5UI__dropdown(e, n, position) {// @position = ('right top', 'left top', 'left bottom', 'right bottom')
+	// e.stopPropagation()
+	// e.preventDefault()
+	var btnNode = n
+	var node = n.nextSibling
+	node.classList.toggle('p5UI__dropdown-show')
+	// console.log('>>> p5UI__dropdown...', {btnNode: btnNode, node: node, 'has show class': node.classList.contains('p5UI__dropdown-show')})
+	var position = position
+	if (node.classList.contains('p5UI__dropdown-show')) {
+		switch (position) {
+			case 'right top': node.style.bottom = '50px'; node.style.right = '100px'; break; // TODO ...
+			case 'left top': node.style.top = 0; node.style.left = '100px'; break; // TODO ...
+			case 'right bottom': node.style.left = '' + btnNode.offsetWidth + 'px'; node.style.top = 0; break; // TODO ...
+			case 'left bottom': node.style.right = '' + btnNode.offsetWidth + 'px'; node.style.top = 0; break;
+		}
+		node.p5UI__onClickOutsideCallback = p5UI__dropdown__onClickOutsideCallback(node, btnNode)
+		node.p5UI__unbindClickOutsideCallback = p5UI__dropdown__unbindClickOutsideCallback(node)
+		if (!document.addEventListener && document.attachEvent) {
+			document.attachEvent('onclick', node.p5UI__onClickOutsideCallback);
+			// document.attachEvent('keydown', this._closeModalKorespInfoIfHitEscape);
+		} else {
+			document.addEventListener('click', node.p5UI__onClickOutsideCallback);
+			// document.addEventListener('keydown', this._closeModalKorespInfoIfHitEscape);
+		}
+	} else {
+		if ('function' === typeof node.p5UI__unbindClickOutsideCallback) {
+			node.p5UI__unbindClickOutsideCallback()
+			delete node.p5UI__onClickOutsideCallback
+			delete node.p5UI__unbindClickOutsideCallback
+		}
+	}
+	node.firstChild.focus() // TODO: find input
+}
+function p5UI__dropdown__unbindClickOutsideCallback(n) {
+	var node = n
+	return function __p5UI__dropdown__unbindClickOutsideCallback(e) {
+		// console.log('p5UI__dropdown__unbindClickOutsideCallback', {
+		// 	'opened': node.classList.contains('p5UI__dropdown-show'),
+		// 	'node': node,
+		// 	'typeof node.p5UI__onClickOutsideCallback': typeof node.p5UI__onClickOutsideCallback
+		// })
+		// console.trace()
+		if (!document.removeEventListener && document.detachEvent) {
+			document.detachEvent('onclick', node.p5UI__onClickOutsideCallback)
+			// document.detachEvent('keydown', this._closeModalKorespInfoIfHitEscape)
+		} else {
+			document.removeEventListener('click', node.p5UI__onClickOutsideCallback)
+			// document.removeEventListener('keydown', this._closeModalKorespInfoIfHitEscape)
+		}
+	}
+}
+function p5UI__dropdown__onClickOutsideCallback(n, btn) {
+	var node = n
+	var btnNode = btn
+	// console.log('define p5UI__dropdown__onClickOutsideCallback...')
+	return function __p5UI__dropdown__onClickOutsideCallback(e) {
+		// console.log('p5UI__dropdown__onClickOutsideCallback', {
+		// 	'opened': node.classList.contains('p5UI__dropdown-show'),
+		// 	'clickedOutside(node)': p5UI__clickedOutsideElement(node, e),
+		// 	'clickedOutside(btnNode)': p5UI__clickedOutsideElement(btnNode, e),
+		// 	'typeof node.p5UI__onClickOutsideCallback': typeof node.p5UI__onClickOutsideCallback,
+		// 	'typeof node.p5UI__unbindClickOutsideCallback': typeof node.p5UI__unbindClickOutsideCallback,
+		// })
+		if (!node.classList.contains('p5UI__dropdown-show')) return
+		if (node.p5UI__unbindClickOutsideCallback && 'function' == typeof node.p5UI__unbindClickOutsideCallback) {
+			if (p5UI__clickedOutsideElement(node, e) && p5UI__clickedOutsideElement(btnNode, e)) {
+				node.classList.remove('p5UI__dropdown-show')
+				node.p5UI__unbindClickOutsideCallback()
+			}
+		}
+	}
+}
+</script>
 <script>
 function p5UI__Clickable(n, eventNamespace, props) {
 	var dbg = <?php echo (DBG::isActive())? 1 : 0; ?>;
@@ -282,6 +364,17 @@ function p5UI__notifyAjaxCallback(data) {
 	jQuery.notify(notify.msg, notify.type);
 }
 
+function p5UI__clickedOutsideElement(element, event) {
+	// offsetParent - first parentNode with position: (relative | absolute)
+	var eventTarget = (event.target)? event.target : event.srcElement;
+	while (eventTarget != null) {
+		// console.log('Outside:', {'eventTarget': eventTarget, 'eventTarget.offsetParent': eventTarget.offsetParent, 'eventTarget.parentNode': eventTarget.parentNode});
+		if (eventTarget === element) return false;
+		eventTarget = eventTarget.offsetParent;
+	}
+	return true;
+}
+
 
 function p5Utils__parseFloatOrZero(strToParse) {
 	if (!strToParse) return 0