-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdataBrowser.html
139 lines (134 loc) · 4.58 KB
/
dataBrowser.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Data Browser</title>
<style>
html,
body {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
font-family: "Segoe UI";
font-size: 13px;
background-color: #f9f9f9;
}
.ShoppingCartRowCloser {
cursor: pointer;
}
</style>
</head>
<body class="claro">
<link rel="stylesheet" href="https://js.arcgis.com/3.35/dijit/themes/claro/claro.css" />
<link rel="stylesheet" href="https://js.arcgis.com/3.35/esri/css/esri.css" />
<script type="text/javascript">
var package_path = window.location.pathname.substring(
0,
window.location.pathname.lastIndexOf("/")
);
var dojoConfig = {
async: true,
//The location.pathname.replace() logic below may look confusing but all its doing is
// enabling us to load the api from a CDN and load local modules from the correct location.
packages: [
{
name: "application",
location: package_path + "/js",
},
],
};
// Have to handle a locale parameter before dojo is loaded
if (location.search.match(/locale=([\w-]+)/)) {
dojoConfig.locale = RegExp.$1;
}
</script>
<script src="https://js.arcgis.com/3.35"></script>
<script type="text/javascript">
var dataBrowser;
require([
"dojo/_base/kernel",
"esri/urlUtils",
"esri/dijit/geoenrichment/DataBrowser",
"dojo/on",
"esri/kernel",
"dojo/cookie",
"dojo/domReady!",
], function (kernel, urlUtils, DataBrowser, on, esriKernel, cookie) {
document.documentElement.lang = kernel.locale;
var userInfo = {};
objRef = window.opener.selectedData;
window.document.title = objRef.selectedTab + " - Data Browser";
userInfo.username = window.opener.selectedData.userInfo.username;
userInfo.token = window.opener.selectedData.userInfo.token;
userInfo.portal = window.opener.selectedData.userInfo.portal;
var cred = "esri_jsapi_id_manager_data";
idJson = cookie(cred);
window.onbeforeunload = function () {
window.opener._showData();
};
//This logic is for handling Identity Manager
//TODO: Minify the code
var baseUrl = window.opener.selectedData.userInfo.portal.helperServices.geoenrichment.url.split(
"/arcgis/rest/services"
)[0];
var serverInfo = {
serverInfos: [
{
server: baseUrl,
tokenServiceUrl: baseUrl + "/ArcGIS/tokens",
adminTokenServiceUrl: baseUrl + "/ArcGIS/admin/generateToken",
currentVersion: 10.02,
hasServer: true,
},
],
oAuthInfos: [],
credentials: [
{
userId: window.opener.selectedData.userInfo.username,
server: baseUrl,
token: window.opener.selectedData.userInfo.token,
expires: window.opener.selectedData.userInfo.credential.expires,
validity: window.opener.selectedData.userInfo.credential.validity,
ssl: window.opener.selectedData.userInfo.credential.ssl,
creationTime:
window.opener.selectedData.userInfo.credential.creationTime,
scope: "server",
resources: [
window.opener.selectedData.userInfo.credential.resources[0],
],
},
],
};
if ("localStorage" in window && window["localStorage"] !== null) {
var idString = JSON.stringify(serverInfo);
window.localStorage.setItem(cred, idString);
} else {
cookie(cred, idString, { expires: 1 });
}
var idObject = JSON.parse(idString);
esriKernel.id.initialize(idObject);
dataBrowser = new DataBrowser(
{
okButton: "Apply",
backButton: null, //Back button text. Can be set to -null- which should hide the button.
cancelButton: "Cancel", //Cancel button text. Can be set to -null- which should hide the button.
countryBox: false, //Show/hide country dropdowm
selection: objRef.selectedVariables, //Array of currently selected variables
countryID: objRef.selectedCountry,
},
"dataBrowser"
);
dataBrowser.startup();
on(dataBrowser, "ok", function (evt) {
window.opener.selectedVariables = dataBrowser.selection.join();
window.opener.selectedTab = objRef.selectedTab;
window.close();
});
on(dataBrowser, "cancel", function (evt) {
window.close();
});
});
</script>
<div id="dataBrowser"></div>
</body>
</html>