#89 added community home page

This commit is contained in:
Christian Scheible
2017-06-09 15:04:48 +02:00
parent d4b7f5f9ce
commit 48c3cb4e46
29 changed files with 250 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommunityPageComponent } from './community-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'communities/:id', component: CommunityPageComponent }
])
]
})
export class CommunityPageRoutingModule { }

View File

@@ -0,0 +1,17 @@
<div class="community-page" *ngIf="communityData.hasSucceeded | async">
<ds-community-page-name [name]="(communityData.payload | async)?.name"></ds-community-page-name>
<ds-community-page-logo *ngIf="logoData" [logo]="logoData.payload | async"></ds-community-page-logo>
<ds-community-page-introductory-text
[introductoryText]="(communityData.payload | async)?.introductoryText">
</ds-community-page-introductory-text>
<ds-community-page-news
[sidebarText]="(communityData.payload | async)?.sidebarText">
</ds-community-page-news>
<ds-community-page-copyright
[copyrightText]="(communityData.payload | async)?.copyrightText">
</ds-community-page-copyright>
<ds-community-page-license
[license]="(communityData.payload | async)?.license">
</ds-community-page-license>
<ds-community-page-sub-collection-list></ds-community-page-sub-collection-list>
</div>

View File

@@ -0,0 +1 @@
@import '../../styles/variables.scss';

View File

@@ -0,0 +1,35 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Community } from "../core/shared/community.model";
import { Bitstream } from "../core/shared/bitstream.model";
import { RemoteData } from "../core/data/remote-data";
import { CommunityDataService } from "../core/data/community-data.service";
@Component({
selector: 'ds-community-page',
styleUrls: ['./community-page.component.css'],
templateUrl: './community-page.component.html',
})
export class CommunityPageComponent implements OnInit {
communityData: RemoteData<Community>;
logoData: RemoteData<Bitstream>;
constructor(
private communityDataService: CommunityDataService,
private route: ActivatedRoute
) {
this.universalInit();
}
ngOnInit(): void {
this.route.params.subscribe((params: Params) => {
this.communityData = this.communityDataService.findById(params['id'])
this.communityData.payload
.subscribe(community => this.logoData = community.logo);
});
}
universalInit() {
}
}

View File

@@ -0,0 +1,37 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from "@angular/router";
import { TranslateModule } from "@ngx-translate/core";
import { CommunityPageComponent } from './community-page.component';
import { FieldWrapperComponent } from './field-wrapper/field-wrapper.component';
import { CommunityPageNameComponent } from './name/community-page-name.component';
import { CommunityPageLogoComponent } from './logo/community-page-logo.component';
import { CommunityPageIntroductoryTextComponent } from './introductory-text/community-page-introductory-text.component';
import { CommunityPageNewsComponent } from './news/community-page-news.component';
import { CommunityPageCopyrightComponent } from './copyright/community-page-copyright.component';
import { CommunityPageLicenseComponent } from './license/community-page-license.component';
import { CommunityPageSubCollectionListComponent } from './sub-collection-list/community-page-sub-collection-list.component';
import { CommunityPageRoutingModule } from './community-page-routing.module';
@NgModule({
imports: [
CommunityPageRoutingModule,
CommonModule,
TranslateModule,
RouterModule,
],
declarations: [
CommunityPageComponent,
FieldWrapperComponent,
CommunityPageNameComponent,
CommunityPageLogoComponent,
CommunityPageIntroductoryTextComponent,
CommunityPageNewsComponent,
CommunityPageCopyrightComponent,
CommunityPageLicenseComponent,
CommunityPageSubCollectionListComponent,
]
})
export class CommunityPageModule { }

View File

@@ -0,0 +1,3 @@
<ds-field-wrapper *ngIf="copyrightText" class="community-page-copyright">
<p [innerHtml]="copyrightText"></p>
</ds-field-wrapper>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-community-page-copyright',
styleUrls: ['./community-page-copyright.component.css'],
templateUrl: './community-page-copyright.component.html',
})
export class CommunityPageCopyrightComponent {
@Input() copyrightText: String;
}

View File

@@ -0,0 +1,3 @@
<div class="community-page-field-wrapper">
<ng-content></ng-content>
</div>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-field-wrapper',
styleUrls: ['./field-wrapper.component.css'],
templateUrl: './field-wrapper.component.html',
})
export class FieldWrapperComponent {
@Input() name: String;
}

View File

@@ -0,0 +1,3 @@
<ds-field-wrapper *ngIf="introductoryText" class="community-page-introductory-text">
<p [innerHtml]="introductoryText"></p>
</ds-field-wrapper>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-community-page-introductory-text',
styleUrls: ['./community-page-introductory-text.component.css'],
templateUrl: './community-page-introductory-text.component.html',
})
export class CommunityPageIntroductoryTextComponent {
@Input() introductoryText: String;
}

View File

@@ -0,0 +1,4 @@
<ds-field-wrapper *ngIf="license" class="community-page-license">
<h2>{{ 'community.page.license' | translate }}</h2>
<p>{{ license }}</p>
</ds-field-wrapper>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-community-page-license',
styleUrls: ['./community-page-license.component.css'],
templateUrl: './community-page-license.component.html',
})
export class CommunityPageLicenseComponent {
@Input() license: String;
}

View File

@@ -0,0 +1,3 @@
<ds-field-wrapper *ngIf="logo" class="community-page-logo">
<img [src]="logo.url" class="img-responsive" alt="Community logo" />
</ds-field-wrapper>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,13 @@
import { Component, Input } from '@angular/core';
import { Bitstream } from "../../core/shared/bitstream.model";
@Component({
selector: 'ds-community-page-logo',
styleUrls: ['./community-page-logo.component.css'],
templateUrl: './community-page-logo.component.html',
})
export class CommunityPageLogoComponent {
@Input() logo: Bitstream;
}

View File

@@ -0,0 +1 @@
<h1 *ngIf="name">{{ name }}</h1>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-community-page-name',
styleUrls: ['./community-page-name.component.css'],
templateUrl: './community-page-name.component.html',
})
export class CommunityPageNameComponent {
@Input() name: String;
}

View File

@@ -0,0 +1,4 @@
<ds-field-wrapper *ngIf="sidebarText" class="community-page-news">
<h2>{{ 'community.page.news' | translate }}</h2>
<p [innerHtml]="sidebarText"></p>
</ds-field-wrapper>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-community-page-news',
styleUrls: ['./community-page-news.component.css'],
templateUrl: './community-page-news.component.html',
})
export class CommunityPageNewsComponent {
@Input() sidebarText: String;
}

View File

@@ -0,0 +1,11 @@
<div *ngIf="subCollections.hasSucceeded | async">
<h2>{{'community.sub-collection-list.head' | translate}}</h2>
<ul>
<li *ngFor="let collection of (subCollections.payload | async)">
<p>
<span class="lead"><a [routerLink]="['/collections', collection.id]">{{collection.name}}</a></span><br>
<span class="text-muted">{{collection.shortDescription}}</span>
</p>
</li>
</ul>
</div>

View File

@@ -0,0 +1 @@
@import '../../../styles/variables.scss';

View File

@@ -0,0 +1,28 @@
import { Component, OnInit } from '@angular/core';
import { CollectionDataService } from "../../core/data/collection-data.service";
import { RemoteData } from "../../core/data/remote-data";
import { Collection } from "../../core/shared/collection.model";
@Component({
selector: 'ds-community-page-sub-collection-list',
styleUrls: ['./community-page-sub-collection-list.component.css'],
templateUrl: './community-page-sub-collection-list.component.html',
})
export class CommunityPageSubCollectionListComponent implements OnInit {
subCollections: RemoteData<Collection[]>;
constructor(
private cds: CollectionDataService
) {
this.universalInit();
}
universalInit() {
}
ngOnInit(): void {
this.subCollections = this.cds.findAll();
}
}