mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
main application
This commit is contained in:
122
src/app/components/recent-files/recent-files.component.html
Normal file
122
src/app/components/recent-files/recent-files.component.html
Normal file
@@ -0,0 +1,122 @@
|
||||
<div class="inner-layout">
|
||||
<div class="inner-layout__header">
|
||||
<adf-breadcrumb root="APP.BROWSE.RECENT.TITLE">
|
||||
</adf-breadcrumb>
|
||||
|
||||
<adf-toolbar class="inline">
|
||||
|
||||
<button
|
||||
md-icon-button
|
||||
*ngIf="canPreviewFile(documentList.selection)"
|
||||
title="{{ 'APP.ACTIONS.VIEW' | translate }}"
|
||||
(click)="showPreview(documentList.selection[0]?.entry?.id)">
|
||||
<md-icon>open_in_browser</md-icon>
|
||||
</button>
|
||||
|
||||
<button
|
||||
md-icon-button
|
||||
*ngIf="hasSelection(documentList.selection)"
|
||||
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
|
||||
[app-download-node]="documentList.selection">
|
||||
<md-icon>get_app</md-icon>
|
||||
</button>
|
||||
|
||||
<button
|
||||
md-icon-button
|
||||
*ngIf="hasSelection(documentList.selection)"
|
||||
title="{{ 'APP.ACTIONS.MORE' | translate }}"
|
||||
[mdMenuTriggerFor]="actionsMenu">
|
||||
<md-icon>more_vert</md-icon>
|
||||
</button>
|
||||
<md-menu #actionsMenu="mdMenu"
|
||||
[overlapTrigger]="false"
|
||||
class="secondary-options">
|
||||
<button
|
||||
md-menu-item
|
||||
#favorite="favorite"
|
||||
[app-favorite-node]="documentList.selection">
|
||||
<md-icon [ngClass]="{ 'icon-highlight': favorite.hasFavorites() }">
|
||||
{{ favorite.hasFavorites() ? 'star' :'star_border' }}
|
||||
</md-icon>
|
||||
<span>{{ 'APP.ACTIONS.FAVORITE' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
md-menu-item
|
||||
[app-copy-node]="documentList.selection">
|
||||
<md-icon>content_copy</md-icon>
|
||||
<span>{{ 'APP.ACTIONS.COPY' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
md-menu-item
|
||||
*ngIf="canMove(documentList.selection)"
|
||||
[app-move-node]="documentList.selection">
|
||||
<md-icon>library_books</md-icon>
|
||||
<span>{{ 'APP.ACTIONS.MOVE' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
md-menu-item
|
||||
*ngIf="canDelete(documentList.selection)"
|
||||
[app-delete-node]="documentList.selection">
|
||||
<md-icon>delete</md-icon>
|
||||
<span>{{ 'APP.ACTIONS.DELETE' | translate }}</span>
|
||||
</button>
|
||||
</md-menu>
|
||||
</adf-toolbar>
|
||||
</div>
|
||||
|
||||
<div class="inner-layout__content">
|
||||
|
||||
<adf-document-list #documentList
|
||||
currentFolderId="-recent-"
|
||||
selectionMode="multiple"
|
||||
[navigate]="false"
|
||||
[sorting]="[ 'modifiedAt', 'desc' ]"
|
||||
[pageSize]="25"
|
||||
[contextMenuActions]="true"
|
||||
[contentActions]="false"
|
||||
(node-dblclick)="onNodeDoubleClick($event.detail?.node?.entry)">
|
||||
|
||||
<data-columns>
|
||||
<data-column
|
||||
key="$thumbnail"
|
||||
type="image"
|
||||
[sortable]="false"
|
||||
class="image-table-cell">
|
||||
</data-column>
|
||||
|
||||
<data-column
|
||||
key="name"
|
||||
class="app-name-column"
|
||||
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
|
||||
<ng-template let-value="value" let-context>
|
||||
<span title="{{ context?.row?.obj | nodeNameTooltip }}">{{ value }}</span>
|
||||
</ng-template>
|
||||
</data-column>
|
||||
|
||||
<data-column
|
||||
key="path"
|
||||
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"
|
||||
type="location"
|
||||
format="/personal-files">
|
||||
</data-column>
|
||||
|
||||
<data-column
|
||||
key="content.sizeInBytes"
|
||||
type="fileSize"
|
||||
title="APP.DOCUMENT_LIST.COLUMNS.SIZE">
|
||||
</data-column>
|
||||
|
||||
<data-column
|
||||
key="modifiedAt"
|
||||
type="date"
|
||||
format="timeAgo"
|
||||
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON">
|
||||
</data-column>
|
||||
</data-columns>
|
||||
|
||||
</adf-document-list>
|
||||
</div>
|
||||
</div>
|
152
src/app/components/recent-files/recent-files.component.spec.ts
Normal file
152
src/app/components/recent-files/recent-files.component.spec.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2017 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Router } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||
|
||||
import { CommonModule } from '../../common/common.module';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
import { RecentFilesComponent } from './recent-files.component';
|
||||
|
||||
describe('RecentFiles Routed Component', () => {
|
||||
let fixture;
|
||||
let component;
|
||||
let router: Router;
|
||||
let alfrescoApi: AlfrescoApiService;
|
||||
let contentService: ContentManagementService;
|
||||
let page;
|
||||
let person;
|
||||
|
||||
beforeEach(() => {
|
||||
page = {
|
||||
list: {
|
||||
entries: [ { entry: { id: 1 } }, { entry: { id: 2 } } ],
|
||||
pagination: { data: 'data'}
|
||||
}
|
||||
};
|
||||
|
||||
person = { entry: { id: 'bogus' } };
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule,
|
||||
RouterTestingModule,
|
||||
CommonModule
|
||||
],
|
||||
declarations: [
|
||||
RecentFilesComponent
|
||||
]
|
||||
})
|
||||
.compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(RecentFilesComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
router = TestBed.get(Router);
|
||||
contentService = TestBed.get(ContentManagementService);
|
||||
alfrescoApi = TestBed.get(AlfrescoApiService);
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(Promise.resolve({
|
||||
entry: { id: 'personId' }
|
||||
}));
|
||||
|
||||
spyOn(alfrescoApi.searchApi, 'search').and.returnValue(Promise.resolve(page));
|
||||
});
|
||||
|
||||
describe('OnInit()', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component, 'refresh').and.stub();
|
||||
});
|
||||
|
||||
it('should reload nodes on onDeleteNode event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.deleteNode.next();
|
||||
|
||||
expect(component.refresh).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload on onRestoreNode event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.restoreNode.next();
|
||||
|
||||
expect(component.refresh).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload on toggleFavorite event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.toggleFavorite.next();
|
||||
|
||||
expect(component.refresh).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload on move node event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.moveNode.next();
|
||||
|
||||
expect(component.refresh).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onNodeDoubleClick()', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component, 'fetchNodes').and.callFake(val => val);
|
||||
});
|
||||
|
||||
it('open preview if node is file', () => {
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
const node: any = { isFile: true };
|
||||
|
||||
component.onNodeDoubleClick(node);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/preview', node.id]);
|
||||
});
|
||||
|
||||
it('does not open preview if node is folder', () => {
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
const node: any = { isFolder: true };
|
||||
|
||||
component.onNodeDoubleClick(node);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('refresh', () => {
|
||||
it('should call document list reload', () => {
|
||||
spyOn(component.documentList, 'reload');
|
||||
fixture.detectChanges();
|
||||
|
||||
component.refresh();
|
||||
|
||||
expect(component.documentList.reload).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
75
src/app/components/recent-files/recent-files.component.ts
Normal file
75
src/app/components/recent-files/recent-files.component.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2017 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { DocumentListComponent } from 'ng2-alfresco-documentlist';
|
||||
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
import { PageComponent } from '../page.component';
|
||||
|
||||
@Component({
|
||||
templateUrl: './recent-files.component.html'
|
||||
})
|
||||
export class RecentFilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(DocumentListComponent)
|
||||
documentList: DocumentListComponent;
|
||||
|
||||
private onDeleteNode: Subscription;
|
||||
private onMoveNode: Subscription;
|
||||
private onRestoreNode: Subscription;
|
||||
private onToggleFavorite: Subscription;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private content: ContentManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.onDeleteNode = this.content.deleteNode.subscribe(() => this.refresh());
|
||||
this.onMoveNode = this.content.moveNode.subscribe(() => this.refresh());
|
||||
this.onRestoreNode = this.content.restoreNode.subscribe(() => this.refresh());
|
||||
this.onToggleFavorite = this.content.toggleFavorite.subscribe(() => this.refresh());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDeleteNode.unsubscribe();
|
||||
this.onMoveNode.unsubscribe();
|
||||
this.onRestoreNode.unsubscribe();
|
||||
this.onToggleFavorite.unsubscribe();
|
||||
}
|
||||
|
||||
onNodeDoubleClick(node: MinimalNodeEntryEntity) {
|
||||
if (node && node.isFile) {
|
||||
this.router.navigate(['/preview', node.id]);
|
||||
}
|
||||
}
|
||||
|
||||
fetchNodes(): void {
|
||||
// todo: remove once all views migrate to native data source
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (this.documentList) {
|
||||
this.documentList.reload();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user