Skip to content

Commit 3f43303

Browse files
author
杜美瑶
committed
提交封装资源删除和更改属性的API接口 --reviewed by huangqh
1 parent 5e94d4e commit 3f43303

File tree

9 files changed

+62
-24
lines changed

9 files changed

+62
-24
lines changed

src/common/iPortal/iPortalResource.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class IPortalResource extends IPortalServiceBase {
3737
this.thumbnail = null;
3838
this.updateTime = 0;
3939
this.userName = "";
40+
this.sourceJSON = {};//返回门户资源详细信息
4041
Util.extend(this, resourceInfo); // INSIGHTS_WORKSPACE MAP_DASHBOARD
4142
this.resourceUrl = portalUrl + "/web/"+this.resourceType.replace("_","").toLowerCase()+"s/" + this.resourceId;
4243
if (this.withCredentials) {
@@ -59,38 +60,20 @@ export class IPortalResource extends IPortalServiceBase {
5960
if (resourceInfo.error) {
6061
return resourceInfo;
6162
}
62-
for (var key in resourceInfo) {
63-
me[key] = resourceInfo[key];
64-
}
63+
me.sourceJSON = resourceInfo;
6564
});
6665
}
6766

6867
/**
6968
* @function SuperMap.IPortalResource.prototype.update
70-
* @description 更新地图参数
69+
* @description 更新资源属性信息
7170
* @returns {Promise} 返回包含更新操作状态的 Promise 对象。
7271
*/
7372
update() {
74-
var resourceUpdateParam = {
75-
units: this.units,
76-
level: this.level,
77-
center: this.center,
78-
controls: this.controls,
79-
description: this.description,
80-
epsgCode: this.epsgCode,
81-
extent: this.extent,
82-
status: this.status,
83-
tags: this.tags,
84-
layers: this.layers,
85-
title: this.title,
86-
thumbnail: this.thumbnail,
87-
sourceType: this.sourceType,
88-
authorizeSetting: this.authorizeSetting
89-
};
9073
var options = {
9174
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
9275
};
93-
return this.request("PUT", this.resourceUrl, JSON.stringify(resourceUpdateParam), options);
76+
return this.request("PUT", this.resourceUrl, JSON.stringify(this.sourceJSON), options);
9477
}
9578

9679
}

src/common/iPortal/iPortalUser.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* Copyright© 2000 - 2019 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {SuperMap} from '../SuperMap';
5+
import {IPortalServiceBase} from './iPortalServiceBase';
6+
/**
7+
* @class SuperMap.IPortalUser
8+
* @classdesc iPortal 门户中用户信息的封装类。用于管理用户资源,包括可删除,添加资源。
9+
* @category iPortal/Online
10+
* @param {string} iportalUrl - iportal根地址。
11+
* @extends {SuperMap.iPortalServiceBase}
12+
*
13+
*/
14+
export class IPortalUser extends IPortalServiceBase {
15+
constructor(iportalUrl) {
16+
super(iportalUrl);
17+
this.iportalUrl = iportalUrl;
18+
}
19+
20+
/**
21+
* @function SuperMap.prototype.deleteResources
22+
* @description 删除资源。
23+
* @param {Object} deleteParams - 删除资源所需的参数对象:{ids,resourceType}。
24+
* @returns {Promise} 返回包含删除操作状态的 Promise 对象。
25+
*/
26+
deleteResources(deleteParams) {
27+
var resourceName = deleteParams.resourceType.replace("_","").toLowerCase();
28+
var deleteResourceUrl = this.iportalUrl+"/web/" + resourceName +"s.json?ids=" + encodeURI(JSON.stringify(deleteParams.ids));
29+
if( resourceName === 'data') {
30+
deleteResourceUrl = this.iportalUrl + "/web/mycontent/datas/delete.json";
31+
return this.request("POST", deleteResourceUrl, JSON.stringify(deleteParams.ids));
32+
}
33+
return this.request("DELETE", deleteResourceUrl);
34+
}
35+
}
36+
37+
SuperMap.iPortalUser = IPortalUser;

src/common/iPortal/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {IPortalInsight} from './iPortalInsight'
1818
import {IPortalInsightsQueryParam} from './iPortalInsightsQueryParam';
1919
import {IPortalScene} from './iPortalScene'
2020
import {IPortalScenesQueryParam} from './iPortalScenesQueryParam';
21+
import {IPortalUser} from "./iPortalUser";
2122

2223
export {IPortal} ;
2324
export {IPortalQueryParam};
@@ -35,4 +36,5 @@ export {IPortalMapdashboardsQueryParam};
3536
export {IPortalInsight};
3637
export {IPortalInsightsQueryParam} ;
3738
export {IPortalScene};
38-
export {IPortalScenesQueryParam} ;
39+
export {IPortalScenesQueryParam} ;
40+
export {IPortalUser}

src/common/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ import {
112112
IPortalServiceBase,
113113
IPortalServicesQueryParam,
114114
IPortalMapdashboard,
115-
IPortalMapdashboardsQueryParam
115+
IPortalMapdashboardsQueryParam,
116+
IPortalUser
116117
} from './iPortal';
117118
import {
118119
AddressMatchService,
@@ -574,7 +575,8 @@ export {
574575
IPortalServiceBase,
575576
IPortalServicesQueryParam,
576577
IPortalMapdashboard,
577-
IPortalMapdashboardsQueryParam
578+
IPortalMapdashboardsQueryParam,
579+
IPortalUser
578580
};
579581
export {
580582
AddressMatchService,

src/leaflet/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import {
8484
IPortalServicesQueryParam,
8585
IPortalMapdashboard,
8686
IPortalMapdashboardsQueryParam,
87+
IPortalUser,
8788
//Online
8889
Online,
8990
OnlineData,
@@ -548,6 +549,7 @@ export {
548549
IPortalServicesQueryParam,
549550
IPortalMapdashboard,
550551
IPortalMapdashboardsQueryParam,
552+
IPortalUser,
551553
//Online
552554
Online,
553555
OnlineData,

src/mapboxgl/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export {
8484
IPortalServicesQueryParam,
8585
IPortalMapdashboard,
8686
IPortalMapdashboardsQueryParam,
87+
IPortalUser,
8788
//Online
8889
Online,
8990
OnlineData,

src/openlayers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export {
8484
IPortalInsightsQueryParam,
8585
IPortalScene,
8686
IPortalScenesQueryParam,
87+
IPortalUser,
8788
//Online
8889
Online,
8990
OnlineData,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {IPortalUser} from '../../../src/common/iPortal/iPortalUser';
2+
3+
describe('IPortalUser', () => {
4+
it('constructor_default', () => {
5+
var iportalUrl = 'https://iptl.supermap.io/iportal';
6+
var iPortalUser = new IPortalUser(iportalUrl);
7+
expect(iPortalUser.iportalUrl).toBe("https://iptl.supermap.io/iportal");
8+
});
9+
});

test/test-main-common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ import './common/iPortal/iPortalInsightSpec.js';
168168
import './common/iPortal/iPortalInsightsQueryParamSpec.js';
169169
import './common/iPortal/iPortalSceneSpec.js';
170170
import './common/iPortal/iPortalScenesQueryParamSpec.js';
171+
import './common/iPortal/iPortalUserSpec.js';
171172

172173
/**common -- thirdparty**/
173174
import './common/thirdparty/elasticsearch/ElasticSearchSpec.js';

0 commit comments

Comments
 (0)