Skip to content

Commit

Permalink
Merge pull request #1724 from slntopp/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SazukinPavel authored May 8, 2024
2 parents 6040449 + dec3e08 commit 505b075
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 19 deletions.
52 changes: 52 additions & 0 deletions admin-ui/src/components/dialogs/unsuspendInstance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<instance-control-btn hint="unsuspend">
<v-dialog v-model="isModalOpen" max-width="500">
<template v-slot:activator="{ on, attrs }">
<v-btn
:disabled="disabled"
:loading="loading"
class="ma-1"
v-bind="attrs"
v-on="on"
>
<v-icon>mdi-weather-sunny</v-icon>
</v-btn>
</template>
<v-card class="pa-5" color="background-light">
<date-picker
label="Unsuspend until"
:min="formatSecondsToDateString(Date.now() / 1000 + 86400)"
v-model="unsuspendTo"
clearable
/>
<v-card-actions class="d-flex justify-end">
<v-btn class="mr-2" @click="isModalOpen = false"> Cancel </v-btn>
<v-btn class="mr-2" @click="unsuspend(false)"> unsuspend </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</instance-control-btn>
</template>

<script setup>
import { toRefs, ref } from "vue";
import { formatSecondsToDateString } from "@/functions";
import InstanceControlBtn from "@/components/ui/hintBtn.vue";
import DatePicker from "@/components/ui/datePicker.vue";
const props = defineProps(["disabled", "loading", "template"]);
const emit = defineEmits(["click"]);
const { disabled, loading } = toRefs(props);
const isModalOpen = ref(false);
const unsuspendTo = ref();
const unsuspend = async () => {
isModalOpen.value = false;
emit("click", new Date(unsuspendTo.value).getTime() / 1000);
};
</script>

<style scoped></style>
42 changes: 37 additions & 5 deletions admin-ui/src/components/instance/controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ export default {
this.runningActionName = "";
}
},
unsuspendInstance(action, date) {
this.sendAction({ action }, { date: date || undefined });
},
async sendInvoice() {
this.isInvoiceLoading = true;
try {
Expand All @@ -428,6 +431,17 @@ export default {
},
baseVmControls() {
return [
this.isFreezed
? {
action: "unfreeze",
title: "Unfreeze",
icon: "mdi-snowflake-off",
}
: {
action: "freeze",
title: "Freeze",
icon: "mdi-snowflake",
},
this.isDetached
? {
action: "attach",
Expand Down Expand Up @@ -462,8 +476,12 @@ export default {
},
{
action: "resume",
title: "Unsuspend",
disabled: this.ioneActions?.resume,
icon: "mdi-play",
type: "method",
component: () =>
import("@/components/dialogs/unsuspendInstance.vue"),
method: (date) => this.unsuspendInstance("resume", date),
},
{
action: "suspend",
Expand Down Expand Up @@ -492,7 +510,12 @@ export default {
disabled: this.ovhActions?.start,
},
{ action: "poweroff", disabled: true, icon: "mdi-stop" },
{ action: "resume", disabled: true, icon: "mdi-play" },
{
action: "resume",
title: "Unsuspend",
disabled: true,
icon: "mdi-weather-sunny",
},
{ action: "suspend", disabled: true, icon: "mdi-power-sleep" },
{ action: "reboot", disabled: true, icon: "mdi-restart" },
{
Expand All @@ -512,9 +535,12 @@ export default {
},
{
action: "resume_vm",
title: "resume",
icon: "mdi-play",
disabled: this.ovhActions?.resume,
title: "Unsuspend",
type: "method",
component: () =>
import("@/components/dialogs/unsuspendInstance.vue"),
method: (date) => this.unsuspendInstance("resume_vm", date),
},
{
action: "suspend_vm",
Expand Down Expand Up @@ -647,7 +673,10 @@ export default {
action: "unsuspend",
title: "unsuspend",
disabled: !this.keywebActions?.unsuspend,
icon: "mdi-weather-sunny",
type: "method",
component: () =>
import("@/components/dialogs/unsuspendInstance.vue"),
method: (date) => this.unsuspendInstance("unsuspend", date),
},
{
action: "vnc",
Expand Down Expand Up @@ -869,6 +898,9 @@ export default {
isDetached() {
return this.template?.status?.toLowerCase() === "detached";
},
isFreezed() {
return this.template.data.freeze;
},
product() {
switch (this.template.type) {
case "ovh": {
Expand Down
7 changes: 6 additions & 1 deletion admin-ui/src/components/ui/instanceState.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<template>
<v-chip :small="small" :color="chipColor">
{{ state }} {{ isDetached ? "(Hided)" : "" }}
{{ isFreezed ? "(Freezed)" : "" }}
</v-chip>
</template>

<script setup>
import { computed, toRefs } from "vue";
import {getState} from "@/functions";
import { getState } from "@/functions";
const props = defineProps(["template", "small"]);
const { template } = toRefs(props);
Expand All @@ -19,6 +20,10 @@ const isDetached = computed(() => {
return template.value?.status.toLowerCase() === "detached";
});
const isFreezed = computed(() => {
return template.value?.data.freeze;
});
const chipColor = computed(() => {
if (!state.value) return "error";
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/src/views/PluginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const store = useStore();
const plugin = ref();
const url = computed(() => route.params.url || route.query.url);
const isMaximized = computed(() => route.query.fullscrean);
const isMaximized = computed(() => route.query.fullscrean === "true");
const params = computed(() => {
const result = {
...route.params.params,
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ require (
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75
github.com/wI2L/jsondiff v0.5.2
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.21.0
golang.org/x/crypto v0.23.0
golang.org/x/oauth2 v0.18.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.1
)

require (
Expand Down Expand Up @@ -62,8 +62,8 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
Expand Down Expand Up @@ -221,17 +221,17 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down Expand Up @@ -268,8 +268,8 @@ google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down

0 comments on commit 505b075

Please sign in to comment.