added icon and login witch other homeservers
This commit is contained in:
parent
d16d7153e3
commit
c964ea93af
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
/dist
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 128 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.7 KiB |
@ -3,7 +3,7 @@
|
|||||||
<form v-on:submit.prevent="sendMessage()">
|
<form v-on:submit.prevent="sendMessage()">
|
||||||
<label for="newMessageInput"></label>
|
<label for="newMessageInput"></label>
|
||||||
<textarea @keyup.enter.exact="sendMessage()" @input="resizeMessageBanner()" ref="newMessageInput" id="newMessageInput" class="newMessageInput"
|
<textarea @keyup.enter.exact="sendMessage()" @input="resizeMessageBanner()" ref="newMessageInput" id="newMessageInput" class="newMessageInput"
|
||||||
autocomplete="off" placeholder="type a message ..." v-model="msg.content.body" />
|
autocomplete="off" rows="1" placeholder="type a message ..." v-model="msg.content.body" />
|
||||||
<icon type="submit" title="press enter to submit" id="sendMessageBtn"
|
<icon type="submit" title="press enter to submit" id="sendMessageBtn"
|
||||||
ic="./sym/ic_send_white_24px.svg" />
|
ic="./sym/ic_send_white_24px.svg" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -2,36 +2,38 @@ import matrix from 'matrix-js-sdk';
|
|||||||
import main from '@/main.js';
|
import main from '@/main.js';
|
||||||
// import Vue from 'vue';
|
// import Vue from 'vue';
|
||||||
|
|
||||||
const client = matrix.createClient({
|
let client = matrix.createClient({});
|
||||||
baseUrl: 'https://adb.sh',
|
|
||||||
accessToken: getCookie('accessToken'),
|
|
||||||
userId: getCookie('userId'),
|
|
||||||
});
|
|
||||||
let session = {
|
let session = {
|
||||||
user: '',
|
user: '',
|
||||||
password: '',
|
baseUrl: '',
|
||||||
accessToken: '',
|
accessToken: '',
|
||||||
rooms: [],
|
rooms: [],
|
||||||
currentRoom: undefined,
|
currentRoom: undefined,
|
||||||
login: {
|
login: {
|
||||||
user: '',
|
user: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
baseUrl: 'https://adb.sh',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(document.cookie);
|
console.log(`cookie => ${document.cookie}`);
|
||||||
|
|
||||||
if (getCookie('accessToken') && getCookie('userId')) {
|
if (getCookie('accessToken') && getCookie('userId') && getCookie('baseUrl')) {
|
||||||
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
||||||
session = {
|
session = {
|
||||||
user: getCookie('userId'),
|
user: getCookie('userId'),
|
||||||
password: '',
|
baseUrl: getCookie('baseUrl'),
|
||||||
accessToken: getCookie('accessToken'),
|
accessToken: getCookie('accessToken'),
|
||||||
rooms: [],
|
rooms: [],
|
||||||
currentRoom: undefined,
|
currentRoom: undefined,
|
||||||
};
|
};
|
||||||
// Vue.$router.push("/rooms/")
|
// Vue.$router.push("/rooms/")
|
||||||
window.location.href = '/#/rooms/';
|
window.location.href = '/#/rooms/';
|
||||||
|
client = matrix.createClient({
|
||||||
|
baseUrl: getCookie('baseUrl'),
|
||||||
|
accessToken: getCookie('accessToken'),
|
||||||
|
userId: getCookie('userId'),
|
||||||
|
});
|
||||||
client.startClient();
|
client.startClient();
|
||||||
client.once('sync', (state) => {
|
client.once('sync', (state) => {
|
||||||
console.log(state);
|
console.log(state);
|
||||||
@ -59,6 +61,9 @@ export default {
|
|||||||
main.methods.error('username is in wrong style');
|
main.methods.error('username is in wrong style');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
client = matrix.createClient({
|
||||||
|
baseUrl: session.login.baseUrl
|
||||||
|
});
|
||||||
client.login('m.login.password', {
|
client.login('m.login.password', {
|
||||||
user: session.login.user,
|
user: session.login.user,
|
||||||
password: session.login.password,
|
password: session.login.password,
|
||||||
@ -66,10 +71,11 @@ export default {
|
|||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
document.cookie = `accessToken=${response.access_token}`;
|
document.cookie = `accessToken=${response.access_token}`;
|
||||||
document.cookie = `userId=${session.login.user}`;
|
document.cookie = `userId=${session.login.user}`;
|
||||||
document.cookie = `max-expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
document.cookie = `baseUrl=${session.login.baseUrl}`;
|
||||||
|
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
||||||
session = {
|
session = {
|
||||||
user: session.login.user,
|
user: session.login.user,
|
||||||
password: '',
|
baseUrl: session.login.baseUrl,
|
||||||
accessToken: response.access_token,
|
accessToken: response.access_token,
|
||||||
rooms: [],
|
rooms: [],
|
||||||
currentRoom: undefined,
|
currentRoom: undefined,
|
||||||
@ -80,12 +86,20 @@ export default {
|
|||||||
console.log(`login error => ${response.error}`);
|
console.log(`login error => ${response.error}`);
|
||||||
}
|
}
|
||||||
window.location.href = '/#/rooms/';
|
window.location.href = '/#/rooms/';
|
||||||
client.startClient();
|
window.location.reload();
|
||||||
|
/*client.startClient();
|
||||||
client.once('sync', (state) => {
|
client.once('sync', (state) => {
|
||||||
console.log(state);
|
console.log(state);
|
||||||
});
|
});*/
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
logout(){
|
||||||
|
document.cookie = `accessToken=`;
|
||||||
|
document.cookie = `userId=`;
|
||||||
|
document.cookie = `baseUrl=`;
|
||||||
|
document.cookie = `expires=${new Date(0)}`;
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
sendMessage(msg) {
|
sendMessage(msg) {
|
||||||
const msgSend = {
|
const msgSend = {
|
||||||
type: msg.type,
|
type: msg.type,
|
||||||
|
@ -63,8 +63,12 @@ export default {
|
|||||||
return {
|
return {
|
||||||
chatroom: main.data().chatroom,
|
chatroom: main.data().chatroom,
|
||||||
session: matrix.data().session,
|
session: matrix.data().session,
|
||||||
showScrollBtn: false
|
showScrollBtn: false,
|
||||||
|
scrollOnUpdate: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updated(){
|
||||||
|
//this.scrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<h1 class="title">[chat]</h1>
|
<h1 class="title">[chat]</h1>
|
||||||
<form @submit.prevent="login()">
|
<form v-if="session.login" @submit.prevent="login()">
|
||||||
<input v-model="session.login.user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br>
|
<input v-model="session.login.user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br>
|
||||||
<input v-model="session.login.password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br>
|
<input v-model="session.login.password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br>
|
||||||
|
<input v-model="session.login.baseUrl" class="input" name="homeserver" maxlength="50" placeholder="https://matrix.org"><br>
|
||||||
<textbtn type="submit" text="login" />
|
<textbtn type="submit" text="login" />
|
||||||
</form>
|
</form>
|
||||||
|
<div v-else>
|
||||||
|
<p>you are already logged in</p>
|
||||||
|
<textbtn @click.native="$router.push('room')" text="chat" />
|
||||||
|
<textbtn @click.native="logout()" text="logout" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -20,7 +26,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
login(){
|
login(){
|
||||||
matrix.methods.login()
|
matrix.methods.login();
|
||||||
|
},
|
||||||
|
logout(){
|
||||||
|
matrix.methods.logout();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div id="roomList" class="roomList">
|
<div id="roomList" class="roomList">
|
||||||
<h1>[chat]</h1>
|
<h1>[chat]{{scrollOnUpdate}}</h1>
|
||||||
<h2>{{session.rooms.length}} rooms:</h2>
|
<h2>{{session.rooms.length}} rooms:</h2>
|
||||||
<div v-for="room in session.rooms" :key="room.roomId" @click="openChat(room)" class="roomListElement">
|
<div v-for="room in session.rooms" :key="room.roomId" @click="openChat(room)" class="roomListElement">
|
||||||
<div class="roomImgPlaceholder">{{room.name.substr(0,2)}}</div>
|
<div class="roomImgPlaceholder">{{room.name.substr(0,2)}}</div>
|
||||||
@ -44,7 +44,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
session: matrix.data().session,
|
session: matrix.data().session
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user