mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-05-07 06:07:40 +02:00
add option for exif stripping
This commit is contained in:
@@ -17,9 +17,7 @@ export class PreferenceDefaultsService {
|
||||
public readonly usrDefaults: {
|
||||
[key in UsrPreference]: () => PrefValueType;
|
||||
} = {
|
||||
[UsrPreference.TestString]: () => 'test_string',
|
||||
[UsrPreference.TestNumber]: () => 123,
|
||||
[UsrPreference.TestBoolean]: () => true,
|
||||
[UsrPreference.ExifStripping]: () => true,
|
||||
};
|
||||
|
||||
public readonly sysDefaults: {
|
||||
@@ -39,9 +37,5 @@ export class PreferenceDefaultsService {
|
||||
[SysPreference.JwtExpiresIn]: () =>
|
||||
this.jwtConfigService.getJwtExpiresIn() ?? '7d',
|
||||
[SysPreference.BCryptStrength]: () => 12,
|
||||
|
||||
[SysPreference.TestString]: () => 'test_string',
|
||||
[SysPreference.TestNumber]: () => 123,
|
||||
[SysPreference.TestBoolean]: () => true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
DecodedUsrPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings,
|
||||
PrefValueTypeStrings
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usrpreferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
UsrPreferenceList,
|
||||
UsrPreferenceValueTypes,
|
||||
UsrPreferenceValueTypes
|
||||
} from '../../models/dto/usrpreferences.dto';
|
||||
import {
|
||||
EUsrPreferenceBackend,
|
||||
EUsrPreferenceSchema,
|
||||
EUsrPreferenceSchema
|
||||
} from '../../models/entities/usrpreference.entity';
|
||||
import { FallBackMutex } from '../../models/util/FallBackMutex';
|
||||
import { PreferenceCommonService } from './preferencecommon.service';
|
||||
@@ -173,7 +173,7 @@ export class UsrPreferenceService {
|
||||
return this.setPreference(
|
||||
userid,
|
||||
key,
|
||||
this.defaultsService.sysDefaults[key](),
|
||||
this.defaultsService.usrDefaults[key](),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,4 @@ export const SysPreferenceValueTypes: {
|
||||
[SysPreference.JwtSecret]: 'string',
|
||||
[SysPreference.JwtExpiresIn]: 'string',
|
||||
[SysPreference.BCryptStrength]: 'number',
|
||||
[SysPreference.TestString]: 'string',
|
||||
[SysPreference.TestNumber]: 'number',
|
||||
[SysPreference.TestBoolean]: 'boolean',
|
||||
};
|
||||
|
||||
@@ -8,7 +8,5 @@ export const UsrPreferenceList: string[] = Object.values(UsrPreference);
|
||||
export const UsrPreferenceValueTypes: {
|
||||
[key in UsrPreference]: PrefValueTypeStrings;
|
||||
} = {
|
||||
[UsrPreference.TestString]: 'string',
|
||||
[UsrPreference.TestNumber]: 'number',
|
||||
[UsrPreference.TestBoolean]: 'boolean',
|
||||
[UsrPreference.ExifStripping]: 'boolean',
|
||||
};
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import {
|
||||
DecodedSysPref,
|
||||
DecodedPref,
|
||||
PrefValueType
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/syspreferences.dto';
|
||||
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Subject } from 'rxjs';
|
||||
import { SysPreferenceFriendlyNames } from 'src/app/i18n/syspref.i18n';
|
||||
import { Required } from 'src/app/models/decorators/required.decorator';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
import { SysPrefService } from 'src/app/services/api/syspref.service';
|
||||
import { Throttle } from 'src/app/util/throttle';
|
||||
import { UtilService } from 'src/app/util/util.service';
|
||||
|
||||
@@ -20,28 +17,25 @@ import { UtilService } from 'src/app/util/util.service';
|
||||
styleUrls: ['./pref-option.component.scss'],
|
||||
})
|
||||
export class PrefOptionComponent implements OnInit {
|
||||
@Input() @Required pref: DecodedSysPref;
|
||||
@Input() @Required pref: DecodedPref;
|
||||
@Input('update') @Required updateFunction: (
|
||||
key: string,
|
||||
pref: PrefValueType
|
||||
) => AsyncFailable<any>;
|
||||
@Input() @Required translator: {
|
||||
[key in string]: string;
|
||||
};
|
||||
|
||||
private updateSubject = new Subject<PrefValueType>();
|
||||
|
||||
constructor(
|
||||
private sysprefService: SysPrefService,
|
||||
private utilService: UtilService
|
||||
) {}
|
||||
constructor(private utilService: UtilService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscribeUpdate();
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return (
|
||||
SysPreferenceFriendlyNames[this.pref.key as SysPreference] ??
|
||||
this.pref.key
|
||||
);
|
||||
return this.translator[this.pref.key] ?? this.pref.key;
|
||||
}
|
||||
|
||||
get valString(): string {
|
||||
@@ -83,8 +77,18 @@ export class PrefOptionComponent implements OnInit {
|
||||
private async updatePreference(value: PrefValueType) {
|
||||
const result = await this.updateFunction(this.pref.key, value);
|
||||
if (!HasFailed(result)) {
|
||||
const message =
|
||||
this.pref.type === 'string'
|
||||
? `Updated ${this.name}`
|
||||
: this.pref.type === 'number'
|
||||
? `Updated ${this.name}`
|
||||
: this.pref.type === 'boolean'
|
||||
? value
|
||||
? `Enabled ${this.name}`
|
||||
: `Disabled ${this.name}`
|
||||
: '';
|
||||
this.utilService.showSnackBar(
|
||||
`Updated ${this.name}`,
|
||||
message,
|
||||
SnackBarType.Success
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,4 @@ export const SysPreferenceFriendlyNames: {
|
||||
[SysPreference.JwtSecret]: 'JWT Secret',
|
||||
[SysPreference.JwtExpiresIn]: 'JWT Expiry Time',
|
||||
[SysPreference.BCryptStrength]: 'BCrypt Strength',
|
||||
[SysPreference.TestString]: 'Test String',
|
||||
[SysPreference.TestNumber]: 'Test Number',
|
||||
[SysPreference.TestBoolean]: 'Test Boolean',
|
||||
};
|
||||
|
||||
@@ -3,7 +3,5 @@ import { UsrPreference } from 'picsur-shared/dist/dto/usrpreferences.dto';
|
||||
export const UsrPreferenceFriendlyNames: {
|
||||
[key in UsrPreference]: string;
|
||||
} = {
|
||||
[UsrPreference.TestString]: 'Test String',
|
||||
[UsrPreference.TestNumber]: 'Test Number',
|
||||
[UsrPreference.TestBoolean]: 'Test Boolean',
|
||||
[UsrPreference.ExifStripping]: 'EXIF data stripping',
|
||||
};
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<pref-option
|
||||
[pref]="pref"
|
||||
[update]="usrPrefService.setPreference.bind(usrPrefService)"
|
||||
[translator]="translator"
|
||||
></pref-option>
|
||||
</ng-container>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { DecodedPref } from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { Observable } from 'rxjs';
|
||||
import { UsrPreferenceFriendlyNames } from 'src/app/i18n/usrpref.i18n';
|
||||
import { UsrPrefService } from 'src/app/services/api/usrpref.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './settings-general.component.html',
|
||||
})
|
||||
export class SettingsGeneralComponent {
|
||||
public translator = UsrPreferenceFriendlyNames;
|
||||
|
||||
preferences: Observable<DecodedPref[]>;
|
||||
|
||||
constructor(public usrPrefService: UsrPrefService) {
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<pref-option
|
||||
[pref]="pref"
|
||||
[update]="sysPrefService.setPreference.bind(sysPrefService)"
|
||||
[translator]="translator"
|
||||
></pref-option>
|
||||
</ng-container>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { DecodedPref } from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { Observable } from 'rxjs';
|
||||
import { SysPreferenceFriendlyNames } from 'src/app/i18n/syspref.i18n';
|
||||
import { SysPrefService } from 'src/app/services/api/syspref.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './settings-syspref.component.html',
|
||||
})
|
||||
export class SettingsSysprefComponent {
|
||||
public translator = SysPreferenceFriendlyNames;
|
||||
|
||||
preferences: Observable<DecodedPref[]>;
|
||||
|
||||
constructor(public sysPrefService: SysPrefService) {
|
||||
|
||||
@@ -4,7 +4,4 @@ export enum SysPreference {
|
||||
JwtSecret = 'jwt_secret',
|
||||
JwtExpiresIn = 'jwt_expires_in',
|
||||
BCryptStrength = 'bcrypt_strength',
|
||||
TestString = 'test_string',
|
||||
TestNumber = 'test_number',
|
||||
TestBoolean = 'test_boolean',
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
// This enum is only here to make accessing the values easier, and type checking in the backend
|
||||
export enum UsrPreference {
|
||||
TestString = 'test_string',
|
||||
TestNumber = 'test_number',
|
||||
TestBoolean = 'test_boolean',
|
||||
ExifStripping = 'exif_stripping',
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user