This commit is contained in:
Valentin Ivanov 2018-04-24 16:31:28 -04:00 committed by Juha Ristolainen
parent ed2b511762
commit 96bd68be7c
3 changed files with 21 additions and 27 deletions

View File

@ -16,8 +16,8 @@
.circle-progress {
float: left;
position: relative;
width: 7rem;
height: 7rem;
width: 6rem;
height: 6rem;
}
.circle-progress .tooltiptext {
@ -58,7 +58,7 @@ svg {
}
.language {
padding-top: 2.5rem;
padding-top: 2rem;
margin: auto;
text-align: center;
}

View File

@ -1,4 +1,4 @@
<link rel="stylesheet" href="file:///${profile.style}">
<link rel="stylesheet" href="file:///${style}">
<h3> ${profile.user} Level ${profile.level} (${profile.total_xp} XP)
<% if( profile.new_xp > 0 ) { %>
<sup>(
@ -62,5 +62,3 @@
</div>
<% } %>
</div>
<circle cx="60" cy="60" r="50"/>

View File

@ -50,33 +50,32 @@ export class ProfileProvider implements TextDocumentContentProvider {
return [ xpP, nxpP ];
}
function getSortedArray(profile: any, obj: string): any[] {
function getSortedArray(obj: any): any[] {
let langs = [];
let languages_object = profile[obj]
for( let lang in languages_object) {
let percents = getLevelProgress(languages_object[lang].xps, languages_object[lang].new_xps);
langs.push(
let items = [];
for( let prop in obj) {
let item = obj[prop];
let percents = getLevelProgress(item.xps, item.new_xps);
items.push(
{
name: lang,
level: getLevel(languages_object[lang].xps),
xp: languages_object[lang].xps,
new_xp: languages_object[lang].new_xps,
name: prop,
level: getLevel(item.xps),
xp: item.xps,
new_xp: item.new_xps,
progress: percents[0],
new_progress: percents[1]
}
);
}
langs = langs.sort( (a,b) => {return b.xp - a.xp;});
return langs;
return items.sort( (a,b) => {return b.xp - a.xp;});
}
return this.api.getProfile().then(profile => {
let htmlTemplate = fs.readFileSync(this.context.asAbsolutePath("assets/profile.html.eex"));
profile["style"] = this.context.asAbsolutePath("assets/profile.css");
profile["level"] = getLevel(profile["total_xp"]);
let percents = getLevelProgress(profile["total_xp"], profile["new_xp"]);
@ -84,15 +83,12 @@ export class ProfileProvider implements TextDocumentContentProvider {
profile["progress"] = percents[0];
profile["new_progress"] = percents[1];
let langs = getSortedArray(profile, "languages");
let machines = getSortedArray(profile, "machines");
let languages = getSortedArray(profile["languages"]);
let machines = getSortedArray(profile["machines"]);
let html = template(htmlTemplate);
return html({profile: profile, languages: langs, machines: machines});
return html({profile: profile, languages: languages, machines: machines, style: this.context.asAbsolutePath("assets/profile.css")});
});
}