Giter Club home page Giter Club logo

application-base-js's Introduction

Deprecated

This repo is no longer maintained. The functionality has been forked and is being maintained in the Templates Common Library repo

ApplicationBase

A class designed to handle common tasks of configurable ArcGIS Web Applications.

See Configurable App Examples using this class.

Purpose

The purpose of this ApplicationBase is to handle fetching and managing ArcGIS Online information used in configurable applications. The ApplicationBase queries and maintains:

  • Portal information
  • User information
  • Item data (webscenes, webmaps, group information, group items)
  • Configured application information
  • URL parameters

The ApplicationBase will handle fetching this information, store it, and perform setup when necessary.

API

This is the API for the ApplicationBase class. ApplicationBase.js

Constructor

new ApplicationBase(ApplicationConfig: ApplicationConfig, ApplicationBaseConfig: ApplicationBaseConfig)

Constructor Options

See ApplicationConfig and ApplicationBaseConfig for more information.

ApplicationConfig

property description type default
appid Application ID for querying application configuration string ""
group Group ID for querying a portal group string or string[] ""
webscene WebScene ID for querying a webscene string or string[] "19faa71a3bf6468cae35b4fce9393a7d"
webmap WebMap ID for querying a webmap string or string[] ""
title Title of the application string ""
portalUrl URL to the ArcGIS Portal string "https://www.arcgis.com"
oauthappid oAuth authentication ID string ""
proxyUrl Enter the url to the proxy if needed by the application. See the Using the proxy page help topic for details. string ""
units Application measurement units string ""
helperServices Object containing URLs to various helper services HelperServices null

Example:

{
  "appid": "",
  "group": "",
  "title": "",
  "webmap": "default",
  "webscene": "",
  "portalUrl": "https://www.arcgis.com",
  "oauthappid": "",
  "proxyUrl": "",
  "units": "",
 }

ApplicationBaseConfig

property description type default
webscene.default The default id to query when not set string ""
webscene.fetch When true the application will query for a webscene Boolean true
webscene.fetchMultiple When true the application will query for multiple webscenes if necessary Boolean true
webmap.default The default id to query when not set string ""
webmap.fetch When true the application will query for a webmap Boolean false
webmap.fetchMultiple When true the application will query for multiple webmaps if necessary Boolean true
group.fetchInfo When true the application will query for a group's information Boolean false
group.fetchItems When true the application will query for a group's items Boolean false
group.itemParams Defines query paramaters for fetching group items itemParams {}
group.fetchMultiple When true the application will query for multiple groups if necessary Boolean true
portal.fetch When true the application will query arcgis.com for default settings for helper services, units etc. If you want to use custom settings for units or any of the helper services set this to false then enter default values for any items you need using the helper services and units properties. Boolean true
urlParams Defines which URL parameters should be captured and stored into the config for use within the application String[] See below
environment.webTierSecurity Support sending credentials with AJAX requests to specific domains. This will allow editing of feature services secured with web-tier authentication Boolean false
environment.isEsri Most users will not need to modify this value. For Esri hosting environments only. Will automatically create a portalUrl and proxyUrl for the application. Only set this is to true if the app is going to be stored on Esri's hosting servers. If you are using your own custom hosted portal, set the portalUrl in instead of setting this to true. Boolean false

Example:

{
  "environment": {
    "isEsri": false,
    "webTierSecurity": false
  },
  "localStorage": {
    "fetch": true
  },
  "group": {
    "default": "908dd46e749d4565a17d2b646ace7b1a",
    "fetchInfo": false,
    "fetchItems": false,
    "itemParams": {
      "sortField": "modified",
      "sortOrder": "desc",
      "num": 9,
      "start": 0
    }
  },
  "portal": {
    "fetch": true
  },
  "urlParams": [
    "appid",
    "center",
    "components",
    "embed",
    "extent",
    "find",
    "group",
    "level",
    "marker",
    "oauthappid",
    "portalUrl",
    "viewpoint",
    "webmap",
    "webscene"
  ],
  "webmap": {
    "default": "1970c1995b8f44749f4b9b6e81b5ba45",
    "fetch": true
  },
  "webscene": {
    "default": "e8f078ba0c1546b6a6e0727f877742a5",
    "fetch": false
  }
}

itemParams

See PortalQueryParams

Example:

{
  "query": "group:\"{groupid}\" AND -type:\"Code Attachment\"",
  "sortField": "modified",
  "sortOrder": "desc",
  "num": 9,
  "start": 0
}

Properties

property description type readonly
config Config created ApplicationConfig true
direction Language direction string true
locale Locale string string true
isIE True when IE11 and older boolean boolean true
portal Portal created by ApplicationBase Portal true
results ApplicationBase query results ApplicationBaseResults true
settings Config created ApplicationBaseConfig true
units Appropriate units of measurement string true

ApplicationBaseResult

property description type
error The error returned from the query Error
value The value returned from the query any
promise The query promise Promise<any>

ApplicationBaseResults

property description type
applicationItem? The application item result ApplicationBaseResult
applicationData? The application data result ApplicationBaseResult
groupInfos? The restults from querying group infos ApplicationBaseResult[]
groupItems? The results from querying group items ApplicationBaseResult[]
localStorage? The local storage configuration result ApplicationConfig
portal? The Portal instance result Portal
urlParams? The results from URL parameters ApplicationConfig
webMapItems? The restults from querying webmap items ApplicationBaseResult[]
webSceneItems? The restults from querying webscene items ApplicationBaseResult[]

Methods

load(): Promise<ApplicationBase>

Loads the requested ApplicationBase resources and returns the class once complete.

queryGroupItems(groupId: string, itemParams: itemParams, portal?: Portal) : Promise<any>

Query a group by parameters. ApplicationBase.queryGroupItems("myid", {}, myPortal).

Support Modules

There are helper modules and utilities you can use that contain common application functionality. See the following documentation:

Requirements

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.

Licensing

Copyright 2017 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.txt file.

application-base-js's People

Contributors

csmith246 avatar dependabot[bot] avatar driskull avatar jgravois avatar kellyhutchins avatar miketschudi avatar rslibed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

application-base-js's Issues

urlUtils and itemUtils: application-level modules?

I wonder if these are really an app-level or an app-base module?

urlUtils seems to be forcing the url/param structure to be a certain pattern and it should be up to the app to decide this. It's also loading libraries that I might not need to load. e.g. camera

https://github.com/Esri/application-base-js/blob/a7a3eecd54389739e8c2af6ed9643913cb12efdb/support/urlUtils.ts

itemUtils beyond this seems app-level too.

https://github.com/Esri/application-base-js/blob/master/support/itemUtils.js#L108

Move to app-template-examples?

@driskull @kellyhutchins

_getEsriEnviromentPortalUrl always returns at line 495

Testing out the boilerplate on dev and if I set isEsri to true then the code below executes but it looks like there is an issue setting the value of appLocationIndex. I think the conditional true value should be isEsriAppsPath and the conditional false should be isEsriHomePath.

`
.....
const isEsriAppsPath = esriAppsPathIndex !== -1 ? true : false;
const isEsriHomePath = esriHomePathIndex !== -1 ? true : false;
const appLocationIndex = isEsriAppsPath ? esriAppsPathIndex : isEsriHomePath ? esriHomePathIndex : null;

if (!appLocationIndex) {
  return;
}

.....
}`

Or maybe we just need to check for appLocationIndex being -1 before return? Because currently we are checking for ! (some numeric value).

Add support for getting the basemap group

Org users can opt-in to displaying vector basemaps so we should add support to check the self for vector basemap support and if there get the vector basemap group otherwise get the default basemap group.

npm @esri/application-base-js 0.0.5 different to master

I started looking at the Esri configurable-app-examples-4x-js and found that the code would not work due to application-base-js syntax issues. The major issue is that the npm 0.0.5 @Esri application-base-js is very different to the code in the Esri git repository for application-base-js. I had to remove the npm package from the example and download the application base js files I needed and store them locally. That code now works. NPM 0.0.5 is not compatible with 4.12

Enhancement to support case-insensitive URL parameters

ApplicationBase.json and the app have case-sensitive URL parameters. We’ve had user problems because people are used to generally ignoring case in the URL, so case-sensitive query parameters get mistyped.

Can we change map[key] in _urlToObject() to map[key.toLowerCase()] and the urlParams list in ApplicationBase.json to all lowercase?

Errors in TypeScript after updating to TS version 2.4

After updating to TS 2.4 transpiling declareDecartor.ts returns the following errors:

error TS2322: Type '(target: Functio
n) => DeclareConstructor' is not assignable to type 'ClassDecorator'.
Type 'DeclareConstructor' is not assignable to type 'void | TFunction'.
Type 'DeclareConstructor' is not assignable to type 'TFunction'.

Seems to be due to the stricter checking for generic functions that happens at 2.4 - see doc here:
https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes

Using tsc --noStrictGenericChecks clears the error and so does using any for example:

return function (target: Function) { return <any>declare(mixins, target.prototype); };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.