//This file describes the format of the config.json.

{
  //Required
  "theme": {
    "name": "FoldableTheme",

    //This property stores all of the theme's styles. The app displays the first style by default.
    "styles": [],

    "customStyles": {
      "mainBackgroundColor": ""
    },

    //Optional. It is the theme version.
    "version": "1.1",

    //from portal self
    "sharedTheme": {
      //whether portal support shared theme, set when create app.
      isPortalSupport: true,

      //optional, default is false
      "useHeader": true,

      //optional, default is false
      "useLogo": true
    }
  },

  //Optional. If not set, do not use proxy.
  "httpProxy": {
    //Optional. Default to false. If false all requests will not use proxy.
    //If true, if the request match proxy rule, use proxy;
    //         if the request doesn't match proxy rule but need proxy(cross domain, i.e.), use proxy url;
    //         if the request neither match proxy rule nor the request doesn't need proxy, framework will check "alwaysUseProxy";
    //            if alwaysUseProxy=true, the request uses proxy url, or the request doesn't use proxy.
    "useProxy": true,

    //Optional. Default to false. If true, all requests use proxy.
    "alwaysUseProxy": false,

    //Optional. If not empty, the url will be set to esriConfig.defaults.io.proxyUrl property.
    "url": "",
    //Optional. If not empty, these rules will be added to urlUtils proxyRule.
    "rules": [{
      "urlPrefix": "",
      "proxyUrl": ""
    }]
  },

  //Optional. The portal URL. If empty, use the URL that app is hosted.
  "portalUrl": "http://mypc.com/arcgis/",

  //Optional. Whether the portal uses webtier authentication. Default to false.
  "isWebTier": false,

  //Optional. If the portal URL is arcgis.com, the appid is required for OAuth2 signin.
  "appId": "",

  //Optional, valid in online/portal only. Save app item id here because after app is downloaded, the app item id is lost, but we still need the item id in some cases.
  "appItemId": "",

  //Optional. Mostly, authorizedCrossOriginDomains stores portals and arcgis servers which use web-tier authentication, such as IWA/PKI/LDAP. If your app uses web-tier portal or arcgis server resources, please put its host(maybe with port) into authorizedCrossOriginDomains.
  "authorizedCrossOriginDomains": [],

  //Optional. The URL of the geometry service used by widgets and the webmap. If not set, it reads from the portal.
  "geometryService": "",

  //Provide Bing key if Bing Maps for maps or geocoding are used.
  bingMapsKey: "",

  //Optional. The logo/title/subtitle of app. Default value is default logo/"HTML5 app"/"A configurable web application".
  "logo": "",
  "title": "ArcGIS Web Application",
  "subtitle": "A configurable web application",

  //Optional. If true, the current map extent and the layer visibility will be kept before you leave the app so you can see the same map extent and layer visibility when open the app next time.
  "keepAppState": true,

  //Optional. App can contain some links.
  "links":[
    {
      "url": "http://www.arcgis.com",
      "label": "ArcGIS Online"
    }
  ],

  //define the layout of onscreen widget and map. if this property does not exist, use the jimu.js/layoutManagers/AbsolutePositionManager, this is the layout manager that WAB app has been using.
  "layoutDefinition": {
    //the layout manager can define how to manage the layout of onscreen widgets/groups.
    //widgets in pool are still managed by controller widget
    "manager": "",

    //the layout structure depends on the manager
    "layout": {
    }
  },

  //define the data source of the app. there are two kinds of data sources: widget data source and extra data source.
  "dataSource": {
    //this array will store external data sources
    "dataSources": {
      'data source id': {
        //the data source id
        //if it's from map, it's: (these are created from map layer, the lay itself is not data source)
        //  map~<layerId>~<filterId>:
        //if it's generated by a widget, it's widget id;
        //  widget~<widgetId>~<dataSourceId>
        //if it's added through extra data source, it's:
        //  external~<id>
        id: "",

        //the filter expression applied to layer or extra datasource
        filter: "",

        filterByExtent: true,

        //the item id that the data source comes from.
        itemId: "",

        //the portal that the item is hosted.
        portalUrl: "",

        label: "",

        isDynamic: ture,

        //minutes
        refreshInterval: 0,

        //Features, FeatureStatistics
        type: "",

        url: "",

        //for Features
        dataSchema: {
          geometryType: "",

          // Field[]: https://developers.arcgis.com/javascript/3/jsapi/field-amd.html
          // includes the selected fields only
          fields: [],

          orderByFields: [], // ['Field1 DESC', 'Field2 ASC']

          displayFieldName: "",
          objectIdFieldName: "",
          typeIdFieldName: ""
        },

        resultRecordType: "", //all, serviceLimitation, custom
        resultRecordCount: 10,

        //for FeatureStatistics
        dataSchema: {
          groupByFields: [], // field name array

          //array of StatisticDefinition: https://developers.arcgis.com/javascript/3/jsapi/statisticdefinition-amd.html
          statistics: [],

          // Field[]: https://developers.arcgis.com/javascript/3/jsapi/field-amd.html
          // includes the used fields only
          fields: [],

          geometryType: "",
          displayFieldName: "",
          objectIdFieldName: "",
          typeIdFieldName: ""
        }
      }
    },

    settings: {
      //If the value of this property is not zero, all dynamic data sources will be refreshed on this interval.
      //the unit is minute.
      unifiedRefreshInterval: 0
    }
  },

  "widgetOnScreen": {
    //Widgets(not in group) are opened in this panel.
    "panel": {
      "uri": "jimu/PanelType1"
    },

    "widgets": [{
      //Required. It is widget main class.
      "uri": "widgets/Header/Widget",

      //Optional. If not set, use the icon in widget folder.
      "icon": "",

      //optional. If not set, use widget name.
      "label": "",

      //Optional. If not set, default value is left=0, top=0.
      //If panel is set, this means panel's position or widget position.
      //If widget is closeable, this means widget icon's position or widget position.
      //The framework uses 6 properties to position widget: left, top, bottom, right, width and height.
      //Four properties  should be enough to position the widget. This position method is the same as the HTML.
      "position": {
        "left": 0,
        "top": 0,
        "right": 0,
        "bottom": 30,
        "width": 100,
        "height": 100,

        //Optional.Value can be either map or browser. If not set, default value is "map".
        "relativeTo": "map",

        //these four properties will be applied to widget's domNode if provided.
        "paddingRight": 10,
        "paddingLeft": 10,
        "paddingTop": 10,
        "paddingBottom": 10,

        //Optional. If not set, widget's z-index is auto. Please use values between 0 and 100.
        "zIndex": 0
      },

      //Optional. Whether the widget will open at app start. The default value is false.
      //Only valid for in-panel widget.
      //If more than one widget in widgetOnScreen are set to true, the first one opens.
      //If more than one widget in widget pool are set to true, it's the controller's responsibility to define how to open.
      "openAtStart": true,

      //Optional. Object or url. If object, it means widget's config object;
      //If url, it means the location of the config file.
      //if not set, the framework will check "hasConfig" property to decide the widget config.
      "config": {},

      //Optional. If not set, the value is true.
      "visible": false,

      //Optional. This property is valid for on-screen off-panel widget only.
      //false means widget will be loaded and be put on the defined position, you can't close the widget;
      //true means app will create an icon for this widget and user can open/close this widget by click the
      //icon.
      "closeable": false,

      //Required. If the following version is older than the lastest widget's version, the framework will run widget's version manager to upgrade the widget's configuration.
      "version": "1.1"
    }],

    //The group has position properties.
    "groups": [{
      //Optional. If set, all widgets in this group display in this panel.
      //If not set, all widgets in this group display in the default panel.
      "panel": {
        "uri": "jimu/PanelType1",
        "position": {
          "left": 0,
          "top": 0,
          "right": 0,
          "bottom": 30,
          "width": 100,
          "height": 100,
          "relativeTo": "map",
        }
      },

      //Widgets in the group have no position properties.
      "widgets": [{
        "uri": "widgets/Header/Widget",
        "icon": "",
        "label": ""
      }],

      //Optional. If not set, the value is true.
      "visible": false,

      //Optional. If not set, there is no limitaion of widget count.
      "maxWidgets": 0
    }]
  },

  "map": {
    //Optional. If both 2D and 3D are not set, a 2D map is created by default.
    //If 3D is true and 2D is false, it's a 3D app.
    //If 3D is false and 2D is true, it's a 2D app.
    //If both 3D and 2D are true, it's an app with ability of switching between 2D and 3D.
    //The default map is 2D.
    "3D": true,
    "2D": true,

    //Optional. The url where webmap is hosted. If not set, use app's portalUrl property.
    "portalUrl": "",

    //Optional. Webmap id or webscene id.
    //If set, framework will use this property and ignore basemaps.
    "itemId": "",

    //The same as widget's fix position.
    "position": {
      "left": 0,
      "top": 0,
      "right": 0,
      "bottom": 30,
      "width": 100,
      "height": 100
    },

    "mapOptions": {
      //These properties are the same as the map API.
      "extent": {
        "xmin": 20, "xmax": 30, "ymin": 40, "ymax": 50, "spatialReference" { "wkid": 4326}
      },
      "center": "",
      "level": 3
    },

    //Optional. It indicates how map refresh. If property 'useWebMapRefreshInterval' is true, means honor the individual interval of each layer and property 'minutes' will be ignored. If property 'useWebMapRefreshInterval' is false, means use a single interval specified by 'minutes' for all layers. The default value of property 'useWebMapRefreshInterval' is true.
    "mapRefreshInterval": {
      "useWebMapRefreshInterval": false,
      "minutes": 0.5
    },

    // Config proxies to replace the premium layer in the map.
    "appProxy": {
      // Webmap id
      "mapItemId": "",
      "proxyItems": [{
        "sourceUrl": "",
        "proxyUrl": "",
        "proxyId": "",
        "useProxy": true
      }]
    }
  },

  //Widgets in this section are not loaded by the app, but are controlled by the widget(controller widget).
  "widgetPool": {
    //Optional. If set, widgets in the container display in this panel. Otherwise they display in the default panel.
    "panel": {
      "uri": "jimu/PanelType1",
      "position": {
        "left": 0,
        "top": 0,
        "right": 0,
        "bottom": 30,
        "width": 100,
        "height": 100,
        "relativeTo": "map"
      }
    },

    "groups": [{
      //Can be one or more widgets.
      "widgets": [{
        "uri": "widgets/Bookmark/Widget",
        "icon": "",
        "label": ""
      }],

      //Optional.If only one widget, this property is ignored.
      "label": "",

      //Optional. The sequence of the group/widget.
      "index": 1,

      //Optional. If not set, use widget container's panel;
      //If set, it overrides the container's panel.
      "panel": {
        "uri": "jimu/PanelType1",
        "position": {
          "left": 0,
          "top": 0,
          "right": 0,
          "bottom": 30,
          "width": 100,
          "height": 100
        }
      }
    }],

    "widgets": [{
      "index": 2,
      "uri": "widgets/Header/Widget",
      "icon": "",
      "label": ""
    }]
  },

  /****************************************
  This section define the app layout in mobile device. For now, app will switch to mobile mode if browser's
  width/height is less than 600px.

  The content of this property is the same as the whole app config, except that it can contain
  on-screen widget/group position only.

  You have two ways to define widget/group's position: array, or object.
  If use array, you need to define widget/group's position one by one.
  If use object, you can use widget's uri as a key, and use position as a value to define.
    For placeholder, because it has no uri, so plese use "ph_<i>" as the key, the <i> is the index of the placeholder.
    For group, so plese use "g_<i>" as the key, the <i> is the index of the group.
  *****************************************/
  "mobileLayout": {
    "widgetOnScreen": {
      "widgets": {
        "themes/FoldableTheme/widgets/HeaderController/Widget":{
          "position": {
            "left": 0,
            "top": 0,
            "right": 0,
            "height": 40,
            "paddingRight": 0,
            "relativeTo": "browser"
          }
        },
        "widgets/Search/Widget":{
          "position": {
            "right": 2,
            "top": 50,
            "relativeTo": "browser",
            "zIndex": 4
          }
        }
      }
    }
  },

  /****************************************
  This section defines the loading page of your application. The background image and loading
  gif are center-aligned.
  *****************************************/
  "loadingPage": {
    //The backgroud color of the loading page.
    "backgroundColor": "#508dca",
    "backgroundImage":{
      //Controls whether the backgroud image is visible. If it is false, the other options under "backgroudImage" will be ignored.
      "visible":false,
      //The uri of the backgroud image whose path is relative to the root of your application.
      "uri": "configs/loading/images/background.png",
      //The width of the image.
      "width": 812,
      //The height of the image.
      "height": 972
    },
    "loadingGif":{
      //Controls whether the gif image is visible. If it is false, the other options under "loadingGif" will be ignored.
      "visible": true,
      //The uri of the gif image whose path is relative to the root of your application.
      "uri": "configs/loading/images/predefined_loading_1.gif",
      //The width of the image.
      "width": 58,
      //The height of the image.
      "height": 58
    }
  },

  // Config proxies to replace the premium urls used in the app.
  "appProxies": [{
    "sourceUrl": "",
    "proxyUrl": "",
    "proxyId": "",
    "useProxy": true
  }],

  /***********************************
   if app is a tempalte or an app create from a template, they will have 'templateConfig' property.
     for themplate: this property is used to define the mapping between the tempalte configuration and the original app.
     for app create from a tempalte: this property is used to define the template based configuration.
   The content of this property is the same with 'configurable parameters for templates' of ArcGIS online.
   Please go here for details: http://server.arcgis.com/en/portal/latest/use/configurable-templates.htm
  ***********************************/
  "templateConfig": {},

  //if this property is true, means this app is created from a template
  "isTemplateApp": true,

  "wabVersion": "1.0"
}
