mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-05-13 22:06:35 +02:00
package update
This commit is contained in:
parent
2036db563d
commit
f68fdafb0e
@ -9,7 +9,6 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"assets": [
|
"assets": [
|
||||||
"assets",
|
"assets",
|
||||||
"favicon.ico",
|
|
||||||
"config_inject.ejs"
|
"config_inject.ejs"
|
||||||
],
|
],
|
||||||
"index": "index.html",
|
"index": "index.html",
|
||||||
|
5
COMPARE.md
Normal file
5
COMPARE.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
| |PiGallery |PiGallery2 |
|
||||||
|
|-----------------|------------|-------------|
|
||||||
|
|Idle memory usage| 8-10Mb | 6-8MB |
|
||||||
|
|Load memory usage| 60-100Mb | 6-8MB |
|
@ -59,12 +59,19 @@ npm start
|
|||||||
To configure it. Run `PiGallery2` first to create `config.json` file, then edit it and restart.
|
To configure it. Run `PiGallery2` first to create `config.json` file, then edit it and restart.
|
||||||
Default user: `admin` pass: `admin`
|
Default user: `admin` pass: `admin`
|
||||||
|
|
||||||
|
|
||||||
### Using nginx
|
### Using nginx
|
||||||
https://stackoverflow.com/questions/5009324/node-js-nginx-what-now
|
https://stackoverflow.com/questions/5009324/node-js-nginx-what-now
|
||||||
|
|
||||||
### making https
|
### making https
|
||||||
https://certbot.eff.org/
|
https://certbot.eff.org/
|
||||||
|
|
||||||
|
### node install error:
|
||||||
|
If you get error during module installation, make sure you have everything to build node modules from source
|
||||||
|
```bash
|
||||||
|
apt-get install build-essential libkrb5-dev gcc g++
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Feature list
|
## Feature list
|
||||||
|
|
||||||
* **Rendering directories as it is**
|
* **Rendering directories as it is**
|
||||||
|
@ -5,7 +5,7 @@ import * as fs from "fs";
|
|||||||
import {DirectoryEntity} from "./enitites/DirectoryEntity";
|
import {DirectoryEntity} from "./enitites/DirectoryEntity";
|
||||||
import {SQLConnection} from "./SQLConnection";
|
import {SQLConnection} from "./SQLConnection";
|
||||||
import {DiskManager} from "../DiskManger";
|
import {DiskManager} from "../DiskManger";
|
||||||
import {PhotoEntity, PhotoMetadataEntity} from "./enitites/PhotoEntity";
|
import {PhotoEntity} from "./enitites/PhotoEntity";
|
||||||
import {Utils} from "../../../common/Utils";
|
import {Utils} from "../../../common/Utils";
|
||||||
import {ProjectPath} from "../../ProjectPath";
|
import {ProjectPath} from "../../ProjectPath";
|
||||||
import {Config} from "../../../common/config/private/Config";
|
import {Config} from "../../../common/config/private/Config";
|
||||||
@ -37,7 +37,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
|
|
||||||
|
|
||||||
if (dir && dir.scanned == true) {
|
if (dir && dir.scanned == true) {
|
||||||
//iF it seems that the content did not changed, do not work on it
|
//If it seems that the content did not changed, do not work on it
|
||||||
if (knownLastModified && knownLastScanned
|
if (knownLastModified && knownLastScanned
|
||||||
&& lastModified == knownLastModified &&
|
&& lastModified == knownLastModified &&
|
||||||
dir.lastScanned == knownLastScanned) {
|
dir.lastScanned == knownLastScanned) {
|
||||||
@ -53,7 +53,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
if (dir.photos) {
|
if (dir.photos) {
|
||||||
for (let i = 0; i < dir.photos.length; i++) {
|
for (let i = 0; i < dir.photos.length; i++) {
|
||||||
dir.photos[i].directory = dir;
|
dir.photos[i].directory = dir;
|
||||||
PhotoMetadataEntity.open(dir.photos[i].metadata);
|
//PhotoMetadataEntity.open(dir.photos[i].metadata);
|
||||||
dir.photos[i].readyThumbnails = [];
|
dir.photos[i].readyThumbnails = [];
|
||||||
dir.photos[i].readyIcon = false;
|
dir.photos[i].readyIcon = false;
|
||||||
}
|
}
|
||||||
@ -67,13 +67,13 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
dir: dir.directories[i].id
|
dir: dir.directories[i].id
|
||||||
})
|
})
|
||||||
.orderBy("photo.metadata.creationDate", "ASC")
|
.orderBy("photo.metadata.creationDate", "ASC")
|
||||||
.setLimit(Config.Server.indexing.folderPreviewSize)
|
.limit(Config.Server.indexing.folderPreviewSize)
|
||||||
.getMany();
|
.getMany();
|
||||||
dir.directories[i].isPartial = true;
|
dir.directories[i].isPartial = true;
|
||||||
|
|
||||||
for (let j = 0; j < dir.directories[i].photos.length; j++) {
|
for (let j = 0; j < dir.directories[i].photos.length; j++) {
|
||||||
dir.directories[i].photos[j].directory = dir.directories[i];
|
dir.directories[i].photos[j].directory = dir.directories[i];
|
||||||
PhotoMetadataEntity.open(dir.directories[i].photos[j].metadata);
|
// PhotoMetadataEntity.open(dir.directories[i].photos[j].metadata);
|
||||||
dir.directories[i].photos[j].readyThumbnails = [];
|
dir.directories[i].photos[j].readyThumbnails = [];
|
||||||
dir.directories[i].photos[j].readyIcon = false;
|
dir.directories[i].photos[j].readyIcon = false;
|
||||||
}
|
}
|
||||||
@ -123,14 +123,14 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
path: scannedDirectory.path
|
path: scannedDirectory.path
|
||||||
}).getOne();
|
}).getOne();
|
||||||
|
|
||||||
if (!!parentDir) {
|
if (!!parentDir) {//Updated parent dir (if it was in the DB previously)
|
||||||
parentDir.scanned = true;
|
parentDir.scanned = true;
|
||||||
parentDir.lastModified = scannedDirectory.lastModified;
|
parentDir.lastModified = scannedDirectory.lastModified;
|
||||||
parentDir.lastScanned = scannedDirectory.lastScanned;
|
parentDir.lastScanned = scannedDirectory.lastScanned;
|
||||||
parentDir = await directoryRepository.persist(parentDir);
|
parentDir = await directoryRepository.save(parentDir);
|
||||||
} else {
|
} else {
|
||||||
(<DirectoryEntity>scannedDirectory).scanned = true;
|
(<DirectoryEntity>scannedDirectory).scanned = true;
|
||||||
parentDir = await directoryRepository.persist(<DirectoryEntity>scannedDirectory);
|
parentDir = await directoryRepository.save(<DirectoryEntity>scannedDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
let indexedDirectories = await directoryRepository.createQueryBuilder("directory")
|
let indexedDirectories = await directoryRepository.createQueryBuilder("directory")
|
||||||
@ -140,6 +140,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
|
|
||||||
for (let i = 0; i < scannedDirectory.directories.length; i++) {
|
for (let i = 0; i < scannedDirectory.directories.length; i++) {
|
||||||
|
|
||||||
|
//Was this child Dir already indexed before?
|
||||||
let directory: DirectoryEntity = null;
|
let directory: DirectoryEntity = null;
|
||||||
for (let j = 0; j < indexedDirectories.length; j++) {
|
for (let j = 0; j < indexedDirectories.length; j++) {
|
||||||
if (indexedDirectories[j].name == scannedDirectory.directories[i].name) {
|
if (indexedDirectories[j].name == scannedDirectory.directories[i].name) {
|
||||||
@ -149,25 +150,26 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directory) { //update existing directory
|
if (directory != null) { //update existing directory
|
||||||
if (!directory.parent && !directory.parent.id) {
|
if (!directory.parent && !directory.parent.id) {
|
||||||
directory.parent = parentDir;
|
directory.parent = parentDir;
|
||||||
delete directory.photos;
|
delete directory.photos;
|
||||||
await directoryRepository.persist(directory);
|
await directoryRepository.save(directory);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scannedDirectory.directories[i].parent = parentDir;
|
scannedDirectory.directories[i].parent = parentDir;
|
||||||
(<DirectoryEntity>scannedDirectory.directories[i]).scanned = false;
|
(<DirectoryEntity>scannedDirectory.directories[i]).scanned = false;
|
||||||
const d = await directoryRepository.persist(<DirectoryEntity>scannedDirectory.directories[i]);
|
const d = await directoryRepository.save(<DirectoryEntity>scannedDirectory.directories[i]);
|
||||||
for (let j = 0; j < scannedDirectory.directories[i].photos.length; j++) {
|
for (let j = 0; j < scannedDirectory.directories[i].photos.length; j++) {
|
||||||
PhotoMetadataEntity.close(scannedDirectory.directories[i].photos[j].metadata);
|
// PhotoMetadataEntity.close(scannedDirectory.directories[i].photos[j].metadata);
|
||||||
scannedDirectory.directories[i].photos[j].directory = d;
|
scannedDirectory.directories[i].photos[j].directory = d;
|
||||||
|
|
||||||
}
|
}
|
||||||
await photosRepository.persist(scannedDirectory.directories[i].photos);
|
|
||||||
|
await photosRepository.save(scannedDirectory.directories[i].photos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Remove child Dirs that are not anymore in the parent dir
|
||||||
await directoryRepository.remove(indexedDirectories);
|
await directoryRepository.remove(indexedDirectories);
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//typeorm not supports recursive embended: TODO:fix it
|
//typeorm not supports recursive embended: TODO:fix it
|
||||||
PhotoMetadataEntity.close(scannedDirectory.photos[i].metadata);
|
// PhotoMetadataEntity.close(scannedDirectory.photos[i].metadata);
|
||||||
|
|
||||||
if (photo.metadata.keywords != scannedDirectory.photos[i].metadata.keywords ||
|
if (photo.metadata.keywords != scannedDirectory.photos[i].metadata.keywords ||
|
||||||
photo.metadata.cameraData != scannedDirectory.photos[i].metadata.cameraData ||
|
photo.metadata.cameraData != scannedDirectory.photos[i].metadata.cameraData ||
|
||||||
@ -209,7 +211,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
photosToSave.push(photo);
|
photosToSave.push(photo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await photosRepository.persist(photosToSave);
|
await photosRepository.save(photosToSave);
|
||||||
await photosRepository.remove(indexedPhotos);
|
await photosRepository.remove(indexedPhotos);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import {Connection, createConnection, DriverOptions, getConnection} from "typeorm";
|
import {Connection, ConnectionOptions, createConnection, getConnection} from "typeorm";
|
||||||
import {UserEntity} from "./enitites/UserEntity";
|
import {UserEntity} from "./enitites/UserEntity";
|
||||||
import {UserRoles} from "../../../common/entities/UserDTO";
|
import {UserRoles} from "../../../common/entities/UserDTO";
|
||||||
import {PhotoEntity, PhotoMetadataEntity} from "./enitites/PhotoEntity";
|
import {PhotoEntity} from "./enitites/PhotoEntity";
|
||||||
import {DirectoryEntity} from "./enitites/DirectoryEntity";
|
import {DirectoryEntity} from "./enitites/DirectoryEntity";
|
||||||
import {Config} from "../../../common/config/private/Config";
|
import {Config} from "../../../common/config/private/Config";
|
||||||
import {SharingEntity} from "./enitites/SharingEntity";
|
import {SharingEntity} from "./enitites/SharingEntity";
|
||||||
@ -24,24 +24,20 @@ export class SQLConnection {
|
|||||||
|
|
||||||
if (this.connection == null) {
|
if (this.connection == null) {
|
||||||
|
|
||||||
this.connection = await createConnection({
|
let options: any = this.getDriver(Config.Server.database);
|
||||||
name: "main",
|
options.name = "main";
|
||||||
driver: this.getDriver(Config.Server.database),
|
options.entities = [
|
||||||
entities: [
|
|
||||||
UserEntity,
|
UserEntity,
|
||||||
DirectoryEntity,
|
DirectoryEntity,
|
||||||
PhotoMetadataEntity,
|
|
||||||
PhotoEntity,
|
PhotoEntity,
|
||||||
SharingEntity
|
SharingEntity
|
||||||
],
|
];
|
||||||
autoSchemaSync: true,
|
options.synchronize = true;
|
||||||
/* logging: {
|
|
||||||
logQueries: true,
|
//options.logging = "all" ;
|
||||||
logOnlyFailedQueries: true,
|
|
||||||
logFailedQueryError: true,
|
|
||||||
logSchemaCreation: true
|
this.connection = await createConnection(options);
|
||||||
}*/
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return this.connection;
|
return this.connection;
|
||||||
|
|
||||||
@ -52,16 +48,29 @@ export class SQLConnection {
|
|||||||
await getConnection("test").close();
|
await getConnection("test").close();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
}
|
}
|
||||||
const conn = await createConnection({
|
let options: any = this.getDriver(config);
|
||||||
name: "test",
|
options.name = "test";
|
||||||
driver: this.getDriver(config)
|
const conn = await createConnection(options);
|
||||||
});
|
|
||||||
await conn.close();
|
await conn.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getDriver(config: DataBaseConfig): DriverOptions {
|
public static async init(): Promise<void> {
|
||||||
let driver: DriverOptions = null;
|
const connection = await this.getConnection();
|
||||||
|
let userRepository = connection.getRepository(UserEntity);
|
||||||
|
let admins = await userRepository.find({role: UserRoles.Admin});
|
||||||
|
if (admins.length == 0) {
|
||||||
|
let a = new UserEntity();
|
||||||
|
a.name = "admin";
|
||||||
|
a.password = PasswordHelper.cryptPassword("admin");
|
||||||
|
a.role = UserRoles.Admin;
|
||||||
|
await userRepository.save(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getDriver(config: DataBaseConfig): ConnectionOptions {
|
||||||
|
let driver: ConnectionOptions = null;
|
||||||
if (config.type == DatabaseType.mysql) {
|
if (config.type == DatabaseType.mysql) {
|
||||||
driver = {
|
driver = {
|
||||||
type: "mysql",
|
type: "mysql",
|
||||||
@ -74,26 +83,12 @@ export class SQLConnection {
|
|||||||
} else if (config.type == DatabaseType.sqlite) {
|
} else if (config.type == DatabaseType.sqlite) {
|
||||||
driver = {
|
driver = {
|
||||||
type: "sqlite",
|
type: "sqlite",
|
||||||
storage: ProjectPath.getAbsolutePath(config.sqlite.storage)
|
database: ProjectPath.getAbsolutePath(config.sqlite.storage)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async init(): Promise<void> {
|
|
||||||
const connection = await this.getConnection();
|
|
||||||
let userRepository = connection.getRepository(UserEntity);
|
|
||||||
let admins = await userRepository.find({role: UserRoles.Admin});
|
|
||||||
if (admins.length == 0) {
|
|
||||||
let a = new UserEntity();
|
|
||||||
a.name = "admin";
|
|
||||||
a.password = PasswordHelper.cryptPassword("admin");
|
|
||||||
a.role = UserRoles.Admin;
|
|
||||||
await userRepository.persist(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async close() {
|
public static async close() {
|
||||||
try {
|
try {
|
||||||
await getConnection().close();
|
await getConnection().close();
|
||||||
|
@ -21,7 +21,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.createQueryBuilder('photo')
|
.createQueryBuilder('photo')
|
||||||
.select('DISTINCT(photo.metadataKeywords)')
|
.select('DISTINCT(photo.metadataKeywords)')
|
||||||
.where('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(5)
|
.limit(5)
|
||||||
.getRawMany())
|
.getRawMany())
|
||||||
.map(r => <Array<string>>JSON.parse(r.metadataKeywords))
|
.map(r => <Array<string>>JSON.parse(r.metadataKeywords))
|
||||||
.forEach(keywords => {
|
.forEach(keywords => {
|
||||||
@ -33,7 +33,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.createQueryBuilder('photo')
|
.createQueryBuilder('photo')
|
||||||
.select('DISTINCT(photo.metadataPositionData)')
|
.select('DISTINCT(photo.metadataPositionData)')
|
||||||
.where('photo.metadata.positionData LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('photo.metadata.positionData LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(5)
|
.limit(5)
|
||||||
.getRawMany())
|
.getRawMany())
|
||||||
.map(r => <PositionMetaData>JSON.parse(r.metadataPositionData))
|
.map(r => <PositionMetaData>JSON.parse(r.metadataPositionData))
|
||||||
.filter(pm => !!pm)
|
.filter(pm => !!pm)
|
||||||
@ -47,7 +47,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.createQueryBuilder('photo')
|
.createQueryBuilder('photo')
|
||||||
.select('DISTINCT(photo.name)')
|
.select('DISTINCT(photo.name)')
|
||||||
.where('photo.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('photo.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(5)
|
.limit(5)
|
||||||
.getRawMany())
|
.getRawMany())
|
||||||
.map(r => r.name), SearchTypes.image));
|
.map(r => r.name), SearchTypes.image));
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.createQueryBuilder('dir')
|
.createQueryBuilder('dir')
|
||||||
.select('DISTINCT(dir.name)')
|
.select('DISTINCT(dir.name)')
|
||||||
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(5)
|
.limit(5)
|
||||||
.getRawMany())
|
.getRawMany())
|
||||||
.map(r => r.name), SearchTypes.directory));
|
.map(r => r.name), SearchTypes.directory));
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
query.orWhere('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"});
|
query.orWhere('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"});
|
||||||
}
|
}
|
||||||
let photos = await query
|
let photos = await query
|
||||||
.setLimit(2001)
|
.limit(2001)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.getRepository(DirectoryEntity)
|
.getRepository(DirectoryEntity)
|
||||||
.createQueryBuilder("dir")
|
.createQueryBuilder("dir")
|
||||||
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(201)
|
.limit(201)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
if (result.directories.length > 200) {
|
if (result.directories.length > 200) {
|
||||||
@ -145,7 +145,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.orWhere('photo.metadata.positionData LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.orWhere('photo.metadata.positionData LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.orWhere('photo.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.orWhere('photo.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.innerJoinAndSelect("photo.directory", "directory")
|
.innerJoinAndSelect("photo.directory", "directory")
|
||||||
.setLimit(10)
|
.limit(10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ export class SearchManager implements ISearchManager {
|
|||||||
.getRepository(DirectoryEntity)
|
.getRepository(DirectoryEntity)
|
||||||
.createQueryBuilder("dir")
|
.createQueryBuilder("dir")
|
||||||
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||||
.setLimit(10)
|
.limit(10)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
result.directories = directories;
|
result.directories = directories;
|
||||||
|
@ -19,7 +19,7 @@ export class SharingManager implements ISharingManager {
|
|||||||
if (sharing.password) {
|
if (sharing.password) {
|
||||||
sharing.password = PasswordHelper.cryptPassword(sharing.password);
|
sharing.password = PasswordHelper.cryptPassword(sharing.password);
|
||||||
}
|
}
|
||||||
return await connection.getRepository(SharingEntity).persist(sharing);
|
return await connection.getRepository(SharingEntity).save(sharing);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ export class SharingManager implements ISharingManager {
|
|||||||
|
|
||||||
let sharing = await connection.getRepository(SharingEntity).findOne({
|
let sharing = await connection.getRepository(SharingEntity).findOne({
|
||||||
id: inSharing.id,
|
id: inSharing.id,
|
||||||
creator: inSharing.creator.id,
|
creator: inSharing.creator,
|
||||||
path: inSharing.path
|
path: inSharing.path
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export class SharingManager implements ISharingManager {
|
|||||||
sharing.includeSubfolders = inSharing.includeSubfolders;
|
sharing.includeSubfolders = inSharing.includeSubfolders;
|
||||||
sharing.expires = inSharing.expires;
|
sharing.expires = inSharing.expires;
|
||||||
|
|
||||||
return await connection.getRepository(SharingEntity).persist(sharing);
|
return await connection.getRepository(SharingEntity).save(sharing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async removeExpiredLink() {
|
private async removeExpiredLink() {
|
||||||
|
@ -44,7 +44,7 @@ export class UserManager implements IUserManager {
|
|||||||
user.permissions = <any>JSON.stringify(<any>user.permissions);
|
user.permissions = <any>JSON.stringify(<any>user.permissions);
|
||||||
}
|
}
|
||||||
user.password = PasswordHelper.cryptPassword(user.password);
|
user.password = PasswordHelper.cryptPassword(user.password);
|
||||||
return await connection.getRepository(UserEntity).persist(user);
|
return await connection.getRepository(UserEntity).save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteUser(id: number) {
|
public async deleteUser(id: number) {
|
||||||
@ -59,7 +59,7 @@ export class UserManager implements IUserManager {
|
|||||||
let userRepository = connection.getRepository(UserEntity);
|
let userRepository = connection.getRepository(UserEntity);
|
||||||
const user = await userRepository.findOne({id: id});
|
const user = await userRepository.findOne({id: id});
|
||||||
user.role = newRole;
|
user.role = newRole;
|
||||||
return await userRepository.persist(user);
|
return await userRepository.save(user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ export class DirectoryEntity implements DirectoryDTO {
|
|||||||
@Column()
|
@Column()
|
||||||
path: string;
|
path: string;
|
||||||
|
|
||||||
@Column()
|
@Column('bigint')
|
||||||
public lastModified: number;
|
public lastModified: number;
|
||||||
@Column()
|
@Column('bigint')
|
||||||
public lastScanned: number;
|
public lastScanned: number;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {Column, EmbeddableEntity, Embedded, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
||||||
import {DirectoryDTO} from "../../../../common/entities/DirectoryDTO";
|
import {DirectoryDTO} from "../../../../common/entities/DirectoryDTO";
|
||||||
import {
|
import {
|
||||||
CameraMetadata,
|
CameraMetadata,
|
||||||
|
GPSMetadata,
|
||||||
ImageSize,
|
ImageSize,
|
||||||
PhotoDTO,
|
PhotoDTO,
|
||||||
PhotoMetadata,
|
PhotoMetadata,
|
||||||
@ -9,28 +10,49 @@ import {
|
|||||||
} from "../../../../common/entities/PhotoDTO";
|
} from "../../../../common/entities/PhotoDTO";
|
||||||
import {DirectoryEntity} from "./DirectoryEntity";
|
import {DirectoryEntity} from "./DirectoryEntity";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class PhotoEntity implements PhotoDTO {
|
||||||
|
|
||||||
@EmbeddableEntity()
|
@PrimaryGeneratedColumn()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("text")
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@ManyToOne(type => DirectoryEntity, directory => directory.photos, {onDelete: "CASCADE"})
|
||||||
|
directory: DirectoryDTO;
|
||||||
|
|
||||||
|
@Column(type => PhotoMetadataEntity)
|
||||||
|
metadata: PhotoMetadataEntity;
|
||||||
|
|
||||||
|
readyThumbnails: Array<number> = [];
|
||||||
|
|
||||||
|
readyIcon: boolean = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Entity()
|
||||||
export class PhotoMetadataEntity implements PhotoMetadata {
|
export class PhotoMetadataEntity implements PhotoMetadata {
|
||||||
|
|
||||||
@Column("string")
|
@Column("simple-array")
|
||||||
keywords: Array<string>;
|
keywords: Array<string>;
|
||||||
|
|
||||||
@Column("string")
|
@Column(type => CameraMetadataEntity)
|
||||||
cameraData: CameraMetadata;
|
cameraData: CameraMetadataEntity;
|
||||||
|
|
||||||
@Column("string")
|
@Column(type => PositionMetaDataEntity)
|
||||||
positionData: PositionMetaData;
|
positionData: PositionMetaDataEntity;
|
||||||
|
|
||||||
@Column("string")
|
@Column(type => ImageSizeEntity)
|
||||||
size: ImageSize;
|
size: ImageSizeEntity;
|
||||||
|
|
||||||
@Column("number")
|
@Column("bigint")
|
||||||
creationDate: number;
|
creationDate: number;
|
||||||
|
|
||||||
@Column("number")
|
@Column("int")
|
||||||
fileSize: number;
|
fileSize: number;
|
||||||
|
/*
|
||||||
//TODO: fixit after typeorm update
|
//TODO: fixit after typeorm update
|
||||||
public static open(m: PhotoMetadataEntity) {
|
public static open(m: PhotoMetadataEntity) {
|
||||||
m.keywords = <any>JSON.parse(<any>m.keywords);
|
m.keywords = <any>JSON.parse(<any>m.keywords);
|
||||||
@ -45,92 +67,70 @@ export class PhotoMetadataEntity implements PhotoMetadata {
|
|||||||
m.cameraData = <any>JSON.stringify(<any>m.cameraData);
|
m.cameraData = <any>JSON.stringify(<any>m.cameraData);
|
||||||
m.positionData = <any>JSON.stringify(<any>m.positionData);
|
m.positionData = <any>JSON.stringify(<any>m.positionData);
|
||||||
m.size = <any>JSON.stringify(<any>m.size);
|
m.size = <any>JSON.stringify(<any>m.size);
|
||||||
}
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class CameraMetadataEntity implements CameraMetadata {
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
ISO: number;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
model: string;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
maker: string;
|
||||||
|
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
fStop: number;
|
||||||
|
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
exposure: number;
|
||||||
|
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
focalLength: number;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
lens: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class PositionMetaDataEntity implements PositionMetaData {
|
||||||
|
|
||||||
|
@Column(type => GPSMetadataEntity)
|
||||||
|
GPSData: GPSMetadataEntity;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
country: string;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
state: string;
|
||||||
|
|
||||||
|
@Column("text", {nullable: true})
|
||||||
|
city: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class GPSMetadataEntity implements GPSMetadata {
|
||||||
|
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
latitude: number;
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
longitude: number;
|
||||||
|
@Column("int", {nullable: true})
|
||||||
|
altitude: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class PhotoEntity implements PhotoDTO {
|
export class ImageSizeEntity implements ImageSize {
|
||||||
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@ManyToOne(type => DirectoryEntity, directory => directory.photos, {onDelete: "CASCADE"})
|
|
||||||
directory: DirectoryDTO;
|
|
||||||
|
|
||||||
@Embedded(type => PhotoMetadataEntity)
|
|
||||||
metadata: PhotoMetadataEntity;
|
|
||||||
|
|
||||||
readyThumbnails: Array<number> = [];
|
|
||||||
|
|
||||||
readyIcon: boolean = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
@EmbeddableTable()
|
|
||||||
export class CameraMetadataEntity implements CameraMetadata {
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
ISO: number;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
model: string;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
maker: string;
|
|
||||||
|
|
||||||
@Column("int")
|
|
||||||
fStop: number;
|
|
||||||
|
|
||||||
@Column("int")
|
|
||||||
exposure: number;
|
|
||||||
|
|
||||||
@Column("int")
|
|
||||||
focalLength: number;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
lens: string;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
|
|
||||||
@EmbeddableTable()
|
|
||||||
export class PositionMetaDataEntity implements PositionMetaData {
|
|
||||||
|
|
||||||
@Embedded(type => GPSMetadataEntity)
|
|
||||||
GPSData: GPSMetadataEntity;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
country: string;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
state: string;
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
city: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@EmbeddableTable()
|
|
||||||
export class GPSMetadataEntity implements GPSMetadata {
|
|
||||||
|
|
||||||
@Column("string")
|
|
||||||
latitude: string;
|
|
||||||
@Column("string")
|
|
||||||
longitude: string;
|
|
||||||
@Column("string")
|
|
||||||
altitude: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EmbeddableTable()
|
|
||||||
export class ImageSizeEntity implements ImageSize {
|
|
||||||
|
|
||||||
@Column("int")
|
@Column("int")
|
||||||
width: number;
|
width: number;
|
||||||
|
|
||||||
@Column("int")
|
@Column("int")
|
||||||
height: number;
|
height: number;
|
||||||
}*/
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Column, EmbeddableEntity, Embedded, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
||||||
import {SharingDTO} from "../../../../common/entities/SharingDTO";
|
import {SharingDTO} from "../../../../common/entities/SharingDTO";
|
||||||
import {UserEntity} from "./UserEntity";
|
import {UserEntity} from "./UserEntity";
|
||||||
import {UserDTO} from "../../../../common/entities/UserDTO";
|
import {UserDTO} from "../../../../common/entities/UserDTO";
|
||||||
@ -8,22 +8,22 @@ export class SharingEntity implements SharingDTO {
|
|||||||
@PrimaryGeneratedColumn()
|
@PrimaryGeneratedColumn()
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
@Column("string")
|
@Column()
|
||||||
sharingKey: string;
|
sharingKey: string;
|
||||||
|
|
||||||
@Column("string")
|
@Column()
|
||||||
path: string;
|
path: string;
|
||||||
|
|
||||||
@Column("string", {nullable: true})
|
@Column({type: "text", nullable: true})
|
||||||
password: string;
|
password: string;
|
||||||
|
|
||||||
@Column("number")
|
@Column()
|
||||||
expires: number;
|
expires: number;
|
||||||
|
|
||||||
@Column("number")
|
@Column()
|
||||||
timeStamp: number;
|
timeStamp: number;
|
||||||
|
|
||||||
@Column("boolean")
|
@Column()
|
||||||
includeSubfolders: boolean;
|
includeSubfolders: boolean;
|
||||||
|
|
||||||
@ManyToOne(type => UserEntity)
|
@ManyToOne(type => UserEntity)
|
||||||
|
@ -16,7 +16,7 @@ export class UserEntity implements UserDTO {
|
|||||||
@Column("smallint")
|
@Column("smallint")
|
||||||
role: UserRoles;
|
role: UserRoles;
|
||||||
|
|
||||||
@Column("string", {nullable: true})
|
@Column("text", {nullable: true})
|
||||||
permissions: string[];
|
permissions: string[];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,12 @@ export class Server {
|
|||||||
keys: ["key1" + s4() + s4() + s4() + s4(), "key2" + s4() + s4() + s4() + s4(), "key3" + s4() + s4() + s4() + s4()]
|
keys: ["key1" + s4() + s4() + s4() + s4(), "key2" + s4() + s4() + s4() + s4(), "key3" + s4() + s4() + s4() + s4()]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
/* this.app.use((req: Request, res: Response, next: NextFunction) => {
|
||||||
|
res.setHeader('Accept-Ranges', 'none');
|
||||||
|
res.setHeader('Connection', 'close');
|
||||||
|
next();
|
||||||
|
});*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse parameters in POST
|
* Parse parameters in POST
|
||||||
*/
|
*/
|
||||||
|
@ -5,12 +5,12 @@ var runSequence = require('run-sequence');
|
|||||||
var jsonModify = require('gulp-json-modify');
|
var jsonModify = require('gulp-json-modify');
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
|
||||||
var tsProject = ts.createProject('tsconfig.json');
|
var tsBackendProject = ts.createProject('backend/tsconfig.json');
|
||||||
gulp.task('build-backend', function () {
|
gulp.task('build-backend', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
"common/**/*.ts",
|
"common/**/*.ts",
|
||||||
"backend/**/*.ts"], {base: "."})
|
"backend/**/*.ts"], {base: "."})
|
||||||
.pipe(tsProject())
|
.pipe(tsBackendProject())
|
||||||
.js
|
.js
|
||||||
.pipe(gulp.dest("./release"))
|
.pipe(gulp.dest("./release"))
|
||||||
|
|
||||||
|
101
package.json
101
package.json
@ -26,58 +26,59 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"body-parser": "1.17.2",
|
"body-parser": "1.18.2",
|
||||||
"cookie-session": "^2.0.0-beta.2",
|
"cookie-session": "^2.0.0-beta.3",
|
||||||
"ejs": "2.5.7",
|
"ejs": "2.5.7",
|
||||||
"express": "4.15.3",
|
"express": "4.16.2",
|
||||||
"jimp": "0.2.28",
|
"jimp": "0.2.28",
|
||||||
|
"mysql": "^2.15.0",
|
||||||
"reflect-metadata": "0.1.10",
|
"reflect-metadata": "0.1.10",
|
||||||
"sqlite3": "^3.1.8",
|
"sqlite3": "^3.1.13",
|
||||||
"ts-exif-parser": "^0.1.23",
|
"ts-exif-parser": "^0.1.23",
|
||||||
"ts-node-iptc": "^1.0.9",
|
"ts-node-iptc": "^1.0.9",
|
||||||
"typeconfig": "1.0.4",
|
"typeconfig": "1.0.4",
|
||||||
"typeorm": "0.0.11",
|
"typeorm": "0.1.1",
|
||||||
"winston": "2.3.1"
|
"winston": "2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@agm/core": "^1.0.0-beta.0",
|
"@agm/core": "^1.0.0-beta.1",
|
||||||
"@angular/animations": "^4.3.2",
|
"@angular/animations": "^4.4.6",
|
||||||
"@angular/cli": "1.2.6",
|
"@angular/cli": "1.4.8",
|
||||||
"@angular/common": "~4.3.2",
|
"@angular/common": "~4.4.6",
|
||||||
"@angular/compiler": "~4.3.2",
|
"@angular/compiler": "~4.4.6",
|
||||||
"@angular/compiler-cli": "^4.3.2",
|
"@angular/compiler-cli": "^4.4.6",
|
||||||
"@angular/core": "~4.3.2",
|
"@angular/core": "~4.4.6",
|
||||||
"@angular/forms": "~4.3.2",
|
"@angular/forms": "~4.4.6",
|
||||||
"@angular/http": "~4.3.2",
|
"@angular/http": "~4.4.6",
|
||||||
"@angular/language-service": "^4.3.2",
|
"@angular/language-service": "^4.4.6",
|
||||||
"@angular/platform-browser": "~4.3.2",
|
"@angular/platform-browser": "~4.4.6",
|
||||||
"@angular/platform-browser-dynamic": "~4.3.2",
|
"@angular/platform-browser-dynamic": "~4.4.6",
|
||||||
"@angular/router": "~4.3.2",
|
"@angular/router": "~4.4.6",
|
||||||
"@types/bcryptjs": "^2.4.0",
|
"@types/bcryptjs": "^2.4.1",
|
||||||
"@types/chai": "^4.0.1",
|
"@types/chai": "^4.0.4",
|
||||||
"@types/cookie-session": "^2.0.32",
|
"@types/cookie-session": "^2.0.33",
|
||||||
"@types/express": "^4.0.36",
|
"@types/express": "^4.0.37",
|
||||||
"@types/gm": "^1.17.31",
|
"@types/gm": "^1.17.33",
|
||||||
"@types/jasmine": "^2.5.53",
|
"@types/jasmine": "^2.6.0",
|
||||||
"@types/jimp": "^0.2.1",
|
"@types/jimp": "^0.2.1",
|
||||||
"@types/node": "^8.0.17",
|
"@types/node": "^8.0.45",
|
||||||
"@types/sharp": "^0.17.2",
|
"@types/sharp": "^0.17.4",
|
||||||
"@types/winston": "^2.3.4",
|
"@types/winston": "^2.3.6",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"chai": "^4.1.0",
|
"chai": "^4.1.2",
|
||||||
"codelyzer": "~3.1.2",
|
"codelyzer": "~3.2.1",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.5.1",
|
||||||
"ejs-loader": "^0.3.0",
|
"ejs-loader": "^0.3.0",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-json-modify": "^1.0.2",
|
"gulp-json-modify": "^1.0.2",
|
||||||
"gulp-typescript": "^3.2.1",
|
"gulp-typescript": "^3.2.2",
|
||||||
"gulp-zip": "^4.0.0",
|
"gulp-zip": "^4.0.0",
|
||||||
"hammerjs": "^2.0.8",
|
"hammerjs": "^2.0.8",
|
||||||
"intl": "^1.2.5",
|
"intl": "^1.2.5",
|
||||||
"jasmine-core": "^2.7.0",
|
"jasmine-core": "^2.8.0",
|
||||||
"jasmine-spec-reporter": "~4.1.1",
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
"jw-bootstrap-switch-ng2": "^1.0.4",
|
"jw-bootstrap-switch-ng2": "^1.0.6",
|
||||||
"karma": "^1.7.0",
|
"karma": "^1.7.1",
|
||||||
"karma-cli": "^1.0.1",
|
"karma-cli": "^1.0.1",
|
||||||
"karma-coverage-istanbul-reporter": "^1.3.0",
|
"karma-coverage-istanbul-reporter": "^1.3.0",
|
||||||
"karma-jasmine": "^1.1.0",
|
"karma-jasmine": "^1.1.0",
|
||||||
@ -85,29 +86,29 @@
|
|||||||
"karma-phantomjs-launcher": "^1.0.4",
|
"karma-phantomjs-launcher": "^1.0.4",
|
||||||
"karma-remap-istanbul": "^0.6.0",
|
"karma-remap-istanbul": "^0.6.0",
|
||||||
"karma-systemjs": "^0.16.0",
|
"karma-systemjs": "^0.16.0",
|
||||||
"merge2": "^1.1.0",
|
"merge2": "^1.2.0",
|
||||||
"mocha": "^3.4.2",
|
"mocha": "^4.0.1",
|
||||||
"ng2-cookies": "^1.0.12",
|
"ng2-cookies": "^1.0.12",
|
||||||
"ng2-slim-loading-bar": "^4.0.0",
|
"ng2-slim-loading-bar": "^4.0.0",
|
||||||
"ng2-toastr": "^4.1.2",
|
"ng2-toastr": "^4.1.2",
|
||||||
"ngx-bootstrap": "^1.8.1",
|
"ngx-bootstrap": "^1.9.3",
|
||||||
"ngx-clipboard": "^8.0.3",
|
"ngx-clipboard": "^8.1.1",
|
||||||
"phantomjs-prebuilt": "^2.1.14",
|
"phantomjs-prebuilt": "^2.1.15",
|
||||||
"protractor": "^5.1.2",
|
"protractor": "^5.2.0",
|
||||||
"remap-istanbul": "^0.9.5",
|
"remap-istanbul": "^0.9.5",
|
||||||
"rimraf": "^2.6.1",
|
"rimraf": "^2.6.2",
|
||||||
"run-sequence": "^2.1.0",
|
"run-sequence": "^2.2.0",
|
||||||
"rxjs": "^5.4.2",
|
"rxjs": "^5.5.0",
|
||||||
"ts-helpers": "^1.1.2",
|
"ts-helpers": "^1.1.2",
|
||||||
"ts-node": "~3.3.0",
|
"ts-node": "~3.3.0",
|
||||||
"tslint": "^5.5.0",
|
"tslint": "^5.7.0",
|
||||||
"typescript": "^2.4.2",
|
"typescript": "^2.5.3",
|
||||||
"zone.js": "^0.8.16"
|
"zone.js": "^0.8.18"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"bcrypt": "^1.0.2",
|
"bcrypt": "^1.0.3",
|
||||||
"gm": "^1.23.0",
|
"gm": "^1.23.0",
|
||||||
"sharp": "^0.18.2"
|
"sharp": "^0.18.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 6.9"
|
"node": ">= 6.9"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user