feat(syncServer): enhance SuperSync configuration and improve form handling

This commit is contained in:
Johannes Millan 2025-11-27 16:01:29 +01:00
parent 328d3d7613
commit fefdb1bba4
5 changed files with 59 additions and 19 deletions

View file

@ -1,3 +1,4 @@
import { environment } from '../../../environments/environment';
import { TRACKING_INTERVAL } from '../../app.constants';
import { getDefaultVoice } from '../domina-mode/getAvailableVoices';
import { TaskReminderOptionId } from '../tasks/task.model';
@ -206,10 +207,12 @@ export const DEFAULT_GLOBAL_CONFIG: GlobalConfigState = {
},
superSync: {
baseUrl: null,
baseUrl: environment.production
? 'https://sync.super-productivity.com'
: 'http://localhost:1900',
userName: null,
password: null,
syncFolderPath: 'super-productivity',
syncFolderPath: null,
},
localFileSync: {

View file

@ -15,18 +15,10 @@ import { FormlyFieldConfig } from '@ngx-formly/core';
* @returns Array of Formly field configurations
*/
const createWebdavFormFields = (options: {
infoText: string;
corsInfoText: string;
baseUrlDescription: string;
}): FormlyFieldConfig[] => {
return [
{
type: 'tpl',
templateOptions: {
tag: 'p',
text: options.infoText,
},
},
...(!IS_ELECTRON && !IS_ANDROID_WEB_VIEW
? [
{
@ -159,23 +151,38 @@ export const SYNC_FORM: ConfigFormSection<SyncConfig> = {
field?.parent?.model.syncProvider !== LegacySyncProvider.WebDAV,
key: 'webDav',
fieldGroup: createWebdavFormFields({
infoText: T.F.SYNC.FORM.WEB_DAV.INFO,
corsInfoText: T.F.SYNC.FORM.WEB_DAV.CORS_INFO,
baseUrlDescription:
'* https://your-next-cloud/nextcloud/remote.php/dav/files/yourUserName/',
}),
},
// SuperSync provider form fields (uses same fields as WebDAV with different description)
// SuperSync provider form fields
{
hideExpression: (m, v, field) =>
field?.parent?.model.syncProvider !== LegacySyncProvider.SuperSync,
key: 'superSync',
fieldGroup: createWebdavFormFields({
infoText: T.F.SYNC.FORM.WEB_DAV.INFO,
corsInfoText: T.F.SYNC.FORM.WEB_DAV.CORS_INFO,
baseUrlDescription: '* http://localhost:1900/',
}),
fieldGroup: [
{
key: 'userName',
type: 'input',
className: 'e2e-userName',
templateOptions: {
required: true,
label: T.F.SYNC.FORM.WEB_DAV.L_USER_NAME,
},
},
{
key: 'password',
type: 'input',
className: 'e2e-password',
templateOptions: {
type: 'password',
required: true,
label: T.F.SYNC.FORM.WEB_DAV.L_PASSWORD,
},
},
],
},
{
@ -196,6 +203,16 @@ export const SYNC_FORM: ConfigFormSection<SyncConfig> = {
type: 'collapsible',
props: { label: T.G.ADVANCED_CFG },
fieldGroup: [
{
key: 'superSync.baseUrl',
type: 'input',
hideExpression: (model) => model.syncProvider !== LegacySyncProvider.SuperSync,
className: 'e2e-baseUrl',
templateOptions: {
required: true,
label: T.F.SYNC.FORM.WEB_DAV.L_BASE_URL,
},
},
{
key: 'isCompressionEnabled',
type: 'checkbox',

View file

@ -1,5 +1,6 @@
import { SyncProviderId } from '../../../pfapi.const';
import { WebdavBaseProvider } from '../webdav/webdav-base-provider';
import { WebdavPrivateCfg } from '../webdav/webdav.model';
/**
* SuperSync provider - a WebDAV-based sync provider with enhanced capabilities.
@ -20,6 +21,25 @@ export class SuperSyncProvider extends WebdavBaseProvider<SyncProviderId.SuperSy
return 'SuperSyncProvider';
}
override async isReady(): Promise<boolean> {
const privateCfg = await this.privateCfg.load();
return !!(
privateCfg &&
privateCfg.userName &&
privateCfg.baseUrl &&
privateCfg.password
);
}
protected override _getFilePath(targetPath: string, cfg: WebdavPrivateCfg): string {
const parts: string[] = [];
if (this._extraPath) {
parts.push(this._extraPath);
}
parts.push(targetPath);
return parts.join('/').replace(/\/+/g, '/');
}
// Future: Add SuperSync-specific methods here
// Example: beginTransaction(), commitTransaction(), etc.
}

View file

@ -117,7 +117,7 @@ export abstract class WebdavBaseProvider<
}
protected _getFilePath(targetPath: string, cfg: WebdavPrivateCfg): string {
const parts = [cfg.syncFolderPath];
const parts = cfg.syncFolderPath ? [cfg.syncFolderPath] : [];
if (this._extraPath) {
parts.push(this._extraPath);
}

View file

@ -13,7 +13,7 @@ export interface WebdavPrivateCfg extends SyncProviderPrivateCfgBase {
baseUrl: string;
userName: string;
password: string;
syncFolderPath: string;
syncFolderPath?: string;
/**
* Server capabilities configuration. If not provided, capabilities will be