Added unsubscribe to community logo subscription.

This commit is contained in:
Christian Scheible
2017-06-16 12:34:17 +02:00
parent f4dba7879b
commit 8c16918728
4 changed files with 100 additions and 92 deletions

View File

@@ -22,11 +22,11 @@
<!-- Copyright --> <!-- Copyright -->
<ds-comcol-page-content <ds-comcol-page-content
[content]="(collectionData.payload | async)?.copyrightText" [content]="(collectionData.payload | async)?.copyrightText"
[hasInnerHtml]="true">> [hasInnerHtml]="true">
</ds-comcol-page-content> </ds-comcol-page-content>
<!-- Licence --> <!-- Licence -->
<ds-comcol-page-content <ds-comcol-page-content
[content]="(collectionData.payload | async)?.license" [content]="(collectionData.payload | async)?.license"
[title]="'collection.page.license'">> [title]="'collection.page.license'">
</ds-comcol-page-content> </ds-comcol-page-content>
</div> </div>

View File

@@ -16,7 +16,7 @@
[content]="(communityData.payload | async)?.sidebarText" [content]="(communityData.payload | async)?.sidebarText"
[hasInnerHtml]="true" [hasInnerHtml]="true"
[title]="'community.page.news'"> [title]="'community.page.news'">
</ds-comcol-page-content > </ds-comcol-page-content>
<!-- Copyright --> <!-- Copyright -->
<ds-comcol-page-content <ds-comcol-page-content
[content]="(communityData.payload | async)?.copyrightText" [content]="(communityData.payload | async)?.copyrightText"

View File

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

View File

@@ -1,87 +1,89 @@
export const COMMUNITIES = [ export const COMMUNITIES = {
{ "communities": [
"name": "Community 1", {
"handle": "10673/1", "name": "Community 1",
"id": "6631", "handle": "10673/1",
"uuid": "83cd3281-f241-48be-9234-d876f8010d14", "id": "6631",
"type": "community", "uuid": "83cd3281-f241-48be-9234-d876f8010d14",
"metadata": [ "type": "community",
{ "metadata": [
"key": "dc.description", {
"value": "<p>This is the introductory text for the <em>Sample Community</em> on the DSpace Demonstration Site. It is editable by System or Community Administrators (of this Community).</p>\r\n<p><strong>DSpace Communities may contain one or more Sub-Communities or Collections (of Items).</strong></p>\r\n<p>This particular Community has its own logo (the <a href=\"http://www.duraspace.org/\">DuraSpace</a> logo).</p>", "key": "dc.description",
"language": null "value": "<p>This is the introductory text for the <em>Sample Community</em> on the DSpace Demonstration Site. It is editable by System or Community Administrators (of this Community).</p>\r\n<p><strong>DSpace Communities may contain one or more Sub-Communities or Collections (of Items).</strong></p>\r\n<p>This particular Community has its own logo (the <a href=\"http://www.duraspace.org/\">DuraSpace</a> logo).</p>",
}, "language": null
{ },
"key": "dc.description.abstract", {
"value": "This is a sample top-level community", "key": "dc.description.abstract",
"language": null "value": "This is a sample top-level community",
}, "language": null
{ },
"key": "dc.description.tableofcontents", {
"value": "<p>This is the <em>news section</em> for this <em>Sample Community</em>. System or Community Administrators (of this Community) can edit this News field.</p>", "key": "dc.description.tableofcontents",
"language": null "value": "<p>This is the <em>news section</em> for this <em>Sample Community</em>. System or Community Administrators (of this Community) can edit this News field.</p>",
}, "language": null
{ },
"key": "dc.rights", {
"value": "<p><em>If this Community had special copyright text to display, it would be displayed here.</em></p>", "key": "dc.rights",
"language": null "value": "<p><em>If this Community had special copyright text to display, it would be displayed here.</em></p>",
}, "language": null
{ },
"key": "dc.title", {
"value": "Sample Community", "key": "dc.title",
"language": null "value": "Sample Community",
} "language": null
], }
"_links": {
"self": {
"href": "http://dspace7.4science.it/dspace-spring-rest/api/core/community/9076bd16-e69a-48d6-9e41-0238cb40d863"
},
"collections": [
{ "href": "/collections/5179" }
], ],
"_links": {
"self": {
"href": "http://dspace7.4science.it/dspace-spring-rest/api/core/community/9076bd16-e69a-48d6-9e41-0238cb40d863"
},
"collections": [
{ "href": "/collections/5179" }
],
"logo": { "href": "/bitstreams/4688" } "logo": { "href": "/bitstreams/4688" }
}
},
{
"name": "Community 2",
"handle": "10673/2",
"id": "2365",
"uuid": "80eec4c6-70bd-4beb-b3d4-5d46c6343157",
"type": "community",
"metadata": [
{
"key": "dc.description",
"value": "<p>This is the introductory text for the <em>Sample Community</em> on the DSpace Demonstration Site. It is editable by System or Community Administrators (of this Community).</p>\r\n<p><strong>DSpace Communities may contain one or more Sub-Communities or Collections (of Items).</strong></p>\r\n<p>This particular Community has its own logo (the <a href=\"http://www.duraspace.org/\">DuraSpace</a> logo).</p>",
"language": null
},
{
"key": "dc.description.abstract",
"value": "This is a sample top-level community",
"language": null
},
{
"key": "dc.description.tableofcontents",
"value": "<p>This is the <em>news section</em> for this <em>Sample Community</em>. System or Community Administrators (of this Community) can edit this News field.</p>",
"language": null
},
{
"key": "dc.rights",
"value": "<p><em>If this Community had special copyright text to display, it would be displayed here.</em></p>",
"language": null
},
{
"key": "dc.title",
"value": "Sample Community",
"language": null
} }
], },
"_links": { {
"self": { "name": "Community 2",
"href": "http://dspace7.4science.it/dspace-spring-rest/api/core/community/9076bd16-e69a-48d6-9e41-0238cb40d863" "handle": "10673/2",
}, "id": "2365",
"collections": [ "uuid": "80eec4c6-70bd-4beb-b3d4-5d46c6343157",
{ "href": "/collections/6547" } "type": "community",
] "metadata": [
{
"key": "dc.description",
"value": "<p>This is the introductory text for the <em>Sample Community</em> on the DSpace Demonstration Site. It is editable by System or Community Administrators (of this Community).</p>\r\n<p><strong>DSpace Communities may contain one or more Sub-Communities or Collections (of Items).</strong></p>\r\n<p>This particular Community has its own logo (the <a href=\"http://www.duraspace.org/\">DuraSpace</a> logo).</p>",
"language": null
},
{
"key": "dc.description.abstract",
"value": "This is a sample top-level community",
"language": null
},
{
"key": "dc.description.tableofcontents",
"value": "<p>This is the <em>news section</em> for this <em>Sample Community</em>. System or Community Administrators (of this Community) can edit this News field.</p>",
"language": null
},
{
"key": "dc.rights",
"value": "<p><em>If this Community had special copyright text to display, it would be displayed here.</em></p>",
"language": null
},
{
"key": "dc.title",
"value": "Sample Community",
"language": null
}
],
"_links": {
"self": {
"href": "http://dspace7.4science.it/dspace-spring-rest/api/core/community/9076bd16-e69a-48d6-9e41-0238cb40d863"
},
"collections": [
{ "href": "/collections/6547" }
]
}
} }
} ]
]; };