Added variable editor and removed the old variable system
This commit is contained in:
@@ -187,67 +187,21 @@
|
||||
useWorker: false
|
||||
}"
|
||||
/>
|
||||
<div class="flex-wrap">
|
||||
<label>{{ $t("query_variables") }}</label>
|
||||
<div>
|
||||
<button
|
||||
class="icon"
|
||||
@click="variables = []"
|
||||
v-tooltip.bottom="$t('clear')"
|
||||
>
|
||||
<i class="material-icons">clear_all</i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul v-for="(variable, index) in variables" :key="index">
|
||||
<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 class="yellow" label="Variables" ref="variables">
|
||||
<Editor
|
||||
v-model="variableString"
|
||||
:lang="'json'"
|
||||
:options="{
|
||||
maxLines: responseBodyMaxLines,
|
||||
minLines: '16',
|
||||
fontSize: '16px',
|
||||
autoScrollEditorIntoView: true,
|
||||
showPrintMargin: false,
|
||||
useWorker: false
|
||||
}"
|
||||
/>
|
||||
</pw-section>
|
||||
|
||||
<pw-section class="purple" label="Response" ref="response">
|
||||
@@ -410,6 +364,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
schemaString: "",
|
||||
variableString: "{}",
|
||||
commonHeaders: [
|
||||
"WWW-Authenticate",
|
||||
"Authorization",
|
||||
@@ -666,19 +621,10 @@ export default {
|
||||
this.headers.forEach(header => {
|
||||
headers[header.key] = header.value;
|
||||
});
|
||||
|
||||
let variables = JSON.parse(this.variableString);
|
||||
|
||||
let variables = {};
|
||||
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 = {
|
||||
method: "post",
|
||||
|
||||
Reference in New Issue
Block a user