WIP: Plugin List

This commit is contained in:
Louis Lam 2022-09-16 17:45:46 +08:00
parent 6d12fb2c2c
commit 53c06c2b06
7 changed files with 131 additions and 0 deletions

View File

@ -127,6 +127,7 @@ const StatusPage = require("./model/status_page");
const { cloudflaredSocketHandler, autoStart: cloudflaredAutoStart, stop: cloudflaredStop } = require("./socket-handlers/cloudflared-socket-handler"); const { cloudflaredSocketHandler, autoStart: cloudflaredAutoStart, stop: cloudflaredStop } = require("./socket-handlers/cloudflared-socket-handler");
const { proxySocketHandler } = require("./socket-handlers/proxy-socket-handler"); const { proxySocketHandler } = require("./socket-handlers/proxy-socket-handler");
const { dockerSocketHandler } = require("./socket-handlers/docker-socket-handler"); const { dockerSocketHandler } = require("./socket-handlers/docker-socket-handler");
const { pluginsHandler } = require("./socket-handlers/plugins-handler");
app.use(express.json()); app.use(express.json());
@ -1452,6 +1453,7 @@ let needSetup = false;
databaseSocketHandler(socket); databaseSocketHandler(socket);
proxySocketHandler(socket); proxySocketHandler(socket);
dockerSocketHandler(socket); dockerSocketHandler(socket);
pluginsHandler(socket);
log.debug("server", "added all socket handlers"); log.debug("server", "added all socket handlers");

View File

@ -0,0 +1,25 @@
const { checkLogin } = require("../util-server");
const axios = require("axios");
/**
* Handlers for plugins
* @param {Socket} socket Socket.io instance
*/
module.exports.pluginsHandler = (socket) => {
// Get Plugin List
socket.on("getPluginList", async (callback) => {
try {
checkLogin(socket);
const res = await axios.get("https://uptime.kuma.pet/c/plugins.json");
callback(res.data);
} catch (error) {
console.log(error);
callback({
ok: false,
msg: error.message,
});
}
});
};

View File

@ -0,0 +1,39 @@
<template>
<div class="plugin-item pt-4 pb-2">
<div>
<h6>{{ plugin.name }}</h6>
<p class="description">{{ plugin.description }}</p>
</div>
<div class="buttons">
<button class="btn btn-primary">Install</button>
</div>
</div>
</template>
<script>
export default {
props: {
plugin: {
type: Object,
required: true,
},
}
};
</script>
<style lang="scss" scoped>
@import "../assets/vars.scss";
.plugin-item {
display: flex;
justify-content: space-between;
align-content: center;
align-items: center;
.description {
font-size: 13px;
margin-bottom: 0;
}
}
</style>

View File

@ -0,0 +1,56 @@
<template>
<div>
<div class="mt-3">{{ pluginListMsg }}</div>
<PluginItem v-for="plugin in pluginList" :key="plugin.id" :plugin="plugin" />
</div>
</template>
<script>
import PluginItem from "../PluginItem.vue";
export default {
components: {
PluginItem
},
data() {
return {
pluginList: [],
pluginListMsg: "",
};
},
computed: {
settings() {
return this.$parent.$parent.$parent.settings;
},
saveSettings() {
return this.$parent.$parent.$parent.saveSettings;
},
settingsLoaded() {
return this.$parent.$parent.$parent.settingsLoaded;
},
},
async mounted() {
this.pluginListMsg = this.$t("Loading") + "...";
this.$root.getSocket().emit("getPluginList", (res) => {
if (res.ok) {
this.pluginList = res.pluginList;
this.pluginListMsg = "";
} else {
this.pluginListMsg = this.$t("loadingError") + " " + res.message;
}
});
},
methods: {
},
};
</script>
<style lang="scss" scoped>
</style>

View File

@ -582,4 +582,5 @@ export default {
goAlert: "GoAlert", goAlert: "GoAlert",
backupOutdatedWarning: "Deprecated: Since a lot of features added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.", backupOutdatedWarning: "Deprecated: Since a lot of features added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.",
backupRecommend: "Please backup the volume or the data folder (./data/) directly instead.", backupRecommend: "Please backup the volume or the data folder (./data/) directly instead.",
loadingError: "Cannot fetch the data, please try again later.",
}; };

View File

@ -101,6 +101,9 @@ export default {
backup: { backup: {
title: this.$t("Backup"), title: this.$t("Backup"),
}, },
plugins: {
title: this.$t("Plugins"),
},
about: { about: {
title: this.$t("About"), title: this.$t("About"),
}, },

View File

@ -26,6 +26,7 @@ import Proxies from "./components/settings/Proxies.vue";
import Backup from "./components/settings/Backup.vue"; import Backup from "./components/settings/Backup.vue";
import About from "./components/settings/About.vue"; import About from "./components/settings/About.vue";
import DockerHosts from "./components/settings/Docker.vue"; import DockerHosts from "./components/settings/Docker.vue";
import Plugins from "./components/settings/Plugins.vue";
const routes = [ const routes = [
{ {
@ -112,6 +113,10 @@ const routes = [
path: "backup", path: "backup",
component: Backup, component: Backup,
}, },
{
path: "plugins",
component: Plugins,
},
{ {
path: "about", path: "about",
component: About, component: About,