diff --git a/frontend/src/api/domain.ts b/frontend/src/api/domain.ts index e72a4dbe..0e6b55ab 100644 --- a/frontend/src/api/domain.ts +++ b/frontend/src/api/domain.ts @@ -13,11 +13,7 @@ class Domain extends Curd { get_template() { return http.get('template') } - - cert_info(path: string) { - return http.get('cert_info?ssl_certificate_path=' + path) - } - + add_auto_cert(domain: string) { return http.post('cert/' + domain) } diff --git a/frontend/src/views/domain/DomainEdit.vue b/frontend/src/views/domain/DomainEdit.vue index aed2fdbf..4ed9622b 100644 --- a/frontend/src/views/domain/DomainEdit.vue +++ b/frontend/src/views/domain/DomainEdit.vue @@ -24,6 +24,8 @@ const ngx_config = reactive({ servers: [] }) +const cert_info_map: any = reactive({}) + const auto_cert = ref(false) const enabled = ref(false) const configText = ref('') @@ -33,13 +35,23 @@ const saving = ref(false) init() +function handle_response(r: any) { + + Object.keys(cert_info_map).forEach(v => { + delete cert_info_map[v] + }) + + configText.value = r.config + enabled.value = r.enabled + auto_cert.value = r.auto_cert + Object.assign(ngx_config, r.tokenized) + Object.assign(cert_info_map, r.cert_info) +} + function init() { if (name.value) { domain.get(name.value).then((r: any) => { - configText.value = r.config - enabled.value = r.enabled - auto_cert.value = r.auto_cert - Object.assign(ngx_config, r.tokenized) + handle_response(r) }).catch(r => { message.error(r.message ?? $gettext('Server error')) }) @@ -74,9 +86,8 @@ const save = async () => { } domain.save(name.value, {content: configText.value}).then(r => { - configText.value = r.config - enabled.value = r.enabled - Object.assign(ngx_config, r.tokenized) + handle_response(r) + message.success($gettext('Saved successfully')) }).catch((e: any) => { @@ -151,6 +162,7 @@ function on_change_enabled(checked: boolean) { { return props.directivesMap['server_name'][0].params.trim() }) -const ssl_certificate_path = computed(() => { - return props.directivesMap['ssl_certificate']?.[0].params.trim() ?? null -}) - - const enabled = computed({ get() { return props.enabled @@ -41,7 +28,8 @@ const enabled = computed({