room and chat view

implement_matrix
adb 4 years ago
parent 9747505da1
commit 6018fd554d

@ -1,6 +1,6 @@
{ {
"name": "open chat", "name": "matrix chat",
"short_name": "open chat", "short_name": "[chat]",
"start_url": "/", "start_url": "/",
"display": "standalone", "display": "standalone",
"background_color": "#14181b", "background_color": "#14181b",

@ -33,17 +33,17 @@ body{
.content{ .content{
position: absolute; position: absolute;
top: 0; top: 0;
left: calc(50% - 25rem); left: calc(50% - 35rem);
padding: 0; padding: 0;
min-height: calc(100%); min-height: calc(100%);
width: 50rem; width: 70rem;
min-width: 18rem; min-width: 18rem;
background-color: #313131; background-color: #313131;
box-shadow: 3px 3px 10px #111; box-shadow: 3px 3px 10px #111;
} }
@media (max-width: 55rem){ @media (max-width: 75rem){
.content{ .content{
width: calc(100%); width: 100%;
left: 0; left: 0;
} }
} }

@ -2,12 +2,11 @@
<div class="topBanner"> <div class="topBanner">
<div> <div>
<icon @click.native="$router.back()" class="smallIcon" id="icon-arrow" ic="./sym/arrow_back-24px.svg" /> <icon @click.native="$router.back()" class="smallIcon" id="icon-arrow" ic="./sym/arrow_back-24px.svg" />
<icon class="smallIcon" id="picTop" ic="./sym/supervisor_account-24px.svg" /> <icon v-on:click.native="showChatInfo()" class="smallIcon" id="picTop" ic="./sym/supervisor_account-24px.svg" />
<div id="container"> <div id="container">
<div id="chatName">{{chatroom.name}}</div> <div id="chatName">{{chatroom.name}}</div>
<div id="users">{{chatroom.user.length}} members</div> <div id="users">{{chatroom.user.length}} members</div>
</div> </div>
<icon v-on:click.native="showChatInfo()" class="smallIcon" id="icon-menu" ic="./sym/menu-24px.svg" />
</div> </div>
</div> </div>
</template> </template>
@ -40,7 +39,6 @@ export default {
width: 100%; width: 100%;
height: 3rem; height: 3rem;
background-color: #1d1d1d; background-color: #1d1d1d;
box-shadow: 0 0px 5px #111;
} }
.smallIcon{ .smallIcon{
top: 0.25rem; top: 0.25rem;
@ -50,22 +48,19 @@ export default {
} }
#icon-arrow{ #icon-arrow{
position: absolute; position: absolute;
left: 1rem; left: 0.5rem;
background-color: unset;
box-shadow: none;
} }
#picTop{ #picTop{
position: absolute; position: absolute;
left: 4rem; left: 3.5rem;
background-color: #42a7b9; background-color: #42a7b9;
} }
#icon-menu{
position: absolute;
right: 1rem;
background-color: #2d2d2d;
}
#container{ #container{
position: absolute; position: absolute;
top: 0.55rem; top: 0.55rem;
left: 7.5rem; left: 7rem;
} }
#chatName{ #chatName{
font-size: 1rem; font-size: 1rem;

@ -25,6 +25,11 @@ const router = new VueRouter({
name: 'chat', name: 'chat',
component: chat component: chat
}, },
{
path: '/rooms/*',
name: 'room',
component: rooms
},
{ {
path: '/rooms', path: '/rooms',
name: 'rooms', name: 'rooms',

@ -1,11 +1,14 @@
import matrix from 'matrix-js-sdk'; import matrix from 'matrix-js-sdk';
import Vue from 'vue'
import main from '@/main.js'; import main from '@/main.js';
const matrix_cli = matrix.createClient("https://adb.sh"); const matrix_cli = matrix.createClient("https://adb.sh");
let session = { let session = {
user: "", user: "",
password: "", password: "",
access_token: "" access_token: "",
rooms: [],
current_room: "open chat"
}; };
let rooms = []; let rooms = [];
@ -29,22 +32,39 @@ export default {
main.methods.error(response.error) main.methods.error(response.error)
console.log(`login error => ${response.error}`) console.log(`login error => ${response.error}`)
} }
main.methods.router({path: "rooms"}) main.methods.router({path: "rooms/"})
matrix_cli.startClient(); matrix_cli.startClient();
matrix_cli.once('sync', function (state){ matrix_cli.once('sync', function (state){
console.log(state) console.log(state)
}) })
matrix_cli.on("event", function(event){
console.log(event.getType());
console.log(event);
})
setTimeout(()=>{this.getRooms()},5000)
}); });
/*let i=0;
let checkRooms = setInterval(()=>{
rooms = matrix_cli.getRooms()
console.log("asdasd"+rooms.length)
if (rooms.length !== 0 || i>10) clearInterval(checkRooms)
i++;
},500)*/
}, },
getRooms(){ getRooms(){
rooms = matrix_cli.getRooms() rooms.push(matrix_cli.getRooms())
return rooms return rooms
} }
} }
} }
new Vue({
el: '#roomList',
data() {
return {
rooms: [],
}
}
})
matrix_cli.on("event", function(event){
console.log(event.getType());
console.log(event);
session.rooms = matrix_cli.getRooms()
console.log(session.rooms)
})

@ -1,32 +1,43 @@
<template> <template>
<div> <div>
<div class="roomList" v-for="room in rooms" :key="room.name"> <div id="roomList" class="roomList">
<router-link :to="'/chat/'+room.roomId"> <h1>[chat]</h1>
<div class="roomListName">{{room.name}}</div> <h2>rooms</h2>
</router-link> <div class="roomListElement" v-for="(room, index) in rooms" :key="index">
<router-link @click="getRooms()" :to="`/rooms/${room.roomId}`">
<div class="roomListName">{{room.name}}</div>
</router-link>
</div>
<textbtn @click.native="getRooms()" text="update" />
</div> </div>
<textbtn @click.native="getRooms()" text="update" /> <chat class="chat" v-if="this.$router.currentRoute.fullPath.split('/',3)[2]" />
<div class="noRoomSelected" v-else>Please select a room to be displayed.</div>
</div> </div>
</template> </template>
<script> <script>
import matrix from '@/matrix.js'; import matrix from '@/matrix.js';
import textbtn from "@/components/textbtn"; import textbtn from "@/components/textbtn";
import chat from '@/views/chat.vue'
export default { export default {
name: "rooms", name: "rooms",
props: {
rooms: String
},
components:{ components:{
textbtn textbtn,
chat
}, },
methods:{ methods:{
getRooms(){ getRooms(){
this.rooms = matrix.methods.getRooms() //matrix.methods.getRooms()
console.log(matrix.methods.getRooms()) //console.log(matrix.methods.getRooms())
} }
}, },
data(){ data(){
return { return {
rooms: matrix.rooms session: matrix.data().session
} }
} }
} }
@ -34,6 +45,24 @@ export default {
<style scoped> <style scoped>
.roomList{ .roomList{
position: absolute;
left: 0;
top: 0;
width: 20rem;
height: 100%;
background-color: #222;
text-align: center;
overflow-y: auto;
}
.chat{
position: absolute;
right: 0;
top: 0;
width: calc(100% - 20rem);
height: 100%;
background-color: #313131;
}
.roomListElement{
position: relative; position: relative;
height: 3rem; height: 3rem;
margin-top: 1rem; margin-top: 1rem;
@ -43,4 +72,32 @@ export default {
position: absolute; position: absolute;
left: 5rem; left: 5rem;
} }
.noRoomSelected{
position: absolute;
width: calc(100% - 20rem);
top: 5rem;
left: 20rem;
text-align: center;
}
/*@media (max-width: 45rem) {
.roomList{
width: 4rem;
}
.chat{
width: calc(100% - 4rem);
}
}*/
@media (max-width: 30rem) {
.roomList{
width: 100%;
}
.chat{
width: 100%;
}
.noRoomSelected{
display: none;
}
}
</style> </style>
Loading…
Cancel
Save