-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDaemonConfigDetailsModal.vue
More file actions
182 lines (167 loc) · 5.63 KB
/
Copy pathDaemonConfigDetailsModal.vue
File metadata and controls
182 lines (167 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!--
- SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div class="daemon-config-modal">
<NcModal :show="show"
:name="t('app_api', 'Deploy daemon configuration') + ' - ' + daemon.display_name"
@close="closeModal">
<div class="daemon-config-modal-details" :aria-label="t('app_api', 'Deploy daemon configuration details')">
<h2>{{ t('app_api', 'Deploy daemon') }} - {{ daemon.display_name }}</h2>
<NcNoteCard v-if="isDefault" type="success">
{{ t('app_api', 'Default daemon. ExApps will be installed on it') }}
</NcNoteCard>
<NcNoteCard v-if="daemon.accepts_deploy_id === 'manual-install'" type="warning">
{{ t('app_api', 'The "Manual install" daemon is usually used for development. It cannot be set as the default daemon.') }}
</NcNoteCard>
<p><b>{{ t('app_api', 'ExApps installed') }}: </b>{{ daemon.exAppsCount }}</p>
<p><b>{{ t('app_api', 'Name') }}: </b>{{ daemon.name }}</p>
<p><b>{{ t('app_api', 'Protocol') }}: </b>{{ daemon.protocol }}</p>
<p><b>{{ t('app_api', 'Host') }}: </b>{{ daemon.host }}</p>
<p v-if="daemon.deploy_config.harp">
<b>{{ t('app_api', 'ExApp direct communication (FRP disabled)') }}: </b>
{{ daemon.deploy_config.harp.exapp_direct ?? false }}
</p>
<h3>{{ t('app_api', 'Deploy options') }}</h3>
<p><b>{{ t('app_api', 'Docker network') }}: </b>{{ daemon.deploy_config.net }}</p>
<p><b>{{ t('app_api', 'Nextcloud URL') }}: </b>{{ daemon.deploy_config.nextcloud_url }}</p>
<p v-if="daemon.deploy_config.haproxy_password" class="external-label">
<label for="haproxy_password"><b>{{ t('app_api', 'HaProxy password') }}: </b></label>
<NcPasswordField
id="haproxy_password"
:value="daemon.deploy_config?.haproxy_password"
:disable="true"
style="width: fit-content;"
readonly
autocomplete="off" />
</p>
<p>
<b>{{ t('app_api', 'GPU support') }}:</b> {{ daemon.deploy_config.computeDevice && daemon.deploy_config?.computeDevice?.id !== 'cpu' || false }}
</p>
<p v-if="daemon.deploy_config.computeDevice">
<b>{{ t('app_api', 'Computation device') }}:</b> {{ daemon.deploy_config?.computeDevice?.label }}
</p>
<p><b>{{ t('app_api', 'Memory limit') }}:</b> {{ formatMemoryLimit(daemon.deploy_config?.resourceLimits?.memory) }}</p>
<p><b>{{ t('app_api', 'CPU limit') }}:</b> {{ formatCpuLimit(daemon.deploy_config?.resourceLimits?.nanoCPUs) }}</p>
<div v-if="daemon.deploy_config.additional_options" class="additional-options">
<h3>{{ t('app_api', 'Additional options') }}</h3>
<p v-for="option_key in Object.keys(daemon.deploy_config.additional_options)" :key="option_key">
<b>{{ option_key }}:</b> {{ daemon.deploy_config.additional_options[option_key] }}
</p>
</div>
<div class="actions">
<NcButton v-if="daemon.accepts_deploy_id !== 'manual-install'" @click="verifyConnection">
{{ t('app_api', 'Check connection') }}
<template #icon>
<NcLoadingIcon v-if="verifying" :size="20" />
<Connection v-else :size="20" />
</template>
</NcButton>
</div>
</div>
</NcModal>
</div>
</template>
<script>
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showSuccess, showError } from '@nextcloud/dialogs'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import Connection from 'vue-material-design-icons/Connection.vue'
export default {
name: 'DaemonConfigDetailsModal',
components: {
NcModal,
NcButton,
NcNoteCard,
NcLoadingIcon,
NcPasswordField,
Connection,
},
props: {
daemon: {
type: Object,
required: true,
default: () => {},
},
show: {
type: Boolean,
required: true,
default: false,
},
isDefault: {
type: Boolean,
required: true,
default: () => false,
},
},
data() {
return {
verifying: false,
}
},
methods: {
closeModal() {
this.$emit('update:show', false)
},
verifyConnection() {
this.verifying = true
axios.post(generateUrl(`/apps/app_api/daemons/${this.daemon.name}/check`))
.then(res => {
if (res.data.success) {
showSuccess(t('app_api', 'Daemon connection successful'))
} else {
showError(t('app_api', 'Failed to connect to the daemon. Check the logs'))
}
this.verifying = false
})
.catch(err => {
this.verifying = false
showError(t('app_api', 'Failed to check connection to the daemon. Check the logs'))
console.debug(err)
})
},
formatMemoryLimit(memoryBytes) {
if (!memoryBytes) {
return t('app_api', 'Unlimited')
}
const memoryMiB = memoryBytes / (1024 * 1024)
if (memoryMiB >= 1024) {
const memoryGiB = memoryMiB / 1024
return t('app_api', '{size} GiB', { size: memoryGiB.toFixed(1) })
}
return t('app_api', '{size} MiB', { size: Math.round(memoryMiB) })
},
formatCpuLimit(nanoCpus) {
if (!nanoCpus) {
return t('app_api', 'Unlimited')
}
const cpus = nanoCpus / 1000000000
return n('app_api', '{n} CPU', '{n} CPUs', cpus, { n: cpus.toFixed(2) })
},
},
}
</script>
<style scoped lang="scss">
.daemon-config-modal-details {
padding: 20px;
}
.actions {
display: flex;
justify-content: space-between;
margin: 20px 0;
}
.external-label {
display: flex;
align-items: center;
width: 100%;
label {
margin-right: 5px;
}
}
</style>