-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
qwc-info.js
149 lines (136 loc) · 4.81 KB
/
qwc-info.js
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
import { LitElement, html, css} from 'lit';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import { infoUrl } from 'build-time-data';
import '@vaadin/progress-bar';
import 'qui-card';
import '@vaadin/icon';
/**
* This component shows the Info Screen
*/
export class QwcInfo extends LitElement {
static styles = css`
:host {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
gap: 1em;
padding: 10px;
}
qui-card {
display: flex;
}
.cardContent {
display: flex;
align-items: center;
padding: 10px;
gap: 10px;
}
vaadin-icon {
font-size: xx-large;
}
`;
static properties = {
_infoUrl: {state: false},
_info: {state: true},
};
constructor() {
super();
this._infoUrl = infoUrl;
this._info = null;
}
async connectedCallback() {
super.connectedCallback();
await this.load();
}
async load() {
const response = await fetch(this._infoUrl)
const data = await response.json();
this._info = data;
}
render() {
if (this._info) {
return html`
${this._renderOsInfo(this._info)}
${this._renderJavaInfo(this._info)}
${this._renderGitInfo(this._info)}
${this._renderBuildInfo(this._info)}
`;
}else{
return html`
<div style="color: var(--lumo-secondary-text-color);width: 95%;" >
<div>Fetching infomation...</div>
<vaadin-progress-bar indeterminate></vaadin-progress-bar>
</div>
`;
}
}
_renderOsInfo(info){
if(info.os){
let os = info.os;
return html`<qui-card title="Operating System">
<div class="cardContent" slot="content">
${this._renderOsIcon(os.name)}
<table class="table">
<tr><td>Name</td><td>${os.name}</td></tr>
<tr><td>Version</td><td>${os.version}</td></tr>
<tr><td>Arch</td><td>${os.arch}</td></tr>
</table>
</div>
</qui-card>`;
}
}
_renderJavaInfo(info){
if(info.java){
let java = info.java;
return html`<qui-card title="Java">
<div class="cardContent" slot="content">
<vaadin-icon icon="font-awesome-brands:java"></vaadin-icon>
<table class="table">
<tr><td>Version</td><td>${java.version}</td></tr>
</table>
</div>
</qui-card>`;
}
}
_renderOsIcon(osname){
if(osname){
if(osname.toLowerCase().startsWith("linux")){
return html`<vaadin-icon icon="font-awesome-brands:linux"></vaadin-icon>`;
}else if(osname.toLowerCase().startsWith("mac") || osname.toLowerCase().startsWith("darwin")){
return html`<vaadin-icon icon="font-awesome-brands:apple"></vaadin-icon>`;
}else if(osname.toLowerCase().startsWith("win")){
return html`<vaadin-icon icon="font-awesome-brands:windows"></vaadin-icon>`;
}
}
}
_renderGitInfo(info){
if(info.git){
let git = info.git;
return html`<qui-card title="Git">
<div class="cardContent" slot="content">
<vaadin-icon icon="font-awesome-brands:git"></vaadin-icon>
<table class="table">
<tr><td>Branch</td><td>${git.branch}</td></tr>
<tr><td>Commit</td><td>${git.commit.id}</td></tr>
<tr><td>Time</td><td>${git.commit.time}</td></tr>
</table>
</div>
</qui-card>`;
}
}
_renderBuildInfo(info){
if(info.build){
let build = info.build;
return html`<qui-card title="Build">
<div class="cardContent" slot="content">
<table class="table">
<tr><td>Group</td><td>${build.group}</td></tr>
<tr><td>Artifact</td><td>${build.artifact}</td></tr>
<tr><td>Version</td><td>${build.version}</td></tr>
<tr><td>Time</td><td>${build.time}</td></tr>
</table>
</div>
</qui-card>`;
}
}
}
customElements.define('qwc-info', QwcInfo);