Skip to content

Commit

Permalink
Merge pull request #181 from wwelling/master
Browse files Browse the repository at this point in the history
Meta Service
  • Loading branch information
artlowel committed Oct 16, 2017
2 parents c9338e2 + 6f42fa5 commit 311fef2
Show file tree
Hide file tree
Showing 36 changed files with 1,252 additions and 210 deletions.
4 changes: 2 additions & 2 deletions e2e/app.e2e-spec.ts
Expand Up @@ -7,9 +7,9 @@ describe('protractor App', () => {
page = new ProtractorPage();
});

it('should display title "DSpace"', () => {
it('should display translated title "DSpace Angular :: Home"', () => {
page.navigateTo();
expect<any>(page.getPageTitleText()).toEqual('DSpace');
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home');
});

it('should display header "Welcome to DSpace"', () => {
Expand Down
51 changes: 25 additions & 26 deletions package.json
Expand Up @@ -12,15 +12,14 @@
},
"scripts": {
"global": "npm install -g @angular/cli marked node-gyp nodemon node-nightly npm-check-updates npm-run-all rimraf typescript ts-node typedoc webpack webpack-bundle-analyzer pm2 rollup",
"clean:coverage": "yarn run rimraf coverage",
"clean:dist": "yarn run rimraf dist",
"clean:doc": "yarn run rimraf doc",
"clean:log": "yarn run rimraf *.log*",
"clean:json": "yarn run rimraf *.records.json",
"clean:node": "yarn run rimraf node_modules",
"clean:coverage": "rimraf coverage",
"clean:dist": "rimraf dist",
"clean:doc": "rimraf doc",
"clean:log": "rimraf *.log*",
"clean:json": "rimraf *.records.json",
"clean:node": "rimraf node_modules",
"clean:prod": "yarn run clean:coverage && yarn run clean:doc && yarn run clean:dist && yarn run clean:log && yarn run clean:json",
"clean": "yarn run clean:prod && yarn run clean:node",
"rimraf": "rimraf",
"prebuild": "yarn run clean:dist",
"prebuild:aot": "yarn run prebuild",
"prebuild:prod": "yarn run prebuild",
Expand Down Expand Up @@ -69,15 +68,15 @@
"coverage": "http-server -c-1 -o -p 9875 ./coverage"
},
"dependencies": {
"@angular/animations": "4.4.4",
"@angular/common": "4.4.4",
"@angular/core": "4.4.4",
"@angular/forms": "4.4.4",
"@angular/http": "4.4.4",
"@angular/platform-browser": "4.4.4",
"@angular/platform-browser-dynamic": "4.4.4",
"@angular/platform-server": "4.4.4",
"@angular/router": "4.4.4",
"@angular/animations": "4.4.5",
"@angular/common": "4.4.5",
"@angular/core": "4.4.5",
"@angular/forms": "4.4.5",
"@angular/http": "4.4.5",
"@angular/platform-browser": "4.4.5",
"@angular/platform-browser-dynamic": "4.4.5",
"@angular/platform-server": "4.4.5",
"@angular/router": "4.4.5",
"@angularclass/bootloader": "1.0.1",
"@angularclass/idle-preload": "1.0.4",
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
Expand All @@ -89,11 +88,11 @@
"@ngx-translate/http-loader": "2.0.0",
"body-parser": "1.18.2",
"bootstrap": "v4.0.0-beta",
"cerialize": "0.1.16",
"cerialize": "0.1.18",
"compression": "1.7.1",
"cookie-parser": "1.4.3",
"core-js": "2.5.1",
"express": "4.16.1",
"express": "4.16.2",
"express-session": "1.15.6",
"font-awesome": "4.7.0",
"http-server": "0.10.0",
Expand All @@ -103,18 +102,18 @@
"methods": "1.1.2",
"morgan": "1.9.0",
"ngx-pagination": "3.0.1",
"pem": "1.12.2",
"pem": "1.12.3",
"reflect-metadata": "0.1.10",
"rxjs": "5.4.3",
"ts-md5": "1.2.2",
"webfontloader": "1.6.28",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/compiler": "4.4.4",
"@angular/compiler-cli": "4.4.4",
"@angular/compiler": "4.4.5",
"@angular/compiler-cli": "4.4.5",
"@ngrx/store-devtools": "4.0.0",
"@ngtools/webpack": "1.7.2",
"@ngtools/webpack": "1.7.4",
"@types/cookie-parser": "1.4.1",
"@types/deep-freeze": "0.1.1",
"@types/express": "4.0.37",
Expand All @@ -123,7 +122,7 @@
"@types/jasmine": "2.6.0",
"@types/memory-cache": "0.0.31",
"@types/mime": "2.0.0",
"@types/node": "8.0.26",
"@types/node": "8.0.34",
"@types/serve-static": "1.7.32",
"@types/source-map": "0.5.1",
"@types/webfontloader": "1.6.29",
Expand Down Expand Up @@ -168,13 +167,13 @@
"postcss-apply": "0.8.0",
"postcss-cli": "4.1.1",
"postcss-cssnext": "3.0.2",
"postcss-loader": "2.0.6",
"postcss-loader": "2.0.7",
"postcss-responsive-type": "1.0.0",
"postcss-smart-import": "0.7.5",
"protractor": "5.1.2",
"protractor-istanbul-plugin": "2.0.0",
"raw-loader": "0.5.1",
"resolve-url-loader": "2.1.0",
"resolve-url-loader": "2.1.1",
"rimraf": "2.6.2",
"rollup": "0.50.0",
"rollup-plugin-commonjs": "8.2.1",
Expand All @@ -191,7 +190,7 @@
"tslint": "5.7.0",
"typedoc": "0.9.0",
"typescript": "2.5.3",
"webpack": "3.6.0",
"webpack": "3.7.1",
"webpack-bundle-analyzer": "2.9.0",
"webpack-dev-middleware": "1.12.0",
"webpack-dev-server": "2.9.1",
Expand Down
4 changes: 4 additions & 0 deletions resources/i18n/en.json
Expand Up @@ -65,12 +65,16 @@
}
},
"home": {
"title": "DSpace Angular :: Home",
"description": "",
"top-level-communities": {
"head": "Communities in DSpace",
"help": "Select a community to browse its collections."
}
},
"search": {
"title": "DSpace Angular :: Search",
"description": "",
"form": {
"search": "Search",
"search_dspace": "Search DSpace"
Expand Down
4 changes: 3 additions & 1 deletion src/app/+collection-page/collection-page-routing.module.ts
Expand Up @@ -10,4 +10,6 @@ import { CollectionPageComponent } from './collection-page.component';
])
]
})
export class CollectionPageRoutingModule { }
export class CollectionPageRoutingModule {

}
18 changes: 12 additions & 6 deletions src/app/+collection-page/collection-page.component.ts
Expand Up @@ -7,6 +7,8 @@ import {
} from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';

import { PageInfo } from '../core/shared/page-info.model';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';

import { Collection } from '../core/shared/collection.model';
Expand All @@ -18,8 +20,8 @@ import { Item } from '../core/shared/item.model';
import { SortOptions, SortDirection } from '../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { hasValue, isNotEmpty, isUndefined } from '../shared/empty.util';
import { PageInfo } from '../core/shared/page-info.model';
import { Observable } from 'rxjs/Observable';

import { MetadataService } from '../core/metadata/metadata.service';

import { fadeIn, fadeInOut } from '../shared/animations/fade';

Expand All @@ -41,9 +43,12 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
private subs: Subscription[] = [];
private collectionId: string;

constructor(private collectionDataService: CollectionDataService,
private itemDataService: ItemDataService,
private route: ActivatedRoute) {
constructor(
private collectionDataService: CollectionDataService,
private itemDataService: ItemDataService,
private metadata: MetadataService,
private route: ActivatedRoute
) {
this.paginationConfig = new PaginationComponentOptions();
this.paginationConfig.id = 'collection-page-pagination';
this.paginationConfig.pageSizeOptions = [4];
Expand All @@ -57,12 +62,13 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
Observable.combineLatest(
this.route.params,
this.route.queryParams,
(params, queryParams,) => {
(params, queryParams, ) => {
return Object.assign({}, params, queryParams);
})
.subscribe((params) => {
this.collectionId = params.id;
this.collectionData = this.collectionDataService.findById(this.collectionId);
this.metadata.processRemoteData(this.collectionData);
this.subs.push(this.collectionData.payload.subscribe((collection) => this.logoData = collection.logo));

const page = +params.page || this.paginationConfig.currentPage;
Expand Down
4 changes: 3 additions & 1 deletion src/app/+community-page/community-page-routing.module.ts
Expand Up @@ -10,4 +10,6 @@ import { CommunityPageComponent } from './community-page.component';
])
]
})
export class CommunityPageRoutingModule { }
export class CommunityPageRoutingModule {

}
11 changes: 6 additions & 5 deletions src/app/+community-page/community-page.component.ts
Expand Up @@ -9,6 +9,8 @@ import { RemoteData } from '../core/data/remote-data';
import { CommunityDataService } from '../core/data/community-data.service';
import { hasValue } from '../shared/empty.util';

import { MetadataService } from '../core/metadata/metadata.service';

import { fadeInOut } from '../shared/animations/fade';

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

constructor(
private communityDataService: CommunityDataService,
private metadata: MetadataService,
private route: ActivatedRoute
) {

Expand All @@ -32,15 +35,13 @@ export class CommunityPageComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.route.params.subscribe((params: Params) => {
this.communityData = this.communityDataService.findById(params.id);
this.subs.push(this.communityData.payload
.subscribe((community) => this.logoData = community.logo));
this.metadata.processRemoteData(this.communityData);
this.subs.push(this.communityData.payload.subscribe((community) => this.logoData = community.logo));
});
}

ngOnDestroy(): void {
this.subs
.filter((sub) => hasValue(sub))
.forEach((sub) => sub.unsubscribe());
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
}

}
2 changes: 1 addition & 1 deletion src/app/+home-page/home-page-routing.module.ts
Expand Up @@ -6,7 +6,7 @@ import { HomePageComponent } from './home-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: HomePageComponent, pathMatch: 'full' }
{ path: '', component: HomePageComponent, pathMatch: 'full', data: { title: 'home.title' } }
])
]
})
Expand Down
10 changes: 6 additions & 4 deletions src/app/+item-page/full/full-item-page.component.ts
@@ -1,15 +1,17 @@
import { Component, OnInit } from '@angular/core';
import { animate, state, transition, trigger, style, keyframes } from '@angular/animations';
import { ActivatedRoute } from '@angular/router';

import { Observable } from 'rxjs/Observable';

import { ItemPageComponent } from '../simple/item-page.component';
import { Metadatum } from '../../core/shared/metadatum.model';
import { ItemDataService } from '../../core/data/item-data.service';
import { ActivatedRoute } from '@angular/router';

import { RemoteData } from '../../core/data/remote-data';
import { Item } from '../../core/shared/item.model';

import { MetadataService } from '../../core/metadata/metadata.service';

import { fadeInOut } from '../../shared/animations/fade';

/**
Expand All @@ -30,8 +32,8 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit {

metadata: Observable<Metadatum[]>;

constructor(route: ActivatedRoute, items: ItemDataService) {
super(route, items);
constructor(route: ActivatedRoute, items: ItemDataService, metadataService: MetadataService) {
super(route, items, metadataService);
}

/*** AoT inheritance fix, will hopefully be resolved in the near future **/
Expand Down
9 changes: 8 additions & 1 deletion src/app/+item-page/simple/item-page.component.ts
Expand Up @@ -8,6 +8,8 @@ import { ItemDataService } from '../../core/data/item-data.service';
import { RemoteData } from '../../core/data/remote-data';
import { Bitstream } from '../../core/shared/bitstream.model';

import { MetadataService } from '../../core/metadata/metadata.service';

import { fadeInOut } from '../../shared/animations/fade';

/**
Expand All @@ -31,7 +33,11 @@ export class ItemPageComponent implements OnInit {

thumbnail: Observable<Bitstream>;

constructor(private route: ActivatedRoute, private items: ItemDataService) {
constructor(
private route: ActivatedRoute,
private items: ItemDataService,
private metadataService: MetadataService
) {

}

Expand All @@ -44,6 +50,7 @@ export class ItemPageComponent implements OnInit {
initialize(params) {
this.id = +params.id;
this.item = this.items.findById(params.id);
this.metadataService.processRemoteData(this.item);
this.thumbnail = this.item.payload.flatMap((i) => i.getThumbnail());
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/+search-page/search-page-routing.module.ts
Expand Up @@ -6,7 +6,7 @@ import { SearchPageComponent } from './search-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: SearchPageComponent }
{ path: '', component: SearchPageComponent, data: { title: 'search.title' } }
])
]
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/+search-page/search-page.component.spec.ts
Expand Up @@ -104,7 +104,7 @@ describe('SearchPageComponent', () => {
(comp as any).updateSearchResults({});

expect(comp.results as any).toBe(mockResults);
});
});

});
});
8 changes: 6 additions & 2 deletions src/app/app.component.spec.ts
@@ -1,4 +1,3 @@
// ... test imports
import {
async,
ComponentFixture,
Expand All @@ -23,14 +22,18 @@ import { AppComponent } from './app.component';

import { HostWindowState } from './shared/host-window.reducer';
import { HostWindowResizeAction } from './shared/host-window.actions';
import { MockTranslateLoader } from './shared/testing/mock-translate-loader';

import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';

import { MetadataService } from './core/metadata/metadata.service';

import { GLOBAL_CONFIG, ENV_CONFIG } from '../config';
import { NativeWindowRef, NativeWindowService } from './shared/window.service';

import { MockTranslateLoader } from './shared/mocks/mock-translate-loader';
import { MockMetadataService } from './shared/mocks/mock-metadata-service';

let comp: AppComponent;
let fixture: ComponentFixture<AppComponent>;
let de: DebugElement;
Expand All @@ -57,6 +60,7 @@ describe('App component', () => {
providers: [
{ provide: GLOBAL_CONFIG, useValue: ENV_CONFIG },
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
{ provide: MetadataService, useValue: new MockMetadataService() },
AppComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
Expand Down

0 comments on commit 311fef2

Please sign in to comment.