{% extends "settings_page.html" %} {% block header_script_files %} {% endblock %} {% block settings_pane %}
{% endblock %} {% block script %} Vue.component('modals', { 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(); var pluginfile = document.querySelector('#pluginupload'); formData.append("file", pluginfile.files[0]); bootstrap.Modal.getInstance(document.getElementById('modalUpload')).hide(); stashrToast('Uploading Plugin', 'info'); axios.post('{{ url_for('api.api_post_upload_plugin') }}', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) .then(res => { if(res.data.status_code == 200) { stashrToast('Plugin Uploaded', 'success') } else { stashrToast(res.data.message, 'error') } }) }, togglePlugin() { if(this.plugin.plugin_state == 'disabled') { console.log('Enabling') axios.post('{{ url_for('api.api_post_plugin_enable', plugin='PLUGINID') }}'.replace('PLUGINID', this.plugin.plugin_name)) .then(res=>{ if(res.data.status_code == 200) { this.plugin.plugin_state='enabled' stashrToast('Plugin Enabled', 'success') } }) } else { console.log('Disabling') axios.post('{{ url_for('api.api_post_plugin_disable', plugin='PLUGINID') }}'.replace('PLUGINID', this.plugin.plugin_name)) .then(res=>{ if(res.data.status_code == 200) { this.plugin.plugin_state='disabled' stashrToast('Plugin Disabled', 'success') } }) } }, deletePlugin() { axios.post('{{ url_for('api.api_post_plugin_remove', plugin='PLUGINID') }}'.replace('PLUGINID', this.plugin.plugin_package_name)) .then(res=>{ if(res.data.status_code == 200) { stashrToast('Plugin Deleted', 'success') } }) }, }, delimiters: ["[[","]]"] }) Vue.component('plugin',{ props:['plugin'], template: `
  • [[ plugin.plugin_name ]]
    [[ plugin.plugin_version ]]
    [[ plugin.plugin_author ]]
  • `, computed: { pluginStatusBG() { let classname = 'bg-danger'; if(this.plugin.plugin_state == 'enabled') { classname = 'bg-success' } return classname; }, }, methods: { changePlugin() { app.changePlugin(this.plugin) } }, delimiters: ["[[","]]"] }) Vue.component('plugins',{ props: ['plugins'], template: `

    Plugins

    `, methods: { restartServer() { app.restartServer() } }, delimiters: ["[[","]]"] }) var app = new Vue({ el: '#app', data: { plugins: [], plugin: [] }, created() { this.getPlugins() }, methods: { getPlugins() { 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: ["[[","]]"] }) {% endblock %}