mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Adding never expiring sharing link. #260
It works by setting the expirity to -1 that setts the expire dat to 01/01/9999. Now the UI does not show expiration if it is longer than 10 years
This commit is contained in:
parent
07012ebd3c
commit
4af6c16aef
@ -55,7 +55,9 @@ export class SharingMWs {
|
|||||||
path: directoryName,
|
path: directoryName,
|
||||||
password: createSharing.password,
|
password: createSharing.password,
|
||||||
creator: req.session.user,
|
creator: req.session.user,
|
||||||
expires: Date.now() + createSharing.valid,
|
expires: createSharing.valid >= 0 ? // if === -1 its forever
|
||||||
|
Date.now() + createSharing.valid :
|
||||||
|
(new Date(9999, 0, 1)).getTime(), // never expire
|
||||||
includeSubfolders: createSharing.includeSubfolders,
|
includeSubfolders: createSharing.includeSubfolders,
|
||||||
timeStamp: Date.now()
|
timeStamp: Date.now()
|
||||||
};
|
};
|
||||||
@ -86,7 +88,9 @@ export class SharingMWs {
|
|||||||
sharingKey: '',
|
sharingKey: '',
|
||||||
password: (updateSharing.password && updateSharing.password !== '') ? updateSharing.password : null,
|
password: (updateSharing.password && updateSharing.password !== '') ? updateSharing.password : null,
|
||||||
creator: req.session.user,
|
creator: req.session.user,
|
||||||
expires: Date.now() + updateSharing.valid,
|
expires: updateSharing.valid >= 0 // if === -1 its forever
|
||||||
|
? Date.now() + updateSharing.valid :
|
||||||
|
(new Date(9999, 0, 1)).getTime(), // never expire
|
||||||
includeSubfolders: updateSharing.includeSubfolders,
|
includeSubfolders: updateSharing.includeSubfolders,
|
||||||
timeStamp: Date.now()
|
timeStamp: Date.now()
|
||||||
};
|
};
|
||||||
|
@ -60,6 +60,11 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
|||||||
if (this.shareService.sharingSubject.value == null) {
|
if (this.shareService.sharingSubject.value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// if the timer is longer than 10 years, just do not show it
|
||||||
|
if ((this.shareService.sharingSubject.value.expires - Date.now()) / 1000 / 86400 / 365 > 10) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
t = Math.floor((this.shareService.sharingSubject.value.expires - Date.now()) / 1000);
|
t = Math.floor((this.shareService.sharingSubject.value.expires - Date.now()) / 1000);
|
||||||
this.countDown = ({} as any);
|
this.countDown = ({} as any);
|
||||||
this.countDown.day = Math.floor(t / 86400);
|
this.countDown.day = Math.floor(t / 86400);
|
||||||
@ -132,7 +137,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
|||||||
directoryName = directoryName || '';
|
directoryName = directoryName || '';
|
||||||
|
|
||||||
this.galleryService.loadDirectory(directoryName);
|
this.galleryService.loadDirectory(directoryName);
|
||||||
}
|
};
|
||||||
|
|
||||||
private onContentChange = (content: ContentWrapper): void => {
|
private onContentChange = (content: ContentWrapper): void => {
|
||||||
const tmp = (content.searchResult || content.directory || {
|
const tmp = (content.searchResult || content.directory || {
|
||||||
@ -153,7 +158,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
private sortDirectories(): void {
|
private sortDirectories(): void {
|
||||||
if (!this.directories) {
|
if (!this.directories) {
|
||||||
|
@ -71,7 +71,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<label class="control-label" for="share-password">
|
<label class="control-label" for="share-password">
|
||||||
<ng-container i18n>Password</ng-container>*:
|
<ng-container i18n>Password</ng-container>
|
||||||
|
*:
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8" *ngIf="passwordProtection">
|
<div class="col-8" *ngIf="passwordProtection">
|
||||||
@ -95,7 +96,8 @@
|
|||||||
<input class="form-control" [(ngModel)]="input.valid.amount" (change)="update()"
|
<input class="form-control" [(ngModel)]="input.valid.amount" (change)="update()"
|
||||||
name="valid-from"
|
name="valid-from"
|
||||||
id="valid-from"
|
id="valid-from"
|
||||||
type="number" min="0" step="1"/>
|
[disabled]="input.valid.type === ValidityTypes.Forever"
|
||||||
|
type="number" min="1" step="1"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4" style="padding-left: 1px">
|
<div class="col-4" style="padding-left: 1px">
|
||||||
<select class="form-control"
|
<select class="form-control"
|
||||||
@ -105,6 +107,7 @@
|
|||||||
<option [ngValue]="ValidityTypes.Hours" i18n>Hours</option>
|
<option [ngValue]="ValidityTypes.Hours" i18n>Hours</option>
|
||||||
<option [ngValue]="ValidityTypes.Days" i18n>Days</option>
|
<option [ngValue]="ValidityTypes.Days" i18n>Days</option>
|
||||||
<option [ngValue]="ValidityTypes.Months" i18n>Months</option>
|
<option [ngValue]="ValidityTypes.Months" i18n>Months</option>
|
||||||
|
<option [ngValue]="ValidityTypes.Forever" i18n>Forever</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
|
|||||||
includeSubfolders: true,
|
includeSubfolders: true,
|
||||||
valid: {
|
valid: {
|
||||||
amount: 30,
|
amount: 30,
|
||||||
type: ValidityTypes.Days
|
type: ValidityTypes.Days as ValidityTypes
|
||||||
},
|
},
|
||||||
password: null as string
|
password: null as string
|
||||||
};
|
};
|
||||||
@ -79,6 +79,8 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
|
|||||||
return this.input.valid.amount * 1000 * 60 * 60 * 24;
|
return this.input.valid.amount * 1000 * 60 * 60 * 24;
|
||||||
case ValidityTypes.Months:
|
case ValidityTypes.Months:
|
||||||
return this.input.valid.amount * 1000 * 60 * 60 * 24 * 30;
|
return this.input.valid.amount * 1000 * 60 * 60 * 24 * 30;
|
||||||
|
case ValidityTypes.Forever:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
throw new Error('unknown type: ' + this.input.valid.type);
|
throw new Error('unknown type: ' + this.input.valid.type);
|
||||||
}
|
}
|
||||||
@ -124,5 +126,5 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
|
|
||||||
export enum ValidityTypes {
|
export enum ValidityTypes {
|
||||||
Minutes = 1, Hours = 2, Days = 3, Months = 4
|
Minutes = 1, Hours = 2, Days = 3, Months = 4, Forever = 99
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ export class ShareLoginComponent implements OnInit {
|
|||||||
await this.authService.shareLogin(this.password);
|
await this.authService.shareLogin(this.password);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && error.code === ErrorCodes.CREDENTIAL_NOT_FOUND) {
|
if (error && error.code === ErrorCodes.CREDENTIAL_NOT_FOUND ||
|
||||||
|
error === 'Unauthorized') {
|
||||||
this.loginError = true;
|
this.loginError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Örökké</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
@ -2732,6 +2732,10 @@
|
|||||||
<source>User creation error!</source>
|
<source>User creation error!</source>
|
||||||
<target>User creation error!</target>
|
<target>User creation error!</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="233324084168950985" datatype="html">
|
||||||
|
<source>Forever</source>
|
||||||
|
<target>Forever</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
Loading…
x
Reference in New Issue
Block a user