Skip to content

Commit

Permalink
SHIBUI-914 Fixed issues with summary page, fixed issues with bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 16, 2018
1 parent 109f52c commit 12b959e
Show file tree
Hide file tree
Showing 34 changed files with 434 additions and 169 deletions.
2 changes: 2 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ label.make-default=Make Default
label.metadata-provider-name-dashboard-display-only=Metadata Provider Name (Dashboard Display Only)
label.default-authentication-methods=Default Authentication Method(s)

label.new-of-type=New { type }

label.filter-name=Filter Name (Dashboard Display Only)
label.metadata-filter-name=Metadata Filter Name (Dashboard Display Only)
label.filter-enable=Enable this Filter?
Expand Down
2 changes: 2 additions & 0 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ label.make-default=Make Default
label.metadata-provider-name-dashboard-display-only=Metadata Provider Name (Dashboard Display Only)
label.default-authentication-methods=Default Authentication Method(s)

label.new-of-type=New { type }

label.filter-name=Filter Name (Dashboard Display Only)
label.metadata-filter-name=Metadata Filter Name (Dashboard Display Only)
label.filter-enable=Enable this Filter?
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div class="mb-3" *ngIf="property">
<ng-container [ngSwitch]="property.type">
<ng-container *ngSwitchDefault>
<ng-container *ngIf="property.name">
<strong class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</strong>
<span class="d-block" role="definition">{{ property.value || property.value === false ? property.value : '-' }}</span>
</ng-container>
</ng-container>
<ng-container *ngSwitchCase="'array'">
<ng-container *ngIf="property.name">
<strong class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</strong>
</ng-container>
<ng-container *ngIf="property.items.type === 'object'">
<p class="text-secondary" *ngIf="!property.value || !property.value.length">&mdash;</p>
<table class="table table-sm table-bordered table-striped" *ngIf="property.value && property.value.length">
<thead>
<tr class="table-secondary">
<th *ngFor="let prop of getKeys(property.items)">
<translate-i18n [key]="property.items.properties[prop].title"></translate-i18n>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let value of property.value">
<td *ngFor="let prop of getKeys(property.items)"
[ngbPopover]="value[prop]"
triggers="mouseenter:mouseleave"
container="body"
placement="top">
{{ value[prop] }}
</td>
</tr>
</tbody>
</table>
</ng-container>
<ng-container *ngIf="property.items.type === 'string'">
<p class="text-secondary" *ngIf="!property.value || !property.value.length">&mdash;</p>
<ul class="list-unstyled" *ngIf="property.value && property.value.length">
<li *ngFor="let item of property.value">
{{ item }}
</li>
</ul>
</ng-container>
</ng-container>
<ng-container *ngSwitchCase="'object'">
<ng-container *ngIf="property.name">
<span class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</span>
</ng-container>
<ng-container *ngIf="property.properties">
<summary-property *ngFor="let prop of property.properties" [property]="prop"></summary-property>
</ng-container>
</ng-container>
</ng-container>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ import { Property } from '../model/property';

export class SummaryPropertyComponent {
@Input() property: Property;

getKeys(schema): string[] {
return Object.keys(schema.properties);
}
}

113 changes: 113 additions & 0 deletions ui/src/app/metadata/domain/component/wizard-summary.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { Component, Input, SimpleChanges, OnChanges, Output, EventEmitter } from '@angular/core';

import { Wizard, WizardStep } from '../../../wizard/model';
import { MetadataProvider, MetadataResolver } from '../../domain/model';
import { Property } from '../model/property';
import { getSplitSchema } from '../../../wizard/reducer';

interface Section {
id: string;
index: number;
label: string;
properties: Property[];
}

export function getDefinition(path: string, definitions): any {
let def = path.split('/').pop();
return definitions[def];
}

export function getPropertyItemSchema(items: any, definitions: any): any {
if (!items) { return null; }
return items.$ref ? getDefinition(items.$ref, definitions) : items;
}

export function getStepProperty(property, model, definitions): Property {
property = property.$ref ? getDefinition(property.$ref, definitions) : property;
return {
name: property.title,
value: model,
type: property.type,
items: getPropertyItemSchema(property.items, definitions),
properties: getStepProperties(
property,
model,
definitions
)
};
}


export function getStepProperties(schema: any, model: any, definitions: any = {}): Property[] {
if (!schema || !schema.properties) { return []; }
return Object
.keys(schema.properties)
.map(property => {
return getStepProperty(
schema.properties[property],
model[property],
definitions
);
});
}

@Component({
selector: 'wizard-summary',
templateUrl: './wizard-summary.component.html',
styleUrls: []
})

export class WizardSummaryComponent implements OnChanges {
@Input() summary: { definition: Wizard<MetadataProvider | MetadataResolver>, schema: { [id: string]: any }, model: any };

@Output() onPageSelect: EventEmitter<string> = new EventEmitter();

sections: Section[];
columns: Array<Section>[];
steps: WizardStep[];

constructor() {}

ngOnChanges(changes: SimpleChanges): void {
if (changes.summary && this.summary) {
const schemas = this.summary.schema;
const model = this.summary.model;
const def = this.summary.definition;
const steps = def.steps;

this.sections = steps
.filter(step => step.id !== 'summary')
.map(
(step: WizardStep) => {
return ({
id: step.id,
index: step.index,
label: step.label,
properties: getStepProperties(
schemas[step.id] || getSplitSchema(schemas['summary'], step),
def.formatter(model),
schemas.definitions || schemas.hasOwnProperty('summary') ? schemas['summary'].definitions : {}
)
});
}
);

this.columns = this.sections.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index / Math.round(this.sections.length / 2));

if (!resultArray[chunkIndex]) {
resultArray[chunkIndex] = [];
}

resultArray[chunkIndex].push(item);

return resultArray;
}, []);
}
}

gotoPage(page: string = ''): void {
this.onPageSelect.emit(page);
}
}

10 changes: 8 additions & 2 deletions ui/src/app/metadata/domain/domain.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ import { PreviewDialogComponent } from './component/preview-dialog.component';
import { MetadataFilterService } from './service/filter.service';
import { AttributesService } from './service/attributes.service';
import { I18nModule } from '../../i18n/i18n.module';
import { WizardSummaryComponent } from './component/wizard-summary.component';
import { SummaryPropertyComponent } from './component/summary-property.component';
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';

export const COMPONENTS = [
PreviewDialogComponent
PreviewDialogComponent,
WizardSummaryComponent,
SummaryPropertyComponent
];

export const DECLARATIONS = [
Expand All @@ -30,7 +35,8 @@ export const DECLARATIONS = [
imports: [
HttpModule,
CommonModule,
I18nModule
I18nModule,
NgbPopoverModule
],
exports: DECLARATIONS,
providers: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export interface Property {
type: string;
name: string;
value: string[];
items: Property;
properties: Property[];
}
47 changes: 36 additions & 11 deletions ui/src/app/metadata/domain/model/wizards/metadata-source-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 1,
id: 'common',
label: 'label.resolver-common-attributes',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'serviceProviderName',
'entityId'
],
fieldsets: [
{
type: 'section',
class: ['col-6'],
fields: [
'serviceProviderName',
'entityId'
Expand All @@ -28,7 +29,7 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 2,
id: 'org-info',
label: 'label.org-info',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'organization',
'contacts'
Expand All @@ -52,7 +53,7 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 3,
id: 'metadata-ui',
label: 'label.metadata-ui',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'mdui'
]
Expand All @@ -61,7 +62,7 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 4,
id: 'descriptor-info',
label: 'label.descriptor-info',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'serviceProviderSsoDescriptor'
]
Expand All @@ -70,7 +71,7 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 5,
id: 'logout-endpoints',
label: 'label.logout-endpoints',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'logoutEndpoints'
],
Expand All @@ -87,7 +88,7 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 6,
id: 'key-info',
label: 'label.key-info',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'securityInfo'
]
Expand All @@ -96,34 +97,58 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
index: 7,
id: 'assertion',
label: 'label.assertion',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'assertionConsumerServices'
],
fieldsets: [
{
type: 'group',
fields: [
'assertionConsumerServices'
]
}
]
},
{
index: 8,
id: 'relying-party',
label: 'label.relying-party',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'relyingPartyOverrides'
],
fieldsets: [
{
type: 'group',
fields: [
'relyingPartyOverrides'
]
}
]
},
{
index: 9,
id: 'attribute',
label: 'label.attribute-release',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'attributeRelease'
],
fieldsets: [
{
type: 'group',
fields: [
'attributeRelease'
]
}
]
},
{
index: 10,
id: 'finish',
id: 'summary',
label: 'label.finished',
schema: '/api/ui/MetadataSources',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'serviceEnabled'
],
Expand Down
Loading

0 comments on commit 12b959e

Please sign in to comment.