1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

improving content caching

This commit is contained in:
Patrik Braun 2017-07-28 00:04:19 +02:00
parent 1d7bc3c489
commit 393731133c
9 changed files with 28 additions and 15 deletions

View File

@ -42,7 +42,7 @@ export class RenderingMWs {
if (!req.resultPipe)
return next();
return res.sendFile(req.resultPipe);
return res.sendFile(req.resultPipe, {maxAge: 31536000});
}
public static renderOK(req: Request, res: Response, next: NextFunction) {

View File

@ -10,7 +10,7 @@ export class PublicRouter {
public static route(app) {
const renderIndex = (req: Request, res: Response) => {
res.sendFile(_path.resolve(__dirname, './../../dist/index.html'));
res.sendFile(_path.resolve(ProjectPath.FrontendFolder, 'index.html'), {maxAge: 31536000});
};
app.use(
@ -29,18 +29,16 @@ export class PublicRouter {
});
app.get('/config_inject.js', (req: Request, res: Response) => {
res.render(_path.resolve(__dirname, './../../dist/config_inject.ejs'), res.tpl);
res.render(_path.resolve(ProjectPath.FrontendFolder, 'config_inject.ejs'), res.tpl);
});
app.get(['/', '/login', "/gallery*", "/share*", "/admin", "/search*"],
AuthenticationMWs.tryAuthenticate,
renderIndex
);
app.use(_express.static(ProjectPath.FrontendFolder));
app.use('/node_modules', _express.static(_path.resolve(__dirname, './../../node_modules')));
app.use('/common', _express.static(_path.resolve(__dirname, './../../common')));
app.use(_express.static(ProjectPath.FrontendFolder, {maxAge: 31536000}));
// app.use('/node_modules', _express.static(_path.resolve(__dirname, './../../node_modules')));
// app.use('/common', _express.static(_path.resolve(__dirname, './../../common')));
}
}

View File

@ -42,7 +42,7 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
indexing: {
folderPreviewSize: 2,
cachedFolderTimeout: 1000 * 60 * 60,
reIndexingSensitivity: ReIndexingSensitivity.high
reIndexingSensitivity: ReIndexingSensitivity.medium
},
enableThreading: true
};

View File

@ -81,6 +81,7 @@ export class GalleryService {
return null
}
this.content.next(null);
const cw: ContentWrapper = await this.networkService.getJson<ContentWrapper>("/search/" + text, {type: type});
console.log("photos", cw.searchResult.photos.length);
console.log("direcotries", cw.searchResult.directories.length);
@ -106,7 +107,7 @@ export class GalleryService {
this.searchId = setTimeout(() => {
this.search(text);
this.searchId = null;
}, Config.Client.Search.InstantSearchTimeout); //TODO: set timeout to config
}, Config.Client.Search.InstantSearchTimeout);
const cw = await this.networkService.getJson<ContentWrapper>("/instant-search/" + text);
this.content.next(cw);

View File

@ -404,6 +404,9 @@ export class GalleryLightboxComponent implements OnDestroy {
public play() {
this.pause();
this.timerSub = this.timer.filter(t => t % 2 == 0).subscribe(() => {
if (this.photoElement.imageLoadFinished == false) {
return;
}
if (this.navigation.hasNext) {
this.nextImage();
} else {
@ -416,6 +419,9 @@ export class GalleryLightboxComponent implements OnDestroy {
public fastForward() {
this.pause();
this.timerSub = this.timer.subscribe(() => {
if (this.photoElement.imageLoadFinished == false) {
return;
}
if (this.navigation.hasNext) {
this.nextImage();
} else {

View File

@ -15,6 +15,7 @@ export class GalleryLightboxPhotoComponent implements OnChanges {
public imageSize = {width: "auto", height: "100"};
imageLoaded: boolean = false;
public imageLoadFinished: boolean = false;
constructor(public elementRef: ElementRef) {
}
@ -22,6 +23,7 @@ export class GalleryLightboxPhotoComponent implements OnChanges {
ngOnChanges() {
this.imageLoaded = false;
this.imageLoadFinished = false;
this.setImageSize();
}
@ -44,11 +46,13 @@ export class GalleryLightboxPhotoComponent implements OnChanges {
onImageLoad() {
this.imageLoadFinished = true;
this.imageLoaded = true;
}
onImageError() {
//TODO:handle error
this.imageLoadFinished = true;
console.error("cant load image");
}

View File

@ -31,7 +31,7 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
};
validityTypes = [];
currentDir: string = "";
sharing: SharingDTO;
sharing: SharingDTO = null;
contentSubscription = null;
passwordProtection = false;
@ -76,6 +76,9 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
}
async update() {
if (this.sharing == null) {
return;
}
this.url = "loading..";
this.sharing = await this._sharingService.updateSharing(this.currentDir, this.sharing.id, this.input.includeSubfolders, this.input.password, this.calcValidity());
console.log(this.sharing);

View File

@ -9,7 +9,8 @@ import {AbstractSettingsService} from "./abstract.settings.service";
import {IPrivateConfig} from "../../../../common/config/private/IPrivateConfig";
export abstract class SettingsComponent<T> implements OnInit, OnDestroy, OnChanges {
export abstract class SettingsComponent<T, S extends AbstractSettingsService<T>=AbstractSettingsService<T>>
implements OnInit, OnDestroy, OnChanges {
@Input()
public simplifiedMode: boolean = true;
@ -32,7 +33,7 @@ export abstract class SettingsComponent<T> implements OnInit, OnDestroy, OnChang
constructor(private name,
private _authService: AuthenticationService,
private _navigation: NavigationService,
public _settingsService: AbstractSettingsService<T>,
public _settingsService: S,
protected notification: NotificationService,
private sliceFN?: (s: IPrivateConfig) => T) {
if (this.sliceFN) {

View File

@ -16,7 +16,7 @@ import {Utils} from "../../../../common/Utils";
'./../_abstract/abstract.settings.component.css'],
providers: [IndexingSettingsService],
})
export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig> {
export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig, IndexingSettingsService> {
types: Array<any> = [];
@ -79,7 +79,7 @@ export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig>
this.inProgress = true;
this.error = "";
try {
await (<IndexingSettingsService>this._settingsService).index();
await this._settingsService.index();
this.updateProgress();
this.notification.success("Folder indexed", "Success");
this.inProgress = false;