1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-29 02:12:25 +02:00

refactoring notModified directory property

This commit is contained in:
Patrik Braun 2017-07-20 23:00:49 +02:00
parent 90c01c57be
commit 93ac783a09
20 changed files with 54 additions and 78 deletions

View File

@ -3,27 +3,7 @@ node_js:
- '7'
- '6'
before_deploy:
- npm i gulp -g
- gulp build-release
deploy:
provider: npm
email: bra.patrik@gmail.com
api_key:
secure: bMv+DrQgqKtx3RNsHqZUOl9L3Bp/i/MSZ52ix8rWXfl1QYFzo7nCnFdHxeq67qCCApdsBrPnOqRsnR5IjLSJGiKwyOxlXNCawLJRKJ+EoM8IAolrZP0zg5DhyifZJ40M0QS8fCetDqKVSO6S52rs4I0nc5whFZ6E9j4EfmkBRoGyPGoTPmGCJdK6JrlN7oftCVm18r7kt7lXcr1EvBqDloJC+M4BukQc4v0iAY/psMEgExvvroCwweQEhumWma7DO1hdiixRh8Pclz+VUQwAggVdP1yZGabqnX80/G+KrmpbNrAGIUdgzMHGG5HkiMrxPUU6LAcDQ+IzZ08u3MzVy//ij4zcom7C99oy5/AL4oWh6tZQtefji9MlOOX4SJNikmsfD2D9skHeGwbFuqEPjrjpUPWtUhW9RS5kr5Dt/LJwMs3ADi9nEsAYAkTip1nH9Ts1Yw+ooy3lCfzuMJGMBzZ6vNlMoAGNyTkrjIkGDL76XuBYvn0X3e3USn+KuKF9qO+N6wCw8zTxI2aetx+z6/5gGiiAHPKkFGGz+2jkl+2ZO4DcOX1lR6AgrHwT/52bQF3UQVT02mUohqfUnpn6rSpYkvh+u3e3GE59sqAPcRleEKdkp68KFSFDstzwF/m7uoAjOIHSfKUjN22s7FP818BulikEhHiCknMJsnOYUZ4=
on:
tags: true
repo: bpatrik/pigallery2
provider: releases
api_key:
secure: NrgDMoHY4j9r4Ht9oPT6cYiGkcpbNsvR6DxEk51kD5qVRPtUq+V5gpIo0tSwIFfPzgY+5hsqK6Onl2AdSsaotHB8PT2CoZ9oZPJO8BlZFvD7iT83Q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Bn2ng1ZOaprKpopp3bBPFD+LRwON9/ZRyRa4YbYkMPWxgj8krYNo50VSRrMz/3xR9py9hgVNnK5H/5QQTcdT0bPQf6lbJn3Q86QTUBxWI12FwKrcr2Nvw/setSACwRucGbbx9hLhrSmjYetsENWba1F2ouBdSpENvpjxETvyE2Z+GRNu4xbuFD9aSttogjJqjTYvRc/RJejvbENIc2/UIqnv/ra0PPY=

View File

@ -2,7 +2,7 @@ import * as path from "path";
import * as fs from "fs";
import {NextFunction, Request, Response} from "express";
import {ErrorCodes, ErrorDTO} from "../../common/entities/Error";
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../common/entities/DirectoryDTO";
import {ObjectManagerRepository} from "../model/ObjectManagerRepository";
import {SearchTypes} from "../../common/entities/AutoCompleteItem";
import {ContentWrapper} from "../../common/entities/ConentWrapper";
@ -28,8 +28,8 @@ export class GalleryMWs {
try {
const directory = await ObjectManagerRepository.getInstance().GalleryManager.listDirectory(directoryName, req.query.knownLastModified, req.query.knownLastScanned);
if ((<NotModifiedDirectoryDTO>directory).notModified == true) {
req.resultPipe = new ContentWrapper(directory, null);
if (directory == null) {
req.resultPipe = new ContentWrapper(null, null, true);
return next();
}
if (req.session.user.permissions &&
@ -52,7 +52,7 @@ export class GalleryMWs {
return next();
let cw: ContentWrapper = req.resultPipe;
if ((<NotModifiedDirectoryDTO>cw.directory).notModified == true) {
if (cw.notModified == true) {
return next();
}
let removeDirs = (dir) => {

View File

@ -6,7 +6,7 @@ import * as os from "os";
import {NextFunction, Request, Response} from "express";
import {ErrorCodes, ErrorDTO} from "../../../common/entities/Error";
import {ContentWrapper} from "../../../common/entities/ConentWrapper";
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {ProjectPath} from "../../ProjectPath";
import {PhotoDTO} from "../../../common/entities/PhotoDTO";
import {Config} from "../../../common/config/private/Config";
@ -85,7 +85,7 @@ export class ThumbnailGeneratorMWs {
return next();
let cw: ContentWrapper = req.resultPipe;
if ((<NotModifiedDirectoryDTO>cw.directory).notModified == true) {
if (cw.notModified == true) {
return next();
}
if (cw.directory) {

View File

@ -1,7 +1,7 @@
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
export interface IGalleryManager {
listDirectory(relativeDirectoryName: string,
knownLastModified?: number,
knownLastScanned?: number): Promise<DirectoryDTO | NotModifiedDirectoryDTO>;
knownLastScanned?: number): Promise<DirectoryDTO>;
}

View File

@ -1,5 +1,6 @@
import {AutoCompleteItem, SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {SearchResultDTO} from "../../../common/entities/SearchResult";
import {SearchResultDTO} from "../../../common/entities/SearchResultDTO";
export interface ISearchManager {
autocomplete(text: string): Promise<AutoCompleteItem[]>;
search(text: string, searchType: SearchTypes): Promise<SearchResultDTO>;

View File

@ -1,4 +1,4 @@
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {IGalleryManager} from "../interfaces/IGalleryManager";
import * as path from "path";
import * as fs from "fs";
@ -8,13 +8,13 @@ import {Config} from "../../../common/config/private/Config";
export class GalleryManager implements IGalleryManager {
public listDirectory(relativeDirectoryName: string, knownLastModified?: number, knownLastScanned?: number): Promise<DirectoryDTO | NotModifiedDirectoryDTO> {
public listDirectory(relativeDirectoryName: string, knownLastModified?: number, knownLastScanned?: number): Promise<DirectoryDTO> {
//If it seems that the content did not changed, do not work on it
if (knownLastModified && knownLastScanned) {
const stat = fs.statSync(path.join(ProjectPath.ImageFolder, relativeDirectoryName));
const lastModified = Math.max(stat.ctime.getTime(), stat.mtime.getTime());
if (Date.now() - knownLastScanned <= Config.Server.cachedFolderTimeout && lastModified == knownLastModified) {
return Promise.resolve(<NotModifiedDirectoryDTO>{notModified: true});
return Promise.resolve(null);
}
}
return DiskManager.scanDirectory(relativeDirectoryName);

View File

@ -1,6 +1,6 @@
import {AutoCompleteItem, SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {ISearchManager} from "../interfaces/ISearchManager";
import {SearchResultDTO} from "../../../common/entities/SearchResult";
import {SearchResultDTO} from "../../../common/entities/SearchResultDTO";
export class SearchManager implements ISearchManager {
autocomplete(text: string): Promise<AutoCompleteItem[]> {

View File

@ -1,5 +1,5 @@
import {IGalleryManager} from "../interfaces/IGalleryManager";
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import * as path from "path";
import * as fs from "fs";
import {DirectoryEntity} from "./enitites/DirectoryEntity";
@ -15,7 +15,7 @@ export class GalleryManager implements IGalleryManager {
public async listDirectory(relativeDirectoryName: string,
knownLastModified?: number,
knownLastScanned?: number): Promise<DirectoryDTO | NotModifiedDirectoryDTO> {
knownLastScanned?: number): Promise<DirectoryDTO> {
relativeDirectoryName = path.normalize(path.join("." + path.sep, relativeDirectoryName));
const directoryName = path.basename(relativeDirectoryName);
const directoryParent = path.join(path.dirname(relativeDirectoryName), path.sep);
@ -40,7 +40,7 @@ export class GalleryManager implements IGalleryManager {
if (Date.now() - knownLastScanned <= Config.Server.cachedFolderTimeout &&
lastModified == knownLastModified &&
dir.lastScanned == knownLastScanned) {
return Promise.resolve(<NotModifiedDirectoryDTO>{notModified: true});
return null;
}
}
if (dir.photos) {

View File

@ -1,6 +1,6 @@
import {AutoCompleteItem, SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {ISearchManager} from "../interfaces/ISearchManager";
import {SearchResultDTO} from "../../../common/entities/SearchResult";
import {SearchResultDTO} from "../../../common/entities/SearchResultDTO";
import {MySQLConnection} from "./MySQLConnection";
import {PhotoEntity} from "./enitites/PhotoEntity";
import {DirectoryEntity} from "./enitites/DirectoryEntity";

View File

@ -1,14 +1,9 @@
import {DirectoryDTO, NotModifiedDirectoryDTO} from "./DirectoryDTO";
import {SearchResultDTO} from "./SearchResult";
import {DirectoryDTO} from "./DirectoryDTO";
import {SearchResultDTO} from "./SearchResultDTO";
export class ContentWrapper {
public directory: DirectoryDTO | NotModifiedDirectoryDTO;
public searchResult: SearchResultDTO;
constructor(directory: DirectoryDTO | NotModifiedDirectoryDTO = null, searchResult: SearchResultDTO = null) {
this.directory = directory;
this.searchResult = searchResult;
constructor(public directory: DirectoryDTO = null,
public searchResult: SearchResultDTO = null,
public notModified?: boolean) {
}
}

View File

@ -11,10 +11,6 @@ export interface DirectoryDTO {
photos: Array<PhotoDTO>;
}
export interface NotModifiedDirectoryDTO {
notModified: boolean;
}
export module DirectoryDTO {
export const addReferences = (dir: DirectoryDTO): void => {
dir.photos.forEach((photo: PhotoDTO) => {

View File

@ -1,6 +1,7 @@
import {DirectoryDTO} from "./DirectoryDTO";
import {PhotoDTO} from "./PhotoDTO";
import {SearchTypes} from "./AutoCompleteItem";
export interface SearchResultDTO {
searchText: string;
searchType: SearchTypes;

View File

@ -21,8 +21,8 @@ export class AppComponent implements OnInit, OnDestroy {
private _authenticationService: AuthenticationService,
private _shareService: ShareService,
private _title: Title, vcr: ViewContainerRef,
notificatin: NotificationService) {
notificatin.setRootViewContainerRef(vcr);
notificationService: NotificationService) {
notificationService.setRootViewContainerRef(vcr);
}
async ngOnInit() {

View File

@ -12,9 +12,9 @@ a {
.no-image {
color: #7f7f7f;
font-size: 50px;
top: calc(50% - 25px);
left: calc(50% - 25px);
font-size: 80px;
top: calc(50% - 40px);
left: calc(50% - 40px);
}
.photo {

View File

@ -4,8 +4,8 @@
<div class="photo-container"
[style.width.px]="size()"
[style.height.px]="size()">
[style.width.px]="calcSize()"
[style.height.px]="calcSize()">
<div class="photo" *ngIf="thumbnail && thumbnail.Available"
[style.background-image]="getSanitizedThUrl()"></div>

View File

@ -24,11 +24,7 @@ export class GalleryDirectoryComponent implements OnInit, OnDestroy {
}
ngOnInit() {
if (this.directory.photos.length > 0) {
this.thumbnail = this.thumbnailService.getThumbnail(new Photo(this.directory.photos[0], this.size(), this.size()));
}
}
size: number = null;
getSanitizedThUrl() {
return this._sanitizer.bypassSecurityTrustStyle('url(' + encodeURI(this.thumbnail.Src).replace(/\(/g, "%28").replace(/\)/g, "%29") + ')');
@ -50,13 +46,20 @@ export class GalleryDirectoryComponent implements OnInit, OnDestroy {
}
}
size() {
let size = 220 + 5;
const containerWidth = this.container.nativeElement.parentElement.parentElement.clientWidth;
size = containerWidth / Math.round((containerWidth / size));
ngOnInit() {
if (this.directory.photos.length > 0) {
this.thumbnail = this.thumbnailService.getThumbnail(new Photo(this.directory.photos[0], this.calcSize(), this.calcSize()));
}
}
return Math.floor(size - 5);
calcSize() {
if (this.size == null ||
document.getElementsByTagName('body')[0].style.overflowY == 'scroll') {
let size = 220 + 5;
const containerWidth = this.container.nativeElement.parentElement.parentElement.clientWidth;
this.size = containerWidth / Math.round((containerWidth / size));
}
return Math.floor(this.size - 5);
}
}

View File

@ -7,7 +7,7 @@ import {GallerySearchComponent} from "./search/search.gallery.component";
import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {Config} from "../../../common/config/public/Config";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {SearchResultDTO} from "../../../common/entities/SearchResult";
import {SearchResultDTO} from "../../../common/entities/SearchResultDTO";
import {ShareService} from "./share.service";
import {NavigationService} from "../model/navigation.service";
import {UserRoles} from "../../../common/entities/UserDTO";

View File

@ -1,7 +1,7 @@
import {Injectable} from "@angular/core";
import {NetworkService} from "../model/network/network.service";
import {ContentWrapper} from "../../../common/entities/ConentWrapper";
import {DirectoryDTO, NotModifiedDirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {GalleryCacheService} from "./cache.gallery.service";
import {BehaviorSubject} from "rxjs/BehaviorSubject";
@ -51,11 +51,11 @@ export class GalleryService {
const cw = await this.networkService.getJson<ContentWrapper>("/gallery/content/" + directoryName, params);
if (!cw || (<NotModifiedDirectoryDTO>cw.directory).notModified == true) {
if (!cw || cw.notModified == true) {
return;
}
this.galleryCacheService.setDirectory(<DirectoryDTO>cw.directory); //save it before adding references
this.galleryCacheService.setDirectory(cw.directory); //save it before adding references
if (this.lastRequest.directory != directoryName) {
return;

View File

@ -55,7 +55,7 @@ export class GalleryMapLightboxComponent implements OnChanges {
};
this.map.triggerResize();
document.getElementsByTagName('body')[0].style.overflow = 'hidden';
document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
this.showImages();
setTimeout(() => {
@ -79,7 +79,7 @@ export class GalleryMapLightboxComponent implements OnChanges {
this.lightboxDimension = this.startPosition;
this.lightboxDimension.top -= this.getBodyScrollTop();
document.getElementsByTagName('body')[0].style.overflow = 'scroll';
document.getElementsByTagName('body')[0].style.overflowY = 'scroll';
this.opacity = 0.0;
setTimeout(() => {
this.visible = false;

View File

@ -10,7 +10,7 @@ export class OverlayService {
public showOverlay() {
//disable scrolling
document.getElementsByTagName('body')[0].style.overflow = 'hidden';
document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
this.OnOverlayChange.trigger(true);
}
@ -33,7 +33,7 @@ export class OverlayService {
let widthNoScroll = outer.offsetWidth;
// force scrollbars
outer.style.overflow = "scroll";
outer.style.overflowY = "scroll";
// add innerdiv
let inner = document.createElement("div");
@ -51,7 +51,7 @@ export class OverlayService {
}
getPhantomScrollbarWidth() {
if (document.getElementsByTagName('body')[0].style.overflow == 'hidden') {
if (document.getElementsByTagName('body')[0].style.overflowY == 'hidden') {
return this.getScrollbarWidth();
}
return 0;