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.title_iPortalAddMapOrScene "> </ title >
9+ < style >
10+ .title-checkbox-container p {
11+ max-width : 150px ;
12+ float : left;
13+ }
14+ .title-checkbox-container input {
15+ float : right;
16+ }
17+ # plottingPanel {
18+ float : left;
19+ background : # ffffff ;
20+ width : 250px ;
21+ height : 100% ;
22+ border : 1px solid # 3473b7 ;
23+ }
24+ .datagrid-cell {
25+ word-break : break-all;
26+ white-space : normal!important ;
27+ }
28+ .tabs-container , .tabs-panels , .panel-body {
29+ height : auto!important ;
30+ }
31+ .panel-title {
32+ margin-top : 0 !important ;
33+ margin-bottom : 0 !important ;
34+ font-size : 16px !important ;
35+ color : inherit!important ;
36+ }
37+ </ style >
38+ </ head >
39+ < body style =" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0; ">
40+ <!-- 资源过滤 and 资源展示 -->
41+ < div class ="container " style ="margin-bottom: 100px; ">
42+ < div class ="page-header ">
43+ < h4 id ="resourceTypeText " data-i18n ="resources.title_iPortalAddMap "> </ h4 >
44+ </ div >
45+ < br />
46+ < div class ="col-md-12 ">
47+ < div class ="row ">
48+ < div class ="col-md-12 " style ="background: #FFF; ">
49+ <!--添加资源-->
50+ < div class ="row " id ="batch-add-resource " style ="padding: 10px; ">
51+ < h5 data-i18n ="resources.title_iPortalQueryResourcesType "> </ h5 >
52+ < select id ='typeSelect ' class ='form-control ' onchange ="onSelectResourcesType() ">
53+ < option value ="MAP " data-i18n ="resources.title_iPortalQueryResourcesMap "> </ option >
54+ < option value ="SCENE " data-i18n ="resources.title_iPortalQueryResourcesScene "> </ option >
55+ </ select >
56+ < h5 data-i18n ="resources.text_serviceAddress "> </ h5 >
57+ < span style ="position: relative; ">
58+ < input id ="address " class ='form-control ' type ="text " style ="width: 100%; "> < i class ="fa fa-question-circle question " aria-hidden ="true "> </ i >
59+ </ span >
60+ < h5 data-i18n ="resources.detail_iPortal_tags "> </ h5 >
61+ < input id ="tags " class ='form-control ' type ="text " style ="width: 100%; " data-i18n ="[placeholder]resources.text_userMap ">
62+ < h5 data-i18n ="resources.title_share_setting "> </ h5 >
63+ < div >
64+ < form class ="form-horizontal ">
65+ < fieldset >
66+ < ul class ="nav nav-tabs " role ="tablist ">
67+ < li role ="presentation " class ="active ">
68+ < a href ="#public " aria-controls ="public " role ="tab " data-toggle ="tab " data-i18n ="resources.title_iPortalQueryResourcesPublic "> </ a >
69+ </ li >
70+ </ ul >
71+ < div class ="tab-content ">
72+ < div role ="tabpanel " class ="tab-pane active " id ="public ">
73+ < div class ="col-md-4 gallery-item " id ="shareCheckboxs ">
74+ < div class ="publicPane sub-font ">
75+ < input id ="search " type ="checkbox " value ="search " onclick ="clickSearchCheckBox() " />
76+ < label for ="search " data-i18n ="resources.text_user_search "> </ label >
77+ </ div >
78+ < div class ="publicPane sub-font ">
79+ < input id ="view " type ="checkbox " value ="view " onclick ="clickViewCheckBox() " />
80+ < label for ="view " data-i18n ="resources.text_user_view "> </ label >
81+ </ div >
82+ < div class ="publicPane sub-font ">
83+ < input id ="edit " type ="checkbox " value ="edit " onclick ="clickEditCheckBox() " />
84+ < label for ="edit " data-i18n ="resources.text_user_editor "> </ label >
85+ </ div >
86+ </ div >
87+ </ div >
88+ </ div >
89+ </ fieldset >
90+ </ form >
91+ </ div >
92+ < div > < button class ="btn btn-primary col-md-offset-6 " style ="margin-top: 20px; " onclick ="addMapOrScene() " data-i18n ="resources.btn_OK "> </ button > </ div >
93+ </ div >
94+ </ div >
95+ </ div >
96+ </ div >
97+ </ div >
98+ < script type ="text/javascript " include ="jquery,bootstrap,plottingPanel,widgets " src ="../js/include-web.js "> </ script >
99+ < script type ="text/javascript " include ="iclient-plot-leaflet " src ="../../dist/leaflet/include-leaflet.js "> </ script >
100+ < script type ="text/javascript " include ="iPortalStylePanel " src ="../js/plottingPanel/PlottingPanel.Include.js "> </ script >
101+ < script >
102+ //iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8091/iportal
103+ var iPortalUrl = "http://rdc.ispeco.com/" ;
104+ // rdc的admin用户的token,模拟admin用户登录状态
105+ var token = "qbzq4N7oA7sC6xJwP_VzbtEqoscT-sLATh83DzePead0gK4Tf5qEnypDY0iO3x7qM4pRSQxM98Zr5WAxLZhONw.." ;
106+ //默认请求资源类型
107+ var resourceType = "MAP" ;
108+ //共享设置
109+ var publicSettingEntity = {
110+ "permissionType" : "" ,
111+ "entityType" : "USER" ,
112+ "entityName" : "GUEST" ,
113+ "entityId" : null ,
114+ "authorizeList" : [ ]
115+ }
116+ function getDefaultUrl ( ) {
117+ iPortalUser = new SuperMap . iPortalUser ( iPortalUrl ) ;
118+ }
119+ // 注册token
120+ function generatePortalToken ( ) {
121+ let serverInfo = new SuperMap . ServerInfo ( SuperMap . ServerType . IPORTAL , {
122+ server : iPortalUrl
123+ } ) ;
124+
125+ SuperMap . SecurityManager . registerServers ( [ serverInfo ] ) ;
126+ SuperMap . SecurityManager . destroyToken ( iPortalUrl ) ;
127+ SuperMap . SecurityManager . registerToken ( iPortalUrl , token ) ;
128+ }
129+ // 添加地图/场景
130+ function addMapOrScene ( ) {
131+ generatePortalToken ( ) ;
132+ iPortalUser = new SuperMap . iPortalUser ( iPortalUrl ) ;
133+ let params = new SuperMap . iPortalAddResourceParam ( {
134+ rootUrl : $ ( "#address" ) . val ( ) ,
135+ tags : $ ( "#tags" ) . val ( ) ,
136+ entities : getShareEntities ( )
137+ } ) ;
138+ if ( resourceType === "MAP" ) {
139+ iPortalUser . addMap ( params ) . then ( res => {
140+ if ( res . succeed ) {
141+ widgets . alert . showAlert ( resources . msg_addSuccess , true ) ;
142+ } else {
143+ widgets . alert . showAlert ( resources . msg_addFailed , false ) ;
144+ }
145+ } )
146+ }
147+ if ( resourceType === "SCENE" ) {
148+ iPortalUser . addScene ( params ) . then ( res => {
149+ if ( res . succeed ) {
150+ widgets . alert . showAlert ( resources . msg_addSuccess , true ) ;
151+ } else {
152+ widgets . alert . showAlert ( resources . msg_addFailed , false ) ;
153+ }
154+ } )
155+ }
156+ }
157+ function getShareEntities ( ) {
158+ shareSettingList = [ ] ;
159+ //公开
160+ addSettingEntity ( publicSettingEntity ) ;
161+ return shareSettingList ;
162+ }
163+ //生成分享的entities参数
164+ function addSettingEntity ( obj ) {
165+ var settingEntity = dealShareSettingParam ( obj ) ;
166+ if ( settingEntity ) {
167+ shareSettingList . push ( settingEntity ) ;
168+ }
169+ }
170+ function dealShareSettingParam ( obj ) {
171+ var authorize = "" ;
172+ if ( ! obj . authorizeList ) {
173+ return null ;
174+ }
175+ if ( obj . authorizeList . includes ( "edit" ) ) {
176+ authorize = "READWRITE" ;
177+ } else if ( obj . authorizeList . includes ( "view" ) ) {
178+ authorize = "READ" ;
179+ } else if ( obj . authorizeList . includes ( "download" ) ) {
180+ authorize = "DOWNLOAD" ;
181+ } else if ( obj . authorizeList . includes ( "search" ) ) {
182+ authorize = "SEARCH" ;
183+ }
184+ if ( authorize ) {
185+ if ( resourceType === "data" ) {
186+ obj . dataPermissionType = authorize ;
187+ }
188+ obj . permissionType = authorize ;
189+ let targetPermissionEntity = Object . assign ( { } , obj ) ;
190+ delete targetPermissionEntity . authorizeList ;
191+ delete targetPermissionEntity . aliasName ;
192+ delete targetPermissionEntity . entityRoles ;
193+ return targetPermissionEntity ;
194+ } else {
195+ return null ;
196+ }
197+ }
198+ // 选择资源类型
199+ function onSelectResourcesType ( ) {
200+ let type = $ ( "#typeSelect" ) . val ( ) ;
201+ resourceType = type ;
202+ if ( resourceType === "MAP" ) {
203+ $ ( "#resourceTypeText" ) [ 0 ] . innerText = resources . title_iPortalAddMap ;
204+ } else if ( resourceType === "SCENE" ) {
205+ $ ( "#resourceTypeText" ) [ 0 ] . innerText = resources . title_iPortalAddScene ;
206+ }
207+ $ ( "#address" ) . val ( "" ) ;
208+ $ ( "#tags" ) . val ( "" ) ;
209+ }
210+ // 点击所有用户可检索
211+ function clickSearchCheckBox ( ) {
212+ if ( ! publicSettingEntity . authorizeList || ( publicSettingEntity . authorizeList ) . indexOf ( "search" ) === - 1 ) {
213+ publicSettingEntity . authorizeList = [ "search" ] ;
214+ } else {
215+ publicSettingEntity . authorizeList = [ ] ;
216+ }
217+ publicSettingEntity . authorizeList . forEach ( authorizeListItem => {
218+ $ ( "input[value='" + authorizeListItem + "']" ) . prop ( "checked" , true ) ;
219+ } )
220+ }
221+ // 点击所有用户可查看
222+ function clickViewCheckBox ( ) {
223+ if ( ! publicSettingEntity . authorizeList || ( publicSettingEntity . authorizeList ) . indexOf ( "view" ) === - 1 ) {
224+ publicSettingEntity . authorizeList = [ "search" , "view" ] ;
225+ } else if ( ( publicSettingEntity . authorizeList ) . indexOf ( "search" ) !== - 1 ) {
226+ publicSettingEntity . authorizeList = [ "search" ] ;
227+ }
228+ publicSettingEntity . authorizeList . forEach ( authorizeListItem => {
229+ $ ( "input[value='" + authorizeListItem + "']" ) . prop ( "checked" , true ) ;
230+ } )
231+ }
232+ // 点击所有用户可编辑
233+ function clickEditCheckBox ( ) {
234+ if ( ! publicSettingEntity . authorizeList || ( publicSettingEntity . authorizeList ) . indexOf ( "edit" ) === - 1 ) {
235+ publicSettingEntity . authorizeList = [ "search" , "view" , "edit" ] ;
236+ } else if ( ( publicSettingEntity . authorizeList ) . indexOf ( "view" ) !== - 1 ) {
237+ publicSettingEntity . authorizeList = [ "search" , "view" ] ;
238+ }
239+ publicSettingEntity . authorizeList . forEach ( authorizeListItem => {
240+ $ ( "input[value='" + authorizeListItem + "']" ) . prop ( "checked" , true ) ;
241+ } )
242+ }
243+ </ script >
244+ </ body >
245+ </ html >
0 commit comments