Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-order sections and add toggle for including authentication in URL #215

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</nav>
</div>
</header>
<br>
<nuxt id="main" />
<footer>
<!-- Top section of footer: GitHub/install links -->
Expand Down
165 changes: 98 additions & 67 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</ul>
</div>
</pw-modal>

<pw-section class="blue" icon="cloud_upload" label="Request" ref="request">
<ul>
<li>
Expand Down Expand Up @@ -206,9 +207,9 @@
id="copyRequest"
ref="copyRequest"
:disabled="!isValidURL"
v-tooltip.bottom="'Sharable request URL'"
v-tooltip.bottom="'Copy Request URL'"
>
<i class="material-icons">share</i>
<i class="material-icons">file_copy</i>
</button>
<button
class="icon"
Expand All @@ -220,7 +221,7 @@
>
<i class="material-icons">save</i>
</button>
<button class="icon" @click="clearContent" v-tooltip.bottom="'Clear all'">
<button class="icon" @click="clearContent" v-tooltip.bottom="'Clear All'">
<i class="material-icons">clear_all</i>
</button>
</div>
Expand Down Expand Up @@ -263,62 +264,7 @@
</li>
</ul>
</pw-section>
<pw-section class="purple" icon="cloud_download" id="response" label="Response" ref="response">
<ul>
<li>
<label for="status">status</label>
<input
:class="statusCategory ? statusCategory.className : ''"
:value="response.status || '(waiting to send request)'"
ref="status"
id="status"
name="status"
readonly
type="text"
/>
</li>
</ul>
<ul v-for="(value, key) in response.headers" :key="key">
<li>
<label :for="key">{{key}}</label>
<input :id="key" :value="value" :name="key" readonly />
</li>
</ul>
<ul v-if="response.body">
<li>
<div class="flex-wrap">
<label for="body">response</label>
<div>
<button class="icon" @click="copyResponse" ref="copyResponse" v-if="response.body">
<i class="material-icons">file_copy</i>
<span>Copy</span>
</button>
</div>
</div>
<div id="response-details-wrapper">
<pre><code
ref="responseBody"
id="body"
rows="16"
placeholder="(waiting to send request)"
>{{response.body}}</code></pre>
<iframe
:class="{hidden: !previewEnabled}"
class="covers-response"
ref="previewFrame"
src="about:blank"
></iframe>
</div>
<div class="align-right" v-if="response.body && responseType === 'text/html'">
<button class="icon" @click.prevent="togglePreview">
<i class="material-icons" v-if="!previewEnabled">visibility</i>
<i class="material-icons" v-if="previewEnabled">visibility_off</i>
<span>{{ previewEnabled ? 'Hide Preview' : 'Preview HTML' }}</span>
</button>
</div>
</li>
</ul>
</pw-section>

<section>
<input id="tab-one" type="radio" name="grp" checked="checked" />
<label for="tab-one">Authentication</label>
Expand Down Expand Up @@ -373,6 +319,9 @@
<input placeholder="Token" name="bearer_token" v-model="bearerToken" />
</li>
</ul>
<p class="align-right"><pw-toggle
:on="!urlExcludes.auth"
@change="setExclude('auth', !$event)">Include Authentication in URL</pw-toggle></p>
</pw-section>
</div>
<input id="tab-two" type="radio" name="grp" />
Expand Down Expand Up @@ -492,10 +441,75 @@
</pw-section>
</div>
</section>
<history @useHistory="handleUseHistory" ref="historyComponent"></history>

<br>

<pw-section class="purple" icon="cloud_download" id="response" label="Response" ref="response">
<ul>
<li>
<label for="status">status</label>
<input
:class="statusCategory ? statusCategory.className : ''"
:value="response.status || '(waiting to send request)'"
ref="status"
id="status"
name="status"
readonly
type="text"
/>
</li>
</ul>
<ul v-for="(value, key) in response.headers" :key="key">
<li>
<label :for="key">{{key}}</label>
<input :id="key" :value="value" :name="key" readonly />
</li>
</ul>
<ul v-if="response.body">
<li>
<div class="flex-wrap">
<label for="body">response</label>
<div>
<button class="icon" @click="copyResponse" ref="copyResponse" v-if="response.body">
<i class="material-icons">file_copy</i>
<span>Copy</span>
</button>
</div>
</div>
<div id="response-details-wrapper">
<pre><code
ref="responseBody"
id="body"
rows="16"
placeholder="(waiting to send request)"
>{{response.body}}</code></pre>
<iframe
:class="{hidden: !previewEnabled}"
class="covers-response"
ref="previewFrame"
src="about:blank"
></iframe>
</div>
<div class="align-right" v-if="response.body && responseType === 'text/html'">
<button class="icon" @click.prevent="togglePreview">
<i class="material-icons" v-if="!previewEnabled">visibility</i>
<i class="material-icons" v-if="previewEnabled">visibility_off</i>
<span>{{ previewEnabled ? 'Hide Preview' : 'Preview HTML' }}</span>
</button>
</div>
</li>
</ul>
</pw-section>

<br>

<pw-section class="yellow" icon="folder_special" label="Collections" ref="Collections">
<collections></collections>
<collections />
</pw-section>

<br>

<history @useHistory="handleUseHistory" ref="historyComponent"></history>
</div>
</template>
<script>
Expand Down Expand Up @@ -577,7 +591,7 @@ export default {
collections,
saveRequestAs
},
data() {
data () {
return {
label: "",
showModal: false,
Expand Down Expand Up @@ -628,10 +642,18 @@ export default {
"text/plain"
],
showRequestModal: false,
editRequest: {}
editRequest: {},

urlExcludes: {}
};
},
watch: {
urlExcludes: {
deep: true,
handler () {
this.$store.commit("postwoman/applySetting", ['URL_EXCLUDES', Object.assign({}, this.urlExcludes)]);
}
},
contentType(val) {
this.rawInput = !this.knownContentTypes.includes(val);
},
Expand Down Expand Up @@ -1218,13 +1240,13 @@ export default {
document.execCommand("copy");
document.body.removeChild(dummy);
this.$refs.copyRequest.innerHTML = this.copiedButton;
this.$toast.success("Copied to clipboard", {
this.$toast.info("Copied to clipboard", {
icon: "done"
});
setTimeout(
() =>
(this.$refs.copyRequest.innerHTML =
'<i class="material-icons">share</i>'),
'<i class="material-icons">file_copy</i>'),
1000
);
}
Expand Down Expand Up @@ -1311,12 +1333,12 @@ export default {
"method",
"url",
"path",
"auth",
!this.urlExcludes.auth ? "auth" : null,
"httpUser",
"httpPassword",
"bearerToken",
"contentType"
].map(item => flat(item));
].filter((item) => item !== null).map(item => flat(item));
let deeps = ["headers", "params"].map(item => deep(item));
let bodyParams = this.rawInput
? [flat("rawParams")]
Expand Down Expand Up @@ -1463,12 +1485,21 @@ export default {
hideRequestModal() {
this.showRequestModal = false;
this.editRequest = {};
},
setExclude (excludedField, excluded) {
this.urlExcludes[excludedField] = excluded;
this.setRouteQueryState();
}
},
mounted() {
this.observeRequestButton();
},
created() {
this.urlExcludes = this.$store.state.postwoman.settings.URL_EXCLUDES || {
// Exclude authentication by default for security reasons.
auth: true
};

if (Object.keys(this.$route.query).length)
this.setRouteQueries(this.$route.query);
this.$watch(
Expand Down
8 changes: 7 additions & 1 deletion store/postwoman.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ export const SETTINGS_KEYS = [
/**
* The security key of the proxy.
*/
"PROXY_KEY"
"PROXY_KEY",

/**
* An array of properties to exclude from the URL.
* e.g. 'auth'
*/
"URL_EXCLUDES"
];

export const state = () => ({
Expand Down