|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
|
import { DEFAULT_LOCALE } from '@ghostfolio/common/config'; |
|
|
|
import { DEFAULT_LOCALE, MCP_ENDPOINT } from '@ghostfolio/common/config'; |
|
|
|
import { CreateAccessDto, UpdateAccessDto } from '@ghostfolio/common/dtos'; |
|
|
|
import { canApplyFiltersToAccess } from '@ghostfolio/common/helper'; |
|
|
|
import { Filter, PortfolioPosition } from '@ghostfolio/common/interfaces'; |
|
|
|
@ -27,6 +27,7 @@ import { |
|
|
|
} from '@ghostfolio/ui/portfolio-filter-form'; |
|
|
|
import { DataService } from '@ghostfolio/ui/services'; |
|
|
|
|
|
|
|
import { JsonPipe } from '@angular/common'; |
|
|
|
import type { HttpErrorResponse } from '@angular/common/http'; |
|
|
|
import { |
|
|
|
ChangeDetectionStrategy, |
|
|
|
@ -69,6 +70,7 @@ import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; |
|
|
|
FormsModule, |
|
|
|
GfAccessLevelIconComponent, |
|
|
|
GfPortfolioFilterFormComponent, |
|
|
|
JsonPipe, |
|
|
|
MatButtonModule, |
|
|
|
MatDatepickerModule, |
|
|
|
MatDialogModule, |
|
|
|
@ -88,6 +90,7 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
public tags: Filter[] = []; |
|
|
|
|
|
|
|
protected accessForm: FormGroup; |
|
|
|
protected readonly baseUrl = window.location.origin; |
|
|
|
protected minExpiresAt: Date; |
|
|
|
protected readonly mode: 'create' | 'update'; |
|
|
|
protected readonly today = startOfDay(new Date()); |
|
|
|
@ -222,6 +225,10 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
this.loadHoldings(); |
|
|
|
} |
|
|
|
|
|
|
|
protected get accessId() { |
|
|
|
return this.data.access?.id; |
|
|
|
} |
|
|
|
|
|
|
|
protected get accessLevel(): AccessLevel { |
|
|
|
return this.accessForm?.get('accessLevel')?.value as AccessLevel; |
|
|
|
} |
|
|
|
@ -234,10 +241,32 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
return this.accessType === 'PUBLIC'; |
|
|
|
} |
|
|
|
|
|
|
|
protected get mcpConfiguration() { |
|
|
|
return { |
|
|
|
headers: { |
|
|
|
Authorization: `Bearer ${this.accessId}` |
|
|
|
}, |
|
|
|
type: 'http', |
|
|
|
url: `${this.baseUrl}${MCP_ENDPOINT}` |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
protected get showExpiresAtErrorMessage() { |
|
|
|
return this.accessForm?.get('expiresAt')?.invalid === true; |
|
|
|
} |
|
|
|
|
|
|
|
protected get showMcpDetails() { |
|
|
|
return this.canGrantMcpAccess && this.isMcpAccess && this.mode === 'update'; |
|
|
|
} |
|
|
|
|
|
|
|
protected get showPublicDetails() { |
|
|
|
return ( |
|
|
|
this.hasExperimentalFeatures && |
|
|
|
this.isPublicAccess && |
|
|
|
this.mode === 'update' |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
protected onCancel() { |
|
|
|
this.dialogRef.close(); |
|
|
|
} |
|
|
|
@ -250,6 +279,10 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private get isMcpAccess() { |
|
|
|
return this.accessType === 'MCP'; |
|
|
|
} |
|
|
|
|
|
|
|
private async createAccess() { |
|
|
|
const filters = this.getFilters(); |
|
|
|
|
|
|
|
@ -343,7 +376,7 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
private async updateAccess() { |
|
|
|
const accessId = this.data.access?.id; |
|
|
|
const accessId = this.accessId; |
|
|
|
|
|
|
|
if (!accessId) { |
|
|
|
return; |
|
|
|
|