diff --git a/src/components/instance/InstanceHeader.vue b/src/components/instance/InstanceHeader.vue index 7d69c24..5cd73a3 100644 --- a/src/components/instance/InstanceHeader.vue +++ b/src/components/instance/InstanceHeader.vue @@ -30,9 +30,19 @@ {{ instance.instance.profileStatus }} + + mdi-cellphone-arrow-down + ({ - disconnect: { - confirm: false, - loading: false, - }, + disconnect: { confirm: false, loading: false }, + restart: { loading: false }, statusMapper: statusMapper, AppStore: useAppStore(), - }), methods: { + async restartInstance() { + this.restart.loading = true; + try { + await instanceController.restart(this.instance.instance.instanceName); + await this.AppStore.reconnect(); + } catch (e) { + console.log(e); + alert(e.message || e.error || "Erro desconhecido"); + } finally { + this.restart.loading = false; + } + }, async disconnectInstance() { if (!this.disconnect.confirm) return (this.disconnect.confirm = true); diff --git a/src/services/instanceController.js b/src/services/instanceController.js index db56b90..c7d30df 100644 --- a/src/services/instanceController.js +++ b/src/services/instanceController.js @@ -45,6 +45,19 @@ const logout = async (instanceName) => { }); } +const restart = async (instanceName) => { + return await http + .post("/instance/restart/:instance", { + params: { + instance: instanceName + } + }) + .then((r) => r.data) + .catch((error) => { + throw error.response?.data || error.response || error; + }); +} + import settings from "./instanceSettingsController.js"; @@ -53,6 +66,7 @@ export default { create, connect, logout, + restart, ...settings }; diff --git a/src/views/Home.vue b/src/views/Home.vue index 80bfebc..0e5ff7e 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -24,22 +24,27 @@ - - -
- mdi-server-network-off -

Nenhuma instância encontrada

-
-
-
+ + +