40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import AbstractView from "../AbstractView.js";
|
|
import { client } from "../../index.js"
|
|
|
|
export default class extends AbstractView {
|
|
constructor(params) {
|
|
super(params, "Profiles");
|
|
}
|
|
|
|
async postInit()
|
|
{
|
|
let profiles = await client.profiles.all()
|
|
let profile_list_element = document.getElementById("profile-list")
|
|
|
|
profiles.forEach((profile) => {
|
|
let profile_element = document.createElement("div");
|
|
profile_element.className = "item";
|
|
|
|
let avatar = document.createElement("img");
|
|
avatar.src = profile.avatar_url;
|
|
|
|
let username = document.createElement("a");
|
|
username.href = `/profiles/${profile.user_id}`;
|
|
username.appendChild(document.createTextNode(profile.username));
|
|
|
|
profile_element.appendChild(avatar);
|
|
profile_element.appendChild(username);
|
|
|
|
profile_list_element.appendChild(profile_element)
|
|
});
|
|
}
|
|
|
|
async getHtml() {
|
|
return `
|
|
<link rel="stylesheet" href="/static/css/profiles/profiles.css">
|
|
<div id="profile-list">
|
|
|
|
</div>
|
|
`;
|
|
}
|
|
} |