Browse Source

Minor bugfixes

pull/1/head
Sebastian 10 years ago
parent
commit
50669cb707
  1. 2
      src/Squidex/Program.cs
  2. 15
      src/Squidex/Startup.cs
  3. 2
      src/Squidex/app/components/layout/profile-menu.component.ts
  4. 10
      src/Squidex/app/shared/services/apps-store.service.spec.ts
  5. 16
      src/Squidex/app/shared/services/apps-store.service.ts
  6. 11
      src/Squidex/app/shared/services/auth.service.ts
  7. 9
      src/Squidex/project.json

2
src/Squidex/Program.cs

@ -16,7 +16,7 @@ namespace Squidex
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseKestrel() .UseKestrel(k => { k.AddServerHeader = false; })
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.UseStartup<Startup>() .UseStartup<Startup>()

15
src/Squidex/Startup.cs

@ -67,6 +67,7 @@ namespace Squidex
services.AddMemoryCache(); services.AddMemoryCache();
services.AddOptions(); services.AddOptions();
services.AddRouting(); services.AddRouting();
services.AddResponseCompression();
services.AddWebpackBuilder(); services.AddWebpackBuilder();
services.Configure<MyMongoDbOptions>( services.Configure<MyMongoDbOptions>(
@ -93,19 +94,21 @@ namespace Squidex
loggerFactory.AddConsole(); loggerFactory.AddConsole();
loggerFactory.AddDebug(); loggerFactory.AddDebug();
app.UseResponseCompression();
if (!Environment.IsDevelopment()) if (!Environment.IsDevelopment())
{ {
app.UseMiddleware<SingleUrlsMiddleware>(); app.UseMiddleware<SingleUrlsMiddleware>();
} }
UseIdentity(app); MapAndUseIdentity(app);
UseApi(app); MapAndUseApi(app);
UseFrontend(app); MapAndUseFrontend(app);
app.UseMyEventStore(); app.UseMyEventStore();
} }
private void UseIdentity(IApplicationBuilder app) private void MapAndUseIdentity(IApplicationBuilder app)
{ {
app.Map(Constants.IdentityPrefix, identityApp => app.Map(Constants.IdentityPrefix, identityApp =>
{ {
@ -127,7 +130,7 @@ namespace Squidex
}); });
} }
private void UseApi(IApplicationBuilder app) private void MapAndUseApi(IApplicationBuilder app)
{ {
app.Map(Constants.ApiPrefix, appApi => app.Map(Constants.ApiPrefix, appApi =>
{ {
@ -145,7 +148,7 @@ namespace Squidex
}); });
} }
private void UseFrontend(IApplicationBuilder app) private void MapAndUseFrontend(IApplicationBuilder app)
{ {
if (Environment.IsDevelopment()) if (Environment.IsDevelopment())
{ {

2
src/Squidex/app/components/layout/profile-menu.component.ts

@ -36,7 +36,7 @@ export class ProfileMenuComponent implements Ng2.OnInit, Ng2.OnDestroy {
public ngOnInit() { public ngOnInit() {
this.authenticationSubscription = this.authenticationSubscription =
this.auth.isAuthenticatedChanges.subscribe(() => { this.auth.isAuthenticated.subscribe(() => {
const user = this.auth.user; const user = this.auth.user;
if (user) { if (user) {

10
src/Squidex/app/shared/services/apps-store.service.spec.ts

@ -23,7 +23,7 @@ describe('AppsStoreService', () => {
}); });
it('should load when authenticated once', () => { it('should load when authenticated once', () => {
authService.setup(x => x.isAuthenticatedChanges) authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true)) .returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());
@ -55,7 +55,7 @@ describe('AppsStoreService', () => {
.returns(() => true) .returns(() => true)
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());
authService.setup(x => x.isAuthenticatedChanges) authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true)) .returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());
@ -85,7 +85,7 @@ describe('AppsStoreService', () => {
}); });
it('should add app to cache when created', () => { it('should add app to cache when created', () => {
authService.setup(x => x.isAuthenticatedChanges) authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true)) .returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());
@ -119,7 +119,7 @@ describe('AppsStoreService', () => {
}); });
it('should not add app to cache when cache is null', () => { it('should not add app to cache when cache is null', () => {
authService.setup(x => x.isAuthenticatedChanges) authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(false)) .returns(() => Observable.of(false))
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());
@ -143,7 +143,7 @@ describe('AppsStoreService', () => {
}); });
it('should select app', () => { it('should select app', () => {
authService.setup(x => x.isAuthenticatedChanges) authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true)) .returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once()); .verifiable(TypeMoq.Times.once());

16
src/Squidex/app/shared/services/apps-store.service.ts

@ -24,20 +24,19 @@ import { AuthService } from './auth.service';
@Ng2.Injectable() @Ng2.Injectable()
export class AppsStoreService { export class AppsStoreService {
private lastApps: AppDto[] | null = null; private lastApps: AppDto[] | null = null;
private isAuthenticated = false;
private readonly apps$ = new Subject<AppDto[]>(); private readonly apps$ = new Subject<AppDto[]>();
private readonly appName$ = new BehaviorSubject<string | null>(null); private readonly appName$ = new BehaviorSubject<string | null>(null);
private readonly appsPublished$ = private readonly appsPublished$ =
this.apps$ this.apps$
.distinctUntilChanged() .distinctUntilChanged()
.publishReplay(1) .publishReplay(1);
.refCount();
private readonly selectedApp$ = private readonly selectedApp$ =
this.appsPublished$.combineLatest(this.appName$, (apps, name) => apps && name ? apps.find(x => x.name === name) || null : null) this.appsPublished$.combineLatest(this.appName$, (apps, name) => apps && name ? apps.find(x => x.name === name) || null : null)
.distinctUntilChanged() .distinctUntilChanged()
.publishReplay(1) .publishReplay(1);
.refCount();
public get apps(): Observable<AppDto[]> { public get apps(): Observable<AppDto[]> {
return this.appsPublished$; return this.appsPublished$;
@ -55,11 +54,16 @@ export class AppsStoreService {
return; return;
} }
this.selectedApp$.connect();
this.appsPublished$.connect();
this.appsPublished$.subscribe(apps => { this.appsPublished$.subscribe(apps => {
this.lastApps = apps; this.lastApps = apps;
}); });
this.auth.isAuthenticatedChanges.subscribe(isAuthenticated => { this.auth.isAuthenticated.subscribe(isAuthenticated => {
this.isAuthenticated = isAuthenticated;
if (isAuthenticated) { if (isAuthenticated) {
this.load(); this.load();
} }
@ -67,7 +71,7 @@ export class AppsStoreService {
} }
public reload() { public reload() {
if (this.auth.isAuthenticated) { if (this.isAuthenticated) {
this.load(); this.load();
} }
} }

11
src/Squidex/app/shared/services/auth.service.ts

@ -43,18 +43,13 @@ export class AuthService {
private readonly isAuthenticatedChangedPublished$ = private readonly isAuthenticatedChangedPublished$ =
this.isAuthenticatedChanged$ this.isAuthenticatedChanged$
.distinctUntilChanged() .distinctUntilChanged()
.publishReplay(1) .publishReplay(1);
.refCount();
public get user(): Profile | null { public get user(): Profile | null {
return this.currentUser; return this.currentUser;
} }
public get isAuthenticated(): boolean { public get isAuthenticated(): Observable<boolean> {
return !!this.currentUser;
}
public get isAuthenticatedChanges(): Observable<boolean> {
return this.isAuthenticatedChangedPublished$; return this.isAuthenticatedChangedPublished$;
} }
@ -87,6 +82,8 @@ export class AuthService {
this.checkLogin(); this.checkLogin();
} }
this.isAuthenticatedChangedPublished$.connect();
} }
public checkLogin(): Promise<boolean> { public checkLogin(): Promise<boolean> {

9
src/Squidex/project.json

@ -3,18 +3,19 @@
"Autofac": "4.1.1", "Autofac": "4.1.1",
"Autofac.Extensions.DependencyInjection": "4.0.0", "Autofac.Extensions.DependencyInjection": "4.0.0",
"IdentityServer4": "1.0.0-rc2", "IdentityServer4": "1.0.0-rc2",
"IdentityServer4.AspNetIdentity": "1.0.0-rc2",
"IdentityServer4.AccessTokenValidation": "1.0.1-rc2", "IdentityServer4.AccessTokenValidation": "1.0.1-rc2",
"Microsoft.AspNetCore.Identity": "1.0.0", "IdentityServer4.AspNetIdentity": "1.0.0-rc2",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0", "Microsoft.AspNetCore.Authentication.Google": "1.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1", "Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": { "Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final", "version": "1.0.0-preview2-final",
"type": "build" "type": "build"
}, },
"Microsoft.AspNetCore.ResponseCompression": "1.0.0-preview2-22573",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1", "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0",
@ -30,13 +31,13 @@
}, },
"MongoDB.Driver": "2.4.0-beta1", "MongoDB.Driver": "2.4.0-beta1",
"OpenCover": "4.6.519", "OpenCover": "4.6.519",
"ReportGenerator": "2.5.0-beta1",
"Squidex.Core": "1.0.0-*", "Squidex.Core": "1.0.0-*",
"Squidex.Events": "1.0.0-*", "Squidex.Events": "1.0.0-*",
"Squidex.Infrastructure": "1.0.0-*", "Squidex.Infrastructure": "1.0.0-*",
"Squidex.Read": "1.0.0-*", "Squidex.Read": "1.0.0-*",
"Squidex.Store.MongoDb": "1.0.0-*", "Squidex.Store.MongoDb": "1.0.0-*",
"Squidex.Write": "1.0.0-*", "Squidex.Write": "1.0.0-*"
"ReportGenerator": "2.5.0-beta1"
}, },
"tools": { "tools": {

Loading…
Cancel
Save