func getRegisteredApps(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "My Registered Apps" f := strings.ToLower(strings.Trim(r.R.FormValue("f"), " ")) if f == "" { return r.RenderUsingBaseTemplate(getRegisteredAppsTemplate) } ris, err := agolclient.GetUserRegisteredApps(r.Transport(), r.Auth) if err != nil { return err } if f == "csv" { r.W.Header().Set("Content-Type", "text/csv") r.W.Header().Set("Content-Disposition", "inline;filename=registeredapps.csv") agolclient.RegisteredAppItemsCsv(r.W, ris, r.PortalHomeUrl()) return } r.AddData(map[string]interface{}{ "RegisteredAppItems": ris, }) return r.RenderUsingBaseTemplate(registeredAppsTemplate) }
func callback(r *agoltools.Request) (err error) { r.AddData(map[string]interface{}{ "PageTitle": "Sign in to ArcGIS Online", "AuthCookieName": agoltools.AuthCookie, }) return r.RenderUsingBaseTemplate(callbackTemplate) }
func signIn(r *agoltools.Request) (err error) { authUrl := portalAuthorizeUrl if redirect := r.R.FormValue("redirect"); strings.HasPrefix(redirect, "/") { redirect = url.QueryEscape(redirect) authUrl += "&state=" + redirect } r.Redirect(authUrl) return nil }
func getMyAGOL(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "Get My ArcGIS Online Information" f := strings.ToLower(strings.Trim(r.R.FormValue("f"), " ")) if f == "" { return r.RenderUsingBaseTemplate(getOrgUsersTemplate) } myagol, err := agolclient.GetMyAGOL(r.Transport(), r.Auth) if err != nil { return err } r.Data["PageTitle"] = "My ArcGIS Online Information" r.Data["MyAGOL"] = myagol orgUrlKey := "" if myagol.Org != nil { orgUrlKey = myagol.Org.UrlKey } r.Data["PortalHomeUrl"] = config.PortalHomeUrl(orgUrlKey) // panel dropdown and ids pdropdown := []string{} pids := map[string]string{} //[display name]id addPanel := func(condition bool, name, id string) { if condition { pdropdown = append(pdropdown, name) pids[name] = id } } addPanel(myagol.User != nil, "User Info", "user-panel") addPanel(myagol.Folders != nil, "My Content", "content-panel") addPanel(myagol.User != nil && myagol.User.Groups != nil, "My Groups", "groups-panel") addPanel(myagol.Org != nil, "Organization Info", "org-panel") addPanel(myagol.Subscription != nil, "Subscription Info", "sub-panel") if len(pdropdown) > 1 { r.Data["PanelDropdown"] = pdropdown r.Data["PanelIds"] = pids } return r.RenderUsingBaseTemplate(orgUsersTemplate) }
func addFolderServices(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "Add Folder Services" folderUrl := strings.Trim(r.R.FormValue("folderUrl"), " ") if folderUrl == "" { return r.RenderUsingBaseTemplate(addFolderServicesTemplate) } folder, catalog, status, err := agolclient.AddFolderServices(r.Transport(), folderUrl, r.Auth) if err != nil { return err } r.Data["Folder"] = folder r.Data["Catalog"] = catalog r.Data["Status"] = status return r.RenderUsingBaseTemplate(folderServicesTemplate) }
func getOrgUsers(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "Get Organization Users" f := strings.ToLower(strings.Trim(r.R.FormValue("f"), " ")) if f == "" { return r.RenderUsingBaseTemplate(getOrgUsersTemplate) } us, err := agolclient.GetAllOrgUsers(r.Transport(), r.Auth) if err != nil { return err } if f == "csv" { r.W.Header().Set("Content-Type", "text/csv") r.W.Header().Set("Content-Disposition", "inline;filename=orgusers.csv") agolclient.UsersCsv(r.W, us) return } r.Data["Users"] = us return r.RenderUsingBaseTemplate(orgUsersTemplate) }
func root(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "ArcGIS Online Tools" return r.RenderUsingBaseTemplate(rootTemplate) }
func signOut(r *agoltools.Request) (err error) { r.SignOut() r.Redirect("/") return nil }
func getWebMapUrls(r *agoltools.Request) (err error) { r.Data["PageTitle"] = "Find Web Maps With URL" url := strings.ToLower(strings.Trim(r.R.FormValue("url"), " ")) if url == "" { return r.RenderUsingBaseTemplate(getWebMapUrlsTemplate) } findFor := strings.ToLower(strings.Trim(r.R.FormValue("for"), " ")) var wmis []*agolclient.WebMapItem if findFor == "org" { accountId := r.OrgId() if accountId == "" { return &agoltools.Error{ Message: "This option is only available to users that belong to an organization", Code: http.StatusBadRequest, } } wmis, err = agolclient.GetOrgWebMapsWithUrl(r.Transport(), accountId, url, r.Auth) if err != nil { return err } } else { wmis, err = agolclient.GetUserWebMapsWithUrl(r.Transport(), url, r.Auth) if err != nil { return err } } f := strings.ToLower(strings.Trim(r.R.FormValue("f"), " ")) if f == "csv" { r.W.Header().Set("Content-Type", "text/csv") r.W.Header().Set("Content-Disposition", "inline;filename=webmaps.csv") agolclient.WebMapItemsCsv(r.W, wmis, r.PortalHomeUrl()) return } r.AddData(map[string]interface{}{ "PageTitle": "Web Maps With URL", "WebMapItems": wmis, "URL": strings.Trim(r.R.FormValue("url"), " "), "For": findFor, }) return r.RenderUsingBaseTemplate(webMapUrlsTemplate) }