mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-14 17:58:44 +00:00
Source Mapping is not working on test debugging (#1931)
* coverage single components run fix * remove spec.ts from coverage * make the coverage and the istanbul-instrumenter-loader works only over the console test because a problem on the remapping for the browser test * move tslint on the main folder of any component * remove build:w from readme * stop build tslint error also in spec files * clear karma file from unnecessary files * add set -f for build all script in order to accept * * fix lint problem and failing tests * fix failing test search component * add loader test for viewer * fix tslint error userinfo * --max_old_space_size=2048 remove * fix tslint error uploader unused EventEmitter * remove spec|index|.*mock|.*model|.*event from coverage
This commit is contained in:
committed by
Eugenio Romano
parent
ed30b74ce6
commit
282e64f93d
@@ -16,7 +16,10 @@
|
||||
*/
|
||||
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ContentService } from 'ng2-alfresco-core';
|
||||
import { Http, Response, RequestOptions, ResponseContentType } from '@angular/http';
|
||||
import 'rxjs/add/operator/toPromise';
|
||||
|
||||
@Component({
|
||||
selector: 'txt-viewer',
|
||||
@@ -26,21 +29,39 @@ import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
export class TxtViewerComponent {
|
||||
|
||||
@Input()
|
||||
nodeId: string;
|
||||
urlFile: any;
|
||||
|
||||
@Input()
|
||||
blobFile: any;
|
||||
|
||||
content: string;
|
||||
|
||||
constructor(private alfrescoContentService: AlfrescoContentService) {
|
||||
constructor(private http: Http, private contentService: ContentService) {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.getNodeContent(this.nodeId);
|
||||
}
|
||||
ngOnChanges(changes: SimpleChange) {
|
||||
let blobFile = changes['blobFile'];
|
||||
if (blobFile && blobFile.currentValue) {
|
||||
this.urlFile = this.contentService.createTrustedUrl(this.blobFile);
|
||||
}
|
||||
if (!this.urlFile && !this.blobFile) {
|
||||
throw new Error('Attribute urlFile or blobFile is required');
|
||||
}
|
||||
|
||||
private getNodeContent(nodeId) {
|
||||
this.alfrescoContentService.getNodeContent(nodeId).subscribe((nodeContent) => {
|
||||
this.content = nodeContent;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getUrlContent(resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
private getUrlContent(resolve, reject): void {
|
||||
this.http.get(this.urlFile, new RequestOptions({
|
||||
responseType: ResponseContentType.Text
|
||||
})).toPromise().then(
|
||||
(res: Response) => {
|
||||
this.content = res.text();
|
||||
resolve();
|
||||
}, (event) => {
|
||||
reject(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user