Make plugin switch actually do something

This commit is contained in:
Jiiks 2018-01-23 18:19:45 +02:00
parent 19b88b4be0
commit 098ac8fb17
3 changed files with 20 additions and 11 deletions

View File

@ -17,6 +17,7 @@ class Plugin {
constructor(pluginInternals) { constructor(pluginInternals) {
this.__pluginInternals = pluginInternals; this.__pluginInternals = pluginInternals;
this.userConfig.enabled = this.userConfig.enabled || false;
this.start = this.start.bind(this); this.start = this.start.bind(this);
this.stop = this.stop.bind(this); this.stop = this.stop.bind(this);
} }
@ -42,7 +43,7 @@ class Plugin {
} }
return false; return false;
} }
return true; //Assume plugin started since it doesn't have onStart return this.userConfig.enabled = true; //Assume plugin started since it doesn't have onStart
} }
stop() { stop() {
@ -54,6 +55,7 @@ class Plugin {
} }
return false; return false;
} }
this.userConfig.enabled = false;
return true; //Assume plugin stopped since it doesn't have onStop return true; //Assume plugin stopped since it doesn't have onStop
} }

View File

@ -17,7 +17,6 @@
} catch (err) { } catch (err) {
} }
this.localPlugins = PluginManager.plugins;
} }
function showLocal() { function showLocal() {
@ -29,8 +28,11 @@
} }
function togglePlugin(plugin) { function togglePlugin(plugin) {
if (plugin.enabled) return PluginManager.stopPlugin(plugin.name); if (plugin.enabled) {
PluginManager.startPlugin(plugin.name); this.pluginManager.stopPlugin(plugin.name);
} else {
this.pluginManager.startPlugin(plugin.name);
}
} }
const methods = { showLocal, showOnline, refreshLocalPlugins, togglePlugin }; const methods = { showLocal, showOnline, refreshLocalPlugins, togglePlugin };
@ -39,8 +41,13 @@
components, components,
data() { data() {
return { return {
localPlugins: [], local: true,
local: true pluginManager: PluginManager
}
},
computed: {
localPlugins: function () {
return this.pluginManager.plugins;
} }
}, },
methods, methods,

View File

@ -167,7 +167,7 @@
display: block; display: block;
} }
.bd-setting-switch .bd-switch-wrapper input { .bd-switch-wrapper input {
position: absolute; position: absolute;
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
@ -176,7 +176,7 @@
z-index: 1; z-index: 1;
} }
.bd-setting-switch .bd-switch-wrapper .bd-switch { .bd-switch-wrapper .bd-switch {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
@ -206,7 +206,7 @@
border-bottom: 0px solid hsla(218,5%,47%,.1); border-bottom: 0px solid hsla(218,5%,47%,.1);
} }
.bd-setting-switch .bd-switch-wrapper .bd-switch:before { .bd-switch-wrapper .bd-switch:before {
content: ""; content: "";
display: block; display: block;
width: 18px; width: 18px;
@ -221,11 +221,11 @@
box-shadow: 0 3px 1px 0 rgba(0,0,0,.05), 0 2px 2px 0 rgba(0,0,0,.1), 0 3px 3px 0 rgba(0,0,0,.05); box-shadow: 0 3px 1px 0 rgba(0,0,0,.05), 0 2px 2px 0 rgba(0,0,0,.1), 0 3px 3px 0 rgba(0,0,0,.05);
} }
.bd-setting-switch .bd-switch-wrapper .bd-switch.bd-checked { .bd-switch-wrapper .bd-switch.bd-checked {
background: $colbdblue; background: $colbdblue;
} }
.bd-setting-switch .bd-switch-wrapper .bd-switch.bd-checked:before { .bd-switch-wrapper .bd-switch.bd-checked:before {
transform: translateX(20px); transform: translateX(20px);
} }