-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathProfileInfo.vue
More file actions
157 lines (145 loc) · 4.47 KB
/
ProfileInfo.vue
File metadata and controls
157 lines (145 loc) · 4.47 KB
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
155
156
157
<template>
<v-tabs grow>
<v-tab href="#tab-profileInfo"> Profile Info </v-tab>
<v-tab href="#tab-inputs"> Inputs </v-tab>
<v-tab-item value="tab-profileInfo">
<v-scroll-y-transition mode="out-in">
<div
v-if="!profile"
class="title grey--text text--lighten-1 font-weight-light"
style="align-self: center"
>
Select a Profile
</div>
<v-card v-else :key="profile.id" flat>
<v-card-title>
<div class="mb-2">
{{ profile.data.title || profile.data.name }}
</div>
</v-card-title>
<v-divider />
<v-row class="text-left pa-4" dense data-cy="profileInfoFields">
<v-col cols="12">
<div v-if="from_file">
<strong>From File:</strong> {{ from_file }}
</div>
<div v-if="version"><strong>Version:</strong> {{ version }}</div>
<div v-if="sha256_hash">
<strong>SHA256 Hash:</strong> {{ sha256_hash }}
</div>
<div v-if="maintainer">
<strong>Maintainer:</strong> {{ maintainer }}
</div>
<div v-if="copyright">
<strong>Copyright:</strong> {{ copyright }}
</div>
<div v-if="copyright_email">
<strong>Copyright Email:</strong> {{ copyright_email }}
</div>
<div v-if="control_count">
<strong>Control Count:</strong> {{ control_count }}
</div>
</v-col>
</v-row>
</v-card>
</v-scroll-y-transition>
</v-tab-item>
<v-tab-item value="tab-inputs">
<v-scroll-y-transition mode="out-in">
<div
v-if="!profile"
class="title grey--text text--lighten-1 font-weight-light"
style="align-self: center"
>
Select a Profile
</div>
<v-card v-else :key="profile.id" flat>
<v-card-title>
<div class="mb-2">Inputs for {{ profile.data.title }}</div>
</v-card-title>
<div v-if="inputs.length !== 0">
<v-data-table :headers="headers" :items="inputs"
><template #[`item.options`]="{item}">
{{ item.options.value }}
</template>
</v-data-table>
</div>
<div v-else>
<v-card-text> No inputs found. </v-card-text>
</div>
</v-card>
</v-scroll-y-transition>
</v-tab-item>
</v-tabs>
</template>
<script lang="ts">
import {SourcedContextualizedProfile} from '@/store/report_intake';
import * as _ from 'lodash';
import Vue from 'vue';
import Component from 'vue-class-component';
import {Prop} from 'vue-property-decorator';
interface Attribute {
name: string;
options: {
value: unknown;
};
}
@Component({})
export default class ProfileInfo extends Vue {
@Prop({required: false}) readonly profile:
| SourcedContextualizedProfile
| undefined;
headers: Object[] = [
{
text: 'Name',
align: 'start',
sortable: true,
value: 'name'
},
{text: 'Value', value: 'options', sortable: true}
];
get from_file(): string | undefined {
return _.get(this.profile, 'sourcedFrom.from_file.filename') as unknown as
| string
| undefined;
}
get version(): string | undefined {
return _.get(this.profile, 'data.version') as unknown as string | undefined;
}
get sha256_hash(): string | undefined {
return _.get(this.profile, 'data.sha256') as unknown as string | undefined;
}
get maintainer(): string | undefined {
return _.get(this.profile, 'data.maintainer') as unknown as
| string
| undefined;
}
get copyright(): string | undefined {
return _.get(this.profile, 'data.copyright') as unknown as
| string
| undefined;
}
get copyright_email(): string | undefined {
return _.get(this.profile, 'data.copyright_email') as unknown as
| string
| undefined;
}
get control_count(): string | undefined {
return `${
(
_.get(this.profile, 'data.controls') as unknown as Record<
string,
unknown
>[]
).length
}`;
}
get inputs(): Attribute[] {
if (this.profile?.data.hasOwnProperty('attributes')) {
return _.get(this.profile, 'data.attributes') as unknown as Attribute[];
} else {
return _.get(this.profile, 'data.inputs') as unknown as Attribute[];
}
}
}
</script>