1+ <!--********************************************************************
2+ * Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+ *********************************************************************-->
4+ <!DOCTYPE html>
5+ < html lang ="en ">
6+ < head >
7+ < meta charset ="UTF-8 ">
8+ < title data-i18n ="resources.text_publish_data "> </ title >
9+ < style >
10+ .gallery-item {
11+ margin-bottom : 30px ;
12+ }
13+ .gallery-item-border {
14+ border : 1px solid # dadada ;
15+ -webkit-box-shadow : 0px 2px 3px # dcdcdc ;
16+ box-shadow : 0px 2px 3px # dcdcdc ;
17+ background : white;
18+ }
19+ .thumbnail > img , .thumbnail a > img {
20+ margin-right : auto;
21+ margin-left : auto;
22+ }
23+ .gallery-item-img {
24+ height : 170px !important ;
25+ width : 262px !important ;
26+ }
27+ .resourcesDetails {
28+ margin : 0px 0 12px 10px ;
29+ height : 21px ;
30+ overflow : hidden;
31+ text-overflow : ellipsis;
32+ white-space : nowrap;
33+ font-size : 14px !important ;
34+ color : # 7c7c7c ;
35+ }
36+ .textEllipsis {
37+ display : inline-block;
38+ padding-left : 10px ;
39+ padding-top : 12px ;
40+ padding-bottom : 12px ;
41+ vertical-align : top;
42+ overflow : hidden;
43+ text-overflow : ellipsis;
44+ white-space : nowrap;
45+ }
46+ .resourcesBottomList {
47+ padding-left : 10px ;
48+ padding-top : 13px ;
49+ padding-bottom : 12px ;
50+ vertical-align : top;
51+ float : right;
52+ padding-right : 30px ;
53+ border-left : 1px solid # ececec ;
54+ }
55+ .publish-data-hdfs , .publish-data-hbase , .publish-data-excel , .publish-data-csv , .publish-data-geojson , .publish-data-json {
56+ display : none;
57+ }
58+ .margin10 {
59+ margin-right : 10px !important ;
60+ }
61+ .checkbox-title .disabled {
62+ color : # bcbcbc ;
63+ }
64+ .custom-checkbox .disabled {
65+ cursor : default !important ;
66+ }
67+ .view-service {
68+ border-bottom : 1px solid # ccc ;
69+ }
70+ .view-service : last-child {
71+ border : none;
72+ }
73+ .view-service p : nth-child (1 ) {
74+ margin-top : 10px ;
75+ }
76+ .view-service a {
77+ display : block;
78+ margin-bottom : 10px ;
79+ }
80+ </ style >
81+ </ head >
82+ < body style =" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0; ">
83+ < div class ="container " style ="margin-bottom: 100px ">
84+ < div class ="page-header ">
85+ < h4 data-i18n ="resources.text_publish_data "> </ h4 >
86+ </ div >
87+ < br />
88+ <!-- 发布数据服务模态框 -->
89+ < div class ="modal fade " tabindex ="-1 " id ="publishModal " role ="dialog " data-backdrop ="static " data-keyboard ="false " >
90+ < div class ="modal-dialog ">
91+ < div class ="modal-content ">
92+ < div class ="modal-header ">
93+ < button type ="button " class ="close " data-dismiss ="modal " aria-hidden ="true ">
94+ ×
95+ </ button >
96+ < h4 class ="modal-title " id ="myModalLabel " data-i18n ="resources.text_publish_data "> </ h4 >
97+ </ div >
98+ < table class ="table table-bordered col-md-6 ">
99+ < tbody >
100+ < tr >
101+ < td >
102+ < div class ="col-md-10 col-md-offset-1 ">
103+ < p data-i18n ="resources.text_publish_message "> </ p >
104+ < div id ="serviceType ">
105+
106+ </ div >
107+ </ div >
108+ </ td >
109+ </ tr >
110+ </ tbody >
111+ </ table >
112+ < div class ="modal-footer ">
113+ < button type ="button " class ="btn btn-default " data-dismiss ="modal " data-i18n ="resources.text_close ">
114+ </ button >
115+ < button type ="button " class ="btn btn-primary " onclick ="publishDataEvent() " data-i18n ="resources.text_confirm ">
116+ </ button >
117+ </ div >
118+ </ div > <!-- /.modal-content -->
119+ </ div > <!-- /.modal -->
120+ </ div >
121+
122+ < div class ="col-md-10 ">
123+ < div class ="row ">
124+ < div class ="col-md-12 ">
125+ <!--所有资源的承载DIV-->
126+ < div class ="row " id ="resourcesList ">
127+ <!--单个资源数据的可视化承载DIV 添加在此位置中-->
128+ </ div >
129+ </ div >
130+ </ div >
131+ </ div >
132+ </ div >
133+ < script type ="text/javascript " include ="jquery,bootstrap-css,bootstrap,widgets " src ="../js/include-web.js "> </ script >
134+ < script type ="text/javascript " src ="../../dist/leaflet/include-leaflet.js "> </ script >
135+ < script >
136+ //iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8190/iportal
137+ var iPortalUrl = "https://iportal.supermap.io/iportal" ;
138+ var token = "MFEKl8kVmkvEDrDFcgnjoUF4o2VKXT1eZhKh7hU3tnJL1jPculOBmvCtA6Xfrw4KuAyxWj2OcUV1Aj3M41nSNQ.." ;
139+ var queryParams = new SuperMap . iPortalQueryParam ( {
140+ resourceType : "DATA" ,
141+ pageSize : 12 ,
142+ currentPage : 1 ,
143+ orderBy : "UPDATETIME" ,
144+ orderType : "DESC" ,
145+ searchType :'MY_RES'
146+ } ) ;
147+ //资源查询初始化工作
148+ var iPortal = new SuperMap . iPortal ( iPortalUrl ) ;
149+ $ ( document ) . ready ( function ( ) {
150+ generatePortalToken ( ) ;
151+ } ) ;
152+ var publishDataId , serviceType ;
153+ // 申请,注册token并查询
154+ function generatePortalToken ( ) {
155+ var serverInfo = new SuperMap . ServerInfo ( SuperMap . ServerType . IPORTAL , {
156+ server : iPortalUrl
157+ } ) ;
158+
159+ SuperMap . SecurityManager . registerServers ( [ serverInfo ] ) ;
160+ SuperMap . SecurityManager . destroyToken ( iPortalUrl ) ;
161+ SuperMap . SecurityManager . registerToken ( iPortalUrl , token ) ;
162+ //加载完DOM后,开始资源数据查询并添加
163+ iPortal = new SuperMap . iPortal ( iPortalUrl ) ;
164+ queryResouces ( queryParams ) ;
165+ }
166+
167+ // 查询iPortal中的资源
168+ function queryResouces ( queryParams ) {
169+ iPortal . queryResources ( queryParams ) . then ( function ( resourcesReslut ) {
170+ //返回的结果集,需要查看可打开下行代码
171+ // console.log(resourcesReslut);
172+ $ ( "#resourcesList" ) . children ( ) . remove ( ) ;
173+ //将结果集进行遍历,并添加到HTML中
174+ $ . each ( resourcesReslut . content , function ( i ) {
175+ var resourceItem = resourcesReslut . content [ i ] ;
176+ //解析时间戳,可根据需求自行处理
177+ var updateTime = new Date ( parseInt ( resourceItem . updateTime ) ) . toLocaleString ( ) ;
178+ var thumbnail = resourceItem . thumbnail ;
179+ // 此判断获取部分相对路径的default图片
180+ if ( thumbnail . indexOf ( "./" ) === 0 ) {
181+ thumbnail = iPortalUrl + thumbnail . replace ( "./" , "/" ) ;
182+ }
183+ var resourcesDOM = $ ( "<div class='col-md-4 gallery-item'>" +
184+ "<div class='gallery-item-border'>" +
185+ "<a class='thumbnail' style='margin-bottom: 10px'>" +
186+ "<img class='gallery-item-img' src='" + thumbnail + "' alt=''>" +
187+ "</a>" +
188+ "<div>" +
189+ "<div style='height:68px'>" +
190+ "<div style='display:flex'>" +
191+ "<p class='resourcesDetails' style='flex: 1 1 auto'>" + resourceItem . name + "</p>" +
192+ "<p style='flex: 1 1 auto;text-align:right;margin-right:13px'>" + resourceItem . resourceSubType + "</p>" +
193+ "</div>" +
194+ "<a style='margin-left:10px;' class='publish-data-" + resourceItem . resourceSubType . toLowerCase ( ) + "' onclick='publishDataService(" + resourceItem . resourceId + ")'>" + resources . text_publish_data + "</a>" +
195+ "<a tabindex='" + i + "'data-animation='true' data-html='true' id='content" + i + "' data-trigger='focus' data-container='body' data-content='无' data-toggle='popover' data-placement='bottom' style='margin-right:12px;float:right;' class='publish-data-" + resourceItem . resourceSubType . toLowerCase ( ) + "' onclick='showPublishedDataService(" + resourceItem . resourceId + "," + i + ")'>" + resources . text_view_service + "</a>" +
196+ "</div>" +
197+ "</div>" )
198+ $ ( "#resourcesList" ) . append ( resourcesDOM ) ;
199+ } ) ;
200+ } )
201+ } ;
202+ function publishDataService ( dataId ) {
203+ publishDataId = dataId ;
204+ $ ( '#publishModal' ) . modal ( 'show' ) ;
205+ $ ( "#serviceType" ) . empty ( ) ;
206+ var items = new SuperMap . iPortalResource ( iPortalUrl , { resourceId :dataId , resourceType :"DATA" } ) ;
207+ items . load ( ) . then ( ( ) => {
208+ var item = items . sourceJSON ;
209+ switch ( item . type ) {
210+ case "WORKSPACE" :
211+ var publishDataDom = $ (
212+ "<div id='mapTypeLine'>" +
213+ "<input id='map' class='margin10' type='checkbox' value='RESTMAP'>" +
214+ "<label class='checkbox-title' for='map'>RESTMAP</label>" +
215+ "</div>" +
216+ "<div id='dataTypeLine'>" +
217+ "<input id='data' class='margin10' type='checkbox' value='RESTDATA'>" +
218+ "<label class='checkbox-title' for='data'>RESTDATA</label>" +
219+ "</div>" +
220+ "<div id='realspaceTypeLine'>" +
221+ "<input id='realspace' class='margin10' type='checkbox' value='RESTREALSPACE'>" +
222+ "<label class='checkbox-title' for='realspace'>RESTREALSPACE</label>" +
223+ "</div>" +
224+ "<div id='spatialAnalystTypeLine'>" +
225+ "<input id='spatialAnalyst' class='margin10' type='checkbox' value='RESTSPATIALANALYST'>" +
226+ "<label class='checkbox-title' for='spatialAnalyst'>RESTSPATIALANALYST</label>" +
227+ "</div>"
228+ )
229+ $ ( "#serviceType" ) . append ( publishDataDom ) ;
230+ break ;
231+ case 'UDB' :
232+ var publishDataDom = $ (
233+ "<div id='dataTypeLine'>" +
234+ "<input id='data' class='margin10' type='checkbox' value='RESTDATA'>" +
235+ "<label class='checkbox-title' for='data'>RESTDATA</label>" +
236+ "</div>" )
237+ $ ( "#serviceType" ) . append ( publishDataDom ) ;
238+ break ;
239+ case 'SHP' :
240+ case 'EXCEL' :
241+ case 'CSV' :
242+ case 'GEOJSON' :
243+ var publishDataDom = $ (
244+ "<div id='mapTypeLine'>" +
245+ "<input id='map' class='margin10' type='checkbox' value='RESTMAP'>" +
246+ "<label class='checkbox-title' for='map'>RESTMAP</label>" +
247+ "</div>" +
248+ "<div id='dataTypeLine'>" +
249+ "<input id='data' class='margin10' type='checkbox' value='RESTDATA'>" +
250+ "<label class='checkbox-title' for='data'>RESTDATA</label>" +
251+ "</div>" )
252+ $ ( "#serviceType" ) . append ( publishDataDom ) ;
253+ break ;
254+ case 'SMTILES' :
255+ case 'SVTILES' :
256+ case 'MBTILES' :
257+ case 'TPK' :
258+ case 'UGCV5' :
259+ case 'UGCV5_MVT' :
260+ var publishDataDom = $ (
261+ "<div id='mapTypeLine'>" +
262+ "<input id='map' class='margin10' type='checkbox' value='RESTMAP'>" +
263+ "<label class='checkbox-title' for='map'>RESTMAP</label>" +
264+ "</div>" )
265+ $ ( "#serviceType" ) . append ( publishDataDom ) ;
266+ break ;
267+ }
268+ var precheckInfos = item . dataItemServices ;
269+ if ( ! precheckInfos ) {
270+ return ;
271+ }
272+ $ . each ( precheckInfos , function ( key , value ) {
273+ if ( value . serviceType === "RESTMAP" ) {
274+ refreshPublishContent ( "mapTypeLine" ) ;
275+ } else if ( value . serviceType === "RESTDATA" ) {
276+ refreshPublishContent ( "dataTypeLine" ) ;
277+ } else if ( value . serviceType === "RESTREALSPACE" ) {
278+ refreshPublishContent ( "realspaceTypeLine" ) ;
279+ } else if ( value . serviceType === "RESTSPATIALANALYST" ) {
280+ refreshPublishContent ( "spatialAnalystTypeLine" ) ;
281+ }
282+ } ) ;
283+ } ) ;
284+ }
285+ function refreshPublishContent ( publishTypeId ) {
286+ $ ( "#" + publishTypeId + " :checkbox" ) . attr ( "disabled" , true ) ;
287+ $ ( "#" + publishTypeId + " :checkbox" ) . addClass ( "disabled" ) ;
288+ $ ( "#" + publishTypeId + " .checkbox-title" ) . addClass ( "disabled" ) ;
289+ $ ( "#" + publishTypeId + " .checkbox-title" ) . attr ( "title" , resources . msg_published ) ;
290+ }
291+ function publishDataEvent ( ) {
292+ if ( checkPublishParam ( ) ) {
293+ publishOrUnpublishEvent ( publishDataId , null , true ) ;
294+ }
295+ $ ( "#publishModal" ) . modal ( "hide" ) ;
296+ }
297+ function publishOrUnpublishEvent ( dataId , dataServiceId , forPublish ) {
298+ var options = {
299+ dataId :dataId ,
300+ serviceType :serviceType ,
301+ dataServiceId :dataServiceId
302+ }
303+ new SuperMap . iPortalUser ( iPortalUrl ) . publishDataService ( options , forPublish ) . then ( res => {
304+ var serviceIdList = res . split ( "," ) ;
305+ for ( var i = 0 ; i < serviceIdList . length ; i ++ ) {
306+ new SuperMap . iPortalUser ( iPortalUrl ) . getDataPublishedStatus ( dataId , serviceIdList [ i ] ) . then ( res => {
307+ if ( res . succeed ) {
308+ widgets . alert . showAlert ( resources . msg_publish_success , true ) ;
309+ } else {
310+ widgets . alert . showAlert ( resources . msg_publish_failed , false ) ;
311+ }
312+ } )
313+ }
314+ } )
315+ }
316+ function checkPublishParam ( ) {
317+ var checkBoxList = $ ( "#publishModal :checkbox" ) ;
318+ var serviceTypes = "" ;
319+ checkBoxList . each ( function ( ) {
320+ if ( this . checked ) {
321+ serviceTypes += $ ( this ) . val ( ) + "," ;
322+ }
323+ } ) ;
324+ if ( serviceTypes . length > 0 ) {
325+ serviceType = serviceTypes . substr ( 0 , serviceTypes . length - 1 ) ;
326+ return true ;
327+ }
328+ return false ;
329+ }
330+ function showPublishedDataService ( id , index ) {
331+ var items = new SuperMap . iPortalResource ( iPortalUrl , { resourceId :id , resourceType :"DATA" } ) ;
332+ items . load ( ) . then ( ( ) => {
333+ var template = "" ;
334+ if ( items . sourceJSON . dataItemServices . length ) {
335+ $ . each ( items . sourceJSON . dataItemServices , function ( i ) {
336+ var option = {
337+ dataId :id ,
338+ serviceType :items . sourceJSON . dataItemServices [ i ] . serviceType ,
339+ dataServiceId :items . sourceJSON . dataItemServices [ i ] . serviceName
340+ }
341+ var msg = items . sourceJSON . dataItemServices [ i ] . serviceStatus === 'PUBLISHED' ?resources . msg_publish_success :resources . msg_publish_failed
342+ template += "<div class='view-service'><p>" + resources . text_service_name + ":" + items . sourceJSON . dataItemServices [ i ] . serviceName + "</p><p>" + resources . text_service_type + ":" + items . sourceJSON . dataItemServices [ i ] . serviceType + "</p><p>" + resources . text_service_status + ":" + msg + "</p><a onclick='unPublishData(" + JSON . stringify ( option ) + ")'>" + resources . text_unpublish_service + "</a></div>"
343+ } )
344+ $ ( "#content" + index ) . attr ( 'data-content' , template ) ;
345+ $ ( "#content" + index ) . popover ( "show" ) ;
346+ } else {
347+ $ ( "#content" + index ) . popover ( "show" ) ;
348+ }
349+ } )
350+ }
351+ //取消发布
352+ function unPublishData ( option ) {
353+ new SuperMap . iPortalUser ( iPortalUrl ) . unPublishDataService ( option ) . then ( res => {
354+ if ( res . succeed ) {
355+ widgets . alert . showAlert ( resources . msg_unpublish_success , true ) ;
356+ } else {
357+ widgets . alert . showAlert ( resources . msg_unpublish_failed , false ) ;
358+ }
359+ } )
360+ }
361+ </ script >
362+ </ body >
363+ </ html >
0 commit comments