2018-11-04 19:28:32 +01:00
|
|
|
import {MediaDTO} from './MediaDTO';
|
2018-11-18 20:26:29 +01:00
|
|
|
import {PhotoDTO} from './PhotoDTO';
|
2018-11-26 00:26:29 +01:00
|
|
|
import {FileDTO} from './FileDTO';
|
2016-12-27 20:55:51 +01:00
|
|
|
|
|
|
|
export interface DirectoryDTO {
|
2017-06-10 22:32:56 +02:00
|
|
|
id: number;
|
|
|
|
name: string;
|
|
|
|
path: string;
|
2017-07-19 20:47:09 +02:00
|
|
|
lastModified: number;
|
|
|
|
lastScanned: number;
|
2017-07-21 19:14:22 +02:00
|
|
|
isPartial?: boolean;
|
2017-06-10 22:32:56 +02:00
|
|
|
parent: DirectoryDTO;
|
2019-01-06 23:15:52 +01:00
|
|
|
mediaCount: number;
|
|
|
|
directories: DirectoryDTO[];
|
2018-11-04 19:28:32 +01:00
|
|
|
media: MediaDTO[];
|
2018-11-26 00:26:29 +01:00
|
|
|
metaFile: FileDTO[];
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2017-07-08 00:18:24 +02:00
|
|
|
|
2017-07-09 12:03:17 +02:00
|
|
|
export module DirectoryDTO {
|
|
|
|
export const addReferences = (dir: DirectoryDTO): void => {
|
2018-11-24 11:50:11 +01:00
|
|
|
dir.media.forEach((media: MediaDTO) => {
|
|
|
|
media.directory = dir;
|
2017-07-08 00:18:24 +02:00
|
|
|
});
|
2018-11-30 15:37:01 +01:00
|
|
|
|
|
|
|
if (dir.metaFile) {
|
|
|
|
dir.metaFile.forEach((file: FileDTO) => {
|
|
|
|
file.directory = dir;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir.directories) {
|
|
|
|
dir.directories.forEach((directory: DirectoryDTO) => {
|
|
|
|
addReferences(directory);
|
|
|
|
directory.parent = dir;
|
|
|
|
});
|
|
|
|
}
|
2018-05-12 12:19:51 -04:00
|
|
|
};
|
2018-11-18 20:26:29 +01:00
|
|
|
|
2018-11-24 11:50:11 +01:00
|
|
|
export const removeReferences = (dir: DirectoryDTO): void => {
|
2018-12-18 00:05:12 +01:00
|
|
|
if (dir.media) {
|
|
|
|
dir.media.forEach((media: MediaDTO) => {
|
|
|
|
media.directory = null;
|
|
|
|
});
|
|
|
|
}
|
2018-11-26 00:26:29 +01:00
|
|
|
if (dir.metaFile) {
|
|
|
|
dir.metaFile.forEach((file: FileDTO) => {
|
|
|
|
file.directory = null;
|
|
|
|
});
|
|
|
|
}
|
2018-11-24 11:50:11 +01:00
|
|
|
if (dir.directories) {
|
|
|
|
dir.directories.forEach((directory: DirectoryDTO) => {
|
|
|
|
removeReferences(directory);
|
|
|
|
directory.parent = null;
|
|
|
|
});
|
|
|
|
}
|
2018-11-18 20:26:29 +01:00
|
|
|
|
|
|
|
};
|
2017-07-08 00:18:24 +02:00
|
|
|
}
|