Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanslatten committed Sep 21, 2024
1 parent 7a0a59b commit fd5136e
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 4 deletions.
182 changes: 179 additions & 3 deletions plugins/arcgis/service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/arcgis/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"homepage": "https://github.com/ngageoint/mage-server#readme",
"dependencies": {
"@esri/arcgis-rest-request": "^4.2.3",
"@terraformer/arcgis": "2.1.2",
"form-data": "^4.0.0"
},
Expand Down
25 changes: 24 additions & 1 deletion plugins/arcgis/service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import { SettingPermission } from '@ngageoint/mage.service/lib/entities/authoriz
import express from 'express'
import { ArcGISPluginConfig } from './ArcGISPluginConfig'
import { ObservationProcessor } from './ObservationProcessor'
import {HttpClient} from './HttpClient'
import { HttpClient } from './HttpClient'
import { FeatureServiceResult } from './FeatureServiceResult'
import { ArcGISIdentityManager } from "@esri/arcgis-rest-request"

const credentials = {
clientId: 'dzoVuv7Apb5gjJIP',
portal: "https://arcgis.geointnext.com/arcgis/sharing/rest",
redirectUri: 'http://localhost:4242/plugins/@ngageoint/mage.arcgis.service/authenticate'
}

const logPrefix = '[mage.arcgis]'
const logMethods = ['log', 'debug', 'info', 'warn', 'error'] as const
Expand Down Expand Up @@ -75,6 +82,22 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
processor.putConfig(arcConfig)
res.status(200).json({})
})
routes.route('/sign-in')
.get(async (req, res, next) => {
ArcGISIdentityManager.authorize(credentials, res);
})
routes.route('/authenticate')
.get(async (req, res, next) => {
const code = req.query.code as string;
ArcGISIdentityManager.exchangeAuthorizationCode(credentials, code)
.then((identityManager: ArcGISIdentityManager) => {
identityManager.getUsername().then((username: string) => {
console.info('logged in user', username)
})
}).catch((error) => {
console.error(error)
});
})
routes.route('/arcgisLayers')
.get(async (req, res, next) => {
const featureUrl = req.query.featureUrl as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class ArcAdminComponent implements OnInit {
this.config = x;
arcService.fetchPopulatedEvents().subscribe(x => this.handleEventResults(x));
})
arcService.authenticate().subscribe(x => {
console.log(x)
})
}

configChanged(config: ArcGISPluginConfig) {
Expand Down
4 changes: 4 additions & 0 deletions plugins/arcgis/web-app/projects/main/src/lib/arc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class ArcService {
return this.http.get<FeatureServiceResult>(`${baseUrl}/arcgisLayers?featureUrl=${featureUrl}`)
}

authenticate() {
return this.http.get(`${baseUrl}/sign-in`)
}

fetchEvents() {
return this.http.get<EventResult[]>(`${apiBaseUrl}/events?populate=false&projection={"name":true,"id":true}`)
}
Expand Down

0 comments on commit fd5136e

Please sign in to comment.