|
|
@ -38,8 +38,7 @@ import { |
|
|
Inject, |
|
|
Inject, |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
OnInit, |
|
|
OnInit, |
|
|
ViewChild, |
|
|
ViewChild |
|
|
signal |
|
|
|
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { |
|
|
import { |
|
|
AbstractControl, |
|
|
AbstractControl, |
|
|
@ -60,7 +59,6 @@ import { |
|
|
MatDialogModule, |
|
|
MatDialogModule, |
|
|
MatDialogRef |
|
|
MatDialogRef |
|
|
} from '@angular/material/dialog'; |
|
|
} from '@angular/material/dialog'; |
|
|
import { MatExpansionModule } from '@angular/material/expansion'; |
|
|
|
|
|
import { MatInputModule } from '@angular/material/input'; |
|
|
import { MatInputModule } from '@angular/material/input'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
@ -79,6 +77,7 @@ import { format } from 'date-fns'; |
|
|
import { StatusCodes } from 'http-status-codes'; |
|
|
import { StatusCodes } from 'http-status-codes'; |
|
|
import { addIcons } from 'ionicons'; |
|
|
import { addIcons } from 'ionicons'; |
|
|
import { |
|
|
import { |
|
|
|
|
|
codeSlashOutline, |
|
|
createOutline, |
|
|
createOutline, |
|
|
ellipsisVertical, |
|
|
ellipsisVertical, |
|
|
readerOutline, |
|
|
readerOutline, |
|
|
@ -106,7 +105,6 @@ import { AssetProfileDialogParams } from './interfaces/interfaces'; |
|
|
MatButtonModule, |
|
|
MatButtonModule, |
|
|
MatCheckboxModule, |
|
|
MatCheckboxModule, |
|
|
MatDialogModule, |
|
|
MatDialogModule, |
|
|
MatExpansionModule, |
|
|
|
|
|
MatInputModule, |
|
|
MatInputModule, |
|
|
MatMenuModule, |
|
|
MatMenuModule, |
|
|
MatSelectModule, |
|
|
MatSelectModule, |
|
|
@ -233,8 +231,6 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
public scraperConfiguationIsExpanded = signal(false); |
|
|
|
|
|
|
|
|
|
|
|
public sectors: { |
|
|
public sectors: { |
|
|
[name: string]: { name: string; value: number }; |
|
|
[name: string]: { name: string; value: number }; |
|
|
}; |
|
|
}; |
|
|
@ -255,7 +251,13 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
private snackBar: MatSnackBar, |
|
|
private snackBar: MatSnackBar, |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
|
) { |
|
|
) { |
|
|
addIcons({ createOutline, ellipsisVertical, readerOutline, serverOutline }); |
|
|
addIcons({ |
|
|
|
|
|
codeSlashOutline, |
|
|
|
|
|
createOutline, |
|
|
|
|
|
ellipsisVertical, |
|
|
|
|
|
readerOutline, |
|
|
|
|
|
serverOutline |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public get canSaveAssetProfileIdentifier() { |
|
|
public get canSaveAssetProfileIdentifier() { |
|
|
@ -504,7 +506,19 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
if (!scraperConfiguration.selector || !scraperConfiguration.url) { |
|
|
if (!scraperConfiguration.selector || !scraperConfiguration.url) { |
|
|
scraperConfiguration = undefined; |
|
|
scraperConfiguration = undefined; |
|
|
} |
|
|
} |
|
|
} catch {} |
|
|
} catch (error) { |
|
|
|
|
|
console.error($localize`Could not parse scraper configuration`, error); |
|
|
|
|
|
|
|
|
|
|
|
this.snackBar.open( |
|
|
|
|
|
'😞 ' + $localize`Could not parse scraper configuration`, |
|
|
|
|
|
undefined, |
|
|
|
|
|
{ |
|
|
|
|
|
duration: ms('3 seconds') |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
sectors = JSON.parse(this.assetProfileForm.get('sectors').value); |
|
|
sectors = JSON.parse(this.assetProfileForm.get('sectors').value); |
|
|
@ -538,7 +552,16 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
object: assetProfile |
|
|
object: assetProfile |
|
|
}); |
|
|
}); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error(error); |
|
|
console.error($localize`Could not validate form`, error); |
|
|
|
|
|
|
|
|
|
|
|
this.snackBar.open( |
|
|
|
|
|
'😞 ' + $localize`Could not validate form`, |
|
|
|
|
|
undefined, |
|
|
|
|
|
{ |
|
|
|
|
|
duration: ms('3 seconds') |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -550,8 +573,29 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
}, |
|
|
}, |
|
|
assetProfile |
|
|
assetProfile |
|
|
) |
|
|
) |
|
|
.subscribe(() => { |
|
|
.subscribe({ |
|
|
this.initialize(); |
|
|
next: () => { |
|
|
|
|
|
this.snackBar.open( |
|
|
|
|
|
'✅ ' + $localize`Asset profile has been saved`, |
|
|
|
|
|
undefined, |
|
|
|
|
|
{ |
|
|
|
|
|
duration: ms('3 seconds') |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.initialize(); |
|
|
|
|
|
}, |
|
|
|
|
|
error: (error) => { |
|
|
|
|
|
console.error($localize`Could not save asset profile`, error); |
|
|
|
|
|
|
|
|
|
|
|
this.snackBar.open( |
|
|
|
|
|
'😞 ' + $localize`Could not save asset profile`, |
|
|
|
|
|
undefined, |
|
|
|
|
|
{ |
|
|
|
|
|
duration: ms('3 seconds') |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -702,8 +746,8 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onTriggerSubmitAssetProfileForm() { |
|
|
public onTriggerSubmitAssetProfileForm() { |
|
|
if (this.assetProfileForm) { |
|
|
if (this.assetProfileForm.valid) { |
|
|
this.assetProfileFormElement.nativeElement.requestSubmit(); |
|
|
this.onSubmitAssetProfileForm(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|