Add QR code next to DM link
This commit is contained in:
parent
7a775a6ca5
commit
0daa3358ae
2 changed files with 81 additions and 80 deletions
|
|
@ -1,11 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<v-expand-transition>
|
<v-expand-transition>
|
||||||
<v-card class="ma-3" v-show="locationLink" flat>
|
<v-card class="ma-3" v-show="locationLink" flat>
|
||||||
<v-container>
|
<v-container>
|
||||||
<slot/>
|
<slot/>
|
||||||
<v-row cols="12" class="qr-container ma-3">
|
<v-row cols="12" class="qr-container ma-3">
|
||||||
<v-col cols="auto" v-if="$slots.qrCode">
|
<v-col cols="auto">
|
||||||
<slot name="qrCode"/>
|
<canvas
|
||||||
|
@click.stop="showFullScreenQR = true"
|
||||||
|
ref="roomQr"
|
||||||
|
class="qr"
|
||||||
|
id="room-qr"
|
||||||
|
></canvas>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col align-self="center" class="public-link">
|
<v-col align-self="center" class="public-link">
|
||||||
<div class="link">{{ locationLink }}</div>
|
<div class="link">{{ locationLink }}</div>
|
||||||
|
|
@ -15,21 +21,29 @@
|
||||||
<v-col align="center" class="mt-0 pt-0">
|
<v-col align="center" class="mt-0 pt-0">
|
||||||
<v-btn
|
<v-btn
|
||||||
id="btn-copy-room-link"
|
id="btn-copy-room-link"
|
||||||
:color="publicRoomLinkCopied ? '#DEE6FF' : 'black'"
|
:color="locationLinkCopied ? '#DEE6FF' : 'black'"
|
||||||
depressed
|
depressed
|
||||||
@click.stop="copyRoomLink"
|
@click.stop="copyRoomLink"
|
||||||
:class="{'filled-button' : true, 'link-copied-in-place' : publicRoomLinkCopied}"
|
:class="{'filled-button' : true, 'link-copied-in-place' : locationLinkCopied}"
|
||||||
>{{ $t(`room_info.${publicRoomLinkCopied ? 'link_copied' : i18nCopyLinkKey}`) }}</v-btn
|
>{{ $t(`room_info.${locationLinkCopied ? 'link_copied' : i18nCopyLinkKey}`) }}</v-btn
|
||||||
>
|
>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-expand-transition>
|
</v-expand-transition>
|
||||||
|
<QRCodePopup :show="showFullScreenQR" :message="locationLink" @close="showFullScreenQR = false" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import QRCode from "qrcode";
|
||||||
|
import QRCodePopup from './QRCodePopup.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
QRCodePopup
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
locationLink: {
|
locationLink: {
|
||||||
type: String
|
type: String
|
||||||
|
|
@ -41,27 +55,57 @@ props: {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
publicRoomLinkCopied: false,
|
locationLinkCopied: false,
|
||||||
|
showFullScreenQR: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyRoomLink() {
|
copyRoomLink() {
|
||||||
if(this.publicRoomLinkCopied) return
|
if(this.locationLinkCopied) return
|
||||||
const self = this;
|
const self = this;
|
||||||
this.$copyText(this.locationLink).then(
|
this.$copyText(this.locationLink).then(
|
||||||
function (ignored) {
|
function (ignored) {
|
||||||
// Success!
|
// Success!
|
||||||
self.publicRoomLinkCopied = true;
|
self.locationLinkCopied = true;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
// Hide again
|
// Hide again
|
||||||
self.publicRoomLinkCopied = false;
|
self.locationLinkCopied = false;
|
||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
function (e) {
|
function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
updateQRCode() {
|
||||||
|
var fullUrl = this.locationLink;
|
||||||
|
var canvas = this.$refs.roomQr;
|
||||||
|
if (fullUrl && canvas) {
|
||||||
|
QRCode.toCanvas(
|
||||||
|
canvas,
|
||||||
|
fullUrl,
|
||||||
|
{
|
||||||
|
type: "image/png",
|
||||||
|
margin: 1,
|
||||||
|
width: 60,
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
if (error) console.error(error);
|
||||||
|
else console.log("success!");
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
locationLink: {
|
||||||
|
handler() {
|
||||||
|
this.updateQRCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateQRCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -78,16 +78,7 @@
|
||||||
{{ $t("room_info.created_by", { user: creator }) }}
|
{{ $t("room_info.created_by", { user: creator }) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<copy-link :locationLink="publicRoomLink" i18nCopyLinkKey="copy_invite_link">
|
<copy-link :locationLink="publicRoomLink" i18nCopyLinkKey="copy_invite_link" />
|
||||||
<template slot="qrCode">
|
|
||||||
<canvas
|
|
||||||
@click.stop="showFullScreenQR = true"
|
|
||||||
ref="roomQr"
|
|
||||||
class="qr"
|
|
||||||
id="room-qr"
|
|
||||||
></canvas>
|
|
||||||
</template>
|
|
||||||
</copy-link>
|
|
||||||
|
|
||||||
<v-card class="account ma-3" flat>
|
<v-card class="account ma-3" flat>
|
||||||
<v-card-title class="h2">{{ $t("room_info.permissions") }}</v-card-title>
|
<v-card-title class="h2">{{ $t("room_info.permissions") }}</v-card-title>
|
||||||
|
|
@ -258,8 +249,6 @@
|
||||||
@close="showPurgeConfirmation = false"
|
@close="showPurgeConfirmation = false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<QRCodePopup :show="showFullScreenQR" :message="publicRoomLink" @close="showFullScreenQR = false" />
|
|
||||||
|
|
||||||
<RoomExport :room="room" v-if="exporting" v-on:close="exporting = false" />
|
<RoomExport :room="room" v-if="exporting" v-on:close="exporting = false" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -271,9 +260,7 @@ import DeviceList from "../components/DeviceList";
|
||||||
import RoomExport from "../components/RoomExport";
|
import RoomExport from "../components/RoomExport";
|
||||||
import RoomAvatarPicker from "../components/RoomAvatarPicker";
|
import RoomAvatarPicker from "../components/RoomAvatarPicker";
|
||||||
import CopyLink from "../components/CopyLink.vue"
|
import CopyLink from "../components/CopyLink.vue"
|
||||||
import QRCode from "qrcode";
|
|
||||||
import roomInfoMixin from "./roomInfoMixin";
|
import roomInfoMixin from "./roomInfoMixin";
|
||||||
import QRCodePopup from './QRCodePopup.vue';
|
|
||||||
import util from "../plugins/utils";
|
import util from "../plugins/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -284,7 +271,6 @@ export default {
|
||||||
PurgeRoomDialog,
|
PurgeRoomDialog,
|
||||||
DeviceList,
|
DeviceList,
|
||||||
RoomExport,
|
RoomExport,
|
||||||
QRCodePopup,
|
|
||||||
RoomAvatarPicker,
|
RoomAvatarPicker,
|
||||||
CopyLink
|
CopyLink
|
||||||
},
|
},
|
||||||
|
|
@ -296,7 +282,6 @@ export default {
|
||||||
showAllMembers: false,
|
showAllMembers: false,
|
||||||
showLeaveConfirmation: false,
|
showLeaveConfirmation: false,
|
||||||
showPurgeConfirmation: false,
|
showPurgeConfirmation: false,
|
||||||
showFullScreenQR: false,
|
|
||||||
expandedMembers: [],
|
expandedMembers: [],
|
||||||
buildVersion: "",
|
buildVersion: "",
|
||||||
updatingJoinRule: false, // Flag if we are processing update curerntly
|
updatingJoinRule: false, // Flag if we are processing update curerntly
|
||||||
|
|
@ -322,9 +307,6 @@ export default {
|
||||||
this.user = this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
|
this.user = this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
|
||||||
this.displayName = this.user.displayName;
|
this.displayName = this.user.displayName;
|
||||||
|
|
||||||
// Set QR code
|
|
||||||
this.updateQRCode();
|
|
||||||
|
|
||||||
// Display build version
|
// Display build version
|
||||||
const version = require("!!raw-loader!../assets/version.txt").default;
|
const version = require("!!raw-loader!../assets/version.txt").default;
|
||||||
console.log("Version", version);
|
console.log("Version", version);
|
||||||
|
|
@ -383,13 +365,9 @@ export default {
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
room: {
|
room: {
|
||||||
handler(ignoredNewVal, ignoredOldVal) {
|
handler() {
|
||||||
console.log("RoomInfo: Current room changed");
|
console.log("RoomInfo: Current room changed");
|
||||||
this.updateMembers();
|
this.updateMembers();
|
||||||
this.$nextTick(() => {
|
|
||||||
// Wait a tick, we want to be sure that the QR canvas ref is already created!
|
|
||||||
this.updateQRCode();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -432,26 +410,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateQRCode() {
|
|
||||||
var fullUrl = this.publicRoomLink;
|
|
||||||
var canvas = this.$refs.roomQr;
|
|
||||||
if (fullUrl && canvas) {
|
|
||||||
QRCode.toCanvas(
|
|
||||||
canvas,
|
|
||||||
fullUrl,
|
|
||||||
{
|
|
||||||
type: "image/png",
|
|
||||||
margin: 1,
|
|
||||||
width: 60,
|
|
||||||
},
|
|
||||||
function (error) {
|
|
||||||
if (error) console.error(error);
|
|
||||||
else console.log("success!");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
memberAvatar(member) {
|
memberAvatar(member) {
|
||||||
if (member) {
|
if (member) {
|
||||||
return member.getAvatarUrl(
|
return member.getAvatarUrl(
|
||||||
|
|
@ -520,7 +478,6 @@ export default {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.updatingJoinRule = false;
|
this.updatingJoinRule = false;
|
||||||
this.updateQRCode();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
startPrivateChat(userId) {
|
startPrivateChat(userId) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue