Merge pull request #654 from liyasthomas/master

even
This commit is contained in:
Liyas Thomas
2020-03-07 08:38:56 +05:30
committed by GitHub
8 changed files with 81 additions and 36 deletions

View File

@@ -147,6 +147,15 @@ export default {
}, },
}) })
editor.commands.addCommand({
name: "prettifyGQLQuery",
exec: () => this.prettifyQuery(),
bindKey: {
mac: "cmd-p",
win: "ctrl-p",
},
})
editor.on("change", () => { editor.on("change", () => {
const content = editor.getValue() const content = editor.getValue()
this.$emit("input", content) this.$emit("input", content)
@@ -158,6 +167,16 @@ export default {
}, },
methods: { methods: {
prettifyQuery() {
try {
this.value = gql.print(gql.parse(this.editor.getValue()))
} catch (e) {
this.$toast.error(`${this.$t("gql_prettify_invalid_query")}`, {
icon: "error",
})
}
},
defineTheme() { defineTheme() {
if (this.theme) { if (this.theme) {
return this.theme return this.theme

View File

@@ -74,7 +74,7 @@
</template> </template>
<script> <script>
import { wsValid } from "~/functions/utils/valid" import { socketioValid } from "~/functions/utils/valid"
import io from "socket.io-client" import io from "socket.io-client"
import realtimeLog from "./log" import realtimeLog from "./log"
@@ -97,7 +97,7 @@ export default {
}, },
computed: { computed: {
urlValid() { urlValid() {
return wsValid(this.url) return socketioValid(this.url)
}, },
}, },
methods: { methods: {

View File

@@ -8,8 +8,8 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<slot name="body"></slot> <slot name="body"></slot>
<div class="fade top"></div> <!-- <div class="fade top"></div>
<div class="fade bottom"></div> <div class="fade bottom"></div> -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<slot name="footer"></slot> <slot name="footer"></slot>

View File

@@ -1,14 +1,21 @@
function generateIPRE(protocol) {
return new RegExp(
`${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])$`
)
}
function generateHostnameRE(protocol) {
return new RegExp(
`${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/])$`
)
}
/** /**
* valid url for ws/wss * valid url for ws/wss
*/ */
export function wsValid(url) { export function wsValid(url) {
const protocol = "^(wss?:\\/\\/)?" const protocol = "^(wss?:\\/\\/)?"
const validIP = new RegExp( const validIP = generateIPRE(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])$` const validHostname = generateHostnameRE(protocol)
)
const validHostname = new RegExp(
`${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/])$`
)
return validIP.test(url) || validHostname.test(url) return validIP.test(url) || validHostname.test(url)
} }
@@ -17,11 +24,17 @@ export function wsValid(url) {
*/ */
export function sseValid(url) { export function sseValid(url) {
const protocol = "^(https?:\\/\\/)?" const protocol = "^(https?:\\/\\/)?"
const validIP = new RegExp( const validIP = generateIPRE(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])$` const validHostname = generateHostnameRE(protocol)
) return validIP.test(url) || validHostname.test(url)
const validHostname = new RegExp( }
`${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/])$`
) /**
* valid url for ws/wss/http/https
*/
export function socketioValid(url) {
const protocol = "^((wss?:\\/\\/)|(https?:\\/\\/))?"
const validIP = generateIPRE(protocol)
const validHostname = generateHostnameRE(protocol)
return validIP.test(url) || validHostname.test(url) return validIP.test(url) || validHostname.test(url)
} }

View File

@@ -182,6 +182,9 @@ export default {
waiting_send_req: "(waiting to send request)", waiting_send_req: "(waiting to send request)",
waiting_receive_response: "(waiting to receive response)", waiting_receive_response: "(waiting to receive response)",
waiting_receive_schema: "(waiting to receive schema)", waiting_receive_schema: "(waiting to receive schema)",
gql_prettify_invalid_query:
"Couldn't prettify an invalid query, solve query syntax errors and try again",
prettify_query: "Prettify Query",
cancel: "Cancel", cancel: "Cancel",
save: "Save", save: "Save",
dismiss: "Dismiss", dismiss: "Dismiss",

36
package-lock.json generated
View File

@@ -906,9 +906,9 @@
} }
}, },
"@firebase/analytics": { "@firebase/analytics": {
"version": "0.2.15", "version": "0.2.16",
"resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.2.15.tgz", "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.2.16.tgz",
"integrity": "sha512-pNRyLU6PndZa0iO+HN+GwY1HobsyU584a1KN5ZWBuwaqbUOB/99uChn2n6XaPrlD/G07uzv6dpw558IQXahhow==", "integrity": "sha512-t4lwd8SxigKULvt8a+VA1cVj7Aml/tUNECV9vzz3G9wusxDE76d7rTw+HexKTNPRbD2E9+JtRKUVPKlJpox9bw==",
"requires": { "requires": {
"@firebase/analytics-types": "0.2.7", "@firebase/analytics-types": "0.2.7",
"@firebase/component": "0.1.6", "@firebase/component": "0.1.6",
@@ -991,12 +991,12 @@
} }
}, },
"@firebase/firestore": { "@firebase/firestore": {
"version": "1.11.2", "version": "1.12.0",
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.11.2.tgz", "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.12.0.tgz",
"integrity": "sha512-WWTKQGUYvZ7BELzEeIhINVm+iKL2ki/f0y16Qc3kABCW4kdXtiUHak6uWMFQ3IXHtnpDGzcNTyDAKOWeZx+TzA==", "integrity": "sha512-GWFU3pPs0xyp2ynFQIyvlmTtg4goGvOkT/lhVCu/Bq6/78xbl395nCPBMjF7IpUl+aVqQVUCwtF/cxrtNXgjMA==",
"requires": { "requires": {
"@firebase/component": "0.1.6", "@firebase/component": "0.1.6",
"@firebase/firestore-types": "1.9.2", "@firebase/firestore-types": "1.10.0",
"@firebase/logger": "0.1.36", "@firebase/logger": "0.1.36",
"@firebase/util": "0.2.41", "@firebase/util": "0.2.41",
"@firebase/webchannel-wrapper": "0.2.36", "@firebase/webchannel-wrapper": "0.2.36",
@@ -1006,9 +1006,9 @@
} }
}, },
"@firebase/firestore-types": { "@firebase/firestore-types": {
"version": "1.9.2", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-1.9.2.tgz", "resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-1.10.0.tgz",
"integrity": "sha512-D264aOrssdbD3PE0JuJdbwBI9zXDTd5HASjJYtYc3AIGC526R+w+TDWes4GsE/zi0dSWqMfgiceVKL0PekjqZw==" "integrity": "sha512-/Pvmu5hpc0pceB96X2mEOAdEB0Xyn6+IQliBl7dUhu23AztnjBq+9uKcsgMB+k34RCApFQfNm1m24E4e+fUSVg=="
}, },
"@firebase/functions": { "@firebase/functions": {
"version": "0.4.36", "version": "0.4.36",
@@ -5270,16 +5270,16 @@
} }
}, },
"firebase": { "firebase": {
"version": "7.9.3", "version": "7.10.0",
"resolved": "https://registry.npmjs.org/firebase/-/firebase-7.9.3.tgz", "resolved": "https://registry.npmjs.org/firebase/-/firebase-7.10.0.tgz",
"integrity": "sha512-9tIxZvA8/Tf5p7nPMEE9zFklbmwqny4qHxGzwG3Hus4TInkxyYeiGY2L1mNTV+WuTJzQYuo9NtCRZLBnsChpqQ==", "integrity": "sha512-j80k8wsgg0N/t8uOkpGK6OT1MHHZ3Y/98nyZJJ+6lNodA6O79mXgyvI4AwXlPYd8qfmYeXwHz1f19sC+EqnZZg==",
"requires": { "requires": {
"@firebase/analytics": "0.2.15", "@firebase/analytics": "0.2.16",
"@firebase/app": "0.5.5", "@firebase/app": "0.5.5",
"@firebase/app-types": "0.5.2", "@firebase/app-types": "0.5.2",
"@firebase/auth": "0.13.6", "@firebase/auth": "0.13.6",
"@firebase/database": "0.5.22", "@firebase/database": "0.5.22",
"@firebase/firestore": "1.11.2", "@firebase/firestore": "1.12.0",
"@firebase/functions": "0.4.36", "@firebase/functions": "0.4.36",
"@firebase/installations": "0.4.4", "@firebase/installations": "0.4.4",
"@firebase/messaging": "0.6.8", "@firebase/messaging": "0.6.8",
@@ -14158,9 +14158,9 @@
} }
}, },
"yargs-parser": { "yargs-parser": {
"version": "17.0.0", "version": "18.0.0",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-17.0.0.tgz", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.0.0.tgz",
"integrity": "sha512-Fl4RBJThsWeJl3cRZeGuolcuH78/foVUAYIUpKn8rkCnjn23ilZvJyEZJjnlzoG/+EJKPb1RggD4xS/Jie2nxg==", "integrity": "sha512-dEcTjO1rkFcERdsoh++v+o7PQ6+POeIS4lOHr5Xy3WuYWhU4+inNSpJSvnsAEd3TOgzytS4DrueTuswP3VAmWQ==",
"requires": { "requires": {
"camelcase": "^5.0.0", "camelcase": "^5.0.0",
"decamelize": "^1.2.0" "decamelize": "^1.2.0"

View File

@@ -38,7 +38,7 @@
"@nuxtjs/sitemap": "^2.0.1", "@nuxtjs/sitemap": "^2.0.1",
"@nuxtjs/toast": "^3.3.0", "@nuxtjs/toast": "^3.3.0",
"ace-builds": "^1.4.8", "ace-builds": "^1.4.8",
"firebase": "^7.9.3", "firebase": "^7.10.0",
"graphql": "^14.6.0", "graphql": "^14.6.0",
"graphql-language-service-interface": "^2.3.3", "graphql-language-service-interface": "^2.3.3",
"nuxt": "^2.11.0", "nuxt": "^2.11.0",
@@ -49,7 +49,7 @@
"vuefire": "^2.2.1", "vuefire": "^2.2.1",
"vuejs-auto-complete": "^0.9.0", "vuejs-auto-complete": "^0.9.0",
"vuex-persist": "^2.2.0", "vuex-persist": "^2.2.0",
"yargs-parser": "^17.0.0" "yargs-parser": "^18.0.0"
}, },
"devDependencies": { "devDependencies": {
"cypress": "^4.1.0", "cypress": "^4.1.0",

View File

@@ -178,6 +178,13 @@
> >
<i class="material-icons">file_copy</i> <i class="material-icons">file_copy</i>
</button> </button>
<button
class="icon"
@click="doPrettifyQuery"
v-tooltip="`${$t('prettify_query')} (${getSpecialKey()}-P)`"
>
<i class="material-icons">photo_filter</i>
</button>
</div> </div>
</div> </div>
<QueryEditor <QueryEditor
@@ -452,6 +459,9 @@ export default {
}, },
methods: { methods: {
getSpecialKey: getPlatformSpecialKey, getSpecialKey: getPlatformSpecialKey,
doPrettifyQuery() {
this.$refs.queryEditor.prettifyQuery()
},
handleJumpToType(type) { handleJumpToType(type) {
const typesTab = document.getElementById("gqltypes-tab") const typesTab = document.getElementById("gqltypes-tab")
typesTab.checked = true typesTab.checked = true