From 2a452df52702fa023172635ee8ee1ee4f6e7bffb Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 25 Mar 2021 21:13:35 -0500 Subject: [PATCH] Rewrite of plugins page --- stashr/templates/settings_page_plugins.html | 177 +++++++++++++------- 1 file changed, 115 insertions(+), 62 deletions(-) diff --git a/stashr/templates/settings_page_plugins.html b/stashr/templates/settings_page_plugins.html index cef4412..ac30160 100644 --- a/stashr/templates/settings_page_plugins.html +++ b/stashr/templates/settings_page_plugins.html @@ -8,7 +8,7 @@
- +
{% endblock %} @@ -16,7 +16,7 @@ {% block script %} Vue.component('modals', { - props: [], + props: ['plugin'], template: `
+ + + `, + computed: { + pluginClass() { + let classname = 'btn-warning'; + if(this.plugin.plugin_state == 'disabled') { + classname = 'btn-success'; + }; + return classname; + }, + pluginAction() { + let text = 'Disable'; + if(this.plugin.plugin_state == 'disabled') { + text = 'Enable'; + }; + return text; + } + }, methods: { uploadFile() { let formData = new FormData(); @@ -62,42 +120,6 @@ Vue.component('modals', { } }) }, - }, - delimiters: ["[[","]]"] -}) - -Vue.component('plugin',{ - props:['plugin'], - template: ` - - [[ plugin.plugin_name ]] - [[ plugin.plugin_description ]] - [[ plugin.plugin_version ]] - [[ plugin.plugin_author ]] - [[ plugin.plugin_url ]] - [[ plugin.plugin_license ]] - [[ plugin.plugin_state ]] - -
- - - - - - - - - - - - - - - - - -
NameDescriptionVersionAuthorURLLicenseStateActionDelete
+
`, + methods: { + restartServer() { + app.restartServer() + } + }, delimiters: ["[[","]]"] }) @@ -179,6 +218,7 @@ var app = new Vue({ el: '#app', data: { plugins: [], + plugin: [] }, created() { this.getPlugins() @@ -188,8 +228,21 @@ var app = new Vue({ axios.get('{{ url_for('api.api_get_plugins') }}') .then(res => { this.plugins = res.data.results + this.plugin = this.plugins[0] }) }, + changePlugin(plugin) { + this.plugin = plugin + }, + restartServer() { + axios.post('{{ url_for('api.restart_server') }}') + .then(res=>{ + if(res.data.status_code == 200) { + stashrToast('Restarting Server', 'success') + } + }) + .catch() + }, }, delimiters: ["[[","]]"] })