mirror of https://github.com/keeweb/keeweb.git
auto-update plugins checkbox
This commit is contained in:
parent
a65f89e1a9
commit
a219d4254c
|
@ -476,6 +476,7 @@
|
|||
"setPlDevelopStart": "Start here",
|
||||
"setPlTranslate": "Or you can {}",
|
||||
"setPlTranslateLink": "translate the app to your language",
|
||||
"setPlAutoUpdate": "Update automatically",
|
||||
|
||||
"setAboutTitle": "About",
|
||||
"setAboutBuilt": "This app is built with these awesome tools",
|
||||
|
|
|
@ -110,10 +110,22 @@ const PluginManager = Backbone.Model.extend({
|
|||
});
|
||||
},
|
||||
|
||||
setAutoUpdate(id, enabled) {
|
||||
const plugins = this.get('plugins');
|
||||
const plugin = plugins.get(id);
|
||||
if (!plugin || plugin.get('autoUpdate') === enabled) {
|
||||
return;
|
||||
}
|
||||
plugin.setAutoUpdate(enabled);
|
||||
this.trigger('change');
|
||||
this.saveState();
|
||||
},
|
||||
|
||||
loadPlugin(desc) {
|
||||
const plugin = new Plugin({
|
||||
manifest: desc.manifest,
|
||||
url: desc.url
|
||||
url: desc.url,
|
||||
autoUpdate: desc.autoUpdate
|
||||
});
|
||||
return plugin.install(desc.enabled, true)
|
||||
.then(() => plugin)
|
||||
|
@ -125,7 +137,8 @@ const PluginManager = Backbone.Model.extend({
|
|||
plugins: this.get('plugins').map(plugin => ({
|
||||
manifest: plugin.get('manifest'),
|
||||
url: plugin.get('url'),
|
||||
enabled: plugin.get('status') === 'active'
|
||||
enabled: plugin.get('status') === 'active',
|
||||
autoUpdate: plugin.get('autoUpdate')
|
||||
}))
|
||||
});
|
||||
},
|
||||
|
|
|
@ -35,6 +35,7 @@ const Plugin = Backbone.Model.extend(_.extend({}, PluginStatus, {
|
|||
manifest: '',
|
||||
url: '',
|
||||
status: '',
|
||||
autoUpdate: false,
|
||||
installTime: null,
|
||||
installError: null,
|
||||
updateCheckDate: null,
|
||||
|
@ -493,6 +494,10 @@ const Plugin = Backbone.Model.extend(_.extend({}, PluginStatus, {
|
|||
});
|
||||
},
|
||||
|
||||
setAutoUpdate(enabled) {
|
||||
this.set('autoUpdate', !!enabled);
|
||||
},
|
||||
|
||||
getSettingPrefix() {
|
||||
return `plugin:${this.id}:`;
|
||||
},
|
||||
|
|
|
@ -25,7 +25,8 @@ const SettingsPluginsView = Backbone.View.extend({
|
|||
'input .settings__plugins-gallery-search': 'gallerySearchInput',
|
||||
'change select.settings__plugins-plugin-input': 'pluginSettingChange',
|
||||
'change input[type=checkbox].settings__plugins-plugin-input': 'pluginSettingChange',
|
||||
'input input[type=text].settings__plugins-plugin-input': 'pluginSettingChange'
|
||||
'input input[type=text].settings__plugins-plugin-input': 'pluginSettingChange',
|
||||
'change .settings__plugins-plugin-updates': 'autoUpdateChange'
|
||||
},
|
||||
|
||||
searchStr: null,
|
||||
|
@ -36,7 +37,7 @@ const SettingsPluginsView = Backbone.View.extend({
|
|||
initialize() {
|
||||
this.listenTo(PluginManager, 'change', this.render.bind(this));
|
||||
this.listenTo(Backbone, 'plugin-gallery-load-complete', this.render.bind(this));
|
||||
PluginGallery.loadPlugins();
|
||||
// PluginGallery.loadPlugins();
|
||||
},
|
||||
|
||||
render() {
|
||||
|
@ -51,6 +52,7 @@ const SettingsPluginsView = Backbone.View.extend({
|
|||
updateCheckDate: Format.dtStr(plugin.get('updateCheckDate')),
|
||||
installError: plugin.get('installError'),
|
||||
official: plugin.get('manifest').publicKey === publicKey,
|
||||
autoUpdate: plugin.get('autoUpdate'),
|
||||
settings: plugin.getSettings()
|
||||
})).sort(Comparators.stringComparator('id', true)),
|
||||
installingFromUrl: this.installFromUrl && !this.installFromUrl.error,
|
||||
|
@ -208,6 +210,12 @@ const SettingsPluginsView = Backbone.View.extend({
|
|||
const val = el.type === 'checkbox' ? el.checked : el.value;
|
||||
const plugin = PluginManager.getPlugin(pluginId);
|
||||
plugin.setSettings({ [setting]: val });
|
||||
},
|
||||
|
||||
autoUpdateChange(e) {
|
||||
const pluginId = $(e.target).data('plugin');
|
||||
const enabled = e.target.checked;
|
||||
PluginManager.setAutoUpdate(pluginId, enabled);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -190,6 +190,11 @@
|
|||
&-plugin-desc {
|
||||
margin-bottom: $base-padding-v;
|
||||
}
|
||||
&-plugin-updates {
|
||||
>label {
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
&-gallery {
|
||||
margin-top: $base-spacing;
|
||||
display: flex;
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
{{#if plugin.installError}}<div class="error-color settings__plugins-install-error"><pre>{{plugin.installError}}</pre></div>{{/if}}
|
||||
{{#if plugin.updateError}}<div class="error-color settings__plugins-install-error"><pre>{{plugin.updateError}}</pre></div>{{/if}}
|
||||
</div>
|
||||
<div class="settings__plugins-plugin-updates">
|
||||
<input type="checkbox" class="settings__plugins-plugin-update-check settings__input input-base"
|
||||
id="plugin-{{plugin.id}}-auto-update" data-plugin="{{plugin.id}}"
|
||||
{{#if plugin.autoUpdate}}checked{{/if}} />
|
||||
<label for="plugin-{{plugin.id}}-auto-update">{{res 'setPlAutoUpdate'}}</label>
|
||||
</div>
|
||||
{{#if plugin.settings}}
|
||||
<div class="settings__plugins-plugin-settings">
|
||||
{{#each plugin.settings as |setting|}}
|
||||
|
|
Loading…
Reference in New Issue