mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 16:48:44 +08:00
optimize sync config panel
This commit is contained in:
parent
23f145f0b0
commit
1190dafbd5
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-douban-plugin",
|
"id": "obsidian-douban-plugin",
|
||||||
"name": "Douban",
|
"name": "Douban",
|
||||||
"version": "v1.7.2",
|
"version": "v1.7.3",
|
||||||
"minAppVersion": "0.12.0",
|
"minAppVersion": "0.12.0",
|
||||||
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
||||||
"author": "Wanxp",
|
"author": "Wanxp",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian-douban-plugin",
|
"name": "obsidian-douban-plugin",
|
||||||
"version": "v1.7.2",
|
"version": "v1.7.3",
|
||||||
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ export class DoubanSyncModal extends Modal {
|
|||||||
const {syncConfig} = syncStatus;
|
const {syncConfig} = syncStatus;
|
||||||
contentEl.createEl("h3", {text: i18nHelper.getMessage('500002')});
|
contentEl.createEl("h3", {text: i18nHelper.getMessage('500002')});
|
||||||
|
|
||||||
this.showConfigPan(contentEl, syncConfig, true);
|
this.showConfigPan(contentEl.createDiv('config'), syncConfig, true);
|
||||||
|
|
||||||
const sliderDiv = contentEl.createEl('div');
|
const sliderDiv = contentEl.createEl('div');
|
||||||
sliderDiv.addClass('obsidian_douban_sync_slider');
|
sliderDiv.addClass('obsidian_douban_sync_slider');
|
||||||
@ -66,27 +66,32 @@ export class DoubanSyncModal extends Modal {
|
|||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.close();
|
this.close();
|
||||||
});
|
});
|
||||||
cancelButton.setClass("obsidian_douban_search_button");
|
|
||||||
syncButton.setClass("obsidian_douban_search_button");
|
|
||||||
this.showProgress(sliderDiv, syncButton);
|
this.showProgress(sliderDiv, syncButton);
|
||||||
|
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
this.showProgress(sliderDiv,syncButton);
|
this.showProgress(sliderDiv,syncButton);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
syncButton.setClass("obsidian_douban_search_button");
|
||||||
|
cancelButton.setClass("obsidian_douban_search_button");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private showProgress(sliderDiv: HTMLDivElement, button:ButtonComponent) {
|
private showProgress(sliderDiv: HTMLDivElement, button:ButtonComponent) {
|
||||||
|
sliderDiv.empty();
|
||||||
|
new Setting(sliderDiv);
|
||||||
|
let progress = sliderDiv.createDiv('progress');
|
||||||
const {syncStatus} = this.plugin.statusHolder;
|
const {syncStatus} = this.plugin.statusHolder;
|
||||||
if (!this.plugin.statusHolder.syncStarted) {
|
if (!this.plugin.statusHolder.syncStarted) {
|
||||||
sliderDiv.innerHTML = `<p>
|
progress.innerHTML = `<p>
|
||||||
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
||||||
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal()}" value="${syncStatus.getHandle()}"> </progress> <span> ${syncStatus.getHandle()}/${syncStatus.getTotal()}:${i18nHelper.getMessage('110036')} </span>
|
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal()}" value="${syncStatus.getHandle()}"> </progress> <span> ${syncStatus.getHandle()}/${syncStatus.getTotal()}:${i18nHelper.getMessage('110036')} </span>
|
||||||
</p>`
|
</p>`
|
||||||
button.setDisabled(true);
|
button.setDisabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sliderDiv.innerHTML = `<p>
|
progress.innerHTML = `<p>
|
||||||
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
||||||
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal()}" value="${syncStatus.getHandle()}"> </progress> <span> ${syncStatus.getHandle()}/${syncStatus.getTotal()} </span>
|
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal()}" value="${syncStatus.getHandle()}"> </progress> <span> ${syncStatus.getHandle()}/${syncStatus.getTotal()} </span>
|
||||||
</p>`}
|
</p>`}
|
||||||
@ -104,7 +109,7 @@ export class DoubanSyncModal extends Modal {
|
|||||||
cacheImage: ( settings.cacheImage == null) ? DEFAULT_SETTINGS.cacheImage : settings.cacheImage,
|
cacheImage: ( settings.cacheImage == null) ? DEFAULT_SETTINGS.cacheImage : settings.cacheImage,
|
||||||
attachmentPath: (settings.attachmentPath == '' || settings.attachmentPath == null) ? DEFAULT_SETTINGS.attachmentPath : settings.attachmentPath,
|
attachmentPath: (settings.attachmentPath == '' || settings.attachmentPath == null) ? DEFAULT_SETTINGS.attachmentPath : settings.attachmentPath,
|
||||||
};
|
};
|
||||||
this.showConfigPan(contentEl, syncConfig, false);
|
this.showConfigPan(contentEl.createDiv('config'), syncConfig, false);
|
||||||
const controls = contentEl.createDiv("controls");
|
const controls = contentEl.createDiv("controls");
|
||||||
|
|
||||||
const syncButton = new ButtonComponent(controls)
|
const syncButton = new ButtonComponent(controls)
|
||||||
@ -137,16 +142,12 @@ export class DoubanSyncModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private showConfigPan(contentEl: HTMLElement, config:SyncConfig, disable:boolean) {
|
private showConfigPan(contentEl: HTMLElement, config:SyncConfig, disable:boolean) {
|
||||||
const typeSelections = contentEl.createDiv('type-selection');
|
new Setting(contentEl);
|
||||||
const folderSelections = contentEl.createDiv('folder-selection');
|
this.showTypeDropdown(contentEl, config, disable);
|
||||||
const fileName = contentEl.createDiv('fileName-item');
|
this.showOutputFolderSelections(contentEl, config, disable);
|
||||||
const attachments = contentEl.createDiv('attachments-item');
|
this.showOutiFleName(contentEl, config, disable);
|
||||||
const forceSelections = contentEl.createDiv('force-selection');
|
this.showAttachmentsFileConfig(contentEl, config, disable);
|
||||||
this.showTypeDropdown(typeSelections, config, disable);
|
this.showForceUpdateConfig(contentEl, config, disable);
|
||||||
this.showOutputFolderSelections(folderSelections, config, disable);
|
|
||||||
this.showOutiFleName(fileName, config, disable);
|
|
||||||
this.showAttachmentsFileConfig(attachments, config, disable);
|
|
||||||
this.showForceUpdateConfig(forceSelections, config, disable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onClose() {
|
async onClose() {
|
||||||
@ -158,7 +159,6 @@ export class DoubanSyncModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private openScopeDropdown(contentEl:HTMLDivElement, config: SyncConfig, disable:boolean) {
|
private openScopeDropdown(contentEl:HTMLDivElement, config: SyncConfig, disable:boolean) {
|
||||||
contentEl.empty();
|
|
||||||
switch (config.syncType) {
|
switch (config.syncType) {
|
||||||
case SyncType.movie:
|
case SyncType.movie:
|
||||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_MOVIE_SYNC, config, disable);
|
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_MOVIE_SYNC, config, disable);
|
||||||
@ -178,9 +178,9 @@ export class DoubanSyncModal extends Modal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private showTypeDropdown(containerEl:HTMLDivElement, config: SyncConfig, disable:boolean) {
|
private showTypeDropdown(containerEl:HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
containerEl.empty();
|
|
||||||
const settings = new Setting(containerEl);
|
const settings = new Setting(containerEl);
|
||||||
|
const scopeSelections = containerEl.createDiv("scope-selection");
|
||||||
settings
|
settings
|
||||||
.setName(i18nHelper.getMessage('110030'))
|
.setName(i18nHelper.getMessage('110030'))
|
||||||
.addDropdown((dropdown) => {
|
.addDropdown((dropdown) => {
|
||||||
@ -188,10 +188,9 @@ export class DoubanSyncModal extends Modal {
|
|||||||
.setValue(config.syncType)
|
.setValue(config.syncType)
|
||||||
.onChange((value) => {
|
.onChange((value) => {
|
||||||
config.syncType = value;
|
config.syncType = value;
|
||||||
this.showTypeDropdown(containerEl, config, disable);
|
this.openScopeDropdown(scopeSelections, config, disable);
|
||||||
});
|
});
|
||||||
}).setDisabled(disable);
|
}).setDisabled(disable);
|
||||||
const scopeSelections = containerEl.createDiv("scope-selection");
|
|
||||||
this.openScopeDropdown(scopeSelections, config, disable);
|
this.openScopeDropdown(scopeSelections, config, disable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,10 +208,8 @@ export class DoubanSyncModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private showOutiFleName(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
private showOutiFleName(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
containerEl.empty();
|
|
||||||
const {settings} = this.plugin;
|
const {settings} = this.plugin;
|
||||||
const placeHolder =(settings.dataFileNamePath == '' || settings.dataFileNamePath == null) ? DEFAULT_SETTINGS.dataFileNamePath : settings.dataFileNamePath;
|
const placeHolder =(settings.dataFileNamePath == '' || settings.dataFileNamePath == null) ? DEFAULT_SETTINGS.dataFileNamePath : settings.dataFileNamePath;
|
||||||
containerEl.empty();
|
|
||||||
const dataFilePathSetting = new Setting(containerEl)
|
const dataFilePathSetting = new Setting(containerEl)
|
||||||
.setName(i18nHelper.getMessage('121601'))
|
.setName(i18nHelper.getMessage('121601'))
|
||||||
.setDesc(i18nHelper.getMessage('121602'))
|
.setDesc(i18nHelper.getMessage('121602'))
|
||||||
@ -224,19 +221,18 @@ export class DoubanSyncModal extends Modal {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.setDisabled(disable);
|
.setDisabled(disable);
|
||||||
dataFilePathSetting.addExtraButton((button) => {
|
// dataFilePathSetting.addExtraButton((button) => {
|
||||||
button
|
// button
|
||||||
.setIcon('reset')
|
// .setIcon('reset')
|
||||||
.setTooltip(i18nHelper.getMessage('121902'))
|
// .setTooltip(i18nHelper.getMessage('121902'))
|
||||||
.onClick(async () => {
|
// .onClick(async () => {
|
||||||
config.dataFileNamePath = placeHolder
|
// config.dataFileNamePath = placeHolder
|
||||||
this.showOutiFleName(containerEl, config, disable);
|
// this.showOutiFleName(containerEl, config, disable);
|
||||||
});
|
// });
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
showOutputFolderSelections(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
showOutputFolderSelections(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
containerEl.empty();
|
|
||||||
const placeHolder:string = this.plugin.settings.dataFilePath ? this.plugin.settings.dataFilePath : DEFAULT_SETTINGS.dataFilePath;
|
const placeHolder:string = this.plugin.settings.dataFilePath ? this.plugin.settings.dataFilePath : DEFAULT_SETTINGS.dataFilePath;
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName( i18nHelper.getMessage('121501'))
|
.setName( i18nHelper.getMessage('121501'))
|
||||||
@ -256,7 +252,6 @@ export class DoubanSyncModal extends Modal {
|
|||||||
|
|
||||||
|
|
||||||
showForceUpdateConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
showForceUpdateConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
containerEl.empty();
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName(i18nHelper.getMessage('110031'))
|
.setName(i18nHelper.getMessage('110031'))
|
||||||
.setDesc(i18nHelper.getMessage('500110'))
|
.setDesc(i18nHelper.getMessage('500110'))
|
||||||
@ -272,9 +267,9 @@ export class DoubanSyncModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showAttachmentsFileConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
showAttachmentsFileConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
containerEl.empty();
|
const settings = new Setting(containerEl);
|
||||||
new Setting(containerEl)
|
let attachmentFileEl = containerEl.createDiv('attachment-file-path-selection');
|
||||||
.setName(i18nHelper.getMessage('121430'))
|
settings.setName(i18nHelper.getMessage('121430'))
|
||||||
.setDesc(i18nHelper.getMessage('121431'))
|
.setDesc(i18nHelper.getMessage('121431'))
|
||||||
.addToggle((toggleComponent) => {
|
.addToggle((toggleComponent) => {
|
||||||
toggleComponent
|
toggleComponent
|
||||||
@ -282,16 +277,18 @@ export class DoubanSyncModal extends Modal {
|
|||||||
.setValue(config.cacheImage)
|
.setValue(config.cacheImage)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
config.cacheImage = value;
|
config.cacheImage = value;
|
||||||
this.showAttachmentsFileConfig(containerEl, config, disable);
|
this.showAttachmentPathSelections(value, attachmentFileEl, config, disable);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.setDisabled(disable);
|
.setDisabled(disable);
|
||||||
if(config.cacheImage) {
|
this.showAttachmentPathSelections(config.cacheImage, attachmentFileEl, config, disable);
|
||||||
this.showAttachmentPathSelections(containerEl, config, disable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showAttachmentPathSelections(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
showAttachmentPathSelections(show:boolean, containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
|
containerEl.empty();
|
||||||
|
if (!show) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const placeHolder:string = this.plugin.settings.attachmentPath ? this.plugin.settings.attachmentPath : DEFAULT_SETTINGS.attachmentPath;
|
const placeHolder:string = this.plugin.settings.attachmentPath ? this.plugin.settings.attachmentPath : DEFAULT_SETTINGS.attachmentPath;
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName( i18nHelper.getMessage('121432'))
|
.setName( i18nHelper.getMessage('121432'))
|
||||||
|
|||||||
@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
.obsidian_douban_search_button {
|
.obsidian_douban_search_button {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-left: 5px;
|
margin-right: 10px;
|
||||||
margin-right: 5px;
|
horiz-align: right;
|
||||||
|
float:right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.obsidian_douban_settings_desc.has_error {
|
.obsidian_douban_settings_desc.has_error {
|
||||||
|
|||||||
@ -17,5 +17,6 @@
|
|||||||
"v1.6.3": "0.12.0",
|
"v1.6.3": "0.12.0",
|
||||||
"v1.7.0": "0.12.0",
|
"v1.7.0": "0.12.0",
|
||||||
"v1.7.1": "0.12.0",
|
"v1.7.1": "0.12.0",
|
||||||
"v1.7.2": "0.12.0"
|
"v1.7.2": "0.12.0",
|
||||||
|
"v1.7.3": "0.12.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user