Pārlūkot izejas kodu

updated wfs request panel

Piotr Labudda 8 gadi atpakaļ
vecāks
revīzija
1d61fc42a2
1 mainītis faili ar 44 papildinājumiem un 11 dzēšanām
  1. 44 11
      SE/se-lib/Route/WfsJsRequestPanel.php

+ 44 - 11
SE/se-lib/Route/WfsJsRequestPanel.php

@@ -128,6 +128,8 @@ class Route_WfsJsRequestPanel extends RouteBase {
 			// $securityLogger->pushHandler($stream);
 			// $securityLogger->addInfo('debug message / label', [ 'dbg-object' => [ 'x' => 'y', 'z' ] ]);
 
+			// 'wfsRequestFeatureTypeName' = 'default_db__x3A__CRM_PROCES:PROCES'
+			echo UI::h('input', [ 'id' => 'wfsRequestFeatureTypeName', 'class' => "form-control", 'value' => 'default_db__x3A__CRM_PROCES:PROCES', 'title' => "Feature name" ]);
 			echo UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px" ], htmlspecialchars($exampleWfsRequestBody));
 			echo UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij");
 			echo UI::h('div', [ 'style' => "display:inline", 'id' => "wfs-example-btns" ]);
@@ -162,28 +164,59 @@ class Route_WfsJsRequestPanel extends RouteBase {
 				])),
 			]);
 			UI::endContainer();
-			$examples = array_map(function ($props) use ($exampleFltr) {
-				return "<wfs:Query>" . "\n" . implode("\n", array_merge($props, $exampleFltr)) . "\n" . "</wfs:Query>";
-			}, $listExampleProp);
+			$examples['Procesy'] = [
+				'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
+				'examples' => array_map(function ($props) use ($exampleFltr) {
+					return "<wfs:Query>" . "\n" . implode("\n", array_merge($props, $exampleFltr)) . "\n" . "</wfs:Query>";
+				}, $listExampleProp),
+			];
+			$examples['BiAudit'] = [
+				'typeName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
+				'examples' => [
+					'BiAudit' => "",
+					'BiAudit lvl3' => "<wfs:Query>" . implode("\n\t", [
+						"<wfs:PropertyName>A_ADM_COMPANY</wfs:PropertyName>",
+						"<wfs:PropertyName>A_CLASSIFIED</wfs:PropertyName>",
+						"<wfs:PropertyName>A_STATUS</wfs:PropertyName>",
+						"<wfs:PropertyName>A_STATUS_INFO</wfs:PropertyName>",
+						"<wfs:PropertyName>BI_analiza_depth</wfs:PropertyName>",
+						"<wfs:PropertyName>BI_analiza_reloadCache</wfs:PropertyName>",
+						"<wfs:PropertyName>FILE_STATUS</wfs:PropertyName>",
+						"<wfs:PropertyName>FILE_STATUS_info</wfs:PropertyName>",
+						"<wfs:PropertyName>ID</wfs:PropertyName>",
+						"<wfs:PropertyName>L_APPOITMENT_USER</wfs:PropertyName>",
+						"<wfs:PropertyName>default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY/*</wfs:PropertyName>",
+						"<wfs:PropertyName>default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI/*</wfs:PropertyName>",
+						"<wfs:PropertyName>default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row/*</wfs:PropertyName>",
+						"<wfs:PropertyName>default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person/*</wfs:PropertyName>",
+					]) . "\n" . "</wfs:Query>",
+				],
+			];
 			echo UI::h('script', [], "
 				var examples = " . json_encode($examples) . ";
 				console.log('examples', examples)
-				function setWfsExample(i) {
-					document.getElementById('wfsRequestBody').value = examples[i]
+				function setWfsExample(label, i) {
+					console.log('label', label, 'i', i)
+					document.getElementById('wfsRequestFeatureTypeName').value = examples[label].typeName
+					document.getElementById('wfsRequestBody').value = examples[label].examples[i]
 					sendWfsRequest()
 				}
-				for (var i in examples) {
-					jQuery(document.getElementById('wfs-example-btns')).append('<button class=\"btn btn-default\" style=\"margin-left:12px\" onClick=\"setWfsExample(\''+i+'\')\">'+i+'</button>')
+				for (var label in examples) {
+					for (var i in examples[label].examples) {
+						jQuery(document.getElementById('wfs-example-btns')).append('<button class=\"btn btn-default\" style=\"margin-left:12px\" onClick=\"setWfsExample(\''+label+'\', \''+i+'\')\">'+i+'</button>')
+					}
 				}
 			");
 			echo UI::h('script', [], "
 				function sendWfsRequest() {
 					document.getElementById('wfsResponse').innerHTML = 'loading...'
+					var featureTypeName = document.getElementById('wfsRequestFeatureTypeName').value
 					var postBody = document.getElementById('wfsRequestBody').value.replace(/&lt;/g, '<').replace(/&gt;/g, '>')
 					console.log('wfsRequestBody:', postBody)
-					p5WFS_GetFeature('default_db__x3A__CRM_PROCES:PROCES', {
-						'ogc:Filter': postBody,
-					}).then(function (features) {
+					p5WFS_GetFeature(featureTypeName, Object.assign({
+						'maxFeatures': 5,
+					}, (!postBody) ? {} : { 'ogc:Filter': postBody }
+					)).then(function (features) {
 						console.log('features', features)
 						document.getElementById('wfsResponse').innerHTML = JSON.stringify(features, null, 2)
 					}).catch(function (e) {
@@ -195,7 +228,7 @@ class Route_WfsJsRequestPanel extends RouteBase {
 				}
 
 				(function () {
-					console.log('p5WFS_GetFeature(default_db__x3A__CRM_PROCES:PROCES, ...)')
+					console.log('p5WFS_GetFeature() ...')
 
 					sendWfsRequest()
 				})()