Skip to content

Commit

Permalink
Merge branch 'master' into SHIBUI-570
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Sep 11, 2018
2 parents 1350872 + 8db57a7 commit 562e204
Show file tree
Hide file tree
Showing 27 changed files with 397 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ public List<MetadataResolver> getResolvers() {
return mutableResolvers;
}

@Override
@Nonnull public Iterable<EntityDescriptor> resolve(@Nullable final CriteriaSet criteria) throws ResolverException {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
//Our overridden method uses a collection of mutable resolvers instead of regular resolvers
for (final MetadataResolver resolver : mutableResolvers) {
try {
final Iterable<EntityDescriptor> descriptors = resolver.resolve(criteria);
if (descriptors != null && descriptors.iterator().hasNext()) {
return descriptors;
}
} catch (final ResolverException e) {
log.warn("Error retrieving metadata from resolver of type {}, proceeding to next resolver",
resolver.getClass().getName(), e);
continue;
}
}

return Collections.emptyList();
}

@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import spock.lang.Unroll
Expand Down Expand Up @@ -150,6 +151,7 @@ class MetadataResolversControllerIntegrationTests extends Specification {
}

@Unroll
@DirtiesContext
def "POST new concrete MetadataResolver of type #resolverType -> /api/MetadataResolvers"(String resolverType) {
given: 'New MetadataResolver JSON representation'
def resolver = generator.buildRandomMetadataResolverOfType(resolverType)
Expand Down
60 changes: 60 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,66 @@ For Providers and Filters, the forms in SHIB-UI are built based on the standard

[Bootstrap](http://getbootstrap.com/) 4 is used for the css framework in SHIB-UI, and provides our base theme, a responsive grid system, consistent styling across all major browsers, and pre-styled components which are connected to Angular using ng-bootstrap, a 3rd party framework.

# Customizing UI

Within the `ui > src` folder, there are two files which can be used to customize the user interface quickly.

### Color Scheme
The `Brand.scss` contains the palette information used by bootstrap to color the user interface buttons and other components. Uncomment the color you wish to override and change the hex value accordingly and rebuild the user interface.

For example:

`// $blue: #00355f;`

change to...

`$blue: #0000FF;`

If you wish to change the __"primary"__ color or any other mapping according to Bootstrap's conventions, there is a block of mappings at the bottom of the `Brand.scss` file to accomodate this as well. Uncomment and change the value allocated to the corresponding aspect of the theme you wish to change.

The supported values are:

`$brand-primary: $blue;` - The primary color used throughout the site. Default: dark blue.

`$brand-secondary: $gray-700;` - An accept color used throughout the site. Default: dark gray.

`$brand-success: $green;` - Indicates success or some other positive action. Default: green.

`$brand-info: $light-blue;` - Indicates some sort of informative text or action for the user. Default: light blue.

`$brand-warning: $yellow;` - Indicates a warning to the user. Default: yellow.

`$brand-danger: $red;` - Indicates a dangerous action or error. Default: red.

`$brand-light: $light-grey;` - Color used for accents, text, etc throughout application. Default: light grey.

`$brand-dark: $dark-grey;` - Color used for accents, text, etc throughout application. Default: dark grey.

### Logos / Footer
The `Brand.ts` contains the links, text, and image paths to modify the logos, text, and links found within the header and footer. Override the values within this Typescript file and rebuild the user interface to view changes. If the local server should host these files, they should be added to the assets folder.

For example:

`export const brand = {};`

change to...

`export const brand = {
header: 'Metadata Management'
};`

### Sitewide text
Finally, this project has support for internationalization (i18n). In the folder `backend > src > main > resources > i18n` folder there is a group of files which can be used to modify the text seen throughout the application. In order to change the default value, you can override the text in the messages_en file with the desired text.

For example:

`action.logout=Logout`

change to...

`action.logout=Sign Out`


# Development

## Scaffolding
Expand Down
10 changes: 2 additions & 8 deletions ui/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function (config) {
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-phantomjs-launcher'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-spec-reporter'),
Expand Down Expand Up @@ -46,13 +46,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_WARN,
autoWatch: false,
browsers: ['PhantomJS_custom'],
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
flags: ['--disk-cache=false']
}
},
browsers: ['ChromeHeadless'],
singleRun: true
});
};
1 change: 0 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"karma-phantomjs-launcher": "^1.0.4",
"karma-spec-reporter": "0.0.31",
"path": "^0.12.7",
"phantomjs-prebuilt": "^2.1.15",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
Expand Down
44 changes: 44 additions & 0 deletions ui/src/app/app.brand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { brand as customBrand } from '../brand';
import { Brand } from './core/model/brand';

export const brand: Brand = {
header: {
title: 'Source Management'
},
logo: {
default: '/assets/shibboleth_logowordmark_color.png',
small: '/assets/shibboleth_icon_color_130x130.png',
large: '/assets/shibboleth_logowordmark_color.png',
alt: 'Shibboleth Logo - Click to be directed to www.shibboleth.net',
link: {
label: 'Shibboleth',
url: 'https://www.shibboleth.net/'
}
},
footer: {
links: [
{
label: 'Home Page',
url: 'https://www.shibboleth.net/',
description: 'Shibboleth.net open-source community home page'
},
{
label: 'Wiki',
url: 'https://wiki.shibboleth.net/',
description: 'Shibboleth.net open-source community wiki'
},
{
label: 'Issue Tracker',
url: 'https://issues.shibboleth.net/',
description: 'Shibboleth.net open-source community issue tracker'
},
{
label: 'Mailing List',
url: 'https://www.shibboleth.net/community/lists/',
description: 'Shibboleth.net open-source community mailing list'
}
],
text: 'Links to Shibboleth resources:'
},
...customBrand
};
23 changes: 13 additions & 10 deletions ui/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!--The content below is only a placeholder and can be replaced.-->
<nav class="navbar navbar-expand-md fixed-top">
<a class="navbar-brand" href="https://www.shibboleth.net/" target="_blank">
<img src="/assets/shibboleth_icon_color_130x130.png" width="30" height="30" class="d-inline-block align-top" alt="Shibboleth Logo - Click to be directed to www.shibboleth.net">
<span class="d-lg-inline d-none">Shibboleth</span>
<a class="navbar-brand" [href]="brand.logo.link.url" target="_blank" [title]="brand.logo.link.description">
<img [src]="brand.logo.small" width="30" height="30" class="d-inline-block align-top" [alt]="brand.logo.alt">
<span class="d-lg-inline d-none">{{ brand.logo.link.label }}</span>
</a>
<span class="navbar-text" i18n="@@label--app">Source Management</span>
<span class="navbar-text" i18n="@@label--app">{{ brand.header.title }}</span>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand Down Expand Up @@ -66,11 +66,12 @@
<div class="row">
<div class="col-md-8 copyright">
<ul class="list-inline">
<li class="list-inline-item" i18n="@@link--links-to-shibboleth-resources">Links to Shibboleth resources:</li>
<li class="list-inline-item"><a href="https://www.shibboleth.net/" target="_blank" i18n="@@link--home-page" aria-label="Shibboleth.net open-source community home page">Home Page</a></li>
<li class="list-inline-item"><a href="https://wiki.shibboleth.net/" target="_blank" i18n="@@link--wiki" aria-label="Shibboleth.net open-source community wiki">Wiki</a></li>
<li class="list-inline-item"><a href="https://issues.shibboleth.net/" target="_blank" i18n="@@link--issue-tracker" aria-label="Shibboleth.net open-source community issue tracker">Issue Tracker</a></li>
<li class="list-inline-item"><a href="https://www.shibboleth.net/community/lists/" target="_blank" i18n="@@link--mailing-list" aria-label="Shibboleth.net open-source community mailing list">Mailing List</a></li>
<li class="list-inline-item">{{ brand.footer.text }}</li>
<li class="list-inline-item" *ngFor="let link of brand.footer.links">
<a [href]="link.url" target="_blank" [attr.aria-label]="link.description" [title]="link.description">
{{ link.label }}
</a>
</li>
</ul>
<p>
<ng-container *ngIf="version$ | async">
Expand All @@ -81,7 +82,9 @@
</p>
</div>
<div class="col-md-4 logo">
<a href="https://www.shibboleth.net/" target="_blank"><img src="/assets/shibboleth_logowordmark_color.png" class="img-fluid float-right" alt="Shibboleth Logo - Click to be directed to www.shibboleth.net"></a>
<a [href]="brand.logo.link.url" target="_blank" [title]="brand.logo.link.label">
<img [src]="brand.logo.default" class="img-fluid float-right" [alt]="brand.logo.alt">
</a>
</div>
</div>
</footer>
6 changes: 6 additions & 0 deletions ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Store } from '@ngrx/store';
import * as fromRoot from './core/reducer';
import { VersionInfo } from './core/model/version';
import { VersionInfoLoadRequestAction } from './core/action/version.action';

import { brand } from './app.brand';
import { Brand } from './core/model/brand';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand All @@ -18,6 +21,9 @@ export class AppComponent implements OnInit {
version: string;
formatted$: Observable<string>;
today = new Date();
year = new Date().getFullYear();

brand: Brand = brand;

formatter = v => v && v.build ? `${v.build.version}-${v.git.commit.id}` : '';

Expand Down
29 changes: 29 additions & 0 deletions ui/src/app/core/model/brand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface Brand {
logo: Logo;
footer: Footer;
header: Header;
}

export interface Header {
title: string;
}

export interface Logo {
default: string;
small: string;
large: string;
alt: string;
link: Link;
[propName: string]: any;
}

export interface Footer {
links: Link[];
text: string;
}

export interface Link {
label: string;
url: string;
description?: string;
}
6 changes: 6 additions & 0 deletions ui/src/app/metadata/domain/effect/entity.effect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModalStub } from '../../../../testing/modal.stub';
import { EntityAttributesFilterEntity, FileBackedHttpMetadataResolver } from '../entity';

import * as fromRoot from '../../../app.reducer';
import { StoreModule } from '@ngrx/store';

describe('Entity Effects', () => {
let effects: EntityEffects;
let providerService: any;
Expand All @@ -35,6 +38,9 @@ describe('Entity Effects', () => {
},
{ provide: Actions, useFactory: getActions }
],
imports: [
StoreModule.forRoot(fromRoot.reducers)
]
});

effects = TestBed.get(EntityEffects);
Expand Down
33 changes: 24 additions & 9 deletions ui/src/app/metadata/domain/effect/entity.effect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { Store } from '@ngrx/store';

import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
Expand All @@ -12,6 +13,10 @@ import { MetadataTypes } from '../domain.type';
import { EntityIdService } from '../service/entity-id.service';
import * as entityActions from '../action/entity.action';

import * as fromRoot from '../../../app.reducer';

import { AddNotification } from '../../../notification/action/notification.action';
import { Notification, NotificationType } from '../../../notification/model/notification';

@Injectable()
export class EntityEffects {
Expand All @@ -27,20 +32,30 @@ export class EntityEffects {
private actions$: Actions,
private modalService: NgbModal,
private providerService: ResolverService,
private entityService: EntityIdService
private entityService: EntityIdService,
private store: Store<fromRoot.State>
) { }

openModal(prev: { id: string, entity: MetadataEntity }): void {
let { id, entity } = prev,
request: Observable<string> = entity.kind === MetadataTypes.FILTER ?
this.entityService.preview(id) : this.providerService.preview(id);
request.subscribe(xml => {
let modal = this.modalService.open(PreviewDialogComponent, {
size: 'lg',
windowClass: 'modal-xl'
});
modal.componentInstance.entity = entity;
modal.componentInstance.xml = xml;
});
request.subscribe(
xml => {
let modal = this.modalService.open(PreviewDialogComponent, {
size: 'lg',
windowClass: 'modal-xl'
});
modal.componentInstance.entity = entity;
modal.componentInstance.xml = xml;
},
err => {
this.store.dispatch(new AddNotification(new Notification(
NotificationType.Danger,
`Unable to preview entity.`,
8000
)));
}
);
}
} /* istanbul ignore next */
Loading

0 comments on commit 562e204

Please sign in to comment.