♻️ Refactor

This commit is contained in:
Liyas Thomas
2020-01-31 00:18:20 +05:30
parent f80c5d6a46
commit 1d6d8af748
5 changed files with 29 additions and 36 deletions

View File

@@ -55,8 +55,8 @@ export default {
mounted() { mounted() {
const editor = ace.edit(this.$refs.editor, { const editor = ace.edit(this.$refs.editor, {
theme: "ace/theme/" + this.defineTheme(), theme: `ace/theme/${this.defineTheme()}`,
mode: "ace/mode/" + this.lang, mode: `ace/mode/${this.lang}`,
...this.options ...this.options
}); });
@@ -74,14 +74,11 @@ export default {
methods: { methods: {
defineTheme() { defineTheme() {
if (this.theme) { if (this.theme) return this.theme;
return this.theme;
} else {
return ( return (
this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
); );
} }
}
}, },
beforeDestroy() { beforeDestroy() {

View File

@@ -363,8 +363,8 @@ export default {
let file = this.$refs.collectionUpload.files[0]; let file = this.$refs.collectionUpload.files[0];
if (file !== undefined && file !== null) { if (file !== undefined && file !== null) {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = e => { reader.onload = ({ target }) => {
this.collectionJSON = e.target.result; this.collectionJSON = target.result;
}; };
reader.readAsText(file); reader.readAsText(file);
this.$toast.info(this.$t("file_imported"), { this.$toast.info(this.$t("file_imported"), {

View File

@@ -531,7 +531,10 @@ export default {
return this.$store.state.gql.variablesJSONString; return this.$store.state.gql.variablesJSONString;
}, },
set(value) { set(value) {
this.$store.commit("setGQLState", { value, attribute: "variablesJSONString" }); this.$store.commit("setGQLState", {
value,
attribute: "variablesJSONString"
});
} }
}, },
headerString() { headerString() {
@@ -780,13 +783,10 @@ export default {
downloadResponse() { downloadResponse() {
const dataToWrite = JSON.stringify(this.schemaString, null, 2); const dataToWrite = JSON.stringify(this.schemaString, null, 2);
const file = new Blob([dataToWrite], { type: "application/json" }); const file = new Blob([dataToWrite], { type: "application/json" });
const a = document.createElement("a"), const a = document.createElement("a");
url = URL.createObjectURL(file); const url = URL.createObjectURL(file);
a.href = url; a.href = url;
a.download = (this.url + " on " + Date() + ".graphql").replace( a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]");
/\./g,
"[dot]"
);
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
this.$refs.downloadResponse.innerHTML = this.doneButton; this.$refs.downloadResponse.innerHTML = this.doneButton;

View File

@@ -211,24 +211,20 @@ export default {
urlValid() { urlValid() {
const protocol = "^(wss?:\\/\\/)?"; const protocol = "^(wss?:\\/\\/)?";
const validIP = new RegExp( const validIP = new RegExp(
protocol + `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
); );
const validHostname = new RegExp( const validHostname = new RegExp(
protocol + `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$"
); );
return validIP.test(this.url) || validHostname.test(this.url); return validIP.test(this.url) || validHostname.test(this.url);
}, },
serverValid() { serverValid() {
const protocol = "^(https?:\\/\\/)?"; const protocol = "^(https?:\\/\\/)?";
const validIP = new RegExp( const validIP = new RegExp(
protocol + `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
); );
const validHostname = new RegExp( const validHostname = new RegExp(
protocol + `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$"
); );
return validIP.test(this.server) || validHostname.test(this.server); return validIP.test(this.server) || validHostname.test(this.server);
} }

View File

@@ -398,9 +398,9 @@ export default {
firebase firebase
.auth() .auth()
.signInWithPopup(provider) .signInWithPopup(provider)
.then(res => { .then(({ additionalUserInfo }) => {
if (res.additionalUserInfo.isNewUser) { if (additionalUserInfo.isNewUser) {
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), { this.$toast.info(`${this.$t("turn_on")} ${this.$t("sync")}`, {
icon: "sync", icon: "sync",
duration: null, duration: null,
closeOnSwipe: false, closeOnSwipe: false,
@@ -427,9 +427,9 @@ export default {
firebase firebase
.auth() .auth()
.signInWithPopup(provider) .signInWithPopup(provider)
.then(res => { .then(({ additionalUserInfo }) => {
if (res.additionalUserInfo.isNewUser) { if (additionalUserInfo.isNewUser) {
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), { this.$toast.info(`${this.$t("turn_on")} ${this.$t("sync")}`, {
icon: "sync", icon: "sync",
duration: null, duration: null,
closeOnSwipe: false, closeOnSwipe: false,
@@ -458,14 +458,14 @@ export default {
fb.writeSettings("syncHistory", true); fb.writeSettings("syncHistory", true);
fb.writeSettings("syncCollections", false); fb.writeSettings("syncCollections", false);
}, },
resetProxy(e) { resetProxy({ target }) {
this.settings.PROXY_URL = `https://postwoman.apollotv.xyz/`; this.settings.PROXY_URL = `https://postwoman.apollotv.xyz/`;
e.target.innerHTML = this.doneButton; target.innerHTML = this.doneButton;
this.$toast.info(this.$t("cleared"), { this.$toast.info(this.$t("cleared"), {
icon: "clear_all" icon: "clear_all"
}); });
setTimeout( setTimeout(
() => (e.target.innerHTML = '<i class="material-icons">clear_all</i>'), () => (target.innerHTML = '<i class="material-icons">clear_all</i>'),
1000 1000
); );
} }