6 Commits

Author SHA1 Message Date
0482aa7124 Added provided in root for schema service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-22 13:37:38 +02:00
75015f6d22 Added schema service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-22 13:12:02 +02:00
aa3707aa56 Added getSchema method to itemtypes service.
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-22 12:20:02 +02:00
Willem Dantuma
ff06b419f2 Fix top in fullscreen mode
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-12 12:53:43 +02:00
Willem Dantuma
c1c0bd2596 Add start of user/account menu
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-12 12:24:08 +02:00
Willem Dantuma
978cbdabfc Read both farmmaps currentuser and authenticate userinfo
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2020-06-10 21:53:54 +02:00
16 changed files with 143 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import { IItemTypes } from '../models/item.types';
import { IListItem } from '../models/list.item';
import { IUser } from '../models/user';
import { IItem } from '../models/item';
import { UserInfo } from 'angular-oauth2-oidc';
export const INITUSER = '[AppCommon] InitUser';
export const INITUSERSUCCESS = '[AppCommon] InitUserSuccess';
@@ -62,7 +63,7 @@ export class InitUser implements Action {
export class InitUserSuccess implements Action {
readonly type = INITUSERSUCCESS;
constructor(public user:IUser ) { }
constructor(public user:IUser,public userinfo:UserInfo ) { }
}
export class InitUserPackagesSuccess implements Action {

View File

@@ -9,6 +9,7 @@ import { OAuthModule, OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
//components
import { ItemTypeService } from './services/itemtype.service';
import { SchemaService } from './services/schema.service';
import { FolderService } from './services/folder.service';
import { TimespanService } from './services/timespan.service';
import { ItemService } from './services/item.service';
@@ -47,7 +48,8 @@ export {
AuthCallbackGuard,
ResumableFileUploadService,
NgbDateNativeAdapter,
StateSerializerService
StateSerializerService,
SchemaService
};
@NgModule({
@@ -71,7 +73,7 @@ export class AppCommonServiceModule {
{
provide: APP_INITIALIZER,
useFactory: appConfigFactory,
deps: [Injector, AppConfig, OAuthService, AuthConfigFactory, OAuthStorage,ItemTypeService],
deps: [Injector, AppConfig, OAuthService, AuthConfigFactory, OAuthStorage, ItemTypeService],
multi: true
},
{

View File

@@ -31,6 +31,7 @@ import { TimespanComponent } from './components/timespan/timespan.component';
import { TagInputComponent } from './components/tag-input/tag-input.component';
import { MenuBackgroundComponent } from './components/menu-background/menu-background.component';
import { HasPackageDirective} from './components/has-package/has-package.directive';
import { UserMenuComponent} from './components/user-menu/user-menu.component';
import { Alert } from './enumerations/alert.enum';
import { IEventMessage } from './models/event.message';
import { IItem, Item } from './models/item';
@@ -60,6 +61,7 @@ export {
SidePanelComponent,
TimespanComponent,
TagInputComponent,
UserMenuComponent,
HasPackageDirective,
Alert,
IEventMessage,
@@ -109,7 +111,8 @@ export {
TagInputComponent,
SessionClearedComponent,
MenuBackgroundComponent,
HasPackageDirective
HasPackageDirective,
UserMenuComponent
],
exports: [
NgbModule,
@@ -127,7 +130,8 @@ export {
TagInputComponent,
SessionClearedComponent,
MenuBackgroundComponent,
HasPackageDirective
HasPackageDirective,
UserMenuComponent
]
})
export class AppCommonModule {

View File

@@ -23,4 +23,7 @@
<ng-container *ngIf="showUploadProgress">
<fm-resumable-file-upload></fm-resumable-file-upload>
</ng-container>
<div class="user-menu">
<fm-user-menu [user]="user|async"></fm-user-menu>
</div>
</div>

View File

@@ -76,3 +76,14 @@ body { background: #f1f1f1; line-height: 18px; user-select:none;}
.logo {
margin-left: 1rem;
}
.user-menu {
transition: top 0.5s ease-out;
position: absolute;
top:0.25em;
right:1em;
}
.fullscreen > .user-menu {
top:1em;
}

View File

@@ -3,6 +3,7 @@ import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConf
import { Meta, Title, MetaDefinition } from '@angular/platform-browser';import { DOCUMENT } from "@angular/common";
import { Subscription , Observable } from 'rxjs';
import { Store, Action } from '@ngrx/store';
import { IUser } from '../../models/user';
//AppCommon
import { IEventMessage } from '../../models/event.message';
@@ -34,6 +35,7 @@ export class AppComponent implements OnInit, OnDestroy {
public fullScreen: Observable<boolean>;
public routeLoading: Observable<boolean>;
public menuVisible: Observable<boolean>;
public user:Observable<IUser>;
@Input() showUploadProgress: boolean =true;
constructor(
@@ -88,6 +90,7 @@ export class AppComponent implements OnInit, OnDestroy {
this.fullScreen = this.store.select(appReducers.selectGetFullScreen);
this.routeLoading = this.store.select(appReducers.selectGetRouteLoading);
this.menuVisible = this.store.select(appReducers.SelectGetMenuVisible);
this.user = this.store.select(appReducers.SelectGetUser);
this.InstallRouteEventHandler();
this.InstallEventServiceEventHandler();
}

View File

@@ -0,0 +1,3 @@
<div *ngIf="user">
<span class="rounded-circle menu-button" [title]="user.name">{{getLetter()}}</span>
</div>

View File

@@ -0,0 +1,10 @@
.menu-button {
background-color: purple;
color:white;
display: inline-block;
width: 2.5em;
height: 2.5em;
line-height: 2.5em;
text-align: center;
font-size: 1rem;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UserMenuComponent } from './user-menu.component';
describe('UserMenuComponent', () => {
let component: UserMenuComponent;
let fixture: ComponentFixture<UserMenuComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UserMenuComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,21 @@
import { Component, OnInit,Input } from '@angular/core';
import { IUser } from '../../models/user';
@Component({
selector: 'fm-user-menu',
templateUrl: './user-menu.component.html',
styleUrls: ['./user-menu.component.scss']
})
export class UserMenuComponent implements OnInit {
@Input() user:IUser;
constructor() { }
ngOnInit(): void {
}
getLetter():string {
return this.user.name ? this.user.name.substr(0,1).toUpperCase():"";
}
}

View File

@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { OAuthService } from 'angular-oauth2-oidc';
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
import { Store, Action } from '@ngrx/store';
import { Effect, Actions,ofType } from '@ngrx/effects';
import { Observable , defer , of } from 'rxjs';
import { Observable , defer , of,from } from 'rxjs';
import { withLatestFrom,mergeMap,switchMap,map,catchError} from 'rxjs/operators';
import * as appCommonActions from '../actions/app-common.actions';
import * as appCommonReducers from '../reducers/app-common.reducer';
@@ -44,9 +44,10 @@ export class AppCommonEffects {
ofType(appCommonActions.INITUSER),
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
switchMap(([action, initialized]) => {
if(!initialized) {
if(!initialized) {
return this.userService$.getCurrentUser().pipe(
map((user: IUser) => new appCommonActions.InitUserSuccess(user)),
withLatestFrom(from(this.oauthService$.loadUserProfile())),
switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
catchError(error => of(new appCommonActions.Fail(error))))
} else {
return [];

View File

@@ -4,5 +4,6 @@ export interface IItemType {
editor?: string;
isFolder?: boolean;
iconColor?: string;
schema?: string;
extraAttributes?: string;
}

View File

@@ -36,7 +36,12 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
switch (action.type) {
case appCommonActions.INITUSERSUCCESS: {
let a = action as appCommonActions.InitUserSuccess;
return tassign(state, { user: a.user,initialized: true });
var user:IUser = {
code:a.user.code,
email:a.userinfo["email"],
name:a.userinfo["name"]
};
return tassign(state, { user: user,initialized: true });
}
case appCommonActions.INITROOTSUCCESS: {
let a = action as appCommonActions.InitRootSuccess;

View File

@@ -9,9 +9,9 @@ export class ItemTypeService {
public itemTypes: IItemTypes;
private httpClient: HttpClient;
constructor(xhrBackend: HttpXhrBackend) {
constructor(xhrBackend: HttpXhrBackend) {
this.httpClient = new HttpClient(xhrBackend);
}
}
getIcon(itemType: string) {
var icon = "fa fa-file-o";
@@ -31,6 +31,12 @@ export class ItemTypeService {
return extraAttributes;
}
getSchema(itemType: string): string {
let schema = null;
if (this.itemTypes[itemType]) schema = this.itemTypes[itemType].schema;
return schema;
}
hasViewer(item: IItem) {
let itemType: string = item.itemType;
if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined;
@@ -49,7 +55,7 @@ export class ItemTypeService {
}
public load(config:AppConfig): Promise<any> {
var url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/`
return this.httpClient.get(url)
.toPromise()
@@ -59,4 +65,4 @@ export class ItemTypeService {
})
.catch(error => this.itemTypes = null);
};
}
}

View File

@@ -0,0 +1,32 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {AppConfig} from '../shared/app.config';
import {Observable} from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class SchemaService {
constructor(private httpClient: HttpClient, private appConfig: AppConfig) {
}
ApiEndpoint() {
return this.appConfig.getConfig('apiEndPoint');
}
public getSchemaIdFromSchemaUrl(schemaUrl): string {
const url = new URL(schemaUrl);
const pathSplit = url.pathname.split('/');
return pathSplit[pathSplit.length - 1].replace('.json', '');
}
public getSchemaWithUrl(schemaUrl): Observable<string> {
const id = this.getSchemaIdFromSchemaUrl(schemaUrl);
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${id}`);
}
public getSchemaWithId(schemaId): Observable<string> {
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${schemaId}`);
}
}

View File

@@ -14,7 +14,7 @@ export class Id4AuthconfigFactory implements IAuthconfigFactory {
authConfig.redirectUri = window.location.origin + "/cb";
authConfig.clientId = appConfig.getConfig("clientId");
authConfig.customQueryParams = { audience: appConfig.getConfig("audience") };
authConfig.scope = "profile api offline_access";
authConfig.scope = "openid profile api offline_access";
authConfig.disableAtHashCheck = true;
authConfig.responseType = "code";
authConfig.requireHttps = appConfig.getConfig("requireHttps");