Hi all, I am trying to build this application that lists all web services within each ArcGIS Server folders. I am trying to programmatically feed a drop down list with ArcGIS Server folder's names so the user just has to select the folder of his choice and it returns all services in a table. The following code works great but I had to manually enter each folder:
<!DOCTYPE html>
<html>
<head>
<title>Service Info</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css">
<style>
html, body, #details {
padding: 0;
margin: 0;
height: 100%;
}
.dgrid-cell-padding {
padding: 10px !important;
}
.dgrid {
height: 100% !important;
}
.dgrid-cell{
border:1px solid black !important;
}
</style>
<script src="http://js.arcgis.com/3.14/"></script>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script>
require([
"esri/request",
"dojo/_base/array",
"dojo/dom",
"dojo/domReady!"
], function (esriRequest, array, dom, Grid) {
$(document).ready(function () {
var baseUrl = "http://webgisdevint1/arcgis/rest/services";
$('.selectpicker').on('change', function(){
var baseFolder = $(this).find("option:selected").val();
esriRequest({
url: baseUrl + "/" + baseFolder,
content: {
"f": "json"
},
callbackParamName: "callback"
}).then(function (response) {
var data = array.map(response.services, function (service, index) {
return {
"url": "<a target='_blank' href='" + baseUrl + "/" + service.name + "/" + service.type + "'>" + baseUrl + "/" + service.name + "/" + service.type + "</a><br>",
"name": service.name,
"type": service.type,
"id": index
}
});
$('#example').DataTable({
destroy: true,
data: data,
columns: [
{ title:"URL", data: "url" },
{ title: "Name", data: "name" },
{ title: "Type", data: "type" }
]
});
});
});
});
});
</script>
</head>
<body class="claro">
<select class="selectpicker">
<option>Search web GIS Folders:</option>
<option>Alex_Try</option>
<option>CalMAPPER</option>
<option>davin</option>
<option>ForestPractice</option>
<option>FRAP</option>
<option>Pipeline</option>
<option>PPFIS</option>
<option>ResourceMgmt</option>
<option>System</option>
<option>testing</option>
<option>Utilities</option>
<option>WatershedMapper</option>
</select>
<table id="example" class="display" width="100%"></table>
</body>
</html>Any idea is more than welcome,
Thanks,
Alex