mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2159] Update angular-cli to latest version (#2874)
* Update angular cli version 1.6.5 * fix tslint problems and update devdependencies using the angularcli 1.6.4 * test fixing * [ADF-2159] start fixing userinfo test * [ADF-2159] fixed userinfo tests * [ADF-2159] added async to accordion component test * [ADF-2159] testing probable failed test on CI * [ADF-2159] check removing fake destroyed view test * [ADF-2159] check viewer tests * [ADF-2159] attempt on test fix * [ADF-2159] test fix * [ADF-2159] fix test * [ADF-2159] fix test * [ADF-2159] rebased * [ADF-2159] check test * [ADF-2159] fixing test * [ADF-2159] Fix#1 * [ADF-2159] Fix#2 * [ADF-2159] Fix#3 * [ADF-2159] Fix #4 * [ADF-2159] Fix #5 * [ADF-2159] Fix #6 * [ADF-2159] fixed viewer test * [ADF-2159] fixed cast element
This commit is contained in:
@@ -46,7 +46,7 @@ describe('AccordionGroupComponent', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should be closed by default', () => {
|
||||
it('should be closed by default', async(() => {
|
||||
component.heading = 'Fake Header';
|
||||
component.headingIcon = 'fake-icon';
|
||||
component.contentWrapper.nativeElement.innerHTML = '<a>Test</a>';
|
||||
@@ -59,9 +59,9 @@ describe('AccordionGroupComponent', () => {
|
||||
let headerToggle = element.querySelector('#accordion-button .material-icons');
|
||||
expect(headerToggle.innerText).toEqual('expand_more');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be open when click', () => {
|
||||
it('should be open when click', async(() => {
|
||||
component.isSelected = true;
|
||||
component.heading = 'Fake Header';
|
||||
component.headingIcon = 'fake-icon';
|
||||
@@ -77,9 +77,9 @@ describe('AccordionGroupComponent', () => {
|
||||
let headerToggle = element.querySelector('#accordion-button .material-icons');
|
||||
expect(headerToggle.innerText).toEqual('expand_less');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show expand icon by default', () => {
|
||||
it('should show expand icon by default', async(() => {
|
||||
component.heading = 'Fake Header';
|
||||
component.headingIcon = 'fake-icon';
|
||||
component.contentWrapper.nativeElement.innerHTML = '<a>Test</a>';
|
||||
@@ -88,9 +88,9 @@ describe('AccordionGroupComponent', () => {
|
||||
let headerIcon = element.querySelector('#accordion-button');
|
||||
expect(headerIcon).toBeDefined();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide expand icon', () => {
|
||||
it('should hide expand icon', async(() => {
|
||||
component.heading = 'Fake Header';
|
||||
component.headingIcon = 'fake-icon';
|
||||
component.hasAccordionIcon = false;
|
||||
@@ -100,19 +100,18 @@ describe('AccordionGroupComponent', () => {
|
||||
let headerIcon = element.querySelector('#accordion-button');
|
||||
expect(headerIcon).toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit an event when a heading clicked', (done) => {
|
||||
it('should emit an event when a heading clicked', async(() => {
|
||||
component.heading = 'Fake Header';
|
||||
fixture.detectChanges();
|
||||
let heading: string = component.heading;
|
||||
component.headingClick.subscribe((headName: string) => {
|
||||
expect(headName).toBeDefined();
|
||||
expect(headName).toEqual(heading);
|
||||
done();
|
||||
});
|
||||
let header = element.querySelector('.adf-panel-heading');
|
||||
header.click();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
|
@@ -339,8 +339,8 @@ describe('ActivitiStartForm', () => {
|
||||
component.showOutcomeButtons = true;
|
||||
component.showRefreshButton = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const formTabs = component.form.tabs;
|
||||
const tabField1 = formTabs.find(tab => tab.id === 'form1');
|
||||
const tabField2 = formTabs.find(tab => tab.id === 'form2');
|
||||
@@ -357,8 +357,8 @@ describe('ActivitiStartForm', () => {
|
||||
component.showOutcomeButtons = true;
|
||||
component.showRefreshButton = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const titleIcon = fixture.debugElement.nativeElement.querySelector('mat-card-title>mat-icon');
|
||||
const titleElement = fixture.debugElement.nativeElement.querySelector('mat-card-title>h2');
|
||||
const actionButtons = fixture.debugElement.nativeElement.querySelectorAll('.mat-button');
|
||||
|
@@ -43,9 +43,9 @@ describe('DropdownWidgetComponent', () => {
|
||||
let element: HTMLElement;
|
||||
|
||||
let fakeOptionList: FormFieldOption[] = [
|
||||
{id: 'opt_1', name: 'option_1'},
|
||||
{id: 'opt_2', name: 'option_2'},
|
||||
{id: 'opt_3', name: 'option_3'}];
|
||||
{ id: 'opt_1', name: 'option_1' },
|
||||
{ id: 'opt_2', name: 'option_2' },
|
||||
{ id: 'opt_3', name: 'option_3' }];
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -71,7 +71,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
widget.ngOnInit();
|
||||
expect(formService.getRestFieldValues).not.toHaveBeenCalled();
|
||||
|
||||
widget.field = new FormFieldModel(null, {restUrl: null});
|
||||
widget.field = new FormFieldModel(null, { restUrl: null });
|
||||
widget.ngOnInit();
|
||||
expect(formService.getRestFieldValues).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -100,7 +100,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should preserve empty option when loading fields', () => {
|
||||
let restFieldValue: FormFieldOption = <FormFieldOption> {id: '1', name: 'Option1'};
|
||||
let restFieldValue: FormFieldOption = <FormFieldOption> { id: '1', name: 'Option1' };
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return Observable.create(observer => {
|
||||
observer.next([restFieldValue]);
|
||||
@@ -108,8 +108,8 @@ describe('DropdownWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
let form = new FormModel({taskId: '<id>'});
|
||||
let emptyOption: FormFieldOption = <FormFieldOption> {id: 'empty', name: 'Empty'};
|
||||
let form = new FormModel({ taskId: '<id>' });
|
||||
let emptyOption: FormFieldOption = <FormFieldOption> { id: 'empty', name: 'Empty' };
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: '<id>',
|
||||
restUrl: '/some/url/address',
|
||||
@@ -133,14 +133,14 @@ describe('DropdownWidgetComponent', () => {
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return Observable.of(fakeOptionList);
|
||||
});
|
||||
widget.field = new FormFieldModel(new FormModel({taskId: 'fake-task-id'}), {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
||||
id: 'dropdown-id',
|
||||
name: 'date-name',
|
||||
type: 'dropdown',
|
||||
readOnly: 'false',
|
||||
restUrl: 'fake-rest-url'
|
||||
});
|
||||
widget.field.emptyOption = {id: 'empty', name: 'Choose one...'};
|
||||
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
|
||||
widget.field.isVisible = true;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
@@ -179,6 +179,8 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
openSelect();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
let dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
@@ -216,14 +218,14 @@ describe('DropdownWidgetComponent', () => {
|
||||
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
|
||||
return Observable.of(fakeOptionList);
|
||||
});
|
||||
widget.field = new FormFieldModel(new FormModel({processDefinitionId: 'fake-process-id'}), {
|
||||
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
|
||||
id: 'dropdown-id',
|
||||
name: 'date-name',
|
||||
type: 'dropdown',
|
||||
readOnly: 'false',
|
||||
restUrl: 'fake-rest-url'
|
||||
});
|
||||
widget.field.emptyOption = {id: 'empty', name: 'Choose one...'};
|
||||
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
|
||||
widget.field.isVisible = true;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
@@ -262,6 +264,8 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
openSelect();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
let dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
@@ -270,7 +274,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should be disabled when the field is readonly', async(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({processDefinitionId: 'fake-process-id'}), {
|
||||
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
|
||||
id: 'dropdown-id',
|
||||
name: 'date-name',
|
||||
type: 'dropdown',
|
||||
|
@@ -91,29 +91,22 @@ describe('TabsWidgetComponent', () => {
|
||||
fixture = TestBed.createComponent(TabsWidgetComponent);
|
||||
tabWidgetComponent = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
|
||||
fakeTabVisible = new TabModel(new FormModel(fakeFormJson), {
|
||||
id: 'tab-id-visible',
|
||||
title: 'tab-title-visible'
|
||||
});
|
||||
fakeTabVisible.isVisible = true;
|
||||
fakeTabInvisible = new TabModel(new FormModel(fakeFormJson), {
|
||||
id: 'tab-id-invisible',
|
||||
title: 'tab-title-invisible'
|
||||
});
|
||||
fakeTabInvisible.isVisible = false;
|
||||
tabWidgetComponent.tabs.push(fakeTabVisible);
|
||||
tabWidgetComponent.tabs.push(fakeTabInvisible);
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fakeTabVisible = new TabModel(new FormModel(fakeFormJson), {
|
||||
id: 'tab-id-visible',
|
||||
title: 'tab-title-visible'
|
||||
});
|
||||
fakeTabVisible.isVisible = true;
|
||||
fakeTabInvisible = new TabModel(new FormModel(fakeFormJson), {
|
||||
id: 'tab-id-invisible',
|
||||
title: 'tab-title-invisible'
|
||||
});
|
||||
fakeTabInvisible.isVisible = false;
|
||||
tabWidgetComponent.tabs.push(fakeTabVisible);
|
||||
tabWidgetComponent.tabs.push(fakeTabInvisible);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('should show only visible tabs', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
|
@@ -43,7 +43,7 @@
|
||||
<span class="adf-userinfo__detail-profile" id="ecm-email"> {{ecmUser.email}} </span>
|
||||
</div>
|
||||
<div class="adf-userinfo-detail">
|
||||
<span class="adf-userinfo__secondary-info">
|
||||
<span class="adf-userinfo__secondary-info" id="ecm-job-title-label">
|
||||
{{ 'USER_PROFILE.LABELS.ECM.JOB_TITLE' | translate }}
|
||||
<span id="ecm-job-title" class="adf-userinfo__detail-profile"> {{ ecmUser.jobTitle ? ecmUser.jobTitle : 'N/A' }} </span>
|
||||
</span>
|
||||
|
@@ -26,6 +26,7 @@ import { BpmUserService } from '../services/bpm-user.service';
|
||||
import { EcmUserService } from '../services/ecm-user.service';
|
||||
import { BpmUserModel } from './../models/bpm-user.model';
|
||||
import { UserInfoComponent } from './user-info.component';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
class FakeSanitazer extends DomSanitizer {
|
||||
|
||||
@@ -58,15 +59,22 @@ class FakeSanitazer extends DomSanitizer {
|
||||
}
|
||||
}
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('User info component', () => {
|
||||
|
||||
let userInfoComp: UserInfoComponent;
|
||||
let component: UserInfoComponent;
|
||||
let fixture: ComponentFixture<UserInfoComponent>;
|
||||
let element: HTMLElement;
|
||||
let stubAuthService: AuthenticationService;
|
||||
let stubContent: ContentService;
|
||||
let authService: AuthenticationService;
|
||||
let contentService: ContentService;
|
||||
let ecmUserService: EcmUserService;
|
||||
let bpmUserService: BpmUserService;
|
||||
|
||||
function openUserInfo() {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -78,18 +86,25 @@ describe('User info component', () => {
|
||||
],
|
||||
providers: [
|
||||
EcmUserService,
|
||||
BpmUserService
|
||||
BpmUserService,
|
||||
ContentService
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(UserInfoComponent);
|
||||
userInfoComp = fixture.componentInstance;
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
|
||||
stubAuthService = TestBed.get(AuthenticationService);
|
||||
stubContent = TestBed.get(ContentService);
|
||||
authService = TestBed.get(AuthenticationService);
|
||||
ecmUserService = TestBed.get(EcmUserService);
|
||||
bpmUserService = TestBed.get(BpmUserService);
|
||||
contentService = TestBed.get(ContentService);
|
||||
});
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should not show any image if the user is not logged in', () => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeNull();
|
||||
@@ -104,107 +119,77 @@ describe('User info component', () => {
|
||||
|
||||
describe('when user is logged on ecm', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
||||
jasmine.Ajax.install();
|
||||
describe('ui ', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(ecmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeEcmEditedUser));
|
||||
});
|
||||
|
||||
it('should show ecm only last name when user first name is null ', async(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
let ecmUsername = fixture.debugElement.query(By.css('#ecm-username'));
|
||||
expect(ecmUsername).toBeDefined();
|
||||
expect(ecmUsername).not.toBeNull();
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('fake-ecm-first-name');
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('null');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the username when showName attribute is true', async(() => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.showName).toBeTruthy();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide the username when showName attribute is false', async(() => {
|
||||
component.showName = false;
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have the defined class to show the name on the right side', async(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container').classList).toContain('adf-userinfo-name-right');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not have the defined class to show the name on the left side', async(() => {
|
||||
component.namePosition = 'left';
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container').classList).not.toContain('adf-userinfo-name-right');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should show ecm only last name when user first name is null ', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
let ecmUsername = fixture.debugElement.query(By.css('#ecm-username'));
|
||||
expect(ecmUsername).toBeDefined();
|
||||
expect(ecmUsername).not.toBeNull();
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('fake-ecm-first-name');
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('null');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the username when showName attribute is true', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(userInfoComp.showName).toBeTruthy();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should hide the username when showName attribute is false', async(() => {
|
||||
userInfoComp.showName = false;
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have the defined class to show the name on the right side', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container').classList).toContain('adf-userinfo-name-right');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not have the defined class to show the name on the left side', async(() => {
|
||||
userInfoComp.namePosition = 'left';
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container').classList).not.toContain('adf-userinfo-name-right');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('and has image', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
spyOn(stubContent, 'getContentUrl').and.returnValue('assets/images/ecmImg.gif');
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(ecmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeEcmUser));
|
||||
spyOn(contentService, 'getContentUrl').and.returnValue('assets/images/ecmImg.gif');
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmUser })
|
||||
});
|
||||
}));
|
||||
|
||||
it('should get the ecm current user image from the service', async(() => {
|
||||
@@ -222,20 +207,22 @@ describe('User info component', () => {
|
||||
}));
|
||||
|
||||
it('should display the current user image if user has avatarId', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
let loggedImage = fixture.debugElement.query(By.css('#logged-user-img'));
|
||||
expect(userInfoComp.ecmUser.avatarId).toBe('fake-avatar-id');
|
||||
expect(component.ecmUser.avatarId).toBe('fake-avatar-id');
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(loggedImage).not.toBeNull();
|
||||
expect(loggedImage.properties.src).toContain('assets/images/ecmImg.gif');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should get the ecm user informations from the service', () => {
|
||||
it('should get the ecm user informations from the service', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
@@ -252,18 +239,16 @@ describe('User info component', () => {
|
||||
expect(ecmFullName.nativeElement.textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
|
||||
expect(ecmJobTitle.nativeElement.textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE');
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('and has no image', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(ecmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeEcmUserNoImage));
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmUserNoImage })
|
||||
});
|
||||
fixture.whenStable().then(() => fixture.detectChanges());
|
||||
}));
|
||||
|
||||
@@ -290,7 +275,7 @@ describe('User info component', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let pipe = new InitialUsernamePipe(new FakeSanitazer());
|
||||
expect(userInfoComp.ecmUser.avatarId).toBeNull();
|
||||
expect(component.ecmUser.avatarId).toBeNull();
|
||||
expect(pipe.transform({
|
||||
id: 13,
|
||||
firstName: 'Wilbur',
|
||||
@@ -305,24 +290,16 @@ describe('User info component', () => {
|
||||
|
||||
describe('when user is logged on bpm', () => {
|
||||
|
||||
let getCurrentUserInfoStub;
|
||||
|
||||
beforeEach(async(() => {
|
||||
spyOn(stubAuthService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
||||
jasmine.Ajax.install();
|
||||
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
getCurrentUserInfoStub = spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeBpmUser));
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should show full name next the user image', () => {
|
||||
it('should show full name next the user image', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeBpmUser)
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
@@ -334,16 +311,10 @@ describe('User info component', () => {
|
||||
expect(bpmUserName).not.toBeNull();
|
||||
expect(bpmUserName.nativeElement.innerHTML).toContain('fake-bpm-first-name fake-bpm-last-name');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should get the bpm current user image from the service', () => {
|
||||
it('should get the bpm current user image from the service', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeBpmUser)
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
@@ -351,118 +322,93 @@ describe('User info component', () => {
|
||||
expect(element.querySelector('#logged-user-img').getAttribute('src'))
|
||||
.toContain('activiti-app/app/rest/admin/profile-picture');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show last name if first name is null', () => {
|
||||
fixture.detectChanges();
|
||||
it('should show last name if first name is null', async(() => {
|
||||
let wrongBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: null,
|
||||
lastName: 'fake-last-name'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongBpmUser;
|
||||
getCurrentUserInfoStub.and.returnValue(Observable.of(wrongBpmUser));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username')).not.toBeNull();
|
||||
expect(element.querySelector('#bpm-username').textContent).toContain('fake-last-name');
|
||||
expect(element.querySelector('#bpm-username').textContent).not.toContain('fake-bpm-first-name');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display')).not.toBeNull();
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).toContain('fake-last-name');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).not.toContain('fake-bpm-first-name');
|
||||
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show first name if it is null string', () => {
|
||||
fixture.detectChanges();
|
||||
it('should not show first name if it is null string', async(() => {
|
||||
let wrongFirstNameBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: 'null',
|
||||
lastName: 'fake-last-name'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongFirstNameBpmUser;
|
||||
getCurrentUserInfoStub.and.returnValue(Observable.of(wrongFirstNameBpmUser));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name').textContent).toContain('fake-last-name');
|
||||
expect(element.querySelector('#bpm-full-name').textContent).not.toContain('null');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display')).toBeDefined();
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).toContain('fake-last-name');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).not.toContain('null');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show last name if it is null string', () => {
|
||||
fixture.detectChanges();
|
||||
it('should not show last name if it is null string', async(() => {
|
||||
let wrongLastNameBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'null'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongLastNameBpmUser;
|
||||
getCurrentUserInfoStub.and.returnValue(Observable.of(wrongLastNameBpmUser));
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name').textContent).toContain('fake-first-name');
|
||||
expect(element.querySelector('#bpm-full-name').textContent).not.toContain('null');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display')).toBeDefined();
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).toContain('fake-first-name');
|
||||
expect(element.querySelector('#adf-userinfo-bpm-name-display').textContent).not.toContain('null');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show the tabs', () => {
|
||||
it('should not show the tabs', async(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#tab-bar-env').getAttribute('hidden')).not.toBeNull();
|
||||
expect(fixture.debugElement.query(By.css('#tab-group-env')).classes['adf-hide-tab']).toBeTruthy();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('when user is logged on bpm and ecm', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
||||
}));
|
||||
let ecmUserInfoSpy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(stubAuthService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/images/ecmImg.gif');
|
||||
jasmine.Ajax.install();
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(true);
|
||||
spyOn(contentService, 'getContentUrl').and.returnValue('src/assets/images/ecmImg.gif');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.requests.first().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ entry: fakeEcmUser })
|
||||
});
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: fakeBpmUser
|
||||
});
|
||||
ecmUserInfoSpy = spyOn(ecmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeEcmUser));
|
||||
spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(Observable.of(fakeBpmUser));
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should get the bpm user informations from the service', () => {
|
||||
it('should get the bpm user informations from the service', async(() => {
|
||||
openUserInfo();
|
||||
let bpmTab = fixture.debugElement.queryAll(By.css('#tab-group-env .mat-tab-labels .mat-tab-label'))[1];
|
||||
bpmTab.triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
let bpmUsername = fixture.debugElement.query(By.css('#bpm-username'));
|
||||
let bpmImage = fixture.debugElement.query(By.css('#bpm-user-detail-image'));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
let bpmUsername = fixture.debugElement.query(By.css('#bpm-username'));
|
||||
let bpmImage = fixture.debugElement.query(By.css('#bpm-user-detail-image'));
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(bpmUsername).not.toBeNull();
|
||||
expect(bpmImage).not.toBeNull();
|
||||
@@ -470,12 +416,14 @@ describe('User info component', () => {
|
||||
expect(bpmUsername.nativeElement.textContent).toContain('fake-bpm-first-name fake-bpm-last-name');
|
||||
expect(fixture.debugElement.query(By.css('#bpm-tenant')).nativeElement.textContent).toContain('fake-tenant-name');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should get the ecm user informations from the service', () => {
|
||||
it('should get the ecm user informations from the service', async(() => {
|
||||
openUserInfo();
|
||||
let ecmUsername = fixture.debugElement.query(By.css('#ecm-username'));
|
||||
let ecmImage = fixture.debugElement.query(By.css('#ecm-user-detail-image'));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(ecmUsername).not.toBeNull();
|
||||
@@ -484,26 +432,29 @@ describe('User info component', () => {
|
||||
expect(fixture.debugElement.query(By.css('#ecm-full-name')).nativeElement.textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
|
||||
expect(fixture.debugElement.query(By.css('#ecm-job-title')).nativeElement.textContent).toContain('job-ecm-test');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the ecm image if exists', () => {
|
||||
it('should show the ecm image if exists', async(() => {
|
||||
openUserInfo();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img').getAttribute('src')).toEqual('src/assets/images/ecmImg.gif');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the bpm image if ecm does not have it', () => {
|
||||
userInfoComp.ecmUserImage = null;
|
||||
it('should show the ecm initials if the ecm user has no image', async(() => {
|
||||
ecmUserInfoSpy.and.returnValue(Observable.of(fakeEcmUserNoImage));
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img').getAttribute('src')).toContain('rest/admin/profile-picture');
|
||||
expect(element.querySelector('#logged-user-img')).toBeNull();
|
||||
expect(element.querySelector('#user-initials-image').textContent).toContain('ff');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the tabs for the env', () => {
|
||||
openUserInfo();
|
||||
let tabGroup = fixture.debugElement.query(By.css('#tab-group-env'));
|
||||
let tabs = fixture.debugElement.queryAll(By.css('#tab-group-env .mat-tab-labels .mat-tab-label'));
|
||||
|
||||
@@ -513,6 +464,7 @@ describe('User info component', () => {
|
||||
});
|
||||
|
||||
it('should not close the menu when a tab is clicked', () => {
|
||||
openUserInfo();
|
||||
let tabGroup = fixture.debugElement.query(By.css('#tab-group-env'));
|
||||
let tabs = fixture.debugElement.queryAll(By.css('#tab-group-env .mat-tab-labels .mat-tab-label'));
|
||||
|
||||
|
@@ -77,8 +77,7 @@ export class UserInfoComponent implements OnInit {
|
||||
.subscribe((res) => {
|
||||
this.ecmUser = new EcmUserModel(res);
|
||||
this.getEcmAvatar();
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.ecmUser = null;
|
||||
this.ecmUserImage = null;
|
||||
|
@@ -65,7 +65,7 @@ export class ImgViewerComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.element = (<HTMLElement> this.el.nativeElement).querySelector('#viewer-image');
|
||||
this.element = <HTMLElement> this.el.nativeElement.querySelector('#viewer-image');
|
||||
|
||||
if (this.element) {
|
||||
this.element.addEventListener('mousedown', this.onMouseDown.bind(this));
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -186,106 +186,113 @@ export class ViewerComponent implements OnChanges {
|
||||
if (!this.isSourceDefined()) {
|
||||
throw new Error('A content source attribute value is missing.');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.blobFile) {
|
||||
this.displayName = this.getDisplayName('Unknown');
|
||||
this.isLoading = true;
|
||||
this.mimeType = this.blobFile.type;
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
|
||||
this.allowDownload = false;
|
||||
// TODO: wrap blob into the data url and allow downloading
|
||||
|
||||
this.extensionChange.emit(this.mimeType);
|
||||
this.isLoading = false;
|
||||
this.scrollTop();
|
||||
resolve();
|
||||
} else if (this.urlFile) {
|
||||
this.isLoading = true;
|
||||
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
|
||||
this.displayName = this.getDisplayName(filenameFromUrl);
|
||||
this.extension = this.getFileExtension(filenameFromUrl);
|
||||
this.urlFileContent = this.urlFile;
|
||||
|
||||
this.downloadUrl = this.urlFile;
|
||||
this.fileName = this.displayName;
|
||||
|
||||
this.viewerType = this.urlFileViewer || this.getViewerTypeByExtension(this.extension);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
}
|
||||
|
||||
this.extensionChange.emit(this.extension);
|
||||
this.isLoading = false;
|
||||
this.scrollTop();
|
||||
resolve();
|
||||
} else if (this.fileNodeId) {
|
||||
this.isLoading = true;
|
||||
this.apiService.getInstance().nodes.getNodeInfo(this.fileNodeId).then(
|
||||
(data: MinimalNodeEntryEntity) => {
|
||||
this.mimeType = data.content.mimeType;
|
||||
this.displayName = this.getDisplayName(data.name);
|
||||
this.urlFileContent = this.apiService.getInstance().content.getContentUrl(data.id);
|
||||
this.extension = this.getFileExtension(data.name);
|
||||
|
||||
this.fileName = data.name;
|
||||
this.downloadUrl = this.apiService.getInstance().content.getContentUrl(data.id, true);
|
||||
|
||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
}
|
||||
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.displayNodeRendition(data.id);
|
||||
} else {
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
this.extensionChange.emit(this.extension);
|
||||
this.sidebarTemplateContext.node = data;
|
||||
this.scrollTop();
|
||||
resolve();
|
||||
},
|
||||
(error) => {
|
||||
this.isLoading = false;
|
||||
reject(error);
|
||||
this.logService.error('This node does not exist');
|
||||
}
|
||||
);
|
||||
} else if (this.sharedLinkId) {
|
||||
this.isLoading = true;
|
||||
|
||||
this.apiService.sharedLinksApi.getSharedLink(this.sharedLinkId).then(details => {
|
||||
this.mimeType = details.entry.content.mimeType;
|
||||
this.displayName = this.getDisplayName(details.entry.name);
|
||||
this.extension = this.getFileExtension(details.entry.name);
|
||||
this.fileName = details.entry.name;
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
this.downloadUrl = this.apiService.contentApi.getSharedLinkContentUrl(this.sharedLinkId, true);
|
||||
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
||||
}
|
||||
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.displaySharedLinkRendition(this.sharedLinkId);
|
||||
} else {
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
this.extensionChange.emit(this.extension);
|
||||
if (this.blobFile) {
|
||||
this.setUpBlobData();
|
||||
} else if (this.urlFile) {
|
||||
this.setUpUrlFile();
|
||||
} else if (this.fileNodeId) {
|
||||
this.isLoading = true;
|
||||
this.apiService.getInstance().nodes.getNodeInfo(this.fileNodeId).then(
|
||||
(data: MinimalNodeEntryEntity) => {
|
||||
this.setUpNodeFile(data);
|
||||
},
|
||||
(error) => {
|
||||
this.isLoading = false;
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
this.logService.error('This node does not exist');
|
||||
}
|
||||
);
|
||||
} else if (this.sharedLinkId) {
|
||||
this.isLoading = true;
|
||||
|
||||
this.apiService.sharedLinksApi.getSharedLink(this.sharedLinkId).then(details => {
|
||||
this.setUpSharedLinkFile(details);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setUpBlobData() {
|
||||
this.displayName = this.getDisplayName('Unknown');
|
||||
this.isLoading = true;
|
||||
this.mimeType = this.blobFile.type;
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
|
||||
this.allowDownload = false;
|
||||
// TODO: wrap blob into the data url and allow downloading
|
||||
|
||||
this.extensionChange.emit(this.mimeType);
|
||||
this.isLoading = false;
|
||||
this.scrollTop();
|
||||
}
|
||||
|
||||
private setUpUrlFile() {
|
||||
this.isLoading = true;
|
||||
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
|
||||
this.displayName = this.getDisplayName(filenameFromUrl);
|
||||
this.extension = this.getFileExtension(filenameFromUrl);
|
||||
this.urlFileContent = this.urlFile;
|
||||
|
||||
this.downloadUrl = this.urlFile;
|
||||
this.fileName = this.displayName;
|
||||
|
||||
this.viewerType = this.urlFileViewer || this.getViewerTypeByExtension(this.extension);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
}
|
||||
|
||||
this.extensionChange.emit(this.extension);
|
||||
this.isLoading = false;
|
||||
this.scrollTop();
|
||||
}
|
||||
|
||||
private setUpNodeFile(data: MinimalNodeEntryEntity) {
|
||||
this.mimeType = data.content.mimeType;
|
||||
this.displayName = this.getDisplayName(data.name);
|
||||
this.urlFileContent = this.apiService.getInstance().content.getContentUrl(data.id);
|
||||
this.extension = this.getFileExtension(data.name);
|
||||
|
||||
this.fileName = data.name;
|
||||
this.downloadUrl = this.apiService.getInstance().content.getContentUrl(data.id, true);
|
||||
|
||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
}
|
||||
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.displayNodeRendition(data.id);
|
||||
} else {
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
this.extensionChange.emit(this.extension);
|
||||
this.sidebarTemplateContext.node = data;
|
||||
this.scrollTop();
|
||||
}
|
||||
|
||||
private setUpSharedLinkFile(details: any) {
|
||||
this.mimeType = details.entry.content.mimeType;
|
||||
this.displayName = this.getDisplayName(details.entry.name);
|
||||
this.extension = this.getFileExtension(details.entry.name);
|
||||
this.fileName = details.entry.name;
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
this.downloadUrl = this.apiService.contentApi.getSharedLinkContentUrl(this.sharedLinkId, true);
|
||||
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
||||
}
|
||||
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.displaySharedLinkRendition(this.sharedLinkId);
|
||||
} else {
|
||||
this.isLoading = false;
|
||||
}
|
||||
this.extensionChange.emit(this.extension);
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
toggleSidebar() {
|
||||
this.showSidebar = !this.showSidebar;
|
||||
if (this.showSidebar && this.fileNodeId) {
|
||||
|
Reference in New Issue
Block a user