Skip to content

Commit ad11684

Browse files
committed
[feature] add DNS CSV Download
1 parent 594a962 commit ad11684

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

frontend/pages/dns.vue

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,30 @@
2727
height="6"
2828
></v-progress-linear>
2929
<v-row justify="space-between" align="end">
30-
<v-col cols="1">
30+
<v-col cols="8">
3131
<v-btn
3232
small
3333
dark
3434
color="yellow darken-3"
3535
@click="openConfirmDialog"
3636
><v-icon dark left> mdi-refresh </v-icon>Update DNS</v-btn
3737
>
38+
<VueJsonToCsv
39+
v-if="subdomains.length > 0"
40+
:json-data="subdomainCsv"
41+
:labels="labels"
42+
:csv-title="title"
43+
>
44+
<v-btn
45+
small
46+
color="light-green darken-1"
47+
dark
48+
@click="downloadCsv"
49+
>
50+
<v-icon dark left> mdi-download </v-icon>
51+
CSV Download
52+
</v-btn>
53+
</VueJsonToCsv>
3854
</v-col>
3955
<v-col cols="4">
4056
<v-text-field
@@ -102,9 +118,13 @@
102118

103119
<script>
104120
import { mapGetters, mapActions, mapMutations } from 'vuex'
121+
import VueJsonToCsv from 'vue-json-to-csv'
105122
106123
export default {
107124
name: 'DnsPage',
125+
components: {
126+
VueJsonToCsv,
127+
},
108128
data() {
109129
return {
110130
subdomain: {},
@@ -114,6 +134,15 @@ export default {
114134
isOpenConfirmDialog: false,
115135
isOpenApplyResultDialog: false,
116136
overlay: false,
137+
subdomainCsv: [],
138+
labels: {
139+
domain_name: { title: 'Domain Name' },
140+
dns_type: { title: 'Type' },
141+
priority: { title: 'Priority' },
142+
ttl: { title: 'TTL' },
143+
value: { title: 'Value' },
144+
},
145+
title: '',
117146
}
118147
},
119148
computed: {
@@ -217,6 +246,21 @@ export default {
217246
this.overlay = false
218247
this.openApplyResultDialog()
219248
},
249+
downloadCsv() {
250+
this.title = 'subdomain_list_' + Date.now()
251+
this.subdomainCsv = []
252+
this.subdomains.forEach((subdomain) => {
253+
subdomain.subdomains.forEach((dns) => {
254+
this.subdomainCsv.push({
255+
domain_name: dns.full_domain,
256+
dns_type: dns.dns_record_name,
257+
priority: dns.priority,
258+
ttl: dns.ttl,
259+
value: dns.value,
260+
})
261+
})
262+
})
263+
},
220264
},
221265
}
222266
</script>

0 commit comments

Comments
 (0)