mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1443] prettier formatting and checks (#629)
* intergrate prettier * update settings * integrate with travis * unified formatting across all files
This commit is contained in:
@@ -38,99 +38,96 @@ import { appSelection } from '../selectors/app.selectors';
|
||||
|
||||
@Injectable()
|
||||
export class DownloadEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private contentApi: ContentApiService,
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private contentApi: ContentApiService,
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
downloadNode$ = this.actions$.pipe(
|
||||
ofType<DownloadNodesAction>(DOWNLOAD_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.downloadNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.downloadNodes(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
downloadNode$ = this.actions$.pipe(
|
||||
ofType<DownloadNodesAction>(DOWNLOAD_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.downloadNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.downloadNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
private downloadNodes(toDownload: Array<MinimalNodeEntity>) {
|
||||
const nodes = toDownload.map(node => {
|
||||
const { id, nodeId, name, isFile, isFolder } = node.entry;
|
||||
private downloadNodes(toDownload: Array<MinimalNodeEntity>) {
|
||||
const nodes = toDownload.map(node => {
|
||||
const { id, nodeId, name, isFile, isFolder } = node.entry;
|
||||
|
||||
return {
|
||||
id: nodeId || id,
|
||||
name,
|
||||
isFile,
|
||||
isFolder
|
||||
};
|
||||
});
|
||||
return {
|
||||
id: nodeId || id,
|
||||
name,
|
||||
isFile,
|
||||
isFolder
|
||||
};
|
||||
});
|
||||
|
||||
if (!nodes || nodes.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodes.length === 1) {
|
||||
this.downloadNode(nodes[0]);
|
||||
} else {
|
||||
this.downloadZip(nodes);
|
||||
}
|
||||
if (!nodes || nodes.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
private downloadNode(node: NodeInfo) {
|
||||
if (node) {
|
||||
if (node.isFolder) {
|
||||
this.downloadZip([node]);
|
||||
} else {
|
||||
this.downloadFile(node);
|
||||
}
|
||||
}
|
||||
if (nodes.length === 1) {
|
||||
this.downloadNode(nodes[0]);
|
||||
} else {
|
||||
this.downloadZip(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
private downloadFile(node: NodeInfo) {
|
||||
if (node) {
|
||||
this.download(
|
||||
this.contentApi.getContentUrl(node.id, true),
|
||||
node.name
|
||||
);
|
||||
}
|
||||
private downloadNode(node: NodeInfo) {
|
||||
if (node) {
|
||||
if (node.isFolder) {
|
||||
this.downloadZip([node]);
|
||||
} else {
|
||||
this.downloadFile(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private downloadZip(nodes: Array<NodeInfo>) {
|
||||
if (nodes && nodes.length > 0) {
|
||||
const nodeIds = nodes.map(node => node.id);
|
||||
|
||||
this.dialog.open(DownloadZipDialogComponent, {
|
||||
width: '600px',
|
||||
disableClose: true,
|
||||
data: {
|
||||
nodeIds
|
||||
}
|
||||
});
|
||||
}
|
||||
private downloadFile(node: NodeInfo) {
|
||||
if (node) {
|
||||
this.download(this.contentApi.getContentUrl(node.id, true), node.name);
|
||||
}
|
||||
}
|
||||
|
||||
private download(url: string, fileName: string) {
|
||||
if (url && fileName) {
|
||||
const link = document.createElement('a');
|
||||
private downloadZip(nodes: Array<NodeInfo>) {
|
||||
if (nodes && nodes.length > 0) {
|
||||
const nodeIds = nodes.map(node => node.id);
|
||||
|
||||
link.style.display = 'none';
|
||||
link.download = fileName;
|
||||
link.href = url;
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
this.dialog.open(DownloadZipDialogComponent, {
|
||||
width: '600px',
|
||||
disableClose: true,
|
||||
data: {
|
||||
nodeIds
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private download(url: string, fileName: string) {
|
||||
if (url && fileName) {
|
||||
const link = document.createElement('a');
|
||||
|
||||
link.style.display = 'none';
|
||||
link.download = fileName;
|
||||
link.href = url;
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,12 @@
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { ADD_FAVORITE, AddFavoriteAction, RemoveFavoriteAction, REMOVE_FAVORITE } from '../actions/favorite.actions';
|
||||
import {
|
||||
ADD_FAVORITE,
|
||||
AddFavoriteAction,
|
||||
RemoveFavoriteAction,
|
||||
REMOVE_FAVORITE
|
||||
} from '../actions/favorite.actions';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../states';
|
||||
import { appSelection } from '../selectors/app.selectors';
|
||||
@@ -34,49 +39,47 @@ import { ContentManagementService } from '../../services/content-management.serv
|
||||
|
||||
@Injectable()
|
||||
export class FavoriteEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private content: ContentManagementService
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private content: ContentManagementService
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
addFavorite$ = this.actions$.pipe(
|
||||
ofType<AddFavoriteAction>(ADD_FAVORITE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.content.addFavorite(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.content.addFavorite(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
addFavorite$ = this.actions$.pipe(
|
||||
ofType<AddFavoriteAction>(ADD_FAVORITE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.content.addFavorite(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.content.addFavorite(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
removeFavorite$ = this.actions$.pipe(
|
||||
ofType<RemoveFavoriteAction>(REMOVE_FAVORITE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.content.removeFavorite(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.content.removeFavorite(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
removeFavorite$ = this.actions$.pipe(
|
||||
ofType<RemoveFavoriteAction>(REMOVE_FAVORITE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.content.removeFavorite(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.content.removeFavorite(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -27,8 +27,10 @@ import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import {
|
||||
DeleteLibraryAction, DELETE_LIBRARY,
|
||||
CreateLibraryAction, CREATE_LIBRARY
|
||||
DeleteLibraryAction,
|
||||
DELETE_LIBRARY,
|
||||
CreateLibraryAction,
|
||||
CREATE_LIBRARY
|
||||
} from '../actions';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
@@ -37,36 +39,36 @@ import { appSelection } from '../selectors/app.selectors';
|
||||
|
||||
@Injectable()
|
||||
export class SiteEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private content: ContentManagementService
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private content: ContentManagementService
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
deleteLibrary$ = this.actions$.pipe(
|
||||
ofType<DeleteLibraryAction>(DELETE_LIBRARY),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.content.deleteLibrary(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.library) {
|
||||
this.content.deleteLibrary(selection.library.entry.id);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
deleteLibrary$ = this.actions$.pipe(
|
||||
ofType<DeleteLibraryAction>(DELETE_LIBRARY),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.content.deleteLibrary(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.library) {
|
||||
this.content.deleteLibrary(selection.library.entry.id);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
createLibrary$ = this.actions$.pipe(
|
||||
ofType<CreateLibraryAction>(CREATE_LIBRARY),
|
||||
map(action => {
|
||||
this.content.createLibrary();
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
createLibrary$ = this.actions$.pipe(
|
||||
ofType<CreateLibraryAction>(CREATE_LIBRARY),
|
||||
map(action => {
|
||||
this.content.createLibrary();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -29,268 +29,260 @@ import { map, take } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../states/app.state';
|
||||
import {
|
||||
PurgeDeletedNodesAction,
|
||||
PURGE_DELETED_NODES,
|
||||
DeleteNodesAction,
|
||||
DELETE_NODES,
|
||||
UndoDeleteNodesAction,
|
||||
UNDO_DELETE_NODES,
|
||||
CreateFolderAction,
|
||||
CREATE_FOLDER,
|
||||
EditFolderAction,
|
||||
EDIT_FOLDER,
|
||||
RestoreDeletedNodesAction,
|
||||
RESTORE_DELETED_NODES,
|
||||
ShareNodeAction,
|
||||
SHARE_NODE
|
||||
PurgeDeletedNodesAction,
|
||||
PURGE_DELETED_NODES,
|
||||
DeleteNodesAction,
|
||||
DELETE_NODES,
|
||||
UndoDeleteNodesAction,
|
||||
UNDO_DELETE_NODES,
|
||||
CreateFolderAction,
|
||||
CREATE_FOLDER,
|
||||
EditFolderAction,
|
||||
EDIT_FOLDER,
|
||||
RestoreDeletedNodesAction,
|
||||
RESTORE_DELETED_NODES,
|
||||
ShareNodeAction,
|
||||
SHARE_NODE
|
||||
} from '../actions';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
import { currentFolder, appSelection } from '../selectors/app.selectors';
|
||||
import {
|
||||
UnshareNodesAction,
|
||||
UNSHARE_NODES,
|
||||
CopyNodesAction,
|
||||
COPY_NODES,
|
||||
MoveNodesAction,
|
||||
MOVE_NODES,
|
||||
ManagePermissionsAction,
|
||||
MANAGE_PERMISSIONS,
|
||||
ManageVersionsAction,
|
||||
MANAGE_VERSIONS
|
||||
UnshareNodesAction,
|
||||
UNSHARE_NODES,
|
||||
CopyNodesAction,
|
||||
COPY_NODES,
|
||||
MoveNodesAction,
|
||||
MOVE_NODES,
|
||||
ManagePermissionsAction,
|
||||
MANAGE_PERMISSIONS,
|
||||
ManageVersionsAction,
|
||||
MANAGE_VERSIONS
|
||||
} from '../actions/node.actions';
|
||||
|
||||
@Injectable()
|
||||
export class NodeEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private contentService: ContentManagementService
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private contentService: ContentManagementService
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
shareNode$ = this.actions$.pipe(
|
||||
ofType<ShareNodeAction>(SHARE_NODE),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.shareNode(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.file) {
|
||||
this.contentService.shareNode(selection.file);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
shareNode$ = this.actions$.pipe(
|
||||
ofType<ShareNodeAction>(SHARE_NODE),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.shareNode(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.file) {
|
||||
this.contentService.shareNode(selection.file);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
unshareNodes$ = this.actions$.pipe(
|
||||
ofType<UnshareNodesAction>(UNSHARE_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.unshareNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.unshareNodes(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
unshareNodes$ = this.actions$.pipe(
|
||||
ofType<UnshareNodesAction>(UNSHARE_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.unshareNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.unshareNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
purgeDeletedNodes$ = this.actions$.pipe(
|
||||
ofType<PurgeDeletedNodesAction>(PURGE_DELETED_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.purgeDeletedNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.purgeDeletedNodes(
|
||||
selection.nodes
|
||||
);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
purgeDeletedNodes$ = this.actions$.pipe(
|
||||
ofType<PurgeDeletedNodesAction>(PURGE_DELETED_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.purgeDeletedNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.purgeDeletedNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
restoreDeletedNodes$ = this.actions$.pipe(
|
||||
ofType<RestoreDeletedNodesAction>(RESTORE_DELETED_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.restoreDeletedNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.restoreDeletedNodes(
|
||||
selection.nodes
|
||||
);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
restoreDeletedNodes$ = this.actions$.pipe(
|
||||
ofType<RestoreDeletedNodesAction>(RESTORE_DELETED_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.restoreDeletedNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.restoreDeletedNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
deleteNodes$ = this.actions$.pipe(
|
||||
ofType<DeleteNodesAction>(DELETE_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.deleteNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.deleteNodes(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
deleteNodes$ = this.actions$.pipe(
|
||||
ofType<DeleteNodesAction>(DELETE_NODES),
|
||||
map(action => {
|
||||
if (action && action.payload && action.payload.length > 0) {
|
||||
this.contentService.deleteNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.deleteNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
undoDeleteNodes$ = this.actions$.pipe(
|
||||
ofType<UndoDeleteNodesAction>(UNDO_DELETE_NODES),
|
||||
map(action => {
|
||||
if (action.payload.length > 0) {
|
||||
this.contentService.undoDeleteNodes(action.payload);
|
||||
}
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
undoDeleteNodes$ = this.actions$.pipe(
|
||||
ofType<UndoDeleteNodesAction>(UNDO_DELETE_NODES),
|
||||
map(action => {
|
||||
if (action.payload.length > 0) {
|
||||
this.contentService.undoDeleteNodes(action.payload);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
createFolder$ = this.actions$.pipe(
|
||||
ofType<CreateFolderAction>(CREATE_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.createFolder(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(currentFolder)
|
||||
.pipe(take(1))
|
||||
.subscribe(node => {
|
||||
if (node && node.id) {
|
||||
this.contentService.createFolder(node.id);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
createFolder$ = this.actions$.pipe(
|
||||
ofType<CreateFolderAction>(CREATE_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.createFolder(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(currentFolder)
|
||||
.pipe(take(1))
|
||||
.subscribe(node => {
|
||||
if (node && node.id) {
|
||||
this.contentService.createFolder(node.id);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
editFolder$ = this.actions$.pipe(
|
||||
ofType<EditFolderAction>(EDIT_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.editFolder(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.folder) {
|
||||
this.contentService.editFolder(selection.folder);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
editFolder$ = this.actions$.pipe(
|
||||
ofType<EditFolderAction>(EDIT_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.contentService.editFolder(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.folder) {
|
||||
this.contentService.editFolder(selection.folder);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
copyNodes$ = this.actions$.pipe(
|
||||
ofType<CopyNodesAction>(COPY_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.contentService.copyNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.copyNodes(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
copyNodes$ = this.actions$.pipe(
|
||||
ofType<CopyNodesAction>(COPY_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.contentService.copyNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.copyNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
moveNodes$ = this.actions$.pipe(
|
||||
ofType<MoveNodesAction>(MOVE_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.contentService.moveNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.moveNodes(selection.nodes);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
moveNodes$ = this.actions$.pipe(
|
||||
ofType<MoveNodesAction>(MOVE_NODES),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.length > 0) {
|
||||
this.contentService.moveNodes(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.moveNodes(selection.nodes);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
managePermissions = this.actions$.pipe(
|
||||
ofType<ManagePermissionsAction>(MANAGE_PERMISSIONS),
|
||||
map(action => {
|
||||
if (action && action.payload) {
|
||||
this.contentService.managePermissions(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.managePermissions(
|
||||
selection.first
|
||||
);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
managePermissions = this.actions$.pipe(
|
||||
ofType<ManagePermissionsAction>(MANAGE_PERMISSIONS),
|
||||
map(action => {
|
||||
if (action && action.payload) {
|
||||
this.contentService.managePermissions(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
this.contentService.managePermissions(selection.first);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
manageVersions$ = this.actions$.pipe(
|
||||
ofType<ManageVersionsAction>(MANAGE_VERSIONS),
|
||||
map(action => {
|
||||
if (action && action.payload) {
|
||||
this.contentService.manageVersions(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.file) {
|
||||
this.contentService.manageVersions(
|
||||
selection.file
|
||||
);
|
||||
}
|
||||
});
|
||||
@Effect({ dispatch: false })
|
||||
manageVersions$ = this.actions$.pipe(
|
||||
ofType<ManageVersionsAction>(MANAGE_VERSIONS),
|
||||
map(action => {
|
||||
if (action && action.payload) {
|
||||
this.contentService.manageVersions(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.file) {
|
||||
this.contentService.manageVersions(selection.file);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -29,113 +29,113 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||
import { MinimalNodeEntryEntity, PathInfoEntity } from 'alfresco-js-api';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
NavigateRouteAction,
|
||||
NavigateToParentFolder,
|
||||
NAVIGATE_PARENT_FOLDER,
|
||||
NAVIGATE_ROUTE,
|
||||
NavigateToFolder,
|
||||
NAVIGATE_FOLDER,
|
||||
NavigateUrlAction,
|
||||
NAVIGATE_URL
|
||||
NavigateRouteAction,
|
||||
NavigateToParentFolder,
|
||||
NAVIGATE_PARENT_FOLDER,
|
||||
NAVIGATE_ROUTE,
|
||||
NavigateToFolder,
|
||||
NAVIGATE_FOLDER,
|
||||
NavigateUrlAction,
|
||||
NAVIGATE_URL
|
||||
} from '../actions';
|
||||
|
||||
@Injectable()
|
||||
export class RouterEffects {
|
||||
constructor(private actions$: Actions, private router: Router) {}
|
||||
constructor(private actions$: Actions, private router: Router) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
navigateUrl$ = this.actions$.pipe(
|
||||
ofType<NavigateUrlAction>(NAVIGATE_URL),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.router.navigateByUrl(action.payload);
|
||||
}
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
navigateUrl$ = this.actions$.pipe(
|
||||
ofType<NavigateUrlAction>(NAVIGATE_URL),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.router.navigateByUrl(action.payload);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
navigateRoute$ = this.actions$.pipe(
|
||||
ofType<NavigateRouteAction>(NAVIGATE_ROUTE),
|
||||
map(action => {
|
||||
this.router.navigate(action.payload);
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
navigateRoute$ = this.actions$.pipe(
|
||||
ofType<NavigateRouteAction>(NAVIGATE_ROUTE),
|
||||
map(action => {
|
||||
this.router.navigate(action.payload);
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
navigateToFolder$ = this.actions$.pipe(
|
||||
ofType<NavigateToFolder>(NAVIGATE_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
navigateToFolder$ = this.actions$.pipe(
|
||||
ofType<NavigateToFolder>(NAVIGATE_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
navigateToParentFolder$ = this.actions$.pipe(
|
||||
ofType<NavigateToParentFolder>(NAVIGATE_PARENT_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToParentFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
navigateToParentFolder$ = this.actions$.pipe(
|
||||
ofType<NavigateToParentFolder>(NAVIGATE_PARENT_FOLDER),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToParentFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
private navigateToFolder(node: MinimalNodeEntryEntity) {
|
||||
let link = null;
|
||||
const { path, id } = node;
|
||||
private navigateToFolder(node: MinimalNodeEntryEntity) {
|
||||
let link = null;
|
||||
const { path, id } = node;
|
||||
|
||||
if (path && path.name && path.elements) {
|
||||
const isLibraryPath = this.isLibraryContent(<PathInfoEntity>path);
|
||||
if (path && path.name && path.elements) {
|
||||
const isLibraryPath = this.isLibraryContent(<PathInfoEntity>path);
|
||||
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
const area = isLibraryPath ? '/libraries' : '/personal-files';
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
const area = isLibraryPath ? '/libraries' : '/personal-files';
|
||||
|
||||
if (!isLibraryPath) {
|
||||
link = [area, id];
|
||||
} else {
|
||||
// parent.id could be 'Site' folder or child as 'documentLibrary'
|
||||
link = [area, parent.name === 'Sites' ? {} : id];
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.router.navigate(link);
|
||||
}, 10);
|
||||
if (!isLibraryPath) {
|
||||
link = [area, id];
|
||||
} else {
|
||||
// parent.id could be 'Site' folder or child as 'documentLibrary'
|
||||
link = [area, parent.name === 'Sites' ? {} : id];
|
||||
}
|
||||
}
|
||||
|
||||
private navigateToParentFolder(node: MinimalNodeEntryEntity) {
|
||||
let link = null;
|
||||
const { path } = node;
|
||||
setTimeout(() => {
|
||||
this.router.navigate(link);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
if (path && path.name && path.elements) {
|
||||
const isLibraryPath = this.isLibraryContent(<PathInfoEntity>path);
|
||||
private navigateToParentFolder(node: MinimalNodeEntryEntity) {
|
||||
let link = null;
|
||||
const { path } = node;
|
||||
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
const area = isLibraryPath ? '/libraries' : '/personal-files';
|
||||
if (path && path.name && path.elements) {
|
||||
const isLibraryPath = this.isLibraryContent(<PathInfoEntity>path);
|
||||
|
||||
if (!isLibraryPath) {
|
||||
link = [area, parent.id];
|
||||
} else {
|
||||
// parent.id could be 'Site' folder or child as 'documentLibrary'
|
||||
link = [area, parent.name === 'Sites' ? {} : parent.id];
|
||||
}
|
||||
}
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
const area = isLibraryPath ? '/libraries' : '/personal-files';
|
||||
|
||||
setTimeout(() => {
|
||||
this.router.navigate(link);
|
||||
}, 10);
|
||||
if (!isLibraryPath) {
|
||||
link = [area, parent.id];
|
||||
} else {
|
||||
// parent.id could be 'Site' folder or child as 'documentLibrary'
|
||||
link = [area, parent.name === 'Sites' ? {} : parent.id];
|
||||
}
|
||||
}
|
||||
|
||||
private isLibraryContent(path: PathInfoEntity): boolean {
|
||||
if (
|
||||
path &&
|
||||
path.elements.length >= 2 &&
|
||||
path.elements[1].name === 'Sites'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.router.navigate(link);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
return false;
|
||||
private isLibraryContent(path: PathInfoEntity): boolean {
|
||||
if (
|
||||
path &&
|
||||
path.elements.length >= 2 &&
|
||||
path.elements[1].name === 'Sites'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -31,13 +31,13 @@ import { Router } from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class SearchEffects {
|
||||
constructor(private actions$: Actions, private router: Router) {}
|
||||
constructor(private actions$: Actions, private router: Router) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
searchByTerm$ = this.actions$.pipe(
|
||||
ofType<SearchByTermAction>(SEARCH_BY_TERM),
|
||||
map(action => {
|
||||
this.router.navigateByUrl('/search;q=' + action.payload);
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
searchByTerm$ = this.actions$.pipe(
|
||||
ofType<SearchByTermAction>(SEARCH_BY_TERM),
|
||||
map(action => {
|
||||
this.router.navigateByUrl('/search;q=' + action.payload);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -30,70 +30,70 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
SnackbarAction,
|
||||
SnackbarErrorAction,
|
||||
SnackbarInfoAction,
|
||||
SnackbarWarningAction,
|
||||
SNACKBAR_ERROR,
|
||||
SNACKBAR_INFO,
|
||||
SNACKBAR_WARNING
|
||||
SnackbarAction,
|
||||
SnackbarErrorAction,
|
||||
SnackbarInfoAction,
|
||||
SnackbarWarningAction,
|
||||
SNACKBAR_ERROR,
|
||||
SNACKBAR_INFO,
|
||||
SNACKBAR_WARNING
|
||||
} from '../actions';
|
||||
import { AppStore } from '../states/app.state';
|
||||
|
||||
@Injectable()
|
||||
export class SnackbarEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private snackBar: MatSnackBar,
|
||||
private translationService: TranslationService
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private snackBar: MatSnackBar,
|
||||
private translationService: TranslationService
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
infoEffect = this.actions$.pipe(
|
||||
ofType<SnackbarInfoAction>(SNACKBAR_INFO),
|
||||
map((action: SnackbarInfoAction) => {
|
||||
this.showSnackBar(action, 'info-snackbar');
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
infoEffect = this.actions$.pipe(
|
||||
ofType<SnackbarInfoAction>(SNACKBAR_INFO),
|
||||
map((action: SnackbarInfoAction) => {
|
||||
this.showSnackBar(action, 'info-snackbar');
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
warningEffect = this.actions$.pipe(
|
||||
ofType<SnackbarWarningAction>(SNACKBAR_WARNING),
|
||||
map((action: SnackbarWarningAction) => {
|
||||
this.showSnackBar(action, 'warning-snackbar');
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
warningEffect = this.actions$.pipe(
|
||||
ofType<SnackbarWarningAction>(SNACKBAR_WARNING),
|
||||
map((action: SnackbarWarningAction) => {
|
||||
this.showSnackBar(action, 'warning-snackbar');
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
errorEffect = this.actions$.pipe(
|
||||
ofType<SnackbarErrorAction>(SNACKBAR_ERROR),
|
||||
map((action: SnackbarErrorAction) => {
|
||||
this.showSnackBar(action, 'error-snackbar');
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
errorEffect = this.actions$.pipe(
|
||||
ofType<SnackbarErrorAction>(SNACKBAR_ERROR),
|
||||
map((action: SnackbarErrorAction) => {
|
||||
this.showSnackBar(action, 'error-snackbar');
|
||||
})
|
||||
);
|
||||
|
||||
private showSnackBar(action: SnackbarAction, panelClass: string) {
|
||||
const message = this.translate(action.payload, action.params);
|
||||
private showSnackBar(action: SnackbarAction, panelClass: string) {
|
||||
const message = this.translate(action.payload, action.params);
|
||||
|
||||
let actionName: string = null;
|
||||
if (action.userAction) {
|
||||
actionName = this.translate(action.userAction.title);
|
||||
}
|
||||
|
||||
const snackBarRef = this.snackBar.open(message, actionName, {
|
||||
duration: action.duration || 4000,
|
||||
panelClass: panelClass
|
||||
});
|
||||
|
||||
if (action.userAction) {
|
||||
snackBarRef.onAction().subscribe(() => {
|
||||
this.store.dispatch(action.userAction.action);
|
||||
});
|
||||
}
|
||||
let actionName: string = null;
|
||||
if (action.userAction) {
|
||||
actionName = this.translate(action.userAction.title);
|
||||
}
|
||||
|
||||
private translate(message: string, params?: Object): string {
|
||||
return this.translationService.instant(message, params);
|
||||
const snackBarRef = this.snackBar.open(message, actionName, {
|
||||
duration: action.duration || 4000,
|
||||
panelClass: panelClass
|
||||
});
|
||||
|
||||
if (action.userAction) {
|
||||
snackBarRef.onAction().subscribe(() => {
|
||||
this.store.dispatch(action.userAction.action);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private translate(message: string, params?: Object): string {
|
||||
return this.translationService.instant(message, params);
|
||||
}
|
||||
}
|
||||
|
@@ -35,82 +35,79 @@ import { UploadFolderAction, UPLOAD_FOLDER } from '../actions/upload.actions';
|
||||
|
||||
@Injectable()
|
||||
export class UploadEffects {
|
||||
private fileInput: HTMLInputElement;
|
||||
private folderInput: HTMLInputElement;
|
||||
private fileInput: HTMLInputElement;
|
||||
private folderInput: HTMLInputElement;
|
||||
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private ngZone: NgZone,
|
||||
private uploadService: UploadService,
|
||||
rendererFactory: RendererFactory2
|
||||
) {
|
||||
const renderer = rendererFactory.createRenderer(null, null);
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private ngZone: NgZone,
|
||||
private uploadService: UploadService,
|
||||
rendererFactory: RendererFactory2
|
||||
) {
|
||||
const renderer = rendererFactory.createRenderer(null, null);
|
||||
|
||||
this.fileInput = renderer.createElement('input') as HTMLInputElement;
|
||||
this.fileInput.id = 'app-upload-files';
|
||||
this.fileInput.type = 'file';
|
||||
this.fileInput.style.display = 'none';
|
||||
this.fileInput.setAttribute('multiple', '');
|
||||
this.fileInput.addEventListener('change', event => this.upload(event));
|
||||
renderer.appendChild(document.body, this.fileInput);
|
||||
this.fileInput = renderer.createElement('input') as HTMLInputElement;
|
||||
this.fileInput.id = 'app-upload-files';
|
||||
this.fileInput.type = 'file';
|
||||
this.fileInput.style.display = 'none';
|
||||
this.fileInput.setAttribute('multiple', '');
|
||||
this.fileInput.addEventListener('change', event => this.upload(event));
|
||||
renderer.appendChild(document.body, this.fileInput);
|
||||
|
||||
this.folderInput = renderer.createElement('input') as HTMLInputElement;
|
||||
this.folderInput.id = 'app-upload-folder';
|
||||
this.folderInput.type = 'file';
|
||||
this.folderInput.style.display = 'none';
|
||||
this.folderInput.setAttribute('directory', '');
|
||||
this.folderInput.setAttribute('webkitdirectory', '');
|
||||
this.folderInput.addEventListener('change', event => this.upload(event));
|
||||
renderer.appendChild(document.body, this.folderInput);
|
||||
}
|
||||
|
||||
this.folderInput = renderer.createElement('input') as HTMLInputElement;
|
||||
this.folderInput.id = 'app-upload-folder';
|
||||
this.folderInput.type = 'file';
|
||||
this.folderInput.style.display = 'none';
|
||||
this.folderInput.setAttribute('directory', '');
|
||||
this.folderInput.setAttribute('webkitdirectory', '');
|
||||
this.folderInput.addEventListener('change', event => this.upload(event));
|
||||
renderer.appendChild(document.body, this.folderInput);
|
||||
}
|
||||
@Effect({ dispatch: false })
|
||||
uploadFiles$ = this.actions$.pipe(
|
||||
ofType<UploadFilesAction>(UPLOAD_FILES),
|
||||
map(() => {
|
||||
this.fileInput.click();
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
uploadFiles$ = this.actions$.pipe(
|
||||
ofType<UploadFilesAction>(UPLOAD_FILES),
|
||||
map(() => {
|
||||
this.fileInput.click();
|
||||
})
|
||||
);
|
||||
@Effect({ dispatch: false })
|
||||
uploadFolder$ = this.actions$.pipe(
|
||||
ofType<UploadFolderAction>(UPLOAD_FOLDER),
|
||||
map(() => {
|
||||
this.folderInput.click();
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
uploadFolder$ = this.actions$.pipe(
|
||||
ofType<UploadFolderAction>(UPLOAD_FOLDER),
|
||||
map(() => {
|
||||
this.folderInput.click();
|
||||
})
|
||||
);
|
||||
|
||||
private upload(event: any): void {
|
||||
this.store
|
||||
.select(currentFolder)
|
||||
.pipe(take(1))
|
||||
.subscribe(node => {
|
||||
if (node && node.id) {
|
||||
const input = <HTMLInputElement>event.currentTarget;
|
||||
const files = FileUtils.toFileArray(input.files).map(
|
||||
file => {
|
||||
return new FileModel(file, {
|
||||
parentId: node.id,
|
||||
path: (file.webkitRelativePath || '').replace(/\/[^\/]*$/, ''),
|
||||
nodeType: 'cm:content'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
this.uploadQueue(files);
|
||||
event.target.value = '';
|
||||
}
|
||||
private upload(event: any): void {
|
||||
this.store
|
||||
.select(currentFolder)
|
||||
.pipe(take(1))
|
||||
.subscribe(node => {
|
||||
if (node && node.id) {
|
||||
const input = <HTMLInputElement>event.currentTarget;
|
||||
const files = FileUtils.toFileArray(input.files).map(file => {
|
||||
return new FileModel(file, {
|
||||
parentId: node.id,
|
||||
path: (file.webkitRelativePath || '').replace(/\/[^\/]*$/, ''),
|
||||
nodeType: 'cm:content'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
private uploadQueue(files: FileModel[]) {
|
||||
if (files.length > 0) {
|
||||
this.ngZone.run(() => {
|
||||
this.uploadService.addToQueue(...files);
|
||||
this.uploadService.uploadFilesInTheQueue();
|
||||
});
|
||||
this.uploadQueue(files);
|
||||
event.target.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private uploadQueue(files: FileModel[]) {
|
||||
if (files.length > 0) {
|
||||
this.ngZone.run(() => {
|
||||
this.uploadService.addToQueue(...files);
|
||||
this.uploadService.uploadFilesInTheQueue();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,77 +33,71 @@ import { AppStore } from '../states';
|
||||
import { appSelection, currentFolder } from '../selectors/app.selectors';
|
||||
|
||||
export const fileToPreview = createSelector(
|
||||
appSelection,
|
||||
currentFolder,
|
||||
(selection, folder) => {
|
||||
return {
|
||||
selection,
|
||||
folder
|
||||
};
|
||||
}
|
||||
appSelection,
|
||||
currentFolder,
|
||||
(selection, folder) => {
|
||||
return {
|
||||
selection,
|
||||
folder
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
@Injectable()
|
||||
export class ViewerEffects {
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private router: Router
|
||||
) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private actions$: Actions,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
viewFile$ = this.actions$.pipe(
|
||||
ofType<ViewFileAction>(VIEW_FILE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
const { id, nodeId, isFile } = action.payload.entry;
|
||||
@Effect({ dispatch: false })
|
||||
viewFile$ = this.actions$.pipe(
|
||||
ofType<ViewFileAction>(VIEW_FILE),
|
||||
map(action => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
const { id, nodeId, isFile } = action.payload.entry;
|
||||
|
||||
if (isFile || nodeId) {
|
||||
this.displayPreview(nodeId || id, action.parentId);
|
||||
}
|
||||
} else {
|
||||
this.store
|
||||
.select(fileToPreview)
|
||||
.pipe(take(1))
|
||||
.subscribe(result => {
|
||||
if (result.selection && result.selection.file) {
|
||||
const {
|
||||
id,
|
||||
nodeId,
|
||||
isFile
|
||||
} = result.selection.file.entry;
|
||||
if (isFile || nodeId) {
|
||||
this.displayPreview(nodeId || id, action.parentId);
|
||||
}
|
||||
} else {
|
||||
this.store
|
||||
.select(fileToPreview)
|
||||
.pipe(take(1))
|
||||
.subscribe(result => {
|
||||
if (result.selection && result.selection.file) {
|
||||
const { id, nodeId, isFile } = result.selection.file.entry;
|
||||
|
||||
if (isFile || nodeId) {
|
||||
const parentId = result.folder
|
||||
? result.folder.id
|
||||
: null;
|
||||
this.displayPreview(nodeId || id, parentId);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (isFile || nodeId) {
|
||||
const parentId = result.folder ? result.folder.id : null;
|
||||
this.displayPreview(nodeId || id, parentId);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
private displayPreview(nodeId: string, parentId: string) {
|
||||
if (!nodeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let previewLocation = this.router.url;
|
||||
if (previewLocation.lastIndexOf('/') > 0) {
|
||||
previewLocation = previewLocation.substr(
|
||||
0,
|
||||
this.router.url.indexOf('/', 1)
|
||||
);
|
||||
}
|
||||
previewLocation = previewLocation.replace(/\//g, '');
|
||||
|
||||
const path = [previewLocation];
|
||||
if (parentId) {
|
||||
path.push(parentId);
|
||||
}
|
||||
path.push('preview', nodeId);
|
||||
this.router.navigateByUrl(path.join('/'));
|
||||
private displayPreview(nodeId: string, parentId: string) {
|
||||
if (!nodeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let previewLocation = this.router.url;
|
||||
if (previewLocation.lastIndexOf('/') > 0) {
|
||||
previewLocation = previewLocation.substr(
|
||||
0,
|
||||
this.router.url.indexOf('/', 1)
|
||||
);
|
||||
}
|
||||
previewLocation = previewLocation.replace(/\//g, '');
|
||||
|
||||
const path = [previewLocation];
|
||||
if (parentId) {
|
||||
path.push(parentId);
|
||||
}
|
||||
path.push('preview', nodeId);
|
||||
this.router.navigateByUrl(path.join('/'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user