Compare commits
16 Commits
feature/Mi
...
4527276254
Author | SHA1 | Date | |
---|---|---|---|
4527276254 | |||
|
6f52302875 | ||
|
cbe27c2add | ||
|
cd156ab1bc | ||
|
f9d0e2aee0 | ||
|
253b3d3c90 | ||
|
28d4adc571 | ||
|
925af1e645 | ||
|
4130e0a796 | ||
|
01933b1602 | ||
0482aa7124 | |||
75015f6d22 | |||
aa3707aa56 | |||
|
ff06b419f2 | ||
|
c1c0bd2596 | ||
|
978cbdabfc |
17
package-lock.json
generated
17
package-lock.json
generated
@@ -2692,14 +2692,14 @@
|
||||
}
|
||||
},
|
||||
"@farmmaps/common": {
|
||||
"version": "0.0.1-prerelease.267",
|
||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.267.tgz",
|
||||
"integrity": "sha512-U2D6IhxIzpZVtExnRHSP8oNyva9eYCGnZEBy7jWFCY83X4R54w/+PxCB8sK8STf14IJFJcmaSXpHc7Wyd7GrbA=="
|
||||
"version": "0.0.1-prerelease.289",
|
||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.289.tgz",
|
||||
"integrity": "sha512-TlgNLEpagOtgC24X/olIrK+9ijLbh1gqLKEw4FgoyRV/T4iYBuZewfGvrPmoeKxY6lNdx2nIAhwOmOoRMcH5qQ=="
|
||||
},
|
||||
"@farmmaps/common-map": {
|
||||
"version": "0.0.1-prerelease.267",
|
||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.267.tgz",
|
||||
"integrity": "sha512-lZG9abbuVNtFNPKLddYfBRD6qhc6fMslL4wTIKjX8P7yfBM6/W5FAlkcQEJqcTj9k/0fzRlzzKQ2dJouGkctcQ=="
|
||||
"version": "0.0.1-prerelease.289",
|
||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.289.tgz",
|
||||
"integrity": "sha512-HOECDkP7xwBQqbGx2WmaKgtyalwgcw/7K4CW5eTMT0kSJXc+2JJbCDcQlso5a1DwzaF24bzpR3L1sEGJiPof4w=="
|
||||
},
|
||||
"@istanbuljs/schema": {
|
||||
"version": "0.1.2",
|
||||
@@ -9669,6 +9669,11 @@
|
||||
"deepmerge": "^3.2.0"
|
||||
}
|
||||
},
|
||||
"ngx-bootstrap": {
|
||||
"version": "5.6.1",
|
||||
"resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-5.6.1.tgz",
|
||||
"integrity": "sha512-8fDs3VaaWgKpupakPKS0QaUc+1E/JMBGJDxUUODjyIkLtFr1A8vH4cjXiV3AfrPvhK27GH0oyTPyKWKcCjEtVg=="
|
||||
},
|
||||
"ngx-openlayers": {
|
||||
"version": "1.0.0-next.13",
|
||||
"resolved": "https://registry.npmjs.org/ngx-openlayers/-/ngx-openlayers-1.0.0-next.13.tgz",
|
||||
|
13
package.json
13
package.json
@@ -19,26 +19,27 @@
|
||||
"@angular/platform-browser": "~9.1.0",
|
||||
"@angular/platform-browser-dynamic": "~9.1.0",
|
||||
"@angular/router": "~9.1.0",
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.289 <0.0.1",
|
||||
"@farmmaps/common-map": ">=0.0.1-prerelease.289 <0.0.1",
|
||||
"@microsoft/signalr": "^3.1.3",
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.267 <0.0.1",
|
||||
"@farmmaps/common-map": ">=0.0.1-prerelease.267 <0.0.1",
|
||||
"@ng-bootstrap/ng-bootstrap": "^6.0",
|
||||
"@ngrx/effects": "^9.0",
|
||||
"@ngrx/router-store": "^9.0",
|
||||
"@ngrx/store": "^9.0",
|
||||
"ngx-uploadx": "^3.3.4",
|
||||
"angular-oauth2-oidc": "^9.1",
|
||||
"bootstrap": "^4.4.1",
|
||||
"core-js": "^2.6.11",
|
||||
"font-awesome": "^4.7.0",
|
||||
"ngrx-store-localstorage": "^9.0",
|
||||
"ngx-bootstrap": "^5.6.1",
|
||||
"ngx-openlayers": "1.0.0-next.13",
|
||||
"ngx-uploadx": "^3.3.4",
|
||||
"ol": "6.1.1",
|
||||
"resumablejs": "^1.1.0",
|
||||
"rxjs": "^6.5.4",
|
||||
"tassign": "^1.0.0",
|
||||
"tslib": "^1.10.0",
|
||||
"zone.js": "~0.10.2",
|
||||
"ngx-openlayers": "1.0.0-next.13",
|
||||
"ol": "6.1.1"
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.901.0",
|
||||
|
@@ -11,7 +11,7 @@
|
||||
"@ngrx/router-store": "^9.0",
|
||||
"@ngrx/store": "^9.0",
|
||||
"tassign": "^1.0.0",
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.265 <0.0.1",
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.284 <0.0.1",
|
||||
"ngx-openlayers": "1.0.0-next.13",
|
||||
"ol": "6.1.1"
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ import { WidgetStatusComponent } from './components/widget-status/widget-status.
|
||||
import { ForChild} from './components/for-item/for-child.decorator';
|
||||
import {ForItemType } from './components/for-item/for-itemtype.decorator';
|
||||
import { ForSourceTask} from './components/for-item/for-sourcetask.decorator';
|
||||
import { ForPackage } from './components/for-item/for-package.decorator';
|
||||
import { PanToLocation} from './components/aol/pan-to-location/pan-to-location.component';
|
||||
import {LayerSwitcher} from './components/layer-switcher/layer-switcher.component';
|
||||
|
||||
@@ -143,7 +144,8 @@ export {
|
||||
IPeriodState,
|
||||
ForChild,
|
||||
ForItemType,
|
||||
ForSourceTask
|
||||
ForSourceTask,
|
||||
ForPackage
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
|
@@ -2,7 +2,7 @@ import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleCh
|
||||
import { Feature } from 'ol';
|
||||
import { FeatureListComponent,AbstractFeatureListComponent } from '../feature-list/feature-list.component';
|
||||
import { WidgetHostDirective } from '../widget-host/widget-host.directive';
|
||||
import {IQueryState } from '@farmmaps/common';
|
||||
import {IQueryState,PackageService } from '@farmmaps/common';
|
||||
import * as mapReducers from '../../reducers/map.reducer';
|
||||
import * as mapActions from '../../actions/map.actions';
|
||||
import { Store } from '@ngrx/store';
|
||||
@@ -16,7 +16,7 @@ import { Observable } from 'rxjs';
|
||||
})
|
||||
export class FeatureListContainerComponent {
|
||||
|
||||
constructor(private store: Store<mapReducers.State>,private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractFeatureListComponent) public featureLists: AbstractFeatureListComponent[] ) {
|
||||
constructor(private store: Store<mapReducers.State>,private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractFeatureListComponent) public featureLists: AbstractFeatureListComponent[],private packageService:PackageService ) {
|
||||
}
|
||||
|
||||
@Input() features: Array<Feature>
|
||||
@@ -28,30 +28,37 @@ export class FeatureListContainerComponent {
|
||||
componentRef:any;
|
||||
|
||||
loadComponent(queryState:IQueryState) {
|
||||
var componentFactory: ComponentFactory<AbstractFeatureListComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListComponent); // default
|
||||
var selected = -1;
|
||||
for (var i = 0; i < this.featureLists.length; i++) {
|
||||
if (this.featureLists[i]['forItemType'] == queryState.itemType && this.featureLists[i]['forChild'] && queryState.parentCode && queryState.parentCode != "") {
|
||||
selected = i;
|
||||
break;
|
||||
} else if (this.featureLists[i]['forItemType'] == queryState.itemType) {
|
||||
selected = i;
|
||||
break;
|
||||
let componentFactory: ComponentFactory<AbstractFeatureListComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListComponent); // default
|
||||
let selected = -1;
|
||||
let maxMatches =0;
|
||||
let showItem = true;
|
||||
for (let i = 0; i < this.featureLists.length; i++) {
|
||||
let matches=0;
|
||||
if (this.featureLists[i]['forItemType'] && this.featureLists[i]['forItemType'].indexOf(queryState.itemType) >= 0) {
|
||||
matches++;
|
||||
}
|
||||
if(this.featureLists[i]['forChild'] && queryState.parentCode && queryState.parentCode != "") {
|
||||
matches++;
|
||||
}
|
||||
if(matches > maxMatches) {
|
||||
selected=i;
|
||||
maxMatches = matches;
|
||||
}
|
||||
}
|
||||
if (selected >= 0) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[i]['constructor'] as any);
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[selected]['constructor'] as any);
|
||||
if (this.featureLists[selected]['collapseSearch'] === true) {
|
||||
this.store.dispatch(new mapActions.CollapseSearch());
|
||||
}
|
||||
}
|
||||
}
|
||||
const viewContainerRef = this.widgetHost.viewContainerRef;
|
||||
viewContainerRef.clear();
|
||||
|
||||
this.componentRef = viewContainerRef.createComponent(componentFactory);
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).features = null;
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).queryState = queryState;
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).selectedFeature = null;
|
||||
if(showItem) {
|
||||
this.componentRef = viewContainerRef.createComponent(componentFactory);
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).features = null;
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).queryState = queryState;
|
||||
(<AbstractFeatureListComponent>this.componentRef.instance).selectedFeature = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@@ -23,11 +23,23 @@ export class FeatureListFeatureContainerComponent {
|
||||
|
||||
loadComponent() {
|
||||
var componentFactory: ComponentFactory<AbstractFeatureListFeatureComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListFeatureComponent); // default
|
||||
for (var i = 0; i < this.featureLists.length; i++) {
|
||||
|
||||
let selected = -1;
|
||||
let maxMatches =0;
|
||||
for (let i = 0; i < this.featureLists.length; i++) {
|
||||
let matches=0;
|
||||
if (this.featureLists[i]['forItemType'] == this.feature.get("itemType")) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[i]['constructor'] as any);
|
||||
matches++;
|
||||
}
|
||||
if(matches > maxMatches) {
|
||||
selected=i;
|
||||
maxMatches = matches;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selected >= 0) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[selected]['constructor'] as any);
|
||||
}
|
||||
|
||||
const viewContainerRef = this.widgetHost.viewContainerRef;
|
||||
viewContainerRef.clear();
|
||||
|
||||
|
@@ -0,0 +1,5 @@
|
||||
export function ForPackage(packageCode: string) {
|
||||
return function (constructor:Function) {
|
||||
constructor.prototype.forPackage = packageCode;
|
||||
};
|
||||
}
|
@@ -23,15 +23,28 @@ export class ItemListItemContainerComponent {
|
||||
|
||||
loadComponent() {
|
||||
var componentFactory: ComponentFactory<AbstractItemListItemComponent> = this.componentFactoryResolver.resolveComponentFactory(ItemListItemComponent); // default
|
||||
for (var i = 0; i < this.itemComponentList.length; i++) {
|
||||
if (this.itemComponentList[i]['forItemType'] &&
|
||||
this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0 &&
|
||||
this.itemComponentList[i]['forSourceTask'] &&
|
||||
this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0 )
|
||||
{
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.itemComponentList[i]['constructor'] as any);
|
||||
|
||||
let selected = -1;
|
||||
let maxMatches =0;
|
||||
let showItem = true;
|
||||
for (let i = 0; i < this.itemComponentList.length; i++) {
|
||||
let matches=0;
|
||||
if (this.itemComponentList[i]['forItemType'] && this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0) {
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
if (this.itemComponentList[i]['forSourceTask'] && this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
if(matches > maxMatches) {
|
||||
selected=i;
|
||||
maxMatches = matches;
|
||||
}
|
||||
}
|
||||
if (selected >= 0) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.itemComponentList[selected]['constructor'] as any);
|
||||
}
|
||||
|
||||
const viewContainerRef = this.widgetHost.viewContainerRef;
|
||||
viewContainerRef.clear();
|
||||
|
||||
|
@@ -23,22 +23,28 @@ export class SelectedItemContainerComponent {
|
||||
|
||||
loadComponent() {
|
||||
let componentFactory: ComponentFactory<AbstractSelectedItemComponent> = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default
|
||||
let firstComponentWithTypeAndTask = this.selectedItemComponents
|
||||
.find(value => value['forSourceTask'] == this.item.sourceTask &&
|
||||
value['forItemType'] == this.item.itemType
|
||||
);
|
||||
|
||||
if (firstComponentWithTypeAndTask) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithTypeAndTask['constructor'] as any);
|
||||
} else {
|
||||
let firstComponentWithType = this.selectedItemComponents
|
||||
.find(value => value['forSourceTask'] == null &&
|
||||
value['forItemType'] == this.item.itemType);
|
||||
|
||||
if (firstComponentWithType) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithType['constructor'] as any);
|
||||
let selected = -1;
|
||||
let maxMatches =0;
|
||||
let showItem = true;
|
||||
for (let i = 0; i < this.selectedItemComponents.length; i++) {
|
||||
let matches=0;
|
||||
if (this.selectedItemComponents[i]['forItemType'] && this.selectedItemComponents[i]['forItemType'].indexOf(this.item.itemType) >= 0) {
|
||||
matches++;
|
||||
}
|
||||
if (this.selectedItemComponents[i]['forSourceTask'] && this.selectedItemComponents[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
if(matches > maxMatches) {
|
||||
selected=i;
|
||||
maxMatches = matches;
|
||||
}
|
||||
}
|
||||
if (selected >= 0) {
|
||||
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[selected]['constructor'] as any);
|
||||
}
|
||||
|
||||
const viewContainerRef = this.widgetHost.viewContainerRef;
|
||||
viewContainerRef.clear();
|
||||
|
||||
|
@@ -7,9 +7,10 @@ import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderServic
|
||||
import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router';
|
||||
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
||||
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable,of } from 'rxjs';
|
||||
import {GeoJSON} from 'ol/format';
|
||||
import {getArea} from 'ol/sphere';
|
||||
import { withLatestFrom,switchMap,combineLatest } from 'rxjs/operators';
|
||||
|
||||
|
||||
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
||||
@@ -38,6 +39,25 @@ export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponen
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this. items = this.folderService$.getItems(this.item.code, 0, 1000);
|
||||
var childItems = this.folderService$.getItems(this.item.code, 0, 1000);
|
||||
var atLocationItems = this.itemService$.getItemList(null,null,null,this.item.code,true);
|
||||
this.items = childItems.pipe(
|
||||
combineLatest(atLocationItems),
|
||||
switchMap(([ci,ali]) => {
|
||||
let retVal:IListItem[] = [];
|
||||
let codes = {};
|
||||
ci.forEach((listItem) => {
|
||||
retVal.push(listItem);
|
||||
codes[listItem.code]=listItem;
|
||||
});
|
||||
ali.forEach((atlocationitem) => {
|
||||
let listItem = atlocationitem as IListItem;
|
||||
let allowedItemTypes = "vnd.farmmaps.itemtype.device.senml"; // this is a hack
|
||||
if(!codes[listItem.code] && allowedItemTypes.indexOf(listItem.itemType) >= 0) {
|
||||
retVal.push(listItem);
|
||||
}
|
||||
});
|
||||
return of(retVal);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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';
|
||||
@@ -28,6 +29,7 @@ import { ResumableFileUploadService } from './components/resumable-file-upload/r
|
||||
import { NgbDateNativeAdapter } from './services/date-adapter.service'
|
||||
import { AuthConfigFactory } from './shared/authconfigFactory';
|
||||
import { StateSerializerService } from './services/state-serializer.service';
|
||||
import { PackageService } from './services/package.service';
|
||||
|
||||
export {
|
||||
FolderService,
|
||||
@@ -47,7 +49,9 @@ export {
|
||||
AuthCallbackGuard,
|
||||
ResumableFileUploadService,
|
||||
NgbDateNativeAdapter,
|
||||
StateSerializerService
|
||||
StateSerializerService,
|
||||
SchemaService,
|
||||
PackageService
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
@@ -71,7 +75,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
|
||||
},
|
||||
{
|
||||
|
@@ -31,6 +31,8 @@ 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 { HasClaimDirective} from './components/has-claim/has-claim.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,7 +62,9 @@ export {
|
||||
SidePanelComponent,
|
||||
TimespanComponent,
|
||||
TagInputComponent,
|
||||
UserMenuComponent,
|
||||
HasPackageDirective,
|
||||
HasClaimDirective,
|
||||
Alert,
|
||||
IEventMessage,
|
||||
IItem,
|
||||
@@ -109,7 +113,9 @@ export {
|
||||
TagInputComponent,
|
||||
SessionClearedComponent,
|
||||
MenuBackgroundComponent,
|
||||
HasPackageDirective
|
||||
HasPackageDirective,
|
||||
HasClaimDirective,
|
||||
UserMenuComponent
|
||||
],
|
||||
exports: [
|
||||
NgbModule,
|
||||
@@ -127,7 +133,9 @@ export {
|
||||
TagInputComponent,
|
||||
SessionClearedComponent,
|
||||
MenuBackgroundComponent,
|
||||
HasPackageDirective
|
||||
HasPackageDirective,
|
||||
HasClaimDirective,
|
||||
UserMenuComponent
|
||||
]
|
||||
})
|
||||
export class AppCommonModule {
|
||||
|
@@ -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>
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input,OnDestroy } from '@angular/core';
|
||||
import { Store} from '@ngrx/store';
|
||||
import * as appCommonReducer from '../../reducers/app-common.reducer'
|
||||
import { IPackages } from '../../models/package';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { skip } from 'rxjs/operators';
|
||||
import {OAuthService } from 'angular-oauth2-oidc';
|
||||
import { IUser } from '../../models/user';
|
||||
|
||||
@Directive({
|
||||
selector: '[fm-hasclaim]',
|
||||
})
|
||||
export class HasClaimDirective implements OnInit{
|
||||
@Input('fm-hasclaim') claim:string;
|
||||
|
||||
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private store$: Store<appCommonReducer.State>) { }
|
||||
private user$:Observable<IUser> = this.store$.select(appCommonReducer.SelectGetUser).pipe(skip(1));
|
||||
private hasView = false;
|
||||
ngOnInit() {
|
||||
this.user$.subscribe((user) => {
|
||||
if (user.claims[this.claim]) {
|
||||
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
||||
this.hasView=true;
|
||||
} else if (this.hasView) {
|
||||
this.viewContainerRef$.clear();
|
||||
this.hasView = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<div *ngIf="user">
|
||||
<span class="rounded-circle menu-button" [title]="user.name">{{getLetter()}}</span>
|
||||
</div>
|
@@ -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;
|
||||
}
|
@@ -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();
|
||||
});
|
||||
});
|
@@ -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():"";
|
||||
}
|
||||
}
|
@@ -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 [];
|
||||
|
@@ -4,5 +4,6 @@ export interface IItemType {
|
||||
editor?: string;
|
||||
isFolder?: boolean;
|
||||
iconColor?: string;
|
||||
schema?: string;
|
||||
extraAttributes?: string;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
export interface IUser {
|
||||
code?: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
}
|
||||
export interface IUser {
|
||||
code?: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
claims: any;
|
||||
}
|
||||
|
@@ -36,7 +36,17 @@ 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 });
|
||||
let claims = {}
|
||||
Object.getOwnPropertyNames(a.userinfo).forEach((k) => {
|
||||
claims[k] = a.userinfo[k];
|
||||
});
|
||||
var user:IUser = {
|
||||
code:a.user.code,
|
||||
email:a.userinfo["email"],
|
||||
name:a.userinfo["name"],
|
||||
claims:claims
|
||||
};
|
||||
return tassign(state, { user: user,initialized: true });
|
||||
}
|
||||
case appCommonActions.INITROOTSUCCESS: {
|
||||
let a = action as appCommonActions.InitRootSuccess;
|
||||
|
@@ -65,13 +65,13 @@ export class ItemService {
|
||||
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}/${itemType}`);
|
||||
}
|
||||
|
||||
getItemList(itemType: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
|
||||
getItemList(itemType?: string, dataFilter?: any, level?:number ,atItemLocationItemCode?:string,indexed?:boolean): Observable<IItem[]> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("it", itemType);
|
||||
if(dataFilter != null){
|
||||
params = params.append("df", JSON.stringify(dataFilter));
|
||||
}
|
||||
params = params.append("lvl", itemType);
|
||||
if(itemType) params = params.append("it", itemType);
|
||||
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
|
||||
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
|
||||
if(indexed) params = params.append("ind",indexed?"true":"false");
|
||||
if(level) params = params.append("lvl", level.toFixed());
|
||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
22
projects/common/src/fm/services/schema.service.ts
Normal file
22
projects/common/src/fm/services/schema.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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');
|
||||
}
|
||||
|
||||
/** Takes decoded schema url id */
|
||||
public getSchema(id): Observable<string> {
|
||||
const encodedId = encodeURIComponent(id);
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${encodedId}`);
|
||||
}
|
||||
}
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user