Skip to content

Commit 34f5301

Browse files
committed
Refactor VHOST details page
1 parent fdc3c1f commit 34f5301

File tree

5 files changed

+128
-105
lines changed

5 files changed

+128
-105
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"express": "^4.16.2",
2020
"fs-extra": "^5.0.0",
2121
"glob-promise": "^3.3.0",
22+
"highlightjs": "^9.10.0",
2223
"lodash.debounce": "^4.0.8",
2324
"lodash.throttle": "^4.1.1",
2425
"lodash.uniqueid": "^4.0.1",

src/components/Details.vue

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<template>
2+
<div class="vh__details" :data-deep="deep" :style="style">
3+
<code class="list__wrapper">
4+
<ul v-for="(item, index) in list" :key="index" class="list">
5+
<li class="list__item">
6+
<span v-if="hasChildren(item)">
7+
<strong>&lt;</strong><span class="item__key">{{ item.key }}</span>&nbsp;<span class="item__value">{{ item.value }}</span><strong>&gt;</strong>
8+
</span>
9+
<span v-else class="item__key">{{ item.key }}</span>
10+
<Details v-if="hasChildren(item)" :list="item._children" :deep="deeper" />
11+
<span v-else class="item__value">{{ item.value | join("&nbsp;&nbsp;") }}</span>
12+
<span v-if="hasChildren(item)" class="item__key">&lt;&sol;{{ item.key }}&gt;</span>
13+
</li>
14+
</ul>
15+
</code>
16+
</div>
17+
</template>
18+
19+
<script>
20+
import Details from './Details.vue'
21+
22+
export default {
23+
24+
name: 'Details',
25+
26+
components: { Details },
27+
28+
props: {
29+
'content': {
30+
type: String,
31+
default: null
32+
},
33+
'list': {
34+
type: Array,
35+
default: {}
36+
},
37+
'deep': {
38+
type: Number,
39+
default: 1
40+
}
41+
},
42+
43+
data () {
44+
return {
45+
index: this.deep
46+
}
47+
},
48+
49+
methods: {
50+
hasChildren (item) {
51+
return item._children && item._children.length
52+
},
53+
joinValue (value) {
54+
return Array.isArray(value)
55+
? value.join(', ')
56+
: value
57+
}
58+
},
59+
60+
computed: {
61+
deeper () {
62+
return this.index += 1
63+
},
64+
style () {
65+
return this.deep !== 1
66+
? {'marginLeft': (12 * this.deeper) + 'px'}
67+
: {}
68+
}
69+
}
70+
}
71+
</script>
72+
73+
<style lang="scss">
74+
@import '../../static/scss/_variables.scss';
75+
76+
.vh__details {
77+
background-color: $dark-color;
78+
79+
&[data-deep="1"] {
80+
margin-bottom: 2em;
81+
padding: .5em .5em .5em 1em;
82+
83+
.list__wrapper .list {
84+
margin: 0;
85+
line-height: 24px;
86+
87+
& > li:nth-child(1) {
88+
padding: 0;
89+
}
90+
}
91+
}
92+
93+
.list__wrapper {
94+
margin: 1em 0;
95+
padding: 0;
96+
97+
.list {
98+
list-style-type: none;
99+
margin-left: 0;
100+
padding-left: 0;
101+
102+
.list__item {
103+
padding: 4px 30px;
104+
font-size: .95em;
105+
color: rgba($white-color, .9);
106+
107+
.item__key {
108+
font-weight: bold;
109+
}
110+
.item__value {
111+
color: rgba($white-color, .7)
112+
}
113+
}
114+
}
115+
}
116+
}
117+
</style>
118+

src/components/List.vue

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/components/Show.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
<p><strong>Chemin complet</strong>&nbsp;:&nbsp;&nbsp;<span>{{ item.filePath }}</span></p>
1212
<p v-if="item.enabled"><strong>Activé</strong>&nbsp;:&nbsp;&nbsp;Oui</p>
1313
<p><strong>Détails&nbsp;:</strong></p>
14-
<List :list="item.parsed" />
14+
<Details :list="item.parsed" :content="item.content" />
1515
</div>
1616
</div>
1717
</div>
1818
</template>
1919

20-
<script lang="babel">
20+
<script>
2121
import Loader from './Loader.vue'
22-
import List from './List.vue'
22+
import Details from './Details.vue'
2323
import Icon from './Icon.vue'
2424
import Actions from './Actions.vue'
2525
import VHMaganer from '../app/VHMaganer'
2626
export default {
27-
components: { Loader, List, Icon, Actions },
27+
components: { Loader, Details, Icon, Actions },
2828
2929
data () {
3030
return {

0 commit comments

Comments
 (0)