mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #93 from artlowel/initial-home-page-content
Initial home page content
This commit is contained in:
@@ -12,8 +12,8 @@ describe('protractor App', function() {
|
|||||||
expect(page.getPageTitleText()).toEqual('DSpace');
|
expect(page.getPageTitleText()).toEqual('DSpace');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display title "Hello, World!"', () => {
|
it('should display header "Welcome to DSpace"', () => {
|
||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
expect(page.getFirstPText()).toEqual('Hello, World!');
|
expect(page.getFirstHeaderText()).toEqual('Welcome to DSpace');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -12,4 +12,8 @@ export class ProtractorPage {
|
|||||||
getFirstPText() {
|
getFirstPText() {
|
||||||
return element(by.xpath('//p[1]')).getText();
|
return element(by.xpath('//p[1]')).getText();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
getFirstHeaderText() {
|
||||||
|
return element(by.xpath('//h1[1]')).getText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,10 +1,4 @@
|
|||||||
{
|
{
|
||||||
"example": {
|
|
||||||
"with": {
|
|
||||||
"data": "{{greeting}}, {{recipient}}!"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"footer": {
|
"footer": {
|
||||||
"copyright": "copyright © 2002-{{ year }}",
|
"copyright": "copyright © 2002-{{ year }}",
|
||||||
"link.dspace": "DSpace software",
|
"link.dspace": "DSpace software",
|
||||||
@@ -34,5 +28,12 @@
|
|||||||
"link": {
|
"link": {
|
||||||
"home-page": "Take me to the home page"
|
"home-page": "Take me to the home page"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"home": {
|
||||||
|
"top-level-communities": {
|
||||||
|
"head": "Communities in DSpace",
|
||||||
|
"help": "Select a community to browse its collections."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,6 @@
|
|||||||
|
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<p>{{ 'example.with.data' | translate:data }}</p>
|
|
||||||
<p>{{ example }}</p>
|
|
||||||
<h2 [ngClass]="{ 'red': EnvConfig.production, 'green': !EnvConfig.production }">
|
|
||||||
<span *ngIf="!EnvConfig.production">development</span>
|
|
||||||
<span *ngIf="EnvConfig.production">production</span>
|
|
||||||
</h2>
|
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
@@ -15,11 +15,3 @@
|
|||||||
.main-content {
|
.main-content {
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2.red {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2.green {
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
@@ -52,8 +52,8 @@ describe('App component', () => {
|
|||||||
|
|
||||||
comp = fixture.componentInstance; // component test instance
|
comp = fixture.componentInstance; // component test instance
|
||||||
|
|
||||||
// query for the title <p> by CSS element selector
|
// query for the <div class="outer-wrapper"> by CSS element selector
|
||||||
de = fixture.debugElement.query(By.css('p'));
|
de = fixture.debugElement.query(By.css('div.outer-wrapper'));
|
||||||
el = de.nativeElement;
|
el = de.nativeElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@ import {
|
|||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Inject,
|
Inject,
|
||||||
ViewEncapsulation,
|
ViewEncapsulation,
|
||||||
OnDestroy,
|
|
||||||
OnInit, HostListener
|
OnInit, HostListener
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { TranslateService } from "ng2-translate";
|
import { TranslateService } from "ng2-translate";
|
||||||
@@ -11,7 +10,7 @@ import { HostWindowState } from "./shared/host-window.reducer";
|
|||||||
import { Store } from "@ngrx/store";
|
import { Store } from "@ngrx/store";
|
||||||
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
||||||
|
|
||||||
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
|
import { EnvConfig, GLOBAL_CONFIG, GlobalConfig } from '../config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
@@ -20,15 +19,7 @@ import { GLOBAL_CONFIG, GlobalConfig } from '../config';
|
|||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.css']
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnDestroy, OnInit {
|
export class AppComponent implements OnInit {
|
||||||
private translateSubscription: any;
|
|
||||||
|
|
||||||
example: string;
|
|
||||||
|
|
||||||
data: any = {
|
|
||||||
greeting: 'Hello',
|
|
||||||
recipient: 'World'
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig,
|
@Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig,
|
||||||
@@ -42,15 +33,9 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.translateSubscription = this.translate.get('example.with.data', { greeting: 'Hello', recipient: 'DSpace' }).subscribe((translation: string) => {
|
const env: string = EnvConfig.production ? "Production" : "Development";
|
||||||
this.example = translation;
|
const color: string = EnvConfig.production ? "red" : "green";
|
||||||
});
|
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
if (this.translateSubscription) {
|
|
||||||
this.translateSubscription.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
|
19
src/app/home/home-news/home-news.component.html
Normal file
19
src/app/home/home-news/home-news.component.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!--.row to offset the app component's .container-fluid padding-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="jumbotron jumbotron-fluid">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<h1 class="display-3">Welcome to DSpace</h1>
|
||||||
|
<p class="lead">DSpace is an open source software platform that enables organisations to:</p>
|
||||||
|
<ul>
|
||||||
|
<li>capture and describe digital material using a submission workflow module, or a variety
|
||||||
|
of
|
||||||
|
programmatic ingest options
|
||||||
|
</li>
|
||||||
|
<li>distribute an organisation's digital assets over the web through a search and retrieval
|
||||||
|
system
|
||||||
|
</li>
|
||||||
|
<li>preserve digital assets over the long term</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
0
src/app/home/home-news/home-news.component.scss
Normal file
0
src/app/home/home-news/home-news.component.scss
Normal file
19
src/app/home/home-news/home-news.component.ts
Normal file
19
src/app/home/home-news/home-news.component.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-home-news',
|
||||||
|
styleUrls: ['./home-news.component.css'],
|
||||||
|
templateUrl: './home-news.component.html'
|
||||||
|
})
|
||||||
|
export class HomeNewsComponent implements OnInit {
|
||||||
|
constructor() {
|
||||||
|
this.universalInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
universalInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,2 @@
|
|||||||
<div class="home">
|
<ds-home-news></ds-home-news>
|
||||||
Home component
|
<ds-top-level-community-list></ds-top-level-community-list>
|
||||||
</div>
|
|
||||||
|
@@ -1,16 +1,11 @@
|
|||||||
import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
|
||||||
encapsulation: ViewEncapsulation.Emulated,
|
|
||||||
selector: 'ds-home',
|
selector: 'ds-home',
|
||||||
styleUrls: ['./home.component.css'],
|
styleUrls: ['./home.component.css'],
|
||||||
templateUrl: './home.component.html'
|
templateUrl: './home.component.html'
|
||||||
})
|
})
|
||||||
export class HomeComponent {
|
export class HomeComponent implements OnInit {
|
||||||
|
|
||||||
data: any = {};
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.universalInit();
|
this.universalInit();
|
||||||
}
|
}
|
||||||
@@ -19,4 +14,6 @@ export class HomeComponent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,14 +3,22 @@ import { NgModule } from '@angular/core';
|
|||||||
import { HomeComponent } from './home.component';
|
import { HomeComponent } from './home.component';
|
||||||
import { HomeRoutingModule } from './home-routing.module';
|
import { HomeRoutingModule } from './home-routing.module';
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { TopLevelCommunityListComponent } from "./top-level-community-list/top-level-community-list.component";
|
||||||
|
import { HomeNewsComponent } from "./home-news/home-news.component";
|
||||||
|
import { RouterModule } from "@angular/router";
|
||||||
|
import { TranslateModule } from "ng2-translate";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
HomeRoutingModule
|
HomeRoutingModule,
|
||||||
|
RouterModule,
|
||||||
|
TranslateModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
HomeComponent
|
HomeComponent,
|
||||||
|
TopLevelCommunityListComponent,
|
||||||
|
HomeNewsComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class HomeModule { }
|
export class HomeModule { }
|
||||||
|
@@ -0,0 +1,12 @@
|
|||||||
|
<div *ngIf="topLevelCommunities.hasSucceeded | async">
|
||||||
|
<h2>{{'home.top-level-communities.head' | translate}}</h2>
|
||||||
|
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
|
||||||
|
<ul>
|
||||||
|
<li *ngFor="let community of (topLevelCommunities.payload | async)">
|
||||||
|
<p>
|
||||||
|
<span class="lead"><a [routerLink]="['/communities', community.id]">{{community.name}}</a></span><br>
|
||||||
|
<span class="text-muted">{{community.shortDescription}}</span>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
@@ -0,0 +1,27 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { CommunityDataService } from "../../core/data/community-data.service";
|
||||||
|
import { RemoteData } from "../../core/data/remote-data";
|
||||||
|
import { Community } from "../../core/shared/community.model";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-top-level-community-list',
|
||||||
|
styleUrls: ['./top-level-community-list.component.css'],
|
||||||
|
templateUrl: './top-level-community-list.component.html'
|
||||||
|
})
|
||||||
|
export class TopLevelCommunityListComponent implements OnInit {
|
||||||
|
topLevelCommunities: RemoteData<Community[]>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private cds: CommunityDataService
|
||||||
|
) {
|
||||||
|
this.universalInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
universalInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.topLevelCommunities = this.cds.findAll();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user