2.7.9 • Published 4 years ago

ember-arcgis-portal-services v2.7.9

Weekly downloads
420
License
Apache-2.0
Repository
github
Last release
4 years ago

ember-arcgis-portal-services

npm version build status apache licensed

Ember Services for working with ArcGIS Portal/Online. Essentially a wrapper around the functions from arcgis-rest-js for working with items, groups, and users that integrates with torii authentication.

Getting Started

Installation

To consume this library in any ember application:

  • ember install ember-arcgis-portal-services

Dependencies

This project uses ember-fetch, and a few packages from arcgis-rest-js, which will be installed as dependencies.

If you're using torii for oauth management, please also npm install torii-provider-arcgis. More information here.

Otherwise, you can use the portalOpts parameter described below, but you need a service named session in your app or addon. You can generate a dummy service using ember generate service session. TODO: there's probably a better way to do this...

ArcGIS Portal Services

After adding this to your project, you will have a number of services available for injection into your routes/controllers/services.

Shared Methods

All the services expose a set of shared helper properties and methods:

PropertyReturnsDescription
geocodeUrlstringReturn the geocode base url

NOTE: Most public methods take an optional portalOpts parameter. This takes the form:

{
  portalHostname: 'some.portal.com',
  token: 'BZSOMETOKENQJ'
}
// it might also look like this
{
  portalHostname: 'https://some.portal.com',
  token: 'BZSOMETOKENQJ'
}
MethodReturnsDescription
encodeFormstringThis is used internally. Formats an object into a html form. In most cases, not necessary to call this.
request (url, options, portalOpts)promiseThis is used internally. Promisified xhr that does basic handling of Portal's 400-in-a-200 errors
getPortalUrl()stringGet the portal url i.e. https://org.maps.arcgis.com
getPortalRestUrl()stringGet the portal rest url i.e. https://org.maps.arcgis.com/sharing/rest

Items Service

MethodReturnsDescription
search(form)promiseExecutes via /sharing/rest/search. The form is an object properties matching the search params
getById(id, portalOpts)promiseReturns the Item.
getDataById(id, portalOpts)promiseReturns the Item-Data (/data).
update(item, portalOpts)promiseUpdates an existing item. The .owner property must be set.
create(item, portalOpts)promiseCreates an item. The .owner property must be set.
move (itemId, folderId, portalOpts)promiseMove the item to a specified folder
remove(itemId, owner, portalOpts)promiseDelete the item.
protect(itemId, owner, portalOpts)promiseProtect the item (to avoid accidental deletion).
unprotect(itemId, owner, portalOpts)promiseUnprotect the item.
getRelatedItems(itemId, relationshipType, direction, portalOpts)promiseRelated Items
addRelationship (username, itemId, destItemId, relType, portalOpts)promiseAdd a relationship between items
removeRelationship (username, itemId, destItemId, relType, portalOpts)promiseDelete a relationship between items
addImageResourceFromUrl (itemId, owner, filename, url)promiseAdd an image at the specified url to the item as a resource
export (username, itemId, title, exportOpts, portalOpts)promiseExport a service item to a file. Call getStatus for job status
getStatus(item, portalOpts)promiseGet item/job status
addPart(item, portalOpts)promiseAdd an item file part
getParts(item, portalOpts)promiseGet a list of uploaded item file parts

Groups Service

MethodReturnsDescription
search(form, portalOpts)promiseExecutes via /sharing/rest/community/groups. The form is an object properties matching the search params
getById(id, portalOpts)promiseReturns the Group.
getBulk(ids, portalOpts)promiseReturns an array of Groups.
getItemsById(id, portalOpts)promiseReturns Items in the group. Note: Does not currently support paging.
save(group, portalOpts)promiseCreates or Updates a group.
rename(group, newTitle, portalOpts)promiseRenames an existing group.
update(group, portalOpts)promiseUpdates an existing group.
create(group, portalOpts)promiseCreates an item. The .owner property must be set.
remove(id, portalOpts)promiseDelete the Group.
protect(id, portalOpts)promiseProtect the Group from deletion.
unprotect(id, portalOpts)promiseUnprotect the Group from deletion.
users(id, portalOpts)promiseReturn array of users that are members of the Group. Documentation
addUsers(id, users, portalOpts)promiseAdds users to the Group. Expects an array of usernames.
addAdmins(id, admins, portalOpts)promiseAdds admins to the Group. Expects an array of usernames.
reassign(id, username, portalOpts)promiseReassign ownership of the group
remove(id, portalOpts)promiseDeletes a group from AGO
join(id, portalOpts)promiseRequest for current user to join a group
leave (id, portalOpts)promiseRequest for current user to leave a group
isUserGroupAdmin (id, username, portalOpts)booleanUser's group admin status
getUserMembership (id, username, portalOpts)promiseReturn the type of group membership of a user
updateUserMemberships (id, users, type, portalOpts)promiseUpdates membership(s) from user to admin or admin to user
ensureUniqueGroupName (title, step, portalOpts)promiseReturn a group name guaranteed to be unique in the org
doesGroupExist (title, portalOpts)promiseReturn a boolean indicating whether the group exists in the org
sendGroupMessage (groupId, subject, message, users, notificationChannelType, portalOpts) (deprecated)promiseSends a notification to the group. See: http://mediawikidev.esri.com/index.php/ArcGIS.com/User_Notifications
sendEmailNotification (groupId, subject, message, users = [], portalOpts)promiseSends an email notification to the specified group members
sendBuiltinNotification (groupId, subject, message, users = [], portalOpts)promiseSends a "builtin" notification to the specified group members
sendPushNotificaiton (groupId, data, users = [], portalOpts)promiseSends a push notification to the specified group members

Sharing Service

The sharing service separates setting Access (private/shared/org/everyone) from sharing with a group. This allows the methods to be more deterministic.

MethodReturnsDescription
setAccess(owner, itemId, access, portalOpts)promisewhere access is null'org''everyone'
shareWithGroup(owner, itemId, groupId, confirmItemControl, portalOpts)promiseShares an item with a group. confirmItemControl defaults to false. If set to true then itemControl (aka edit permission) is conferred via group membership
unShareWithGroup(owner, itemId, groupId, portalOpts)promiseUn-Share an item with a group.
changeGroupSharing(action, owner, itemId, groupId, portalOpts)promiseActual implementation of the sharing. Action can be 'share' or 'unshare'
isItemSharedWithGroup(itemId, groupId, portalOpts)promiseChecks to see if an item has already been shared with a group

User Service

MethodReturnsDescription
search(form, portalOpts) (deprecated)promiseDelegates to allUsers if user is authenticated or portalOpts is provided, otherwise delegates to searchUsers
searchCommunityUsers(form, portalOpts)promiseExecutes via /sharing/rest/community/users. The form is an object properties matching the search params
searchPortalUsers(form, portalOpts)promiseExecutes via /sharing/rest/portals/self/users. The form is an object properties matching the search params
getByName(username, portalOpts)promiseGet a user object by name.
update(user, portalOpts)promiseUpdate a user
signup (user, portalOpts)promiseSigns the user up to the organization
getNotifications (portalOpts)promiseGets the user's "builtin" notifications
removeNotification (id, portalOpts)promiseRemoves the notification
getInvitations (portalOpts)promiseGets the user's invitations
getInvitationById (id, portalOpts)promiseGets the specified invitation for the user
acceptInvitation (id, portalOpts)promiseAccepts the invitation
declineInvitation (id, portalOpts)promiseDeclines the invitation
getUserTags (username, portalOpts)promiseGets item tags used by the user

OAuth Service

Note: This is not used for authentication - rather its purpose is to allow Application Items to be programatically manipulated.

MethodReturnsDescription
registerApp (itemId, redirectUris, appType = 'browser', portalOpts)promiseRegisters an App item. Returning clientId, client secret etc
updateApp(clientId, redirectUris, portalOpts)promiseCurrently just supports changing the set of valid redirect uris. PR's accepted to expand this

Geocode Service

MethodReturnsDescription
findLocationAddress(inputString)promiseReturns a location address based on an input string that moves through a specified or default geocode url

Portal Service

MethodReturnsDescription
getById (id, portalOpts)promiseGet portal info by Id
self (portalOpts)promisePerform a portals/self call
update(portal, portalOpts)promiseUpdate a portal. Lots of rules apply to what can be changed
uploadResource (file)promiseUpload a file as a portal resource
addImageResourceFromUrl (url, filename)promiseUpload a file as a portal resource, from a url
addResource (name, content, portalOpts)promiseAdd a resource to a portal
getResources ()promiseGet list of portal resources
removeResource (resourceName, portalOpts)promiseRemove a resource from a porta
users(portalId, start = 1, num = 100, portalOpts)promiseGet a portal users.
configureSocialProviders (opts, portalOpts)promiseConfigure social logins.
checkUsername (username, portalOpts)promiseChecks whether the specified username is available
checkUrlKey (urlKey, portalOpts)promiseChecks whether the specified urlKey is available
activate (opts, portalOpts)promiseActivates the organization
addApprovedApp (itemId, properties, portalOpts)promiseAdds an approved app to the portal. Used to create App Launcher entries
getApprovedApps (portalOpts)promiseGets all approved apps to the portal.
sendMessage (subject, message, users, notificationChannelType, portalOpts) (deprecated)promiseSends a notification to the specified users. See: http://mediawikidev.esri.com/index.php/ArcGIS.com/User_Notifications
sendEmailNotification (subject, message, users = [], portalOpts)promiseSends an email notification to the specified users
sendBuiltinNotification (subject, message, users = [], portalOpts)promiseSends a builtin notification to the specified users
sendPushNotification (data, users = [], portalOpts)promiseSends a push notification to the specified users
setUserDefaultSettings (opts, portalOpts)promisesets default user settings
getUserDefaultSettings (opts, portalOpts)promisegets default user settings
setSigninSettings (opts, portalOpts)promisesets organization signin settings
getSigninSettings (opts, portalOpts)promisegets organization signin settings
validatePassword (password, portalOpts)promisevalidates whether the provided password meets the requirements

| removeSocialProviders (portalOpts) | promise | remove social logins | | updateContacts (users = [], portalOpts) | promise | update organization support contacts |

Folders Service

MethodReturnsDescription
getUserFolders (username, portalOpts)promiseResolves with an array of folders
folderExists (folderTitle, username, portalOpts)promiseResolves with bool
create (folderTitle, username, portalOpts)promiseCreates a folder
remove (folderId, username, portalOpts)promiseRemoves a folder

Hosted Service

Used to create/manage hosted feature services. Use the feature-service in ember-arcgis-server-services to work with features/records in the service.

MethodReturnsDescription
serviceExists (serviceName, orgId, portalOpts)promiseCheck if a service exists
create (svcParams, username, folderId, portalOpts)promiseCreate a Service + Item
addToDefinition (fsUrl, definition, layerId, portalOpts)promiseAdd/Edit a layer or table to the service
updateDefinition (fsUrl, definition, layerId, portalOpts)promiseUpdate a service/layer's definition
deleteFromDefinition (fsUrl, definition, layerId, portalOpts)promiseDelete from a service/layer's definition

environment.js

Configuration for how to connect to the portal is managed in the torii section. If you are using ArcGIS Online, the portalUrl property is not needed.

// environment.js
...
torii: {
  sessionServiceName: 'session',
  providers: {
    'arcgis-oauth-bearer': {
      apiKey: 'SECRET-KEY-FOR-YOUR-APP',
      portalUrl: 'https://yourawesomeportal.com'
    }
  }
}
...

Running

Running Tests

Note: Currently there are no automated tests for this addon. PR's welcomed :)

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

For more information on using ember-cli, visit http://ember-cli.com/" target="_blank" class="rg-linkified-code">http://ember-cli.com/.

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

License

Copyright © 2016-2018 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's LICENSE file.

2.7.9

4 years ago

2.7.8

4 years ago

2.7.6

4 years ago

2.7.7

4 years ago

2.7.5

4 years ago

2.7.2

4 years ago

2.7.1

4 years ago

2.7.0

4 years ago

2.6.4

4 years ago

2.6.3

4 years ago

2.6.2

4 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

1.15.3

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.3

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.15.2

5 years ago

1.15.1

5 years ago

1.15.0

5 years ago

1.14.0

5 years ago

1.13.0

5 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.30.0

6 years ago

0.29.0

6 years ago

0.28.0

6 years ago

0.27.1

6 years ago

0.27.0

6 years ago

0.26.0

6 years ago

0.25.1

6 years ago

0.25.0

6 years ago

0.24.0

7 years ago

0.23.1

7 years ago

0.23.0

7 years ago

0.22.0

7 years ago

0.21.1

7 years ago

0.21.0

7 years ago

0.20.3

7 years ago

0.20.2

7 years ago

0.20.1

7 years ago

0.20.0

7 years ago

0.19.0

7 years ago

0.18.0

7 years ago

0.17.0

7 years ago

0.16.0

7 years ago

0.15.0

7 years ago

0.14.0

7 years ago

0.13.5

7 years ago

0.13.4

7 years ago

0.13.3

7 years ago

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.2

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.4

7 years ago

0.10.3

7 years ago

0.10.2

7 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.9

7 years ago

0.8.8

7 years ago

0.8.7

7 years ago

0.8.6

7 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago