diff --git a/src/api/settings.js b/src/api/settings.js
index 61c9523e..f07ece4d 100644
--- a/src/api/settings.js
+++ b/src/api/settings.js
@@ -1,6 +1,7 @@
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
+import _ from 'lodash'
export async function deleteInstanceDocument(name, authHost, token) {
return await request({
@@ -78,12 +79,13 @@ export async function fetchFrontends(authHost, token) {
}
export async function installFrontend(data, authHost, token) {
+ const filteredData = _.pickBy(data)
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/frontends/install`,
method: 'post',
headers: authHeaders(token),
- data
+ data: filteredData
})
}
diff --git a/src/lang/en.js b/src/lang/en.js
index f193abaf..61a66eda 100644
--- a/src/lang/en.js
+++ b/src/lang/en.js
@@ -473,8 +473,9 @@ export default {
ref: 'Ref',
file: 'File',
buildUrl: 'Build URL',
- buildDir: 'Build Directory'
-
+ buildDir: 'Build Directory',
+ frontendSuccess: 'Frontend installed successfully!',
+ frontendStartedInstallation: 'Installation started'
},
invites: {
inviteTokens: 'Invite tokens',
diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js
index 05b3084e..a36f6eda 100644
--- a/src/store/modules/settings.js
+++ b/src/store/modules/settings.js
@@ -10,6 +10,8 @@ import {
updateSettings } from '@/api/settings'
import { formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers'
import _ from 'lodash'
+import { Message } from 'element-ui'
+import i18n from '@/lang'
const settings = {
state: {
@@ -122,11 +124,18 @@ const settings = {
commit('TOGGLE_TABS', false)
commit('SET_LOADING', false)
},
- async InstallFrontend({ commit, getters }, { name, _ref, _file, _buildUrl, _buildDir }) {
- const { data } = _ref
- ? await installFrontend({ name, ref: _ref, file: _file, build_url: _buildUrl, build_dir: _buildDir }, getters.authHost, getters.token)
- : await installFrontend({ name }, getters.authHost, getters.token)
- commit('SET_FRONTENDS', data)
+ async InstallFrontend({ commit, getters }, { name, ref, file, buildUrl, buildDir }) {
+ try {
+ const { data } = await installFrontend({ name, ref, file, build_url: buildUrl, build_dir: buildDir }, getters.authHost, getters.token)
+ commit('SET_FRONTENDS', data)
+ } catch (_e) {
+ return
+ }
+ Message({
+ message: i18n.t('settings.frontendSuccess'),
+ type: 'success',
+ duration: 5 * 1000
+ })
},
async RemoveInstanceDocument({ dispatch, getters }, name) {
await deleteInstanceDocument(name, getters.authHost, getters.token)
diff --git a/src/views/settings/components/Frontend.vue b/src/views/settings/components/Frontend.vue
index 26f1e2f0..f74b1e5b 100644
--- a/src/views/settings/components/Frontend.vue
+++ b/src/views/settings/components/Frontend.vue
@@ -45,8 +45,8 @@
@click="toggleFrontendInput"/>
{{ $t('settings.installAnotherFrontend') }}
-
-
+
+
@@ -123,6 +123,9 @@ export default {
file: '',
buildUrl: '',
buildDir: ''
+ },
+ rules: {
+ name: { required: true, message: 'Please input Name', trigger: 'blur' }
}
}
},
@@ -214,10 +217,39 @@ export default {
},
methods: {
installFrontend({ name }) {
- this.$store.dispatch('InstallFrontend', { name })
+ try {
+ this.$store.dispatch('InstallFrontend', { name })
+ this.$message({
+ type: 'success',
+ message: i18n.t('settings.frontendStartedInstallation')
+ })
+ } catch (e) {
+ return
+ }
},
installNewFrontend() {
-
+ try {
+ this.$refs['frontendFormData'].validate((valid) => {
+ if (valid) {
+ this.$store.dispatch('InstallFrontend', this.frontendFormData)
+ this.frontendFormData = {
+ name: '',
+ ref: '',
+ file: '',
+ buildUrl: '',
+ buildDir: ''
+ }
+ this.$message({
+ type: 'success',
+ message: i18n.t('settings.frontendStartedInstallation')
+ })
+ } else {
+ return false
+ }
+ })
+ } catch (e) {
+ return
+ }
},
async onSubmit() {
try {
diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss
index e85113be..2ab89f69 100644
--- a/src/views/settings/styles/main.scss
+++ b/src/views/settings/styles/main.scss
@@ -79,7 +79,7 @@
margin-right: 30px;
}
.frontend-form-input {
- margin-top: 15px;
+ margin-top: 20px;
}
.frontends-button-container {
width: 100%;