Skip to content

Commit a4c38a4

Browse files
authored
Merge pull request #113 from netgrif/NAE-1678
[NAE-1678] User impersonation
2 parents b3a32ea + 4ffd177 commit a4c38a4

File tree

74 files changed

+1377
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1377
-34
lines changed

nae.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
"name": "filter",
4949
"address": "http://localhost:8080/api/",
5050
"format": "json"
51+
},
52+
{
53+
"name": "impersonation",
54+
"address": "http://localhost:8080/api/",
55+
"format": "json"
5156
}
5257
]
5358
},
@@ -164,6 +169,17 @@
164169
"path": "recover/:token"
165170
}
166171
},
172+
"demo-impersonation": {
173+
"component": {
174+
"class": "ImpersonationDemoComponent",
175+
"from": "./doc/impersonation-demo/impersonation-demo.component"
176+
},
177+
"access": "private",
178+
"navigation": true,
179+
"routing": {
180+
"path": "impersonation-view"
181+
}
182+
},
167183
"demo-drawer": {
168184
"component": {
169185
"class": "DrawerExampleComponent",
@@ -216,7 +232,9 @@
216232
"from": "./doc/workflow-view-example/workflow-view-example.component"
217233
},
218234
"access": {
219-
"authority": ["ROLE_ADMIN"]
235+
"authority": [
236+
"ROLE_ADMIN"
237+
]
220238
},
221239
"navigation": {
222240
"title": "Workflow view",

projects/nae-example-app/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import { WrapperEmptyViewComponent } from './views/wrapper/wrapper-empty-view.co
9898
import {DoubleDrawerExampleComponent} from './doc/double-drawer-example/double-drawer-example.component';
9999
import { PublicSingleTaskViewComponent } from './doc/public-single-task-view/public-single-task-view.component';
100100
import { BreadcrumbsExampleComponent } from './doc/breadcrumbs-example/breadcrumbs-example.component';
101+
import {ImpersonationDemoComponent} from './doc/impersonation-demo/impersonation-demo.component';
101102

102103
export function HttpLoaderFactory(http: HttpClient) {
103104
return new TranslateHttpLoader(http);
@@ -130,6 +131,7 @@ export function HttpLoaderFactory(http: HttpClient) {
130131
DashboardExampleComponent,
131132
FilterRepositoryExampleComponent,
132133
ProfileComponent,
134+
ImpersonationDemoComponent,
133135
NavigationExampleComponent,
134136
ButtonsNavComponent,
135137
RolesAssignComponent,

projects/nae-example-app/src/app/doc/drawer-example/drawer-example.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nc-navigation-drawer #sidenav [fixed]="fixed" [user]="true" [quickPanel]="true" [navigation]="true"
1+
<nc-navigation-drawer #sidenav [fixed]="fixed" [user]="true" [quickPanel]="true" [navigation]="true" [panelItems]="['language', 'settings', 'logout', 'impersonation']"
22
(openedChange)="openStatusChanged($event)">
33

44
<div fxLayout="column" fxLayoutAlign="start start" style="padding: 16px; height: 1000px;">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<button (click)="impersonate()">IMPERSONATE</button>
2+
3+
<button (click)="stopImpersonate()">STOP IMPERSONATE</button>

projects/nae-example-app/src/app/doc/impersonation-demo/impersonation-demo.component.scss

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import {ImpersonationDemoComponent} from './impersonation-demo.component';
3+
4+
5+
describe('ImpersonationDemoComponent', () => {
6+
let component: ImpersonationDemoComponent;
7+
let fixture: ComponentFixture<ImpersonationDemoComponent>;
8+
9+
beforeEach(waitForAsync(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ ImpersonationDemoComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ImpersonationDemoComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {Component, OnInit} from '@angular/core';
2+
import {ImpersonationService, ImpersonationUserSelectService, LoggerService} from '@netgrif/components-core';
3+
4+
@Component({
5+
selector: 'nae-app-impersonation-demo',
6+
templateUrl: './impersonation-demo.component.html',
7+
styleUrls: ['./impersonation-demo.component.scss']
8+
})
9+
export class ImpersonationDemoComponent {
10+
11+
constructor(
12+
private _impersonationSelect: ImpersonationUserSelectService,
13+
private _impersonation: ImpersonationService,
14+
private _log: LoggerService,
15+
) {
16+
this._impersonation.impersonating$.subscribe((isImpersonating: boolean) => {
17+
this._log.debug("Is impersonating " + isImpersonating);
18+
});
19+
}
20+
21+
public impersonate(): void {
22+
this._impersonationSelect.selectImpersonate();
23+
}
24+
25+
public stopImpersonate(): void {
26+
this._impersonation.cease();
27+
}
28+
29+
}

projects/nae-example-app/src/app/nae-example-app-view.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {WrapperEmptyViewComponent} from './views/wrapper/wrapper-empty-view.comp
3939
import {DoubleDrawerExampleComponent} from './doc/double-drawer-example/double-drawer-example.component';
4040
import {PublicSingleTaskViewComponent} from './doc/public-single-task-view/public-single-task-view.component';
4141
import {BreadcrumbsExampleComponent} from './doc/breadcrumbs-example/breadcrumbs-example.component';
42+
import {ImpersonationDemoComponent} from './doc/impersonation-demo/impersonation-demo.component';
4243

4344
@Injectable({
4445
providedIn: 'root'
@@ -48,6 +49,7 @@ export class NaeExampleAppViewService extends ViewService {
4849
// This class is managed by schematics. Do not modify it by hand.
4950
// If you want to add views to the application run the 'create-view' schematic.
5051
super([
52+
{id: 'ImpersonationDemoComponent', class: ImpersonationDemoComponent},
5153
{id: 'BreadcrumbsExampleComponent', class: BreadcrumbsExampleComponent},
5254
{id: 'TitleConfigComponent', class: TitleConfigComponent},
5355
{id: 'PublicSingleTaskViewComponent', class: PublicSingleTaskViewComponent},

projects/netgrif-components-core/src/assets/i18n/de.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
"option-selector": {
110110
"select": "Auswählen",
111111
"choose-one-option": "Wählen Sie eine Option aus"
112+
},
113+
"impersonation": {
114+
"title": "Benutzer vertreten",
115+
"submit": "Vertreten",
116+
"cease": "Vertretung abbrechen",
117+
"impersonating": "in Vertretung als"
112118
}
113119
},
114120
"search": {
@@ -457,5 +463,16 @@
457463
},
458464
"dynamicNavigation": {
459465
"couldNotResolveView": "Ein Fehler ist aufgetreten während des Ansichtauflösungsprocess. Der Ansicht kann nicht angezeigt werden"
466+
},
467+
"impersonation": {
468+
"user": {
469+
"successfullyRepresented": "Benutzer wird jetzt vertreten",
470+
"currentlyAlreadyRepresented": "Für den Benutzer existiert bereits eine Vertretung",
471+
"currentlyLogged": "Benutzer ist bereits angemeldet"
472+
},
473+
"action": {
474+
"failed": "Aktion ist fehlgeschlagen",
475+
"deactivated": "Vertretung wurde erfolgreich deaktiviert"
476+
}
460477
}
461478
}

projects/netgrif-components-core/src/assets/i18n/en.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
"option-selector": {
110110
"select": "Select",
111111
"choose-one-option": "Choose one of the provided options"
112+
},
113+
"impersonation": {
114+
"title": "Impersonate user",
115+
"submit": "Impersonate",
116+
"cease": "Cancel impersonation",
117+
"impersonating": "impersonating"
112118
}
113119
},
114120
"search": {
@@ -457,5 +463,16 @@
457463
},
458464
"dynamicNavigation": {
459465
"couldNotResolveView": "An error has occurred during the view resolution process. The view could not be displayed"
466+
},
467+
"impersonation": {
468+
"user": {
469+
"successfullyRepresented": "User successfully represented",
470+
"currentlyAlreadyRepresented": "User is already being represented by someone else",
471+
"currentlyLogged": "User is currently logged in"
472+
},
473+
"action": {
474+
"failed": "Action failed",
475+
"deactivated": "Representation was successfully deactivated"
476+
}
460477
}
461478
}

0 commit comments

Comments
 (0)