summaryrefslogtreecommitdiff
path: root/src/client/pages/instance/object-storage.vue
blob: 814aeb6e48667b41b779c8987fb4ee8ef5142603 (plain)
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
<template>
<FormBase>
	<FormSuspense :p="init">
		<FormSwitch v-model:value="useObjectStorage">{{ $ts.useObjectStorage }}</FormSwitch>

		<template v-if="useObjectStorage">
			<FormInput v-model:value="objectStorageBaseUrl">
				<span>{{ $ts.objectStorageBaseUrl }}</span>
				<template #desc>{{ $ts.objectStorageBaseUrlDesc }}</template>
			</FormInput>

			<FormInput v-model:value="objectStorageBucket">
				<span>{{ $ts.objectStorageBucket }}</span>
				<template #desc>{{ $ts.objectStorageBucketDesc }}</template>
			</FormInput>

			<FormInput v-model:value="objectStoragePrefix">
				<span>{{ $ts.objectStoragePrefix }}</span>
				<template #desc>{{ $ts.objectStoragePrefixDesc }}</template>
			</FormInput>

			<FormInput v-model:value="objectStorageEndpoint">
				<span>{{ $ts.objectStorageEndpoint }}</span>
				<template #desc>{{ $ts.objectStorageEndpointDesc }}</template>
			</FormInput>

			<FormInput v-model:value="objectStorageRegion">
				<span>{{ $ts.objectStorageRegion }}</span>
				<template #desc>{{ $ts.objectStorageRegionDesc }}</template>
			</FormInput>

			<FormInput v-model:value="objectStorageAccessKey">
				<template #prefix><i class="fas fa-key"></i></template>
				<span>Access key</span>
			</FormInput>

			<FormInput v-model:value="objectStorageSecretKey">
				<template #prefix><i class="fas fa-key"></i></template>
				<span>Secret key</span>
			</FormInput>

			<FormSwitch v-model:value="objectStorageUseSSL">
				{{ $ts.objectStorageUseSSL }}
				<template #desc>{{ $ts.objectStorageUseSSLDesc }}</template>
			</FormSwitch>

			<FormSwitch v-model:value="objectStorageUseProxy">
				{{ $ts.objectStorageUseProxy }}
				<template #desc>{{ $ts.objectStorageUseProxyDesc }}</template>
			</FormSwitch>

			<FormSwitch v-model:value="objectStorageSetPublicRead">
				{{ $ts.objectStorageSetPublicRead }}
			</FormSwitch>

			<FormSwitch v-model:value="objectStorageS3ForcePathStyle">
				s3ForcePathStyle
			</FormSwitch>
		</template>

		<FormButton @click="save" primary><i class="fas fa-save"></i> {{ $ts.save }}</FormButton>
	</FormSuspense>
</FormBase>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import FormSwitch from '@client/components/form/switch.vue';
import FormInput from '@client/components/form/input.vue';
import FormButton from '@client/components/form/button.vue';
import FormBase from '@client/components/form/base.vue';
import FormGroup from '@client/components/form/group.vue';
import FormSuspense from '@client/components/form/suspense.vue';
import * as os from '@client/os';
import * as symbols from '@client/symbols';
import { fetchInstance } from '@client/instance';

export default defineComponent({
	components: {
		FormSwitch,
		FormInput,
		FormBase,
		FormGroup,
		FormButton,
		FormSuspense,
	},

	emits: ['info'],

	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.objectStorage,
				icon: 'fas fa-cloud'
			},
			useObjectStorage: false,
			objectStorageBaseUrl: null,
			objectStorageBucket: null,
			objectStoragePrefix: null,
			objectStorageEndpoint: null,
			objectStorageRegion: null,
			objectStoragePort: null,
			objectStorageAccessKey: null,
			objectStorageSecretKey: null,
			objectStorageUseSSL: false,
			objectStorageUseProxy: false,
			objectStorageSetPublicRead: false,
			objectStorageS3ForcePathStyle: true,
		}
	},

	async mounted() {
		this.$emit('info', this[symbols.PAGE_INFO]);
	},

	methods: {
		async init() {
			const meta = await os.api('meta', { detail: true });
			this.useObjectStorage = meta.useObjectStorage;
			this.objectStorageBaseUrl = meta.objectStorageBaseUrl;
			this.objectStorageBucket = meta.objectStorageBucket;
			this.objectStoragePrefix = meta.objectStoragePrefix;
			this.objectStorageEndpoint = meta.objectStorageEndpoint;
			this.objectStorageRegion = meta.objectStorageRegion;
			this.objectStoragePort = meta.objectStoragePort;
			this.objectStorageAccessKey = meta.objectStorageAccessKey;
			this.objectStorageSecretKey = meta.objectStorageSecretKey;
			this.objectStorageUseSSL = meta.objectStorageUseSSL;
			this.objectStorageUseProxy = meta.objectStorageUseProxy;
			this.objectStorageSetPublicRead = meta.objectStorageSetPublicRead;
			this.objectStorageS3ForcePathStyle = meta.objectStorageS3ForcePathStyle;
		},
		save() {
			os.apiWithDialog('admin/update-meta', {
				useObjectStorage: this.useObjectStorage,
				objectStorageBaseUrl: this.objectStorageBaseUrl ? this.objectStorageBaseUrl : null,
				objectStorageBucket: this.objectStorageBucket ? this.objectStorageBucket : null,
				objectStoragePrefix: this.objectStoragePrefix ? this.objectStoragePrefix : null,
				objectStorageEndpoint: this.objectStorageEndpoint ? this.objectStorageEndpoint : null,
				objectStorageRegion: this.objectStorageRegion ? this.objectStorageRegion : null,
				objectStoragePort: this.objectStoragePort ? this.objectStoragePort : null,
				objectStorageAccessKey: this.objectStorageAccessKey ? this.objectStorageAccessKey : null,
				objectStorageSecretKey: this.objectStorageSecretKey ? this.objectStorageSecretKey : null,
				objectStorageUseSSL: this.objectStorageUseSSL,
				objectStorageUseProxy: this.objectStorageUseProxy,
				objectStorageSetPublicRead: this.objectStorageSetPublicRead,
				objectStorageS3ForcePathStyle: this.objectStorageS3ForcePathStyle,
			}).then(() => {
				fetchInstance();
			});
		}
	}
});
</script>