Merge branch 'master' into fork

This commit is contained in:
EveryOS 2020-01-14 10:08:29 -05:00 committed by GitHub
commit 9edf45753e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 113 additions and 159 deletions

View file

@ -2,13 +2,13 @@
<div <div
class="member" class="member"
@click="openUserInformation()" @click="openUserInformation()"
@mouseover="hover = true" @mouseover="mouseOverEvent"
@mouseleave="hover = false" @mouseleave="hover = false"
@contextmenu.prevent="rightClickEvent" @contextmenu.prevent="rightClickEvent"
> >
<Profile-picture <Profile-picture
class="avatar" class="avatar"
:url="`${userAvatar}${hover ? '' : '?type=png'}`" :url="`${userAvatar}${hover || !isGif ? '' : '?type=webp'}`"
size="30px" size="30px"
:unique-i-d="user.uniqueID" :unique-i-d="user.uniqueID"
:status="presense" :status="presense"
@ -32,7 +32,8 @@ export default {
props: ["user", "avatar", "type", "member"], props: ["user", "avatar", "type", "member"],
data() { data() {
return { return {
hover: false hover: false,
isGif: false,
}; };
}, },
computed: { computed: {
@ -87,6 +88,9 @@ export default {
return false; return false;
} }
}, },
mounted() {
this.isGif = this.userAvatar.endsWith(".gif");
},
methods: { methods: {
openUserInformation() { openUserInformation() {
this.$store.dispatch("setUserInformationPopout", this.user.uniqueID); this.$store.dispatch("setUserInformationPopout", this.user.uniqueID);
@ -100,6 +104,11 @@ export default {
x, x,
y y
}); });
},
mouseOverEvent() {
if (this.isGif) {
this.hover = true;
}
} }
} }
}; };

View file

@ -1,5 +1,9 @@
<template> <template>
<div class="container" @mouseover="hover = true" @mouseleave="hover = false"> <div
class="container"
@mouseover="mouseOverEvent"
@mouseleave="hover = false"
>
<div <div
v-if="!type || type === 0" v-if="!type || type === 0"
:class="{ :class="{
@ -14,7 +18,7 @@
<div class="avatar"> <div class="avatar">
<profile-picture <profile-picture
:admin="$props.admin" :admin="$props.admin"
:url="`${userAvatar}${hover ? '' : '?type=png'}`" :url="`${userAvatar}${hover || !isGif ? '' : '?type=webp'}`"
size="50px" size="50px"
:hover="true" :hover="true"
@click.native="openUserInformation" @click.native="openUserInformation"
@ -166,10 +170,16 @@ export default {
}, },
data() { data() {
return { return {
hover: false hover: false,
isGif: false
}; };
}, },
methods: { methods: {
mouseOverEvent() {
if (this.isGif) {
this.hover = true;
}
},
openContextMenu(event) { openContextMenu(event) {
const x = event.clientX; const x = event.clientX;
const y = event.clientY; const y = event.clientY;
@ -261,6 +271,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.isGif = this.userAvatar.endsWith(".gif");
const files = this.files; const files = this.files;
if (!files || files.length === 0 || !files[0].dimensions) return undefined; if (!files || files.length === 0 || !files[0].dimensions) return undefined;
this.imageSize(); this.imageSize();

View file

@ -2,10 +2,12 @@
<div class="my-mini-information"> <div class="my-mini-information">
<ProfilePicture <ProfilePicture
class="avatar" class="avatar"
:url="`${avatar}${hover ? '' : '?type=png'}`" :url="`${avatar}${hover ? '' : '?type=webp'}`"
:admin="user.admin" :admin="user.admin"
size="35px" size="35px"
:hover="true" :hover="true"
@mouseenter.native="hover = true"
@mouseleave.native="hover = false"
@click.native="openUserInformation" @click.native="openUserInformation"
/> />
<div class="information"> <div class="information">

View file

@ -136,13 +136,13 @@ export default {
const file = event.target.files[0]; const file = event.target.files[0];
const _this = this; const _this = this;
const maxSize = 2092000; const maxSize = 2092000;
event.target.value = "";
if (file.size > maxSize) { if (file.size > maxSize) {
return this.$store.dispatch( return this.$store.dispatch(
"setGenericMessage", "setGenericMessage",
"Image is larger than 2MB" "Image is larger than 2MB"
); );
} }
event.target.value = "";
const allowedFormats = [".png", ".jpeg", ".gif", ".jpg"]; const allowedFormats = [".png", ".jpeg", ".gif", ".jpg"];
if (!allowedFormats.includes(path.extname(file.name).toLowerCase())) { if (!allowedFormats.includes(path.extname(file.name).toLowerCase())) {
return this.$store.dispatch( return this.$store.dispatch(

View file

@ -122,11 +122,11 @@ export default {
} }
const file = event.target.files[0]; const file = event.target.files[0];
const _this = this; const _this = this;
const maxSize = 2092000; const maxSize = 8092000;
if (file.size > maxSize) { if (file.size > maxSize) {
return this.$store.dispatch( return this.$store.dispatch(
"setGenericMessage", "setGenericMessage",
"Image is larger than 2MB" "Image is larger than 8MB"
); );
} }
event.target.value = ""; event.target.value = "";

View file

@ -2,7 +2,7 @@
<div class="manage-emoji-panel"> <div class="manage-emoji-panel">
<div class="info"> <div class="info">
<div class="title"> <div class="title">
Upload your own pretty emojis for free! Emojis must be 1MB or less. Upload your own pretty emojis for free! Emojis must be 3MB or less.
(png, jpg, gif) (png, jpg, gif)
</div> </div>
<div class="button" @click="addEmojiBtn"> <div class="button" @click="addEmojiBtn">
@ -36,23 +36,6 @@
class="hidden" class="hidden"
@change="emojiBrowse" @change="emojiBrowse"
/> />
<!-- <div class="option" @click="changePassword">Change Password</div> -->
<div v-if="alert.show" class="alert-outer">
<div class="alert">
<div class="alert-title">
Error
</div>
<div class="alert-content">
{{ alert.content }}
</div>
<div class="alert-buttons">
<div class="alert-button" @click="alert.show = false">
Okay
</div>
</div>
</div>
</div>
</div> </div>
</template> </template>
@ -67,14 +50,13 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
alert: {
content: "",
show: false
},
domain: config.domain + "/files/" domain: config.domain + "/files/"
}; };
}, },
methods: { methods: {
errorBox(msg) {
return this.$store.dispatch("setGenericMessage", msg);
},
keyDownEvent(event) { keyDownEvent(event) {
const keyCode = event.keyCode; const keyCode = event.keyCode;
if (keyCode == 13) { if (keyCode == 13) {
@ -83,61 +65,66 @@ export default {
}, },
async blurEvent(emojiID, event) { async blurEvent(emojiID, event) {
// send put request // send put request
const { ok, error } = await customEmoji.put({ const { ok } = await customEmoji.put({
emojiID, emojiID,
name: event.target.value name: event.target.value
}); });
if (!ok) { if (!ok) {
this.alert.content = this.errorBox("Something weng wrong. Try again later.");
"Upload failed - " + error.response.data.message || return;
"Something weng wrong. Try again later.";
return (this.alert.show = true);
} }
}, },
onProgress(percent) {
//update vue
console.log("emoji upload progress: ", percent);
},
async emojiBrowse(event) { async emojiBrowse(event) {
const file = event.target.files[0]; const file = event.target.files[0];
event.target.value = ""; event.target.value = "";
const allowedFormats = [".png", ".jpeg", ".gif", ".jpg"]; const allowedFormats = [".png", ".jpeg", ".gif", ".jpg"];
if (!allowedFormats.includes(path.extname(file.name).toLowerCase())) { if (!allowedFormats.includes(path.extname(file.name).toLowerCase())) {
this.alert.content = "Upload failed - Unsupported image file."; this.errorBox("Upload failed - Unsupported image file.");
return (this.alert.show = true); return;
} else if (file.size >= 1048576) { } else if (file.size >= 3048576) {
// 1048576 = 1mb // 3048576 = 3mb
this.alert.content = this.errorBox(
"Upload failed - Image size must be less than 1 megabytes."; "Upload failed - Image size must be less than 1 megabytes."
return (this.alert.show = true); );
return;
} }
const formData = new FormData();
//check if emoji name is already used by twemoji
const fileName = path.basename(file.name, path.extname(file.name));
const emojiExists = emojiParser.allEmojis.find(e => let reader = new FileReader();
e.shortcodes.find(ee => ee === fileName.toLowerCase()) reader.readAsDataURL(file);
); const _this = this;
if (emojiExists) { reader.onload = async function() {
formData.append( //check if emoji name is already used by twemoji
"emoji", const fileName = path.basename(file.name, path.extname(file.name));
file,
`${fileName.substring(0, 28)}-1${path.extname(file.name)}` const emojiExists = emojiParser.allEmojis.find(e =>
e.shortcodes.find(ee => ee === fileName.toLowerCase())
); );
} else {
formData.append( let finalEmojiName = () => {
"emoji", if (emojiExists) {
file, return `${fileName.substring(0, 28)}-1`;
`${fileName.substring(0, 30)}${path.extname(file.name)}` } else {
); return fileName.substring(0, 30);
} }
const { ok, error } = await customEmoji.post(formData, this.onProgress); };
if (!ok) {
this.alert.content = const { ok, error } = await customEmoji.post({
"Upload failed - " + error.response.data.message || name: finalEmojiName(),
"Something weng wrong. Try again later."; avatar: reader.result
return (this.alert.show = true); });
} if (!ok) {
if (error.response && error.response.data) {
_this.errorBox(error.response.data.message);
} else {
_this.errorBox("Something went wrong. Try again later.");
}
return;
}
};
reader.onerror = function(error) {
console.log("Error: ", error);
_this.errorBox("Something went wrong. Try again later.");
};
}, },
addEmojiBtn() { addEmojiBtn() {
if (!this.GDriveLinked) { if (!this.GDriveLinked) {
@ -149,17 +136,19 @@ export default {
this.$refs.emojiBrowser.click(); this.$refs.emojiBrowser.click();
}, },
async removeEmoji(emojiID) { async removeEmoji(emojiID) {
const { ok, error } = await customEmoji.delete(emojiID); const { ok } = await customEmoji.delete(emojiID);
if (!ok) { if (!ok) {
this.alert.content = this.errorBox("Something weng wrong. Try again later.");
"Upload failed - " + error.response.data.message || return;
"Something weng wrong. Try again later.";
return (this.alert.show = true);
} }
} }
}, },
computed: { computed: {
...mapState("settingsModule", ["GDriveLinked", "customEmojis"]) ...mapState("settingsModule", ["GDriveLinked"]),
customEmojis() {
const customEmojis = [...this.$store.state.settingsModule.customEmojis];
return customEmojis ? customEmojis.reverse() : [];
}
} }
}; };
</script> </script>
@ -219,6 +208,7 @@ input:focus {
width: 100%; width: 100%;
height: 100%; height: 100%;
margin-bottom: 20px; margin-bottom: 20px;
overflow: hidden;
} }
.emojis-list { .emojis-list {

View file

@ -34,11 +34,6 @@
const Survey = () => import("./survey.vue"); const Survey = () => import("./survey.vue");
const EditProfile = () => import("./EditProfile.vue"); const EditProfile = () => import("./EditProfile.vue");
import AvatarUpload from "@/services/AvatarUpload.js";
import config from "@/config.js";
import path from "path";
import { mapState } from "vuex";
export default { export default {
components: { components: {
Survey, Survey,
@ -52,57 +47,6 @@ export default {
show: false show: false
} }
}; };
},
methods: {
onProgress(percent) {
//update vue
console.log("Avatar upload progress: ", percent);
},
async avatarBrowse(event) {
const file = event.target.files[0];
event.target.value = "";
const allowedFormats = [".png", ".jpeg", ".gif", ".jpg"];
if (!allowedFormats.includes(path.extname(file.name).toLowerCase())) {
this.alert.content = "Upload failed - Unsupported image file.";
return (this.alert.show = true);
} else if (file.size >= 2092000) {
// 2092000 = 2mb
this.alert.content =
"Upload failed - Image size must be less than 2 megabytes.";
return (this.alert.show = true);
}
const formData = new FormData();
formData.append("avatar", file);
const { ok } = await AvatarUpload.uploadAvatar(formData, this.onProgress);
if (!ok) {
this.alert.content =
"Upload failed - Something went wrong. Try again later.";
return (this.alert.show = true);
}
},
changePassword() {
this.alert.content = "Not implemented yet.";
return (this.alert.show = true);
},
editAvatarBtn() {
if (!this.GDriveLinked) {
return this.$store.dispatch("setPopoutVisibility", {
name: "GDLinkMenu",
visibility: true
});
}
this.$refs.avatarBrowser.click();
}
},
computed: {
...mapState("settingsModule", ["GDriveLinked"]),
user() {
return this.$store.getters.user;
},
avatar() {
return config.domain + "/avatars/" + this.$store.getters.user.avatar;
}
} }
}; };
</script> </script>

View file

@ -16,7 +16,7 @@
v-if="server && server.banner" v-if="server && server.banner"
:style="{ :style="{
backgroundImage: `url(${bannerDomain}${server.banner}${ backgroundImage: `url(${bannerDomain}${server.banner}${
bannerHover ? '' : '?type=png' bannerHover ? '' : '?type=webp'
})` })`
}" }"
/> />
@ -144,6 +144,7 @@ export default {
display: flex; display: flex;
flex: 1; flex: 1;
height: 100%; height: 100%;
overflow: auto;
} }
.right { .right {
display: flex; display: flex;
@ -166,6 +167,7 @@ export default {
border-radius: 4px; border-radius: 4px;
margin: 10px; margin: 10px;
box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.13); box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.13);
flex-shrink: 0;
} }
.extendBanner { .extendBanner {
height: 130px; height: 130px;

View file

@ -14,7 +14,7 @@
<profile-picture <profile-picture
size="45px" size="45px"
class="avatar" class="avatar"
:url="`${avatarDomain}/${serverData.avatar}${hover ? '' : '?type=png'}`" :url="`${avatarDomain}/${serverData.avatar}${hover ? '' : '?type=webp'}`"
/> />
</div> </div>
</template> </template>

View file

@ -6,7 +6,7 @@
v-if="server.server.banner" v-if="server.server.banner"
:style="{ :style="{
backgroundImage: `url(${bannerDomain + server.server.banner}${ backgroundImage: `url(${bannerDomain + server.server.banner}${
hover ? '' : '?type=png' hover ? '' : '?type=webp'
})` })`
}" }"
/> />

View file

@ -6,7 +6,7 @@
class="background-dark" class="background-dark"
:style="{ :style="{
backgroundImage: `url(${bannerDomain + backgroundImage: `url(${bannerDomain +
theme.screenshot}${'?type=png'})` theme.screenshot}${'?type=webp'})`
}" }"
/> />
</div> </div>
@ -76,7 +76,7 @@ export default {
bannerImageClicked() { bannerImageClicked() {
this.$store.dispatch( this.$store.dispatch(
"setImagePreviewURL", "setImagePreviewURL",
this.bannerDomain + this.theme.screenshot + "?type=png" this.bannerDomain + this.theme.screenshot + "?type=webp"
); );
}, },
unApplyButton() { unApplyButton() {

View file

@ -3,7 +3,7 @@
class="friend" class="friend"
:class="{ selected: uniqueIDSelected, tree }" :class="{ selected: uniqueIDSelected, tree }"
@click="openChat" @click="openChat"
@mouseover="hover = true" @mouseover="mouseOverEvent"
@mouseleave="hover = false" @mouseleave="hover = false"
> >
<div <div
@ -11,7 +11,7 @@
:style=" :style="
`border-color: ${ `border-color: ${
status.statusColor status.statusColor
}; background-image: url(${userAvatar}${hover ? '' : '?type=png'})` }; background-image: url(${userAvatar}${hover || !isGif ? '' : '?type=webp'})`
" "
@click="openUserInformation" @click="openUserInformation"
> >
@ -53,9 +53,13 @@ export default {
], ],
data() { data() {
return { return {
hover: false hover: false,
isGif: false
}; };
}, },
mounted() {
this.isGif = this.userAvatar.endsWith(".gif");
},
computed: { computed: {
notifications() { notifications() {
const channelID = this.$props.channelID; const channelID = this.$props.channelID;
@ -97,6 +101,11 @@ export default {
} }
}, },
methods: { methods: {
mouseOverEvent() {
if (this.isGif) {
this.hover = true;
}
},
async closeChannel() { async closeChannel() {
this.channelID; this.channelID;
await channelService.delete(this.channelID); await channelService.delete(this.channelID);

View file

@ -6,21 +6,8 @@ let domain = "";
if (config.serverURL) domain = config.serverURL+"/" if (config.serverURL) domain = config.serverURL+"/"
export default { export default {
post(data, onProgress) { post(data) {
const url = `/settings/emoji`; return wrapper(instance().post(domain+"/settings/emoji", data));
let config = {
onUploadProgress(progressEvent) {
var percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
// execute the callback
if (onProgress) onProgress(percentCompleted);
return percentCompleted;
}
};
return wrapper(instance().post(domain+url, data, config));
}, },
delete(emojiID) { delete(emojiID) {
return wrapper(instance().delete(domain+`/settings/emoji`, { data: { emojiID } })); return wrapper(instance().delete(domain+`/settings/emoji`, { data: { emojiID } }));

View file

@ -3,7 +3,7 @@ const config = [
version: 9.2, version: 9.2,
title: "Image cache, more role permissions!", title: "Image cache, more role permissions!",
shortTitle: "", shortTitle: "",
date: "08/01/2019", date: "09/01/2019",
headColor: "#007792", headColor: "#007792",
new: [ new: [
"Image cache has been implimented.", "Image cache has been implimented.",