Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ngageoint/mage-server in…
Browse files Browse the repository at this point in the history
…to fix-event-sync
  • Loading branch information
ryanslatten committed Jan 15, 2025
2 parents e98eb82 + 95d6319 commit 81961d5
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 183 deletions.
20 changes: 10 additions & 10 deletions plugins/arcgis/service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const InjectedServices = {

const pluginWebRoute = "plugins/@ngageoint/mage.arcgis.service"

const sanitizeFeatureService = async (config: FeatureServiceConfig, identityService: ArcGISIdentityService): Promise<Omit<FeatureServiceConfig & { authenticated: boolean }, 'identityManager'>> => {
const sanitizeFeatureService = async (config: FeatureServiceConfig, identityService: ArcGISIdentityService): Promise<Omit<FeatureServiceConfig & { authenticated: boolean }, 'identityManager'>> => {
let authenticated = false
try {
await identityService.signin(config)
authenticated = true
} catch(ignore) {}
} catch (ignore) { }

const { identityManager, ...sanitized } = config;
return { ...sanitized, authenticated }
Expand Down Expand Up @@ -133,7 +133,7 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
</head>
</html>
`);
}).catch((error) => res.status(400).json(error))
}).catch((error) => res.status(400).json(error))
})

return routes
Expand Down Expand Up @@ -167,7 +167,7 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
const config = await stateRepo.get()
const { featureServices: updatedServices, ...updateConfig } = req.body


// Convert event names to event IDs
// Fetch all events and create a mapping of event names to event IDs
const allEvents = await eventRepo.findAll();
Expand All @@ -176,7 +176,7 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
eventNameToIdMap.set(event.name, event.id);
});

// Process the incoming feature services with eventIds instead of event names
// Process the incoming feature services with eventIds instead of event names
const featureServices: FeatureServiceConfig[] = updatedServices.map((updateService: any) => {
const existingService = config.featureServices.find(
(featureService: FeatureServiceConfig) => featureService.url === updateService.url
Expand Down Expand Up @@ -206,12 +206,12 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
url: updateService.url,
layers: layers,
// Map exisiting identityManager, client does not send this
identityManager: existingService?.identityManager,
identityManager: existingService?.identityManager || '',
};
});

await stateRepo.patch({ ...updateConfig, featureServices })

// Sync configuration with feature servers by restarting observation processor
processor.stop()
processor.start()
Expand All @@ -229,7 +229,7 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
let service: FeatureServiceConfig
let identityManager: ArcGISIdentityManager
if (token) {
identityManager = await ArcGISIdentityManager.fromToken({ token })
identityManager = await ArcGISIdentityManager.fromToken({ token })
service = { url, layers: [], identityManager: identityManager.serialize() }
} else if (username && password) {
identityManager = await ArcGISIdentityManager.signIn({
Expand All @@ -255,7 +255,7 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
return res.send('Invalid credentials provided to communicate with feature service').status(400)
}
})

routes.get('/featureService/layers', async (req, res, next) => {
const url = req.query.featureServiceUrl as string
const config = await processor.safeGetConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,88 @@ <h1>ArcGIS Configuration</h1>
<mat-card appearance="outlined">
<mat-card-header>
<mat-card-title>
Processing <button class="edit-button" mat-icon-button (click)="onEditProcessing()"><mat-icon>edit</mat-icon></button>
Processing
</mat-card-title>
<mat-card-subtitle>MAGE ArcGIS plugin processing settings.</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div class="processing">
<table class="processing-table">
<tr>
<th>Enabled
<button class="info-button" mat-icon-button
(click)="showInfo('Enabled', 'Process observations and send to configured ArcGIS feature layers')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.enabled}}</td>
</tr>
<tr>
<th>Base URL
<button class="info-button" mat-icon-button (click)="showInfo('Base URL', 'MAGE server base URL')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.baseUrl}}</td>
</tr>
<tr>
<th>Interval (s)
<button class="info-button" mat-icon-button
(click)="showInfo('Interval', 'Observation query and processing frequency time interval in seconds')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.intervalSeconds}}</td>
</tr>
<tr>
<th>Startup Interval (s)
<button class="info-button" mat-icon-button
(click)="showInfo('Startup Interval', 'Startup interval in seconds to wait for feature layer processors to be ready')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.startupIntervalSeconds}}</td>
</tr>
<tr>
<th>Update Interval (s)
<button class="info-button" mat-icon-button
(click)="showInfo('Update Interval', 'Processing wait time interval in seconds when pending observation updates exist')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.updateIntervalSeconds}}</td>
</tr>
<tr>
<th>Batch Size
<button class="info-button" mat-icon-button
(click)="showInfo('Batch Size', 'Maximum number of observations to process during a single time interval')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.batchSize}}</td>
</tr>
<tr>
<th>Attachment Tolerance (ms)
<button class="info-button" mat-icon-button
(click)="showInfo('Attachment Tolerance', 'Time tolerance in milliseconds to consider an attachment as modified compared to the observation')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</th>
<td>{{config.attachmentModifiedTolerance}}</td>
</tr>
</table>
<div style="width: 100%;">
<div class="edit-processing-form">
<div class="edit-enabled-field">
<mat-form-field appearance="fill">
<mat-label>Enabled</mat-label>
<mat-select placeholder="Enabled" [(value)]="editConfig.enabled"
(selectionChange)="setField('enabled', $event.value)">
<mat-option [value]="true">true</mat-option>
<mat-option [value]="false">false</mat-option>
</mat-select>
<mat-hint>Process observations and send to configured ArcGIS feature layers</mat-hint>
</mat-form-field>
</div>
<div class="edit-enabled-field">
<mat-form-field appearance="fill" floatLabel="always">
<mat-label>Base URL</mat-label>
<input type="text" matInput value="{{editConfig.baseUrl}}"
placeholder="https://mock.mage.com"
(keyup)="setField('baseUrl', baseUrlField.value)"
(input)="setField('baseUrl', baseUrlField.value)" #baseUrlField />
<mat-hint>Mage server base URL</mat-hint>
</mat-form-field>
</div>
<div class="edit-interval-field">
<mat-form-field appearance="fill">
<mat-label>Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.intervalSeconds}}"
(keyup)="setNumberField('intervalSeconds', intervalSecondsField.value, 0)"
(input)="setNumberField('intervalSeconds', intervalSecondsField.value, 0)" #intervalSecondsField />
<mat-hint>Observation query and processing frequency time interval in seconds</mat-hint>
</mat-form-field>
</div>
<div class="edit-startup-interval-field">
<mat-form-field appearance="fill">
<mat-label>Startup Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.startupIntervalSeconds}}"
(keyup)="setNumberField('startupIntervalSeconds', startupIntervalSecondsField.value, 0)"
(input)="setNumberField('startupIntervalSeconds', startupIntervalSecondsField.value, 0)"
#startupIntervalSecondsField />
<mat-hint>Startup interval in seconds to wait for feature layer processors to be ready</mat-hint>
</mat-form-field>
</div>
<div class="edit-update-interval-field">
<mat-form-field appearance="fill">
<mat-label>Update Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.updateIntervalSeconds}}"
(keyup)="setNumberField('updateIntervalSeconds', updateIntervalSecondsField.value, 0)"
(input)="setNumberField('updateIntervalSeconds', updateIntervalSecondsField.value, 0)"
#updateIntervalSecondsField />
<mat-hint>Processing wait time interval in seconds when pending observation updates exist</mat-hint>
</mat-form-field>
</div>
<div class="batch-size-field">
<mat-form-field appearance="fill">
<mat-label>Batch Size</mat-label>
<input type="number" min="1" matInput value="{{editConfig.batchSize}}"
(keyup)="setNumberField('batchSize', batchSizeField.value, 1)"
(input)="setNumberField('batchSize', batchSizeField.value, 1)" #batchSizeField />
<mat-hint>Maximum number of observations to process during a single time interval</mat-hint>
</mat-form-field>
</div>
<div class="attachment-modified-tolerance-field">
<mat-form-field appearance="fill">
<mat-label>Attachment Tolerance</mat-label>
<input type="number" min="0" matInput value="{{editConfig.attachmentModifiedTolerance}}"
(keyup)="setNumberField('attachmentModifiedTolerance', attachmentModifiedToleranceField.value, 0)"
(input)="setNumberField('attachmentModifiedTolerance', attachmentModifiedToleranceField.value, 0)"
#attachmentModifiedToleranceField />
<mat-hint>Time tolerance in milliseconds to consider an attachment as modified compared to the observation</mat-hint>
</mat-form-field>
</div>
</div>
</div>
</mat-card-content>
<mat-card-actions>
<button (click)="onEditProcessing()" mat-button>Edit</button>
<button mat-flat-button color="primary" matDialogClose (click)="saveEdit()">SAVE</button>
<button mat-button matDialogClose (click)="cancelEdit()">CANCEL</button>
</mat-card-actions>
</mat-card>
<arc-layer [config]="config" (configChanged)="configChanged($event)"></arc-layer>
Expand Down Expand Up @@ -651,104 +659,6 @@ <h3 matDialogTitle>{{infoTitle}}</h3>
</div>
</mat-dialog-content>
</ng-template>
<ng-template #editProcessingDialog let-data>
<h2 matDialogTitle>Processing Configuration</h2>
<mat-dialog-content>
<div class="edit-processing-form">
<div class="edit-enabled-field">
<mat-form-field [style.width.%]="90">
<mat-select placeholder="Enabled" [(value)]="editConfig.enabled"
(selectionChange)="setField('enabled', $event.value)">
<mat-option [value]="true">true</mat-option>
<mat-option [value]="false">false</mat-option>
</mat-select>
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Enabled', 'Process observations and send to configured ArcGIS feature layers')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="edit-enabled-field">
<mat-form-field [style.width.%]="90">
<input type="text" matInput value="{{editConfig.baseUrl}}"
(keyup)="setField('baseUrl', baseUrlField.value)"
(input)="setField('baseUrl', baseUrlField.value)" #baseUrlField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Base URL', 'Mage server base URL')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="edit-interval-field">
<mat-form-field [style.width.%]="90">
<mat-label>Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.intervalSeconds}}"
(keyup)="setNumberField('intervalSeconds', intervalSecondsField.value, 0)"
(input)="setNumberField('intervalSeconds', intervalSecondsField.value, 0)" #intervalSecondsField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Interval', 'Observation query and processing frequency time interval in seconds')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="edit-startup-interval-field">
<mat-form-field [style.width.%]="90">
<mat-label>Startup Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.startupIntervalSeconds}}"
(keyup)="setNumberField('startupIntervalSeconds', startupIntervalSecondsField.value, 0)"
(input)="setNumberField('startupIntervalSeconds', startupIntervalSecondsField.value, 0)"
#startupIntervalSecondsField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Startup Interval', 'Startup interval in seconds to wait for feature layer processors to be ready')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="edit-update-interval-field">
<mat-form-field [style.width.%]="90">
<mat-label>Update Interval</mat-label>
<input type="number" min="0" matInput value="{{editConfig.updateIntervalSeconds}}"
(keyup)="setNumberField('updateIntervalSeconds', updateIntervalSecondsField.value, 0)"
(input)="setNumberField('updateIntervalSeconds', updateIntervalSecondsField.value, 0)"
#updateIntervalSecondsField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Update Interval', 'Processing wait time interval in seconds when pending observation updates exist')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="batch-size-field">
<mat-form-field [style.width.%]="90">
<mat-label>Batch Size</mat-label>
<input type="number" min="1" matInput value="{{editConfig.batchSize}}"
(keyup)="setNumberField('batchSize', batchSizeField.value, 1)"
(input)="setNumberField('batchSize', batchSizeField.value, 1)" #batchSizeField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Batch Size', 'Maximum number of observations to process during a single time interval')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
<div class="attachment-modified-tolerance-field">
<mat-form-field [style.width.%]="90">
<mat-label>Attachment Tolerance</mat-label>
<input type="number" min="0" matInput value="{{editConfig.attachmentModifiedTolerance}}"
(keyup)="setNumberField('attachmentModifiedTolerance', attachmentModifiedToleranceField.value, 0)"
(input)="setNumberField('attachmentModifiedTolerance', attachmentModifiedToleranceField.value, 0)"
#attachmentModifiedToleranceField />
</mat-form-field>
<button class="info-button" mat-icon-button
(click)="showInfo('Attachment Tolerance', 'Time tolerance in milliseconds to consider an attachment as modified compared to the observation')">
<mat-icon class="info-icon" [inline]="true">info_outline</mat-icon>
</button>
</div>
</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button matDialogClose (click)="cancelEdit()">CANCEL</button>
<button mat-flat-button color="primary" matDialogClose (click)="saveEdit()">SAVE</button>
</mat-dialog-actions>
</ng-template>
<ng-template #editAttributesDialog let-data>
<h2 matDialogTitle>Attributes Configuration</h2>
<mat-dialog-content>
Expand Down Expand Up @@ -888,8 +798,8 @@ <h2 matDialogTitle>Attributes Configuration</h2>
</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button matDialogClose (click)="cancelEdit()">CANCEL</button>
<button mat-flat-button color="primary" matDialogClose (click)="saveEdit()">SAVE</button>
<button mat-button matDialogClose (click)="cancelEdit()">CANCEL</button>
</mat-dialog-actions>
</ng-template>
<ng-template #deleteFieldDialog let-data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
padding: 1rem;
}

.edit-processing-form .mat-form-field {
margin-bottom: 1.5rem !important;
}

section {
>* {
margin-inline-start: 0em;
Expand Down
Loading

0 comments on commit 81961d5

Please sign in to comment.