Skip to content

Commit d847ad7

Browse files
Merge pull request #23 from aturingmachine/0.0.4-lib-snapshots
0.0.4 Lib Snapshots
2 parents 4f1851a + 8fde492 commit d847ad7

44 files changed

Lines changed: 1020 additions & 266 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ core/logs/**
1212

1313
todos
1414

15-
temp
15+
temp
16+
17+
db.json

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

client/src/assets/styles/buttons.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ button,
5252
padding: 16px;
5353
}
5454

55+
&.bare {
56+
background: none;
57+
border: none;
58+
59+
&:hover {
60+
filter: none;
61+
box-shadow: none;
62+
}
63+
}
64+
5565
&.icon {
5666
background: transparent;
5767
border: none;

client/src/assets/styles/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
@import './modals.scss';
33
@import './widgets.scss';
44
@import './buttons.scss';
5+
@import './snapshots.scss';
56
@import './main.scss';
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@import './colors.scss';
2+
3+
.snapshot-wrapper {
4+
display: flex;
5+
flex-direction: column;
6+
width: 100%;
7+
8+
h3 {
9+
font-weight: 700;
10+
font-size: 22px;
11+
text-align: left;
12+
margin: 16px 0 12px 16px;
13+
}
14+
}
15+
16+
.dir-line-wrapper {
17+
display: flex;
18+
flex-direction: column;
19+
align-items: flex-start;
20+
width: 100%;
21+
border-top: 1px solid $border-primary;
22+
color: $text-primary;
23+
24+
.expandable {
25+
width: 100%;
26+
max-height: 1000px;
27+
}
28+
29+
.expand-enter-active,
30+
.expand-leave-active {
31+
transition: all 0.3s ease-in-out;
32+
}
33+
34+
.expand-enter,
35+
.expand-leave-to {
36+
max-height: 0px;
37+
opacity: 0;
38+
}
39+
40+
.dir-line {
41+
width: 100%;
42+
height: 40px;
43+
display: flex;
44+
align-items: center;
45+
cursor: pointer;
46+
color: $text-primary;
47+
48+
.bracket {
49+
position: relative;
50+
bottom: 4px;
51+
margin-right: 4px;
52+
}
53+
54+
.material-icons {
55+
margin-right: 6px;
56+
}
57+
58+
&.file {
59+
cursor: auto;
60+
}
61+
62+
&.dir {
63+
&:hover {
64+
font-weight: 700;
65+
66+
.material-icons {
67+
text-shadow: 0 0 10px $text-accent;
68+
}
69+
70+
.dir-name-label {
71+
text-decoration: underline;
72+
}
73+
}
74+
}
75+
}
76+
}
77+
78+
@for $i from 1 through 7 {
79+
.dir-level-#{$i} {
80+
padding-left: calc(#{$i} * 20px);
81+
}
82+
}

client/src/components/navigation/NavDrawer.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export default Vue.extend({
4040
route: '/logs',
4141
icon: 'list',
4242
},
43+
{
44+
title: 'Snapshots',
45+
route: '/snapshots',
46+
icon: 'settings_backup_restore',
47+
},
4348
{
4449
title: 'Configuration',
4550
route: '/config',
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<template>
2+
<div class="dir-line-wrapper">
3+
<button
4+
@click="isOpen = !isOpen"
5+
:class="[levelClass, isDir ? 'dir' : 'file']"
6+
class="dir-line bare"
7+
>
8+
<span class="bracket" v-if="!isRoot"> &#8990;</span>
9+
<icon>{{ iconName }}</icon>
10+
<span class="dir-name-label">{{ path }}</span>
11+
</button>
12+
<template v-if="hasChildren">
13+
<transition name="expand">
14+
<div class="expandable" v-show="isOpen">
15+
<dir-line
16+
v-for="[key, child] in children"
17+
:struct="child.contents"
18+
:key="child.fullRelativePath"
19+
:level="level + 1"
20+
:path="key"
21+
:isDir="child.isDir"
22+
/>
23+
</div>
24+
</transition>
25+
</template>
26+
</div>
27+
</template>
28+
29+
<script lang="ts">
30+
import Vue, { PropType } from 'vue'
31+
import { DirStructInside } from '../../models/lib-snapshots'
32+
33+
export default Vue.extend({
34+
name: 'DirLine',
35+
36+
props: {
37+
path: {
38+
type: String,
39+
required: true,
40+
},
41+
42+
struct: {
43+
type: Object as PropType<DirStructInside>,
44+
required: true,
45+
},
46+
47+
level: {
48+
type: Number,
49+
required: true,
50+
},
51+
52+
isDir: {
53+
type: Boolean,
54+
required: true,
55+
},
56+
},
57+
58+
data: () => {
59+
return {
60+
isOpen: false,
61+
}
62+
},
63+
64+
computed: {
65+
children(): [string, DirStructInside][] {
66+
return Object.entries(this.struct)
67+
},
68+
69+
hasChildren(): boolean {
70+
return this.children.length > 0
71+
},
72+
73+
isRoot(): boolean {
74+
return this.level === 1
75+
},
76+
77+
levelClass(): string {
78+
const evaluatedLevel = Math.min(7, this.level)
79+
80+
return `dir-level-${evaluatedLevel}`
81+
},
82+
83+
iconName(): string {
84+
if (!this.isDir) {
85+
return 'description'
86+
}
87+
88+
return this.isOpen ? 'folder_open' : 'folder'
89+
},
90+
},
91+
92+
methods: {},
93+
})
94+
</script>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<template>
2+
<div class="lib-root-wrapper">
3+
<h1>{{ libName }}</h1>
4+
<div class="lib-structure">
5+
<snapshot
6+
v-for="snapshot in libSnapshots"
7+
:dirStruct="snapshot.dirStruct"
8+
:timestamp="snapshot.timestamp"
9+
:key="snapshot.timestamp"
10+
/>
11+
</div>
12+
</div>
13+
</template>
14+
15+
<script lang="ts">
16+
import Vue, { PropType } from 'vue'
17+
import { LibSnapshot } from '../../models/lib-snapshots'
18+
import Snapshot from './Snapshot.vue'
19+
20+
export default Vue.extend({
21+
name: 'LibRoot',
22+
23+
components: {
24+
Snapshot,
25+
},
26+
27+
props: {
28+
libSnapshots: {
29+
type: Array as PropType<LibSnapshot[]>,
30+
required: true,
31+
},
32+
33+
libName: {
34+
type: String,
35+
required: true,
36+
},
37+
},
38+
39+
data: () => {
40+
return {}
41+
},
42+
})
43+
</script>
44+
45+
<style lang="scss" scoped>
46+
@import '@/assets/styles/colors.scss';
47+
48+
.lib-root-wrapper {
49+
display: flex;
50+
flex-direction: column;
51+
align-items: flex-start;
52+
width: 80%;
53+
}
54+
55+
.lib-structure {
56+
width: 100%;
57+
border: 1px solid $border-primary;
58+
border-radius: 10px;
59+
background-color: $secondary;
60+
padding-bottom: 12px;
61+
}
62+
</style>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<div class="snapshot-wrapper">
3+
<h3>{{ new Date(timestamp).toLocaleString() }}</h3>
4+
<dir-line
5+
v-for="[key, line] in initialDirLines"
6+
:key="line.fullRelativepath"
7+
:level="1"
8+
:struct="line.contents"
9+
:path="key"
10+
:isDir="line.isDir"
11+
/>
12+
</div>
13+
</template>
14+
15+
<script lang="ts">
16+
import Vue, { PropType } from 'vue'
17+
import { DirStruct, DirStructInside } from '../../models/lib-snapshots'
18+
import DirLine from './DirLine.vue'
19+
20+
export default Vue.extend({
21+
name: 'Snapshot',
22+
23+
components: {
24+
DirLine,
25+
},
26+
27+
props: {
28+
dirStruct: {
29+
type: Object as PropType<DirStruct>,
30+
required: true,
31+
},
32+
33+
timestamp: {
34+
type: Number,
35+
required: true,
36+
},
37+
},
38+
39+
data: () => {
40+
return {}
41+
},
42+
43+
computed: {
44+
initialDirLines(): [string, DirStructInside][] {
45+
return Object.entries(this.dirStruct)
46+
},
47+
},
48+
})
49+
</script>

client/src/models/lib-snapshots.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export interface DirStruct {
2+
[key: string]: DirStructInside
3+
}
4+
5+
export interface DirStructInside {
6+
fullRelativePath: string
7+
isDir: boolean
8+
contents: DirStruct
9+
}
10+
11+
export type RunDetails = {
12+
source: string
13+
destination: string
14+
backup: string
15+
}
16+
17+
export type LibSnapshot = {
18+
libName: string
19+
run: RunDetails
20+
timestamp: number
21+
path: string
22+
dirStruct: DirStruct
23+
}
24+
25+
export type LibSnapshotRecord = {
26+
[libName: string]: LibSnapshot[]
27+
}

0 commit comments

Comments
 (0)