google drive is usable now
This commit is contained in:
+8
-4
@@ -3,7 +3,7 @@
|
||||
* To avoid circular dependency.
|
||||
*/
|
||||
|
||||
import type { ProConfig } from "../pro/src/baseTypesPro";
|
||||
import type { GoogleDriveConfig, ProConfig } from "../pro/src/baseTypesPro";
|
||||
import type { LangTypeAndAuto } from "./i18n";
|
||||
|
||||
export const DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
||||
@@ -13,13 +13,15 @@ export type SUPPORTED_SERVICES_TYPE =
|
||||
| "webdav"
|
||||
| "dropbox"
|
||||
| "onedrive"
|
||||
| "webdis";
|
||||
| "webdis"
|
||||
| "googledrive";
|
||||
|
||||
export type SUPPORTED_SERVICES_TYPE_WITH_REMOTE_BASE_DIR =
|
||||
| "webdav"
|
||||
| "dropbox"
|
||||
| "onedrive"
|
||||
| "webdis";
|
||||
| "webdis"
|
||||
| "googledrive";
|
||||
|
||||
export interface S3Config {
|
||||
s3Endpoint: string;
|
||||
@@ -113,7 +115,8 @@ export type QRExportType =
|
||||
| "dropbox"
|
||||
| "onedrive"
|
||||
| "webdav"
|
||||
| "webdis";
|
||||
| "webdis"
|
||||
| "googledrive";
|
||||
|
||||
export interface ProfilerConfig {
|
||||
enablePrinting?: boolean;
|
||||
@@ -126,6 +129,7 @@ export interface RemotelySavePluginSettings {
|
||||
dropbox: DropboxConfig;
|
||||
onedrive: OnedriveConfig;
|
||||
webdis: WebdisConfig;
|
||||
googledrive: GoogleDriveConfig;
|
||||
password: string;
|
||||
serviceType: SUPPORTED_SERVICES_TYPE;
|
||||
currLogLevel?: string;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { FakeFsGoogleDrive } from "../pro/src/fsGoogleDrive";
|
||||
import type { RemotelySavePluginSettings } from "./baseTypes";
|
||||
import type { FakeFs } from "./fsAll";
|
||||
import { FakeFsDropbox } from "./fsDropbox";
|
||||
@@ -41,6 +42,12 @@ export function getClient(
|
||||
vaultName,
|
||||
saveUpdatedConfigFunc
|
||||
);
|
||||
case "googledrive":
|
||||
return new FakeFsGoogleDrive(
|
||||
settings.googledrive,
|
||||
vaultName,
|
||||
saveUpdatedConfigFunc
|
||||
);
|
||||
default:
|
||||
throw Error(`cannot init client for serviceType=${settings.serviceType}`);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export const exportQrCodeUri = async (
|
||||
delete settings2.onedrive;
|
||||
delete settings2.webdav;
|
||||
delete settings2.webdis;
|
||||
delete settings2.googledrive;
|
||||
delete settings2.pro;
|
||||
} else if (exportFields === "s3") {
|
||||
settings2 = { s3: cloneDeep(settings.s3) };
|
||||
@@ -35,6 +36,8 @@ export const exportQrCodeUri = async (
|
||||
settings2 = { webdav: cloneDeep(settings.webdav) };
|
||||
} else if (exportFields === "webdis") {
|
||||
settings2 = { webdis: cloneDeep(settings.webdis) };
|
||||
} else if (exportFields === "googledrive") {
|
||||
settings2 = { googledrive: cloneDeep(settings.googledrive) };
|
||||
}
|
||||
|
||||
delete settings2.vaultRandomID;
|
||||
|
||||
@@ -64,6 +64,7 @@ import { SyncAlgoV3Modal } from "./syncAlgoV3Notice";
|
||||
import AggregateError from "aggregate-error";
|
||||
import throttle from "lodash/throttle";
|
||||
import { COMMAND_CALLBACK_PRO } from "../pro/src/baseTypesPro";
|
||||
import { DEFAULT_GOOGLEDRIVE_CONFIG } from "../pro/src/fsGoogleDrive";
|
||||
import { exportVaultSyncPlansToFiles } from "./debugMode";
|
||||
import { FakeFsEncrypt } from "./fsEncrypt";
|
||||
import { getClient } from "./fsGetter";
|
||||
@@ -79,6 +80,7 @@ const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
||||
dropbox: DEFAULT_DROPBOX_CONFIG,
|
||||
onedrive: DEFAULT_ONEDRIVE_CONFIG,
|
||||
webdis: DEFAULT_WEBDIS_CONFIG,
|
||||
googledrive: DEFAULT_GOOGLEDRIVE_CONFIG,
|
||||
password: "",
|
||||
serviceType: "s3",
|
||||
currLogLevel: "info",
|
||||
@@ -1062,6 +1064,10 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.settings.profiler.recordSize = false;
|
||||
}
|
||||
|
||||
if (this.settings.googledrive === undefined) {
|
||||
this.settings.googledrive = DEFAULT_GOOGLEDRIVE_CONFIG;
|
||||
}
|
||||
|
||||
await this.saveSettings();
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -341,11 +341,17 @@ export const checkHasSpecialCharForDir = (x: string) => {
|
||||
return /[?/\\]/.test(x);
|
||||
};
|
||||
|
||||
export const unixTimeToStr = (x: number | undefined | null) => {
|
||||
export const unixTimeToStr = (x: number | undefined | null, hasMs = false) => {
|
||||
if (x === undefined || x === null || Number.isNaN(x)) {
|
||||
return undefined;
|
||||
}
|
||||
return window.moment(x).format() as string;
|
||||
if (hasMs) {
|
||||
// 1716712162574 => '2024-05-26T16:29:22.574+08:00'
|
||||
return window.moment(x).toISOString(true);
|
||||
} else {
|
||||
// 1716712162574 => '2024-05-26T16:29:22+08:00'
|
||||
return window.moment(x).format() as string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+44
-3
@@ -21,6 +21,7 @@ import type {
|
||||
} from "./baseTypes";
|
||||
|
||||
import cloneDeep from "lodash/cloneDeep";
|
||||
import { generateGoogleDriveSettingsPart } from "../pro/src/settingsGoogleDrive";
|
||||
import { generateProSettingsPart } from "../pro/src/settingsPro";
|
||||
import { API_VER_ENSURE_REQURL_OK, VALID_REQURL } from "./baseTypesObs";
|
||||
import { messyConfigToNormal } from "./configPersist";
|
||||
@@ -169,7 +170,7 @@ class EncryptionMethodModal extends Modal {
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeRemoteBaseDirModal extends Modal {
|
||||
export class ChangeRemoteBaseDirModal extends Modal {
|
||||
readonly plugin: RemotelySavePlugin;
|
||||
readonly newRemoteBaseDir: string;
|
||||
readonly service: SUPPORTED_SERVICES_TYPE_WITH_REMOTE_BASE_DIR;
|
||||
@@ -1791,6 +1792,22 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// below for googledrive
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
const {
|
||||
googleDriveDiv,
|
||||
googleDriveAllowedToUsedDiv,
|
||||
googleDriveNotShowUpHintSetting,
|
||||
} = generateGoogleDriveSettingsPart(
|
||||
containerEl,
|
||||
t,
|
||||
this.app,
|
||||
this.plugin,
|
||||
() => this.plugin.saveSettings()
|
||||
);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// below for general chooser (part 2/2)
|
||||
//////////////////////////////////////////////////
|
||||
@@ -1806,6 +1823,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
dropdown.addOption("webdav", t("settings_chooseservice_webdav"));
|
||||
dropdown.addOption("onedrive", t("settings_chooseservice_onedrive"));
|
||||
dropdown.addOption("webdis", t("settings_chooseservice_webdis"));
|
||||
dropdown.addOption(
|
||||
"googledrive",
|
||||
t("settings_chooseservice_googledrive")
|
||||
);
|
||||
|
||||
dropdown
|
||||
.setValue(this.plugin.settings.serviceType)
|
||||
@@ -1831,6 +1852,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
"webdis-hide",
|
||||
this.plugin.settings.serviceType !== "webdis"
|
||||
);
|
||||
googleDriveDiv.toggleClass(
|
||||
"googledrive-hide",
|
||||
this.plugin.settings.serviceType !== "googledrive"
|
||||
);
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
@@ -2383,6 +2408,16 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
button.onClick(async () => {
|
||||
new ExportSettingsQrCodeModal(this.app, this.plugin, "webdis").open();
|
||||
});
|
||||
})
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("settings_export_googledrive_button"));
|
||||
button.onClick(async () => {
|
||||
new ExportSettingsQrCodeModal(
|
||||
this.app,
|
||||
this.plugin,
|
||||
"googledrive"
|
||||
).open();
|
||||
});
|
||||
});
|
||||
|
||||
let importSettingVal = "";
|
||||
@@ -2442,8 +2477,14 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
const proDiv = containerEl.createEl("div");
|
||||
generateProSettingsPart(proDiv, t, this.app, this.plugin, () =>
|
||||
this.plugin.saveSettings()
|
||||
generateProSettingsPart(
|
||||
proDiv,
|
||||
t,
|
||||
this.app,
|
||||
this.plugin,
|
||||
() => this.plugin.saveSettings(),
|
||||
googleDriveAllowedToUsedDiv,
|
||||
googleDriveNotShowUpHintSetting
|
||||
);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
+1
-1
@@ -1508,7 +1508,7 @@ export async function syncer(
|
||||
// check pro feature
|
||||
// if anything goes wrong, it will throw
|
||||
await checkProRunnableAndFixInplace(
|
||||
["feature-smart_conflict"],
|
||||
["feature-smart_conflict", "feature-google_drive"],
|
||||
settings,
|
||||
pluginVersion,
|
||||
configSaver
|
||||
|
||||
Reference in New Issue
Block a user