Skip to content

Commit

Permalink
F/add latest functions from arcgis-rest-js v2.4.0 (#172)
Browse files Browse the repository at this point in the history
* add new item functions
* add upload parameters
* add getUserTags()
* update dependencies
  • Loading branch information
haoliangyu authored Aug 29, 2019
1 parent 74fc111 commit 1b4c990
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
### Added
- `addParts`, `getParts`, `getStatus` functions in `items-service`
- `getUserTags` function in the `user-service`

## 2.4.0
### Added
- `export` call to `item-service` to export an item
Expand Down
74 changes: 61 additions & 13 deletions addon/services/items-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import {
searchItems,
getItem,
getItemData,
getItemStatus,
getItemParts,
updateItem,
createItemInFolder,
moveItem,
removeItem,
protectItem,
unprotectItem
unprotectItem,
addItemPart
} from '@esri/arcgis-rest-portal';

export default Service.extend(serviceMixin, {
Expand Down Expand Up @@ -77,7 +80,14 @@ export default Service.extend(serviceMixin, {
const args = this.addOptions({
item,
owner: item.owner,
folderId
folderId,
// have to add these parameters to avoid changing the exiting function params
file: item.file,
filename: item.filename,
dataUrl: item.dataUrl,
text: item.text,
multipart: item.multipart,
async: item.async
}, portalOpts);

return createItemInFolder(args)
Expand Down Expand Up @@ -198,6 +208,21 @@ export default Service.extend(serviceMixin, {
return this.request(urlPath, options, portalOpts);
},

/**
* Add an item part
*/
addPart ({ id, owner, file, partNum }, portalOpts) {
const args = this.addOptions({
id,
owner,
file,
partNum
}, portalOpts);

return addItemPart(args)
.catch(handleError);
},

/**
* Update a resource
*/
Expand Down Expand Up @@ -273,6 +298,34 @@ export default Service.extend(serviceMixin, {
}, portalOpts);
},

/**
* Get item (job) status
*/
getStatus ({ id, owner, jobId, jobType }, portalOpts) {
const args = this.addOptions({
id,
owner,
jobId,
jobType,
}, portalOpts);

return getItemStatus(args)
.catch(handleError);
},

/**
* Get uploaded item parts
*/
getParts ({ id, owner }, portalOpts) {
const args = this.addOptions({
id,
owner
}, portalOpts);

return getItemParts(args)
.catch(handleError);
},

/**
* Export item
*/
Expand All @@ -288,17 +341,12 @@ export default Service.extend(serviceMixin, {
}
}, portalOpts)
.then(job => {
let jobStatusUrl = `/content/users/${username}/items/${job.exportItemId}/status`;
job.getStatus = () => {
return this.request(jobStatusUrl, {
method: 'POST',
data: {
jobId: job.jobId,
jobType: 'export',
f: 'json'
}
}, portalOpts);
};
job.getStatus = this.getStatus.bind(this, {
id: job.exportItemId,
owner: username,
jobId: job.jobId,
jobType: 'export'
}, portalOpts);
return job;
});
}
Expand Down
8 changes: 7 additions & 1 deletion addon/services/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
getUserInvitations,
getUserInvitation,
acceptInvitation,
declineInvitation
declineInvitation,
getUserTags
} from '@esri/arcgis-rest-portal';
import { generateToken } from '@esri/arcgis-rest-auth';

Expand Down Expand Up @@ -109,6 +110,11 @@ export default Service.extend(serviceMixin, {
return generateToken(url, args);
},

getUserTags (username, portalOpts) {
const args = this.addOptions({ username }, portalOpts);
return getUserTags(args);
},

/**
* Extra logic to transform the item prior to POSTing it
*/
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
"ember-fetch": "^6.2.0"
},
"peerDependencies": {
"@esri/arcgis-rest-auth": "^2.3.0",
"@esri/arcgis-rest-portal": "^2.3.0",
"@esri/arcgis-rest-request": "^2.3.0",
"@esri/arcgis-rest-types": "^2.3.0"
"@esri/arcgis-rest-auth": "^2.4.0",
"@esri/arcgis-rest-portal": "^2.4.0",
"@esri/arcgis-rest-request": "^2.4.0",
"@esri/arcgis-rest-types": "^2.4.0"
},
"devDependencies": {
"@ember/optional-features": "^0.6.3",
"@esri/arcgis-rest-auth": "^2.3.0",
"@esri/arcgis-rest-portal": "^2.3.0",
"@esri/arcgis-rest-request": "^2.3.0",
"@esri/arcgis-rest-types": "^2.3.0",
"@esri/arcgis-rest-auth": "^2.4.0",
"@esri/arcgis-rest-portal": "^2.4.0",
"@esri/arcgis-rest-request": "^2.4.0",
"@esri/arcgis-rest-types": "^2.4.0",
"broccoli-asset-rev": "^2.7.0",
"ember-cli": "~3.5.0",
"ember-cli-active-link-wrapper": "0.5.0",
Expand Down
Loading

0 comments on commit 1b4c990

Please sign in to comment.