diff --git a/src/app/features/config/default-global-config.const.ts b/src/app/features/config/default-global-config.const.ts index a6608797d..5be2ecc60 100644 --- a/src/app/features/config/default-global-config.const.ts +++ b/src/app/features/config/default-global-config.const.ts @@ -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: { diff --git a/src/app/features/config/form-cfgs/sync-form.const.ts b/src/app/features/config/form-cfgs/sync-form.const.ts index 432ddb32f..d0f8866b9 100644 --- a/src/app/features/config/form-cfgs/sync-form.const.ts +++ b/src/app/features/config/form-cfgs/sync-form.const.ts @@ -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 = { 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 = { 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', diff --git a/src/app/pfapi/api/sync/providers/super-sync/super-sync.ts b/src/app/pfapi/api/sync/providers/super-sync/super-sync.ts index f473240c7..b6aad5e0d 100644 --- a/src/app/pfapi/api/sync/providers/super-sync/super-sync.ts +++ b/src/app/pfapi/api/sync/providers/super-sync/super-sync.ts @@ -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 { + 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. } diff --git a/src/app/pfapi/api/sync/providers/webdav/webdav-base-provider.ts b/src/app/pfapi/api/sync/providers/webdav/webdav-base-provider.ts index 3cd4725b3..734f1de31 100644 --- a/src/app/pfapi/api/sync/providers/webdav/webdav-base-provider.ts +++ b/src/app/pfapi/api/sync/providers/webdav/webdav-base-provider.ts @@ -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); } diff --git a/src/app/pfapi/api/sync/providers/webdav/webdav.model.ts b/src/app/pfapi/api/sync/providers/webdav/webdav.model.ts index afd7d8a23..5547f90f0 100644 --- a/src/app/pfapi/api/sync/providers/webdav/webdav.model.ts +++ b/src/app/pfapi/api/sync/providers/webdav/webdav.model.ts @@ -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