Added variable editor and removed the old variable system
This commit is contained in:
@@ -187,67 +187,21 @@
|
|||||||
useWorker: false
|
useWorker: false
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<div class="flex-wrap">
|
</pw-section>
|
||||||
<label>{{ $t("query_variables") }}</label>
|
|
||||||
<div>
|
<pw-section class="yellow" label="Variables" ref="variables">
|
||||||
<button
|
<Editor
|
||||||
class="icon"
|
v-model="variableString"
|
||||||
@click="variables = []"
|
:lang="'json'"
|
||||||
v-tooltip.bottom="$t('clear')"
|
:options="{
|
||||||
>
|
maxLines: responseBodyMaxLines,
|
||||||
<i class="material-icons">clear_all</i>
|
minLines: '16',
|
||||||
</button>
|
fontSize: '16px',
|
||||||
</div>
|
autoScrollEditorIntoView: true,
|
||||||
</div>
|
showPrintMargin: false,
|
||||||
<ul v-for="(variable, index) in variables" :key="index">
|
useWorker: false
|
||||||
<li>
|
}"
|
||||||
<input
|
/>
|
||||||
:placeholder="$t('variable_count', { count: index + 1 })"
|
|
||||||
:name="'variable_key_' + index"
|
|
||||||
:value="variable.key"
|
|
||||||
@change="
|
|
||||||
$store.commit('setGQLVariableKey', {
|
|
||||||
index,
|
|
||||||
value: $event.target.value
|
|
||||||
})
|
|
||||||
"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<input
|
|
||||||
:placeholder="$t('value_count', { count: index + 1 })"
|
|
||||||
:name="'variable_value_' + index"
|
|
||||||
:value="variable.value"
|
|
||||||
@change="
|
|
||||||
$store.commit('setGQLVariableValue', {
|
|
||||||
index,
|
|
||||||
value: $event.target.value
|
|
||||||
})
|
|
||||||
"
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<div>
|
|
||||||
<li>
|
|
||||||
<button
|
|
||||||
class="icon"
|
|
||||||
@click="removeQueryVariable(index)"
|
|
||||||
v-tooltip.bottom="$t('delete')"
|
|
||||||
>
|
|
||||||
<i class="material-icons">delete</i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</div>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<button class="icon" @click="addQueryVariable">
|
|
||||||
<i class="material-icons">add</i>
|
|
||||||
<span>{{ $t("add_new") }}</span>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</pw-section>
|
</pw-section>
|
||||||
|
|
||||||
<pw-section class="purple" label="Response" ref="response">
|
<pw-section class="purple" label="Response" ref="response">
|
||||||
@@ -410,6 +364,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
schemaString: "",
|
schemaString: "",
|
||||||
|
variableString: "{}",
|
||||||
commonHeaders: [
|
commonHeaders: [
|
||||||
"WWW-Authenticate",
|
"WWW-Authenticate",
|
||||||
"Authorization",
|
"Authorization",
|
||||||
@@ -667,18 +622,9 @@ export default {
|
|||||||
headers[header.key] = header.value;
|
headers[header.key] = header.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
let variables = {};
|
let variables = JSON.parse(this.variableString);
|
||||||
|
|
||||||
const gqlQueryString = this.gqlQueryString;
|
const gqlQueryString = this.gqlQueryString;
|
||||||
this.variables.forEach(variable => {
|
|
||||||
// todo: better variable type validation
|
|
||||||
if (gqlQueryString.indexOf(`\$${variable.key}: Int`) > -1) {
|
|
||||||
variables[variable.key] = parseInt(variable.value);
|
|
||||||
} else if (gqlQueryString.indexOf(`\$${variable.key}: Float`) > -1) {
|
|
||||||
variables[variable.key] = parseFloat(variable.value);
|
|
||||||
} else {
|
|
||||||
variables[variable.key] = variable.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const reqOptions = {
|
const reqOptions = {
|
||||||
method: "post",
|
method: "post",
|
||||||
|
|||||||
Reference in New Issue
Block a user