Add start of user/account menu
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-06-12 12:24:08 +02:00
parent 978cbdabfc
commit c1c0bd2596
8 changed files with 77 additions and 2 deletions

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,9 @@ body { background: #f1f1f1; line-height: 18px; user-select:none;}
.logo {
margin-left: 1rem;
}
.user-menu {
position: absolute;
top:1em;
right: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():"";
}
}