mirror of
https://gitlab.com/aviortheking/code-stats-vscode.git
synced 2025-04-22 10:52:13 +00:00
Add machines
This commit is contained in:
parent
e5536d8c23
commit
1643159674
@ -1,8 +1,8 @@
|
|||||||
.language {
|
.language {
|
||||||
float: left;
|
float: left;
|
||||||
width: 6rem;
|
width: 5rem;
|
||||||
height: 6rem;
|
height: 5rem;
|
||||||
padding-top: 2rem;
|
padding-top: 1.5rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0.1rem;
|
margin: 0.1rem;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@ -13,6 +13,11 @@
|
|||||||
border: solid 2px;
|
border: solid 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.language span{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.language span {
|
.language span {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
@ -41,4 +46,55 @@ h3 {
|
|||||||
|
|
||||||
img {
|
img {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.machines {
|
||||||
|
clear: both;
|
||||||
|
margin-top: 1rem;
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
.machine {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
height: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
/* background-color: #f5f5f5; */
|
||||||
|
border-radius: 4px;
|
||||||
|
border: solid 1px;
|
||||||
|
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
|
||||||
|
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
float: left;
|
||||||
|
width: 0%;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 20px;
|
||||||
|
/* color: #fff; */
|
||||||
|
text-align: center;
|
||||||
|
background-color: #337ab7;
|
||||||
|
-webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||||
|
box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||||
|
-webkit-transition: width .6s ease;
|
||||||
|
-o-transition: width .6s ease;
|
||||||
|
transition: width .6s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar-success {
|
||||||
|
background-color: #ddca7e;;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sr-only {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
margin: -1px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0,0,0,0);
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,40 @@
|
|||||||
<link rel="stylesheet" href="file:///${style}">
|
<link rel="stylesheet" href="file:///${profile.style}">
|
||||||
<h3> ${user}'s Profile Level ${level} (${xp} XP)
|
<h3> ${profile.user} Level ${profile.level} (${profile.total_xp} XP)
|
||||||
<% if( newxp > 0 ) { %>
|
<% if( profile.new_xp > 0 ) { %>
|
||||||
<sup>(<%= newxp %>)</sup>
|
<sup>(
|
||||||
|
<%= profile.new_xp %>)</sup>
|
||||||
<% } %>
|
<% } %>
|
||||||
</h3>
|
</h3>
|
||||||
|
<div style="display: block;">
|
||||||
|
<% for( let l in languages) { %>
|
||||||
|
<div class="language">
|
||||||
|
<%= languages[l].name %>
|
||||||
|
<span>
|
||||||
|
<%= languages[l].xp %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
<p/>
|
||||||
|
<div class="machines">
|
||||||
|
<% for( let m in machines) { %>
|
||||||
|
<div class="machine">
|
||||||
|
<strong>
|
||||||
|
<%= machines[m].name %>
|
||||||
|
</strong>
|
||||||
|
<span>
|
||||||
|
<%= machines[m].xp %>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar progress-bar-success" style="width:50%">
|
||||||
|
<span class="sr-only">Level progress ${machines[m].progress}%.</span>
|
||||||
|
</div>
|
||||||
|
<div class="progress-bar progress-bar-striped progress-bar-warning" style="width: 7%;">
|
||||||
|
<span class="sr-only">Recent level progress 7%.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
@ -47,45 +47,42 @@ export class ProfileHtmlProvider implements TextDocumentContentProvider {
|
|||||||
return Math.round(haveXp * 100.0 / needXp);
|
return Math.round(haveXp * 100.0 / needXp);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLanguages(languages: any): string {
|
function getSortedArray(profile: any, obj: string): any[] {
|
||||||
|
|
||||||
let ret = '';
|
let langs = [];
|
||||||
for (let lang in languages) {
|
let languages_object = profile[obj]
|
||||||
ret += `<div class="language">${lang}<span style="display:block;">${languages[lang]["xps"]}</span></div>`;
|
for( let lang in languages_object) {
|
||||||
|
langs.push(
|
||||||
|
{
|
||||||
|
name: lang,
|
||||||
|
xp: languages_object[lang].xps,
|
||||||
|
new_xp: languages_object[lang].new_xps,
|
||||||
|
progress: getLevelProgress(languages_object[lang].xps)
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
langs = langs.sort( (a,b) => {return b.xp - a.xp;});
|
||||||
return ret;
|
|
||||||
|
return langs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeader(context: ExtensionContext, profile: any): string {
|
|
||||||
|
|
||||||
let userName = profile["user"];
|
|
||||||
let totalXp = profile["total_xp"];
|
|
||||||
let newXp = profile["new_xp"];
|
|
||||||
let currentLevel = getLevel(totalXp);
|
|
||||||
|
|
||||||
return `<h3> ${userName}'s Profile Level ${currentLevel} (${totalXp} XP) ${newXp > 0 ? '<sup>(+' + newXp + ')</sup>' : ''}</h3>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return this.api.getProfile().then(profile => {
|
return this.api.getProfile().then(profile => {
|
||||||
|
|
||||||
// let htmlTemplate = fs.readFileSync(this.context.asAbsolutePath("assets/profile.html"));
|
let htmlTemplate = fs.readFileSync(this.context.asAbsolutePath("assets/profile.html"));
|
||||||
|
|
||||||
|
profile["style"] = this.context.asAbsolutePath("assets/profile.css");
|
||||||
|
profile["level"] = getLevel(profile["total_xp"]);
|
||||||
|
|
||||||
|
|
||||||
|
let langs = getSortedArray(profile, "languages");
|
||||||
|
|
||||||
|
let machines = getSortedArray(profile, "machines");
|
||||||
|
|
||||||
// let html = template(htmlTemplate);
|
|
||||||
// let result = html({ style: this.context.asAbsolutePath("assets/style.css"), user: 'Architect' });
|
|
||||||
// let userName = profile["user"];
|
|
||||||
// let totalXp = profile["total_xp"];
|
|
||||||
// let newXp = profile["new_xp"];
|
|
||||||
// let currentLevel = getLevel(totalXp);
|
|
||||||
|
|
||||||
|
|
||||||
return `
|
let html = template(htmlTemplate);
|
||||||
<link rel="stylesheet" href="file:///${this.context.asAbsolutePath("assets/style.css")}">
|
|
||||||
<img width="64px" height="64px" src="file:///${this.context.asAbsolutePath("assets/r2.svg")}">
|
return html({profile: profile, languages: langs, machines: machines});
|
||||||
${getHeader(this.context, profile)}
|
|
||||||
${getLanguages(profile["languages"])}
|
|
||||||
`;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user