mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
4345- Text File Viewer withCredentials (#4349)
* 4345-Text File Viewer not passing withCredentials * added new line
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Component, Input, OnChanges, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnChanges, ViewEncapsulation } from '@angular/core';
|
||||||
import { SimpleChanges } from '@angular/core';
|
import { SimpleChanges } from '@angular/core';
|
||||||
|
import { AppConfigService } from './../../app-config/app-config.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-txt-viewer',
|
selector: 'adf-txt-viewer',
|
||||||
@@ -36,7 +37,7 @@ export class TxtViewerComponent implements OnChanges {
|
|||||||
|
|
||||||
content: string | ArrayBuffer;
|
content: string | ArrayBuffer;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private appConfigService: AppConfigService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): Promise<any> {
|
ngOnChanges(changes: SimpleChanges): Promise<any> {
|
||||||
@@ -57,8 +58,10 @@ export class TxtViewerComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getUrlContent(url: string): Promise<any> {
|
private getUrlContent(url: string): Promise<any> {
|
||||||
|
let withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.http.get(url, { responseType: 'text' }).subscribe((res) => {
|
this.http.get(url, { responseType: 'text', withCredentials: withCredentialsMode }).subscribe((res) => {
|
||||||
this.content = res;
|
this.content = res;
|
||||||
resolve();
|
resolve();
|
||||||
}, (event) => {
|
}, (event) => {
|
||||||
|
Reference in New Issue
Block a user