Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 4340b11

Browse files
committed
testinfg
1 parent 17820e9 commit 4340b11

14 files changed

Lines changed: 118 additions & 67 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace JPProject.Admin.Api.Controllers
5+
{
6+
[Route("version"), Authorize(Policy = "ReadOnly"), ApiController]
7+
public class VersionController
8+
{
9+
[HttpGet]
10+
public string Get() => "light";
11+
}
12+
}

src/Backend/JPProject.Admin.Api/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ASPNETCORE_ENVIRONMENT": "Development"
1616
}
1717
},
18-
"Jp.UserManagement": {
18+
"JPProject.Admin.Api": {
1919
"commandName": "Project",
2020
"launchUrl": "swagger/index.html",
2121
"environmentVariables": {

src/Frontend/Jp.AdminUI/src/app/app.routing.module.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { NgModule } from "@angular/core";
2-
import { RouterModule } from "@angular/router";
3-
import { LayoutComponent } from "./shared/layout/layout.component";
4-
import { MenuService } from "./core/menu/menu.service";
5-
import { TranslatorService } from "./core/translator/translator.service";
6-
import { menu } from "./core/menu/menu";
7-
import { PagesModule } from "./pages/pages.module";
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
import { SettingsService } from '@core/settings/settings.service';
4+
import { VersionService } from '@shared/services/version.service';
5+
6+
import { menu } from './core/menu/menu';
7+
import { MenuService } from './core/menu/menu.service';
8+
import { TranslatorService } from './core/translator/translator.service';
9+
import { PagesModule } from './pages/pages.module';
10+
import { LayoutComponent } from './shared/layout/layout.component';
811

912
export const routes = [
1013

@@ -31,7 +34,9 @@ export const routes = [
3134
]
3235
})
3336
export class RoutesModule {
34-
constructor(public menuService: MenuService, tr: TranslatorService) {
35-
menuService.addMenu(menu);
37+
constructor(public menuService: MenuService, tr: TranslatorService, private settings: SettingsService) {
38+
39+
let isLight = this.settings.isLightVersion;
40+
menuService.addMenu(menu.filter(f => f.lightVersion == null || f.lightVersion == isLight));
3641
}
3742
}

src/Frontend/Jp.AdminUI/src/app/core/core.module.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
import { NgModule, Optional, SkipSelf, ModuleWithProviders } from "@angular/core";
1+
import { HttpClientModule } from '@angular/common/http';
2+
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
3+
import { environment } from '@env/environment';
4+
import { VersionService } from '@shared/services/version.service';
5+
import {
6+
AuthConfig,
7+
JwksValidationHandler,
8+
OAuthModule,
9+
OAuthModuleConfig,
10+
OAuthStorage,
11+
ValidationHandler,
12+
} from 'angular-oauth2-oidc';
213

3-
import { SettingsService } from "./settings/settings.service";
4-
import { ThemesService } from "./themes/themes.service";
5-
import { TranslatorService } from "./translator/translator.service";
6-
import { MenuService } from "./menu/menu.service";
7-
import { throwIfAlreadyLoaded } from "./module-import-guard";
8-
import { AuthGuardWithForcedLogin } from "./auth/auth-guard-with-forced-login.service";
9-
import { AuthService } from "./auth/auth.service";
10-
import { OAuthModule, AuthConfig, OAuthModuleConfig, ValidationHandler, JwksValidationHandler, OAuthStorage } from "angular-oauth2-oidc";
11-
import { HttpClientModule } from "@angular/common/http";
12-
import { authModuleConfig } from "./auth/auth-module-config";
13-
import { AuthGuard } from "./auth/auth-guard.service";
14-
import { authConfig } from "./auth/auth-config";
15-
import { authProdConfig } from "./auth/auth-config.prod";
16-
import { environment } from "@env/environment";
14+
import { authConfig } from './auth/auth-config';
15+
import { authProdConfig } from './auth/auth-config.prod';
16+
import { AuthGuardWithForcedLogin } from './auth/auth-guard-with-forced-login.service';
17+
import { AuthGuard } from './auth/auth-guard.service';
18+
import { authModuleConfig } from './auth/auth-module-config';
19+
import { AuthService } from './auth/auth.service';
20+
import { MenuService } from './menu/menu.service';
21+
import { throwIfAlreadyLoaded } from './module-import-guard';
22+
import { SettingsService } from './settings/settings.service';
23+
import { ThemesService } from './themes/themes.service';
24+
import { TranslatorService } from './translator/translator.service';
1725

1826
export function storageFactory(): OAuthStorage {
1927
return localStorage;
@@ -27,6 +35,7 @@ export function storageFactory(): OAuthStorage {
2735
],
2836
providers: [
2937
SettingsService,
38+
VersionService,
3039
ThemesService,
3140
TranslatorService,
3241
MenuService,

src/Frontend/Jp.AdminUI/src/app/core/menu/menu.service.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Injectable } from "@angular/core";
1+
import { Injectable } from '@angular/core';
2+
3+
import { MenuItem } from './menu';
24

35
@Injectable()
46
export class MenuService {
@@ -9,16 +11,7 @@ export class MenuService {
911
this.menuItems = [];
1012
}
1113

12-
addMenu(items: Array<{
13-
text: string,
14-
heading?: boolean,
15-
link?: string, // internal route links
16-
elink?: string, // used only for external links
17-
target?: string, // anchor target="_blank|_self|_parent|_top|framename"
18-
icon?: string,
19-
alert?: string,
20-
submenu?: Array<any>
21-
}>) {
14+
addMenu(items: Array<MenuItem>) {
2215
items.forEach((item) => {
2316
this.menuItems.push(item);
2417
});

src/Frontend/Jp.AdminUI/src/app/core/menu/menu.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
export class MenuItem {
2+
constructor() { }
3+
text: string;
4+
heading?: boolean;
5+
link?: string; // internal route links
6+
elink?: string; // used only for external links
7+
target?: string; // anchor target="_blank|_self|_parent|_top|framename"
8+
icon?: string;
9+
alert?: string;
10+
submenu?: Array<any>;
11+
lightVersion?: boolean;
12+
}
113

2-
const Home = {
14+
const Home: MenuItem = {
315
text: "Home",
416
link: "/home",
517
icon: "icon-home"
618
};
719

8-
const Clients = {
20+
const Clients: MenuItem = {
921
text: "Clients",
1022
link: "/clients",
1123
icon: "fa fa-desktop",
@@ -21,7 +33,7 @@ const Clients = {
2133
]
2234
};
2335

24-
const IdentityResource = {
36+
const IdentityResource: MenuItem = {
2537
text: "Identity Resources",
2638
link: "/identity-resource",
2739
icon: "far fa-id-card",
@@ -37,7 +49,7 @@ const IdentityResource = {
3749
]
3850
};
3951

40-
const ApiResource = {
52+
const ApiResource: MenuItem = {
4153
text: "Api Resources",
4254
link: "/api-resource",
4355
icon: "fas fa-cloud",
@@ -53,13 +65,13 @@ const ApiResource = {
5365
]
5466
};
5567

56-
const PersistedGrants = {
68+
const PersistedGrants: MenuItem = {
5769
text: "Persisted Grants",
5870
link: "/persisted-grants",
5971
icon: "fas fa-key"
6072
};
6173

62-
const Users = {
74+
const Users: MenuItem = {
6375
text: "Users",
6476
link: "/users",
6577
icon: "fas fa-users-cog",
@@ -72,10 +84,11 @@ const Users = {
7284
text: "Add",
7385
link: "/users/add"
7486
}
75-
]
87+
],
88+
lightVersion: false
7689
};
7790

78-
const Roles = {
91+
const Roles: MenuItem = {
7992
text: "Roles",
8093
link: "/roles",
8194
icon: "fas fa-user-tag",
@@ -88,24 +101,27 @@ const Roles = {
88101
text: "Add",
89102
link: "/roles/add"
90103
}
91-
]
104+
],
105+
lightVersion: false
92106
};
93107

94-
const headingMain = {
108+
const headingMain: MenuItem = {
95109
text: "IdentityServer4",
96110
heading: true
97111
};
98112

99-
const headingUsers = {
113+
const headingUsers: MenuItem = {
100114
text: "Users",
101-
heading: true
115+
heading: true,
116+
lightVersion: false
102117
};
103-
const headingSettings = {
118+
const headingSettings: MenuItem = {
104119
text: "SSO Settings",
105-
heading: true
120+
heading: true,
121+
lightVersion: false
106122
};
107123

108-
export const menu = [
124+
export const menu: MenuItem[] = [
109125
headingMain,
110126
Home,
111127
Clients,

src/Frontend/Jp.AdminUI/src/app/core/settings/settings.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { HttpClient } from '@angular/common/http';
21
import { Injectable } from '@angular/core';
32
import { Router } from '@angular/router';
43
import { environment } from '@env/environment';
4+
import { VersionService } from '@shared/services/version.service';
55
import { UserProfile } from '@shared/viewModel/userProfile.model';
66
import { OAuthService } from 'angular-oauth2-oidc';
77
import { defer, from, Observable, of } from 'rxjs';
@@ -18,13 +18,13 @@ export class SettingsService {
1818
userProfileObservable: Observable<object>;
1919
loadDiscoveryDocumentAndTryLoginObservable: Observable<any>;
2020
doc: any;
21+
isLightVersion: boolean;
2122

2223
constructor(
23-
private http: HttpClient,
2424
private oauthService: OAuthService,
25-
private router: Router) {
26-
25+
private versionService: VersionService) {
2726

27+
this.versionService.getVersion().subscribe(s => this.isLightVersion = s == "light");
2828
// App Settings
2929
// -----------------------------------
3030
this.app = {

src/Frontend/Jp.AdminUI/src/app/panel/persisted-grants/list/persisted-grants-list.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<tr>
1818
<th></th>
1919
<th>{{ 'persistedGrant.list.creationTime' | translate }}</th>
20-
<th> {{ 'persistedGrant.list.picture' | translate }} </th>
21-
<th> {{ 'persistedGrant.list.email' | translate }}</th>
20+
<th *ngIf="!settings.isLightVersion"> {{ 'persistedGrant.list.picture' | translate }} </th>
21+
<th *ngIf="!settings.isLightVersion"> {{ 'persistedGrant.list.email' | translate }}</th>
2222
<th> {{ 'persistedGrant.list.clientId' | translate }}</th>
2323
<th> {{ 'persistedGrant.list.type' | translate }} </th>
2424
<th></th>
@@ -33,8 +33,8 @@
3333
&nbsp;
3434
</td>
3535
<td>{{grant.creationTime | date: 'short'}}</td>
36-
<td><img *ngIf="grant.picture" width="32" [src]="grant.picture" /></td>
37-
<td>{{grant.email}}</td>
36+
<td *ngIf="!settings.isLightVersion"><img *ngIf="grant.picture" width="32" [src]="grant.picture" /></td>
37+
<td *ngIf="!settings.isLightVersion">{{grant.email}}</td>
3838
<td>{{grant.clientId}}</td>
3939
<td>{{grant.type}}</td>
4040
<td>

src/Frontend/Jp.AdminUI/src/app/panel/persisted-grants/list/persisted-grants-list.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { SettingsService } from '@core/settings/settings.service';
23
import { TranslatorService } from '@core/translator/translator.service';
34
import { ProblemDetails } from '@shared/viewModel/default-response.model';
45
import { PersistedGrant } from '@shared/viewModel/persisted-grants.model';
@@ -22,7 +23,8 @@ export class PersistedGrantListComponent implements OnInit {
2223
public quantity: number = 10;
2324
constructor(
2425
public translator: TranslatorService,
25-
private persistedGrantService: PersistedGrantsService) { }
26+
private persistedGrantService: PersistedGrantsService,
27+
public settings: SettingsService) { }
2628

2729
ngOnInit() {
2830
this.loadGrants();

src/Frontend/Jp.AdminUI/src/app/panel/persisted-grants/persisted-grants.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
3+
import { SettingsService } from '@core/settings/settings.service';
34
import { environment } from '@env/environment';
45
import { ProblemDetails } from '@shared/viewModel/default-response.model';
56
import { ListOfPersistedGrant } from '@shared/viewModel/persisted-grants.model';
@@ -10,7 +11,7 @@ export class PersistedGrantsService {
1011

1112
endpoint: string;
1213

13-
constructor(private http: HttpClient) {
14+
constructor(private http: HttpClient, private settings: SettingsService) {
1415
this.endpoint = environment.ResourceServer + "persisted-grants";
1516
}
1617

@@ -21,6 +22,4 @@ export class PersistedGrantsService {
2122
public remove(key: string): Observable<void> {
2223
return this.http.delete<void>(`${this.endpoint}/${key}`);
2324
}
24-
25-
2625
}

0 commit comments

Comments
 (0)