Skip to content

Commit 3bca939

Browse files
author
杜美瑶
committed
修复共享设置案例接口请求失败的问题 批量添加地图和场景 公开共享设置可视化修改 --reviewed by huanqgh
1 parent c566817 commit 3bca939

File tree

4 files changed

+112
-348
lines changed

4 files changed

+112
-348
lines changed

examples/leaflet/iPortalBatchAddResource.html

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ <h5 data-i18n="resources.title_share_setting"></h5>
100100
<script type="text/javascript" include="iPortalStylePanel" src="../js/plottingPanel/PlottingPanel.Include.js"></script>
101101
<script>
102102
//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..";
103+
var iPortalUrl = "https://iportal.supermap.io/iportal";
104+
// iptl的admin1用户的token,模拟admin1用户登录状态
105+
var token = "Uqag_k3dTfo9FoTj26IlGlLEhn1e276OZ-4twNtVr_etQ-2u6sUKYr9jwjWCtQKNwzTCV2CIMxiaKuOwvKwMag..";
106106
//默认请求资源类型
107107
var resourceType = "MAP";
108108
//共享设置
@@ -214,9 +214,17 @@ <h5 data-i18n="resources.title_share_setting"></h5>
214214
}else {
215215
publicSettingEntity.authorizeList = [];
216216
}
217-
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
218-
$("input[value='"+authorizeListItem+"']").prop("checked", true);
219-
})
217+
if($("input[value='search']").is(':checked')){
218+
publicSettingEntity.authorizeList.forEach(authorizeListItem=>{
219+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
220+
$("input[value='view']").prop("checked", false);
221+
$("input[value='edit']").prop("checked", false);
222+
})
223+
}else {
224+
$("input[value='search']").prop("checked", false);
225+
$("input[value='view']").prop("checked", false);
226+
$("input[value='edit']").prop("checked", false);
227+
}
220228
}
221229
// 点击所有用户可查看
222230
function clickViewCheckBox(){
@@ -225,9 +233,13 @@ <h5 data-i18n="resources.title_share_setting"></h5>
225233
}else if((publicSettingEntity.authorizeList).indexOf("search") !== -1){
226234
publicSettingEntity.authorizeList = ["search"];
227235
}
228-
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
229-
$("input[value='"+authorizeListItem+"']").prop("checked", true);
230-
})
236+
if($("input[value='view']").is(':checked')){
237+
publicSettingEntity.authorizeList.forEach(authorizeListItem=>{
238+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
239+
})
240+
}else {
241+
$("input[value='edit']").prop("checked", false);
242+
}
231243
}
232244
// 点击所有用户可编辑
233245
function clickEditCheckBox(){
@@ -236,9 +248,11 @@ <h5 data-i18n="resources.title_share_setting"></h5>
236248
}else if((publicSettingEntity.authorizeList).indexOf("view") !== -1){
237249
publicSettingEntity.authorizeList = ["search","view"];
238250
}
239-
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
240-
$("input[value='"+authorizeListItem+"']").prop("checked", true);
241-
})
251+
if($("input[value='edit']").is(':checked')){
252+
publicSettingEntity.authorizeList.forEach(authorizeListItem=>{
253+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
254+
})
255+
}
242256
}
243257
</script>
244258
</body>

examples/leaflet/iPortalQueryMyResources.html

Lines changed: 30 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -69,77 +69,23 @@
6969
font-size: 16px!important;
7070
color: inherit!important;
7171
}
72-
#login-btn {
73-
display:none;
74-
text-align: center;
75-
position: absolute;
76-
left: 50%;
77-
top: 50%;
78-
margin-left: 64px;
79-
}
8072
.input-group-addon {
8173
cursor: pointer;
8274
}
75+
.tab-content {
76+
max-height: 500px;
77+
overflow-y: auto;
78+
}
79+
table {
80+
margin-top: 12px;
81+
}
82+
.choose {
83+
display: block;
84+
margin-top: 12px;
85+
}
8386
</style>
8487
</head>
8588
<body style=" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0;">
86-
<!-- 登录按钮 -->
87-
<input type="button" class="btn btn-default" data-i18n="[value]resources.text_login" id="login-btn" onclick="showLoginModel()">
88-
<!-- 登录模态框(Modal) -->
89-
<div class="modal fade" id="loginModal" tabindex="-1" 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-
&times;
95-
</button>
96-
<h4 class="modal-title" id="myModalLabel" data-i18n="resources.text_login"></h4>
97-
</div>
98-
<table class="table table-bordered col-md-6">
99-
<tbody>
100-
<!--token 申请-->
101-
<tr>
102-
<td>
103-
<div class="col-md-10 col-md-offset-1">
104-
<form class="form-horizontal">
105-
<fieldset>
106-
<div class="form-group">
107-
<label for="username_iportal" class="col-md-2 control-label" style="width:26.666667%;" data-i18n="resources.title_resource_address"></label>
108-
109-
<div class="col-md-8">
110-
<input type="text" class="form-control" id="resource_address" >
111-
</div>
112-
</div>
113-
<div class="form-group">
114-
<label for="username_iportal" class="col-md-2 control-label" data-i18n="resources.text_userName" style="width:26.666667%;"></label>
115-
116-
<div class="col-md-8">
117-
<input type="text" class="form-control" id="username_iportal">
118-
</div>
119-
</div>
120-
<div class="form-group">
121-
<label for="password_iportal" class="col-md-2 control-label" data-i18n="resources.text_password" style="width:26.666667%;"></label>
122-
123-
<div class="col-md-8">
124-
<input type="password" class="form-control" id="password_iportal">
125-
</div>
126-
</div>
127-
</fieldset>
128-
</form>
129-
</div>
130-
</td>
131-
</tr>
132-
</tbody>
133-
</table>
134-
<div class="modal-footer">
135-
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="getDefaultUrl()" data-i18n="resources.text_close">
136-
</button>
137-
<button type="button" class="btn btn-primary" onclick="generatePortalToken()" data-i18n="resources.text_confirm">
138-
</button>
139-
</div>
140-
</div><!-- /.modal-content -->
141-
</div><!-- /.modal -->
142-
</div>
14389
<!-- 删除资源模态框(Modal) -->
14490
<div class="modal fade" tabindex="-1" role="dialog" id="deleteModel">
14591
<div class="modal-dialog" role="document">
@@ -209,7 +155,7 @@ <h4 class="modal-title" data-i18n="resources.title_share_setting"></h4>
209155
<input type="text" class="form-control" data-i18n="[placeholder]resources.text_input_user_name" id="add-user-val">
210156
<span class="input-group-addon" onclick="searchUser()" data-i18n="resources.btn_add"></span>
211157
</div>
212-
<span data-i18n="resources.text_choose_user"></span>
158+
<span data-i18n="resources.text_choose_user" class="choose"></span>
213159
<table border="1" bordercolor="black" width="100%">
214160
<thead id="user_thead">
215161

@@ -220,11 +166,7 @@ <h4 class="modal-title" data-i18n="resources.title_share_setting"></h4>
220166
</table>
221167
</div>
222168
<div role="tabpanel" class="tab-pane" id="department">
223-
<div class="input-group" style="margin-top: 12px;" style="width: 100%;">
224-
<input type="text" class="form-control" data-i18n="[placeholder]resources.text_input_department_name" id="add-department-val">
225-
<span class="input-group-addon" onclick="searchDepartment()" data-i18n="resources.btn_add"></span>
226-
</div>
227-
<span data-i18n="resources.text_choose_department"></span>
169+
<span data-i18n="resources.text_choose_department" class="choose"></span>
228170
<table border="1" bordercolor="black" width="100%">
229171
<thead id="department_thead">
230172

@@ -305,6 +247,7 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
305247
<script>
306248
//iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8091/iportal
307249
var iPortalUrl = "https://iportal.supermap.io/iportal";
250+
var token = "Uqag_k3dTfo9FoTj26IlGlLEhn1e276OZ-4twNtVr_etQ-2u6sUKYr9jwjWCtQKNwzTCV2CIMxiaKuOwvKwMag..";
308251
//默认请求资源类型
309252
var resourceType = "MAP";
310253
//全局变量,承载请求后,一共有多少页数
@@ -336,67 +279,28 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
336279
var groupsSettingEntities = [];
337280
// 用户的登陆信息对象
338281
var userStateObj = {};
339-
// 部门列表
340-
var departmentList = [];
341282
// 群组列表
342283
var groupList = [];
343284
$(document).ready(function () {
344-
// 获取群组列表数据
345-
getGroupList();
346-
// 获取登录用户信息数据
347-
getLoginUserInfos();
348-
$("#loginModal").modal();
349-
$("#resource_address").attr("value",iPortalUrl)
285+
generatePortalToken();
350286
});
351-
//获取默认url
352-
function getDefaultUrl(){
353-
iPortal = new SuperMap.iPortal(iPortalUrl);
354-
}
355-
// 展示用户登录弹框 获取token
356-
function showLoginModel (){
357-
$("#loginModal").modal("show");
358-
}
359287
// 申请,注册token并查询
360288
function generatePortalToken() {
361-
var resourceAddress = $("#resource_address").val();
362289
var serverInfo = new SuperMap.ServerInfo(SuperMap.ServerType.IPORTAL, {
363-
server: resourceAddress
290+
server: iPortalUrl
364291
});
365292

366293
SuperMap.SecurityManager.registerServers([serverInfo]);
367-
var userName = $('#username_iportal').val();
368-
var password = $('#password_iportal').val();
369-
var clientType = "NONE";
370-
var referer = "";
371-
var expiration = "1440"; // 过期时间1440分钟,即一天
372-
373-
SuperMap.SecurityManager.generateToken(resourceAddress, new SuperMap.TokenServiceParameter({
374-
userName: userName,
375-
password: password,
376-
clientType: clientType,
377-
referer: referer,
378-
ip: referer,
379-
expiration: expiration
380-
})).then(function (result) {
381-
if(result.indexOf("succeed") === -1) {
382-
SuperMap.SecurityManager.destroyToken(resourceAddress);
383-
SuperMap.SecurityManager.registerToken(resourceAddress, result);
384-
// todo
385-
$("#loginModal").modal("hide");
386-
iPortalUrl = resourceAddress;
387-
//加载完DOM后,开始资源数据查询并添加
388-
iPortal = new SuperMap.iPortal(iPortalUrl);
389-
queryResouces(queryParams);
390-
} else {
391-
iPortal = new SuperMap.iPortal(iPortalUrl);
392-
widgets.alert.showAlert(resources.msg_login_failed, false);
393-
}
394-
});
294+
SuperMap.SecurityManager.destroyToken(iPortalUrl);
295+
SuperMap.SecurityManager.registerToken(iPortalUrl, token);
296+
//加载完DOM后,开始资源数据查询并添加
297+
iPortal = new SuperMap.iPortal(iPortalUrl);
298+
queryResouces(queryParams);
395299
}
396300

397301
//获取用户的登陆信息
398302
function getLoginUserInfos() {
399-
var url = iPortalUrl + "/web/config/userprofile.json";
303+
var url = iPortalUrl + "/web/config/userprofile.json?token=" + token;
400304
$.get(url,(res)=>{
401305
userStateObj = res;
402306
})
@@ -405,7 +309,6 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
405309
// 查询iPortal中的资源
406310
function queryResouces(queryParams) {
407311
iPortal.queryResources(queryParams).then(function (resourcesReslut) {
408-
$("#login-btn").css("display","none");
409312
//返回的结果集,需要查看可打开下行代码
410313
// console.log(resourcesReslut);
411314
// 切换资源类型 清空之前的资源DOM
@@ -442,7 +345,6 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
442345
$("#resourcesList").append(resourcesDOM);
443346
});
444347
}).catch (()=>{
445-
$("#login-btn").css("display","block");
446348
widgets.alert.showAlert(resources.msg_query_failed, false);
447349

448350
})
@@ -826,7 +728,7 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
826728
//搜索添加用户
827729
function searchUser(){
828730
var userName = $("#add-user-val").val();
829-
var nicknameInfosUrl = iPortalUrl+"/web/users/nicknameinfos.json?name="+userName;
731+
var nicknameInfosUrl = iPortalUrl+"/web/users/nicknameinfos.json?name="+userName + "&token=" + token;
830732
$.get(nicknameInfosUrl,(res)=>{
831733
if(res.length === 0){
832734
widgets.alert.showAlert(resources.msg_user_not_exist,false);
@@ -955,44 +857,6 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
955857
this.showUserShare();
956858
}
957859

958-
// 获取部门列表数据函数
959-
function getDepartmentList() {
960-
var departmentUrl = iPortalUrl + "/manager/iportalconfig/departments.json"
961-
$.get(departmentUrl,(res)=>{
962-
departmentList = res;
963-
})
964-
}
965-
// 搜索添加部门函数
966-
function searchDepartment(){
967-
var departmentName = $("#add-department-val").val();
968-
if(departmentName) {
969-
for(var dep of departmentSettingEntities){
970-
if(dep.entityName === departmentName){
971-
widgets.alert.showAlert(resources.msg_department_added,false);
972-
return;
973-
}
974-
}
975-
let department = checkDepartmentIsExist(departmentName,departmentList);
976-
if(department){
977-
let authorizeList= getAuthorizeList("SEARCH");//添加的用户默认具有搜索权限
978-
let entity = {
979-
"permissionType": null,
980-
"aliasName": null,
981-
"entityRoles": [],
982-
"entityType": "DEPARTMENT",
983-
"entityName": department.name,
984-
"entityId": department.id,
985-
"authorizeList": authorizeList
986-
};
987-
departmentSettingEntities.push(entity);
988-
showDepartmentShare();
989-
return;
990-
}
991-
widgets.alert.showAlert(resources.msg_department_not_exist,false);
992-
}else {
993-
widgets.alert.showAlert(resources.msg_input_department_name,false);
994-
}
995-
}
996860
// 根据查询的部门记录,渲染页面,进行共享设置
997861
function showDepartmentShare() {
998862
$("#department_tbody").empty();
@@ -1093,7 +957,7 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
1093957

1094958
// 获取群组列表数据函数
1095959
function getGroupList() {
1096-
var groupUrl = iPortalUrl + "/web/groups/sharegroups.json"
960+
var groupUrl = iPortalUrl + "/web/groups/sharegroups.json?token=" + token;
1097961
$.get(groupUrl,(res)=>{
1098962
if(res.length>0) {
1099963
groupList = res;
@@ -1185,6 +1049,10 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
11851049

11861050
//点击共享设置前,确认弹框(初始化弹框内容)
11871051
function shareResource(ids){
1052+
// 获取群组列表数据
1053+
getGroupList();
1054+
// 获取登录用户信息数据
1055+
getLoginUserInfos();
11881056
groupsSettingEntities = [];
11891057
for(let group of groupList){
11901058
let settingEntity = {
@@ -1199,7 +1067,6 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
11991067
groupsSettingEntities.push(settingEntity);
12001068
}
12011069
$('#shareModal').modal('show');
1202-
getDepartmentList();
12031070
shareIds = ids ? [ids] : getDeleteAndShareCheckArr();
12041071
if(shareIds.length<=0) {
12051072
widgets.alert.showAlert(resources.msg_choise_resources_share, false);
@@ -1577,7 +1444,6 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
15771444
groupsSettingEntities[index] = obj;
15781445
}
15791446
if($("input[value='search-group"+index+"']").is(':checked')){
1580-
console.log(11)
15811447
obj.authorizeList.forEach(authorizeListItem=>{
15821448
$("input[value='"+authorizeListItem+"-group"+index+"']").prop("checked", true);
15831449
$("input[value='view-group"+index+"']").prop("checked", false);
@@ -1650,6 +1516,8 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyRes
16501516
obj.authorizeList.forEach(authorizeListItem=>{
16511517
$("input[value='"+authorizeListItem+"']").prop("checked", true);
16521518
})
1519+
}else {
1520+
$("input[value='edit']").prop("checked", false);
16531521
}
16541522
}else if(type === 'user') {
16551523
usersSettingEntities.forEach((item,index)=>{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy