Réarrangement du code; correction css; écriture uniquement du nouveau message
This commit is contained in:
20
frontend/static/css/profile.css
Normal file
20
frontend/static/css/profile.css
Normal file
@ -0,0 +1,20 @@
|
||||
#app #avatar
|
||||
{
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#app #username
|
||||
{
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
#app #block {
|
||||
cursor: pointer;
|
||||
font-size: 0.7em;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#app {
|
||||
margin-top: 20px;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#app #avatar
|
||||
{
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#app #username
|
||||
{
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#app .item img
|
||||
{
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#app .item a
|
||||
{
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
|
||||
#app #chat {
|
||||
position: relative;
|
||||
max-height: 86vh;
|
||||
max-height: 100vh;
|
||||
width: 100vh;
|
||||
/*border: 2px solid green;*/
|
||||
overflow: hidden;
|
||||
@ -50,7 +50,7 @@
|
||||
}
|
||||
|
||||
#app #messages {
|
||||
max-height: 40em;
|
||||
max-height: 60vh;
|
||||
overflow: scroll;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
|
@ -31,6 +31,17 @@ class Profiles
|
||||
await profile.init(user_id);
|
||||
return profile;
|
||||
}
|
||||
|
||||
async block(user_id) {
|
||||
|
||||
// blocker & blocked
|
||||
let response = await this.client._post("/api/block/",
|
||||
[this.client.me.user_id, user_id],
|
||||
);
|
||||
|
||||
let data = await response.json();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export {Profiles}
|
||||
export {Profiles}
|
||||
|
@ -10,9 +10,9 @@ import GameView from "./views/Game.js"
|
||||
|
||||
import PageNotFoundView from './views/PageNotFoundView.js'
|
||||
|
||||
import AbstractRedirectView from "./views/AbstractRedirectView.js";
|
||||
import AbstractRedirectView from "./views/abstracts/AbstractRedirectView.js";
|
||||
import MeView from "./views/MeView.js";
|
||||
import ProfilePageView from "./views/profiles/ProfilePageView.js";
|
||||
import ProfilePageView from "./views/ProfilePageView.js";
|
||||
import MatchMakingView from "./views/MatchMakingView.js";
|
||||
|
||||
let client = new Client(location.protocol + "//" + location.host)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractView from "./AbstractView.js";
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
@ -16,4 +16,4 @@ export default class extends AbstractView {
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractView from './AbstractView.js'
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractAuthentificateView from "./AbstractAuthentifiedView.js";
|
||||
import AbstractAuthentificateView from "./abstracts/AbstractAuthentifiedView.js";
|
||||
|
||||
export default class extends AbstractAuthentificateView {
|
||||
constructor(params) {
|
||||
@ -15,4 +15,4 @@ export default class extends AbstractAuthentificateView {
|
||||
<a href="/logout" class="nav__link" data-link>Logout</a>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { client, navigateTo } from "../index.js";
|
||||
import AbstractView from "./AbstractView.js";
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
|
||||
function game_found(game_id)
|
||||
{
|
||||
@ -26,4 +26,4 @@ export default class extends AbstractView {
|
||||
{
|
||||
await client.matchmaking.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { client, navigateTo } from "../index.js";
|
||||
import { clear, fill_errors } from "../utils/formUtils.js";
|
||||
import AbstractAuthentificateView from "./AbstractAuthentifiedView.js";
|
||||
import AbstractAuthentificateView from "./abstracts/AbstractAuthentifiedView.js";
|
||||
|
||||
export default class extends AbstractAuthentificateView
|
||||
{
|
||||
@ -102,4 +102,4 @@ export default class extends AbstractAuthentificateView
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractView from "./AbstractView.js";
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
|
48
frontend/static/js/views/ProfilePageView.js
Normal file
48
frontend/static/js/views/ProfilePageView.js
Normal file
@ -0,0 +1,48 @@
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
import { client } from "../index.js"
|
||||
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
super(params, "Profile ");
|
||||
this.user_id = params.id;
|
||||
}
|
||||
|
||||
async postInit()
|
||||
{
|
||||
let profile = await client.profiles.getProfile(this.user_id);
|
||||
let info = document.getElementById("info");
|
||||
|
||||
// Username
|
||||
let username = document.createElement("a");
|
||||
username.id = "username";
|
||||
username.appendChild(document.createTextNode(profile.username));
|
||||
info.appendChild(username);
|
||||
|
||||
info.appendChild(document.createElement("br"));
|
||||
|
||||
// Avatar
|
||||
let avatar = document.createElement("img");
|
||||
avatar.id = "avatar";
|
||||
avatar.src = profile.avatar_url;
|
||||
info.appendChild(avatar);
|
||||
|
||||
// Block option
|
||||
let block = document.createElement("a");
|
||||
block.id = "block";
|
||||
block.addEventListener("click", async () => {
|
||||
if (client.me.user_id != user.user_id) {
|
||||
}
|
||||
});
|
||||
block.appendChild(document.createTextNode("Block"));
|
||||
info.appendChild(block);
|
||||
}
|
||||
|
||||
async getHtml() {
|
||||
return `
|
||||
<link rel="stylesheet" href="/static/css/profile.css">
|
||||
<div id="info">
|
||||
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import AbstractView from "./AbstractView.js";
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
import {client} from "../index.js";
|
||||
import {Message} from "../api/chat/message.js"
|
||||
|
||||
@ -81,13 +81,6 @@ export default class extends AbstractView {
|
||||
|
||||
new_user.appendChild(document.createTextNode(" "));
|
||||
|
||||
let block = document.createElement("a");
|
||||
block.addEventListener("click", async () => {
|
||||
if (client.me.user_id != user.user_id) {
|
||||
}
|
||||
});
|
||||
block.appendChild(document.createTextNode("Block"));
|
||||
new_user.appendChild(block);
|
||||
}
|
||||
|
||||
// break line
|
||||
@ -108,11 +101,11 @@ export default class extends AbstractView {
|
||||
async chat() {
|
||||
|
||||
let logged = await client.isAuthentificate();
|
||||
let reload = document.getElementById("messages");
|
||||
/*let reload = document.getElementById("messages");
|
||||
if (reload != null)
|
||||
reload.remove();
|
||||
reload.remove();*/
|
||||
|
||||
reload = document.getElementById("members");
|
||||
let reload = document.getElementById("members");
|
||||
if (reload != null)
|
||||
reload.remove();
|
||||
|
||||
@ -127,13 +120,33 @@ export default class extends AbstractView {
|
||||
chats.appendChild(chat);
|
||||
}
|
||||
|
||||
|
||||
// div des messages
|
||||
let messages = document.createElement("div");
|
||||
messages.id = "messages";
|
||||
if (document.getElementById("input_chat") == null)
|
||||
chat.appendChild(messages);
|
||||
else
|
||||
document.getElementById("input_chat").before(messages);
|
||||
let messages = document.getElementById("messages");
|
||||
if (messages == null) {
|
||||
messages = document.createElement("div");
|
||||
messages.id = "messages";
|
||||
if (document.getElementById("input_chat") == null)
|
||||
chat.appendChild(messages);
|
||||
else
|
||||
document.getElementById("input_chat").before(messages);
|
||||
}
|
||||
|
||||
// les messages, réecriture seulement du dernier
|
||||
let i = 0;
|
||||
client.channel.messages.forEach((message) => {
|
||||
if (messages[i] == null || message != messages.children[i].innerText) {
|
||||
let text = document.createElement("p");
|
||||
text.appendChild(document.createTextNode(message.content));
|
||||
if (message.author_id == client.me.user_id)
|
||||
text.id = "you";
|
||||
else
|
||||
text.id = "other";
|
||||
|
||||
messages.appendChild(text);
|
||||
}
|
||||
i++;
|
||||
});
|
||||
|
||||
// Input pour rentrer un message
|
||||
if (document.getElementById("input_chat") == null) {
|
||||
@ -173,17 +186,6 @@ export default class extends AbstractView {
|
||||
members.appendChild(document.createTextNode(usernames));
|
||||
messages.before(members);
|
||||
|
||||
// les messages
|
||||
client.channel.messages.forEach((message) => {
|
||||
let text = document.createElement("p");
|
||||
text.appendChild(document.createTextNode(message.content));
|
||||
if (message.author_id == client.me.user_id)
|
||||
text.id = "you";
|
||||
else
|
||||
text.id = "other";
|
||||
|
||||
messages.appendChild(text);
|
||||
});
|
||||
|
||||
// Scroll to the bottom of messages
|
||||
messages.scrollTop = messages.scrollHeight;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { client, navigateTo } from "../index.js";
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import AbstractRedirectView from "./AbstractRedirectView.js";
|
||||
|
||||
export default class extends AbstractRedirectView{
|
@ -1,4 +1,4 @@
|
||||
import { client, navigateTo } from "../index.js";
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import AbstractRedirectView from "./AbstractRedirectView.js";
|
||||
|
||||
export default class extends AbstractRedirectView{
|
@ -1,4 +1,4 @@
|
||||
import { navigateTo } from "../index.js";
|
||||
import { navigateTo } from "../../index.js";
|
||||
import AbstractView from "./AbstractView.js";
|
||||
|
||||
export default class extends AbstractView{
|
@ -1,6 +1,6 @@
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import { clear, fill_errors } from "../../utils/formUtils.js";
|
||||
import AbstractNonAuthentifiedView from "../AbstractNonAuthentified.js";
|
||||
import AbstractNonAuthentifiedView from "../abstracts/AbstractNonAuthentified.js";
|
||||
|
||||
async function login()
|
||||
{
|
||||
@ -44,4 +44,4 @@ export default class extends AbstractNonAuthentifiedView {
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import AbstractAuthentifiedView from "../AbstractAuthentifiedView.js";
|
||||
import AbstractAuthentifiedView from "../abstracts/AbstractAuthentifiedView.js";
|
||||
|
||||
export default class extends AbstractAuthentifiedView
|
||||
{
|
||||
@ -8,4 +8,4 @@ export default class extends AbstractAuthentifiedView
|
||||
client.logout();
|
||||
navigateTo("/login")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import { clear, fill_errors } from "../../utils/formUtils.js";
|
||||
import AbstractNonAuthentifiedView from "../AbstractNonAuthentified.js";
|
||||
import AbstractNonAuthentifiedView from "../abstracts/AbstractNonAuthentified.js";
|
||||
|
||||
async function register()
|
||||
{
|
||||
|
@ -1,29 +0,0 @@
|
||||
import AbstractView from "../AbstractView.js";
|
||||
import { client } from "../../index.js"
|
||||
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
super(params, "Profile ");
|
||||
this.user_id = params.id;
|
||||
}
|
||||
|
||||
async postInit()
|
||||
{
|
||||
let profile = await client.profiles.getProfile(this.user_id);
|
||||
|
||||
let username_element = document.getElementById("username");
|
||||
username_element.href = `/profiles/${this.user_id}`;
|
||||
username_element.appendChild(document.createTextNode(profile.username));
|
||||
|
||||
let avatar_element = document.getElementById("avatar");
|
||||
avatar_element.src = profile.avatar_url;
|
||||
}
|
||||
|
||||
async getHtml() {
|
||||
return `
|
||||
<link rel="stylesheet" href="/static/css/profiles/profile.css">
|
||||
<img id="avatar"/>
|
||||
<a id="username"></a>
|
||||
`;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user