Skip to content

Commit

Permalink
Merge branch 'feature/SHIBUI-1281' into feature/SHIBUI-1268
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 21, 2019
2 parents a46c753 + 230b3fb commit c3e6a81
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 77 deletions.
5 changes: 5 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ label.email=Email
label.role=Role
label.delete=Delete?

label.title=Title
label.enabled=Enabled
label.author=Author
label.creation-date=Creation Date

label.metadata-resolver-history=Metadata resolver history
label.metadata-version-history=Metadata Version History
label.select-version=Select Version
Expand Down
13 changes: 13 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"deepmerge": "^2.2.1",
"file-saver": "^1.3.3",
"font-awesome": "^4.7.0",
"ngx-infinite-scroll": "^7.2.0",
"ngx-schema-form": "^2.2.0-beta.1",
"rxjs": "^6.5.1",
"rxjs-compat": "^6.5.1",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</ul>
</div>
</nav>
<main>
<main class="pad-content">
<router-outlet></router-outlet>
<notification-list></notification-list>
</main>
Expand Down
12 changes: 12 additions & 0 deletions ui/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ nav.navbar {
max-height: 60px;
}
}

@media only screen and (min-width: 1024px) {
.pad-content {
padding: 1rem 3rem;
}
}

@media only screen and (min-width: 1200px) {
.pad-content {
padding: 2rem 5rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('Configuration Reducer', () => {
const model: MetadataResolver = {
id: 'foo',
serviceProviderName: 'foo',
'@type': 'MetadataResolver'
'@type': 'MetadataResolver',
createdBy: 'admin'
};
const xml = `<entity-descriptor></entity-descriptor>`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class EntityAttributesFilterEntity implements MetadataFilter, MetadataEnt
modifiedDate?: string;
version: string;
resourceId: string;
createdBy: string;

name = '';
filterEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class NameIDFormatFilterEntity implements MetadataFilter, MetadataEntity
modifiedDate?: string;
version: string;
resourceId: string;
createdBy: string;

name = '';
filterEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class FileBackedHttpMetadataResolver implements MetadataResolver, Metadat
createdDate?: string;
modifiedDate?: string;
version: string;
createdBy: string;

entityId = '';
serviceProviderName = '';
Expand Down Expand Up @@ -48,6 +49,8 @@ export class FileBackedHttpMetadataResolver implements MetadataResolver, Metadat

attributeRelease = [] as string[];

[property: string]: unknown;

constructor(descriptor?: Partial<MetadataResolver>) {
Object.assign(this, descriptor);
}
Expand All @@ -65,7 +68,7 @@ export class FileBackedHttpMetadataResolver implements MetadataResolver, Metadat
}

getCreationDate(): Date {
return new Date(this.createdDate);
return this.createdDate ? new Date(this.createdDate) : null;
}

get name(): string {
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/metadata/domain/model/metadata-base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface MetadataBase {
id?: string;
createdDate?: string;
createdBy: string;
modifiedDate?: string;
version?: string;
}
2 changes: 2 additions & 0 deletions ui/src/app/metadata/domain/model/metadata-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export interface MetadataEntity {
enabled: boolean;
kind: string;

createdBy: string;

getId(): string;
getDisplayId(): string;
isDraft(): boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form [formGroup]="searchForm">
<div class="input-group input-group-sm">
<div class="input-group">
<label [for]="search" class="sr-only" translate="action.search">Search</label>
<input
id="search"
Expand All @@ -12,7 +12,7 @@
role="textbox"
(keyup)="search.emit($event.target.value)">
<div class="input-group-append">
<button class="btn btn-light"
<button class="btn btn-link"
type="button"
tabindex="0"
aria-label="Clear search text field"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
<section class="section">
<div class="section-body border border-top-0 border-primary">
<div class="section-header bg-primary p-2 text-light">
<div class="row justify-content-between">
<div class="col-md-8">
<span class="lead" translate="label.current-metadata-sources">Current Metadata Sources</span>
</div>
<div class="col-md-4">
<provider-search
[query]="searchQuery$ | async"
[searching]="loading$ | async"
(search)="search($event)">
</provider-search>
</div>
</div>
<span class="lead" translate="label.current-metadata-sources">Current Metadata Sources</span>
</div>
<div class="p-3">
<ul class="list-unstyled m-0">
<li *ngFor="let resolver of limited$ | async; index as i"
[ngClass]="{'mt-2': i > 0}"
aria-label="Provider Item Accordion. Press Spacebar to open">
<resolver-item
[entity]="resolver"
[isOpen]="(entitiesOpen$ | async)[resolver.getId()]"
(select)="edit(resolver)"
(toggle)="toggleEntity(resolver)"
(preview)="viewConfiguration(resolver)"
(delete)="deleteResolver(resolver)"
(history)="viewMetadataHistory(resolver)"
[allowDelete]="resolver.isDraft()">
</resolver-item>
</li>
</ul>
<div class="mt-3 clearfix" *ngIf="(total$ | async) > limit">
<ngb-pagination
class="float-right"
[collectionSize]="total$ | async"
[page]="page"
[pageSize]="limit"
(pageChange)="changePage($event)"
aria-label="Pages">
</ngb-pagination>
<provider-search
class="w-50 d-block"
[query]="searchQuery$ | async"
[searching]="loading$ | async"
(search)="search($event)">
</provider-search>
<div class="table-responsive mt-3" *ngIf="limited$ | async">
<table class="table table-striped w-100 table-hover">
<thead>
<th translate="label.title">Title</th>
<th class="w-40" translate="label.entity-id">Entity ID</th>
<th class="w-15" translate="label.author">Author</th>
<th class="w-15" translate="label.creation-date">Created Date</th>
<th class="text-right w-15" translate="label.enabled">Enabled</th>
</thead>
<tbody infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
(scrolled)="onScroll($event)">
<tr *ngFor="let resolver of limited$ | async; index as i">
<td><a [routerLink]="['/', 'metadata', 'resolver', resolver.getId(), 'configuration', 'options']">{{ resolver.name }}</a></td>
<td>{{ resolver.getDisplayId() }}</td>
<td>{{ resolver.createdBy }}</td>
<td>{{ resolver.getCreationDate() ? (resolver.getCreationDate() | customDate) : '&mdash;' }}</td>
<td class="text-right">
<span class="badge badge-warning"
*ngIf="resolver.isDraft()"
aria-label="Warning Badge: Incomplete Form"
translate="message.incomplete-form">
Incomplete Form
</span>
<span class="badge"
*ngIf="!resolver.isDraft()"
[class.badge-danger]="!resolver.enabled"
[class.badge-success]="resolver.enabled">
<span *ngIf="resolver.enabled" translate="value.enabled">Enabled</span>
<span *ngIf="!resolver.enabled" translate="value.disabled">Enabled</span>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { Router, RouterModule } from '@angular/router';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { StoreModule, Store, combineReducers } from '@ngrx/store';
import { NgbPaginationModule, NgbModal, NgbModalModule, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
Expand All @@ -11,9 +11,9 @@ import { RouterStub } from '../../../../testing/router.stub';
import { NgbModalStub } from '../../../../testing/modal.stub';
import { FileBackedHttpMetadataResolver } from '../../domain/entity';
import { DashboardResolversListComponent } from './dashboard-resolvers-list.component';
import { ResolverItemComponent } from '../component/resolver-item.component';
import { MockI18nModule } from '../../../../testing/i18n.stub';
import { CustomDatePipe } from '../../../shared/pipe/date.pipe';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';


describe('Dashboard Resolvers List Page', () => {
Expand Down Expand Up @@ -49,12 +49,13 @@ describe('Dashboard Resolvers List Page', () => {
ReactiveFormsModule,
NgbPaginationModule,
NgbModalModule,
MockI18nModule
MockI18nModule,
InfiniteScrollModule,
RouterModule
],
declarations: [
DashboardResolversListComponent,
ProviderSearchComponent,
ResolverItemComponent,
DeleteDialogComponent,
CustomDatePipe
],
Expand All @@ -75,23 +76,6 @@ describe('Dashboard Resolvers List Page', () => {
expect(fixture).toBeDefined();
});

xdescribe('getPagedResolvers method', () => {});

describe('changePage method', () => {
it('should update the page value', () => {
let page = 2;
instance.changePage(page);
expect(instance.page).toBe(page);
});

it('should update the paged resolvers list', () => {
let page = 2;
spyOn(instance, 'getPagedResolvers');
instance.changePage(page);
expect(instance.getPagedResolvers).toHaveBeenCalled();
});
});

describe('toggleResolver method', () => {
it('should fire a redux action', () => {
instance.toggleEntity(draft);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { MetadataEntity, MetadataResolver } from '../../domain/model';
import { MetadataTypes, Metadata } from '../../domain/domain.type';
import * as searchActions from '../action/search.action';
import * as fromDashboard from '../reducer';
import { ToggleEntityDisplay } from '../action/manager.action';
import { DeleteDialogComponent } from '../component/delete-dialog.component';
import { PreviewEntity } from '../../domain/action/entity.action';
import { RemoveDraftRequest } from '../../resolver/action/draft.action';

@Component({
Expand All @@ -26,7 +24,7 @@ export class DashboardResolversListComponent implements OnInit {

total$: Observable<number>;
page = 1;
limit = 8;
limit = 20;
limited$: Observable<MetadataEntity[]>;

entitiesOpen$: Observable<{ [key: string]: boolean }>;
Expand Down Expand Up @@ -54,13 +52,13 @@ export class DashboardResolversListComponent implements OnInit {
return list$.pipe(
map((providers: MetadataEntity[]) => {
let maxIndex = (page * this.limit) - 1,
minIndex = ((page - 1) * this.limit);
minIndex = 0;
return providers.filter((resolver: MetadataEntity, index: number) => (maxIndex >= index && index >= minIndex));
})
);
}

changePage(index: number): void {
loadMore(index: number): void {
this.page = index;
this.limited$ = this.getPagedResolvers(index, this.resolvers$);
}
Expand All @@ -70,6 +68,10 @@ export class DashboardResolversListComponent implements OnInit {
this.page = 1;
}

onScroll(event: Event): void {
this.loadMore(this.page + 1);
}

edit(entity: MetadataEntity): void {
if (entity.isDraft()) {
this.router.navigate(['metadata', 'resolver', 'new', 'blank', 'common'], {
Expand All @@ -86,11 +88,6 @@ export class DashboardResolversListComponent implements OnInit {
this.store.dispatch(new ToggleEntityDisplay(entity.getId()));
}

viewConfiguration(entity: MetadataEntity): void {
// this.store.dispatch(new PreviewEntity({ id: entity.getId(), entity }));
this.router.navigate(['metadata', 'resolver', entity.getId(), 'configuration', 'options']);
}

viewMetadataHistory(entity: MetadataEntity): void {
this.router.navigate(['metadata', 'resolver', entity.getId(), 'versions']);
}
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/manager/manager.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ReactiveFormsModule } from '@angular/forms';
import { NgbPaginationModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';

import { ManagerComponent } from './container/manager.component';
import { EntityItemComponent } from './component/entity-item.component';
Expand Down Expand Up @@ -44,7 +45,8 @@ import { I18nModule } from '../../i18n/i18n.module';
NgbDropdownModule,
HttpClientModule,
SharedModule,
I18nModule
I18nModule,
InfiniteScrollModule
],
exports: [
ResolverItemComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Provider Collection Reducer', () => {
name: 'name',
'@type': 'foo',
enabled: true,
createdBy: 'admin',
createdDate: new Date().toLocaleDateString(),
sortKey: 1,
xmlId: 'foo',
Expand All @@ -34,6 +35,7 @@ describe('Provider Collection Reducer', () => {
name: 'bar',
'@type': 'bar',
enabled: false,
createdBy: 'admin',
createdDate: new Date().toLocaleDateString(),
sortKey: 2,
xmlId: 'bar',
Expand Down
Loading

0 comments on commit c3e6a81

Please sign in to comment.