This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
317 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ortmaster/src/app/pages/app-view/merge-profile-dialog/merge-profile-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<header class="flex flex-row items-center justify-between mb-2"> | ||
<h1 class="text-sm font-light m-0"> | ||
Merge Profiles | ||
</h1> | ||
|
||
<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" class="w-3 h-3 text-secondary hover:text-primary cursor-pointer" (click)="dialogRef.close()"> | ||
<path fill="currentColor" d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"></path> | ||
</svg> | ||
</header> | ||
|
||
<span class="py-2 text-secondary text-xxs"> | ||
Please select the primary profile. All other selected profiles will be merged into the primary profile by copying metadata, fingerprints and icons into a new profile. | ||
Only the settings of the primary profile will be kept. | ||
</span> | ||
|
||
<div class="flex flex-row gap-2 justify-between border-b border-gray-500 p-2 items-center"> | ||
<label class="text-primary text-xxs relative">Primary Profile:</label> | ||
<sfng-select [(ngModel)]="primary" (ngModelChange)="newName = newName || primary?.Name || ''" class="border border-gray-500"> | ||
<ng-container *ngFor="let p of profiles; trackBy: trackProfile"> | ||
<sfng-select-item *sfngSelectValue="p; label:p.Name" class="flex flex-row items-center gap-2"> | ||
<app-icon [profile]="p"></app-icon> | ||
{{ p.Name }} | ||
</sfng-select-item> | ||
</ng-container> | ||
</sfng-select> | ||
</div> | ||
|
||
<div class="flex flex-row gap-2 justify-between items-center p-2"> | ||
<label class="text-primary text-xxs relative">Name for the new Profile</label> | ||
<input type="text" [(ngModel)]="newName" placeholder="New Profile Name" class="!border !border-gray-500 flex-grow"> | ||
</div> | ||
|
||
<div class="flex flex-row justify-end gap-2"> | ||
<button (click)="dialogRef.close()">Abort</button> | ||
<button class="bg-blue text-white" (click)="mergeProfiles()" [disabled]="!primary || !newName">Merge</button> | ||
</div> |
62 changes: 62 additions & 0 deletions
62
.../portmaster/src/app/pages/app-view/merge-profile-dialog/merge-profile-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { AppProfile } from './../../../../../dist-lib/safing/portmaster-api/lib/app-profile.types.d'; | ||
import { ChangeDetectionStrategy, Component, OnInit, TrackByFunction, inject } from "@angular/core"; | ||
import { Router } from '@angular/router'; | ||
import { PortapiService } from '@safing/portmaster-api'; | ||
import { SFNG_DIALOG_REF, SfngDialogRef } from "@safing/ui"; | ||
import { ActionIndicatorService } from 'src/app/shared/action-indicator'; | ||
|
||
@Component({ | ||
templateUrl: './merge-profile-dialog.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
styles: [ | ||
` | ||
:host { | ||
@apply flex flex-col gap-2 justify-start h-96 w-96; | ||
} | ||
` | ||
] | ||
}) | ||
export class MergeProfileDialogComponent implements OnInit { | ||
readonly dialogRef: SfngDialogRef<MergeProfileDialogComponent, unknown, AppProfile[]> = inject(SFNG_DIALOG_REF); | ||
private readonly portapi = inject(PortapiService); | ||
private readonly router = inject(Router); | ||
private readonly uai = inject(ActionIndicatorService); | ||
|
||
get profiles(): AppProfile[] { | ||
return this.dialogRef.data; | ||
} | ||
|
||
primary: AppProfile | null = null; | ||
newName = ''; | ||
|
||
trackProfile: TrackByFunction<AppProfile> = (_, p) => `${p.Source}/${p.ID}` | ||
|
||
ngOnInit(): void { | ||
(() => { }); | ||
} | ||
|
||
mergeProfiles() { | ||
if (!this.primary) { | ||
return | ||
} | ||
|
||
this.portapi.mergeProfiles( | ||
this.newName, | ||
`${this.primary.Source}/${this.primary.ID}`, | ||
this.profiles | ||
.filter(p => p !== this.primary) | ||
.map(p => `${p.Source}/${p.ID}`) | ||
) | ||
.subscribe({ | ||
next: newID => { | ||
this.router.navigate(['/app/' + newID]) | ||
this.uai.success('Profiles Merged Successfully', 'All selected profiles have been merged') | ||
|
||
this.dialogRef.close() | ||
}, | ||
error: err => { | ||
this.uai.error('Failed To Merge Profiles', this.uai.getErrorMessgae(err)) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.