Initial prettier formatted files

This commit is contained in:
Dmitry Yankowski
2020-02-24 13:44:50 -05:00
parent 1543c990ca
commit 777e629b3d
83 changed files with 18556 additions and 19258 deletions

View File

@@ -4,7 +4,7 @@
<ul>
<li>
<div class="flex-wrap">
<h3 class="title">{{ $t("new_environment") }}</h3>
<h3 class="title">{{ $t('new_environment') }}</h3>
<div>
<button class="icon" @click="hideModal">
<i class="material-icons">close</i>
@@ -31,10 +31,10 @@
<span></span>
<span>
<button class="icon" @click="hideModal">
{{ $t("cancel") }}
{{ $t('cancel') }}
</button>
<button class="icon primary" @click="addNewEnvironment">
{{ $t("save") }}
{{ $t('save') }}
</button>
</span>
</div>
@@ -43,52 +43,50 @@
</template>
<script>
import { fb } from "../../functions/fb";
import { fb } from '../../functions/fb'
export default {
props: {
show: Boolean
show: Boolean,
},
components: {
modal: () => import("../../components/modal")
modal: () => import('../../components/modal'),
},
data() {
return {
name: undefined
};
name: undefined,
}
},
methods: {
syncEnvironments() {
if (fb.currentUser !== null) {
if (fb.currentSettings[1].value) {
fb.writeEnvironments(
JSON.parse(JSON.stringify(this.$store.state.postwoman.environments))
);
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
}
}
},
addNewEnvironment() {
if (!this.$data.name) {
this.$toast.info(this.$t("invalid_environment_name"));
return;
this.$toast.info(this.$t('invalid_environment_name'))
return
}
let newEnvironment = [
{
name: this.$data.name,
variables: []
}
];
this.$store.commit("postwoman/importAddEnvironments", {
variables: [],
},
]
this.$store.commit('postwoman/importAddEnvironments', {
environments: newEnvironment,
confirmation: "Environment added"
});
this.$emit("hide-modal");
this.syncEnvironments();
confirmation: 'Environment added',
})
this.$emit('hide-modal')
this.syncEnvironments()
},
hideModal() {
this.$data.name = undefined;
this.$emit("hide-modal");
}
}
};
this.$data.name = undefined
this.$emit('hide-modal')
},
},
}
</script>

View File

@@ -4,7 +4,7 @@
<ul>
<li>
<div class="flex-wrap">
<h3 class="title">{{ $t("edit_environment") }}</h3>
<h3 class="title">{{ $t('edit_environment') }}</h3>
<div>
<button class="icon" @click="hideModal">
<i class="material-icons">close</i>
@@ -28,13 +28,9 @@
<ul>
<li>
<div class="flex-wrap">
<label for="variableList">{{ $t("env_variable_list") }}</label>
<label for="variableList">{{ $t('env_variable_list') }}</label>
<div>
<button
class="icon"
@click="clearContent($event)"
v-tooltip.bottom="$t('clear')"
>
<button class="icon" @click="clearContent($event)" v-tooltip.bottom="$t('clear')">
<i class="material-icons">clear_all</i>
</button>
</div>
@@ -49,10 +45,7 @@
></textarea>
</li>
</ul>
<ul
v-for="(variable, index) in this.editingEnvCopy.variables"
:key="index"
>
<ul v-for="(variable, index) in this.editingEnvCopy.variables" :key="index">
<li>
<input
:placeholder="$t('parameter_count', { count: index + 1 })"
@@ -61,7 +54,7 @@
@change="
$store.commit('postwoman/setVariableKey', {
index,
value: $event.target.value
value: $event.target.value,
})
"
autofocus
@@ -72,14 +65,12 @@
:placeholder="$t('value_count', { count: index + 1 })"
:name="'value' + index"
:value="
typeof variable.value === 'string'
? variable.value
: JSON.stringify(variable.value)
typeof variable.value === 'string' ? variable.value : JSON.stringify(variable.value)
"
@change="
$store.commit('postwoman/setVariableValue', {
index,
value: $event.target.value
value: $event.target.value,
})
"
/>
@@ -101,7 +92,7 @@
<li>
<button class="icon" @click="addEnvironmentVariable">
<i class="material-icons">add</i>
<span>{{ $t("add_new") }}</span>
<span>{{ $t('add_new') }}</span>
</button>
</li>
</ul>
@@ -111,10 +102,10 @@
<span></span>
<span>
<button class="icon" @click="hideModal">
{{ $t("cancel") }}
{{ $t('cancel') }}
</button>
<button class="icon primary" @click="saveEnvironment">
{{ $t("save") }}
{{ $t('save') }}
</button>
</span>
</div>
@@ -123,99 +114,94 @@
</template>
<script>
import textareaAutoHeight from "../../directives/textareaAutoHeight";
import textareaAutoHeight from '../../directives/textareaAutoHeight'
export default {
directives: {
textareaAutoHeight
textareaAutoHeight,
},
props: {
show: Boolean,
editingEnvironment: Object,
editingEnvironmentIndex: Number
editingEnvironmentIndex: Number,
},
components: {
modal: () => import("../../components/modal")
modal: () => import('../../components/modal'),
},
data() {
return {
name: undefined
};
name: undefined,
}
},
watch: {
editingEnvironment: function(update) {
this.name = this.$props.editingEnvironment && this.$props.editingEnvironment.name
? this.$props.editingEnvironment.name
: undefined
this.$store.commit(
"postwoman/setEditingEnvironment",
this.$props.editingEnvironment
);
}
this.name =
this.$props.editingEnvironment && this.$props.editingEnvironment.name
? this.$props.editingEnvironment.name
: undefined
this.$store.commit('postwoman/setEditingEnvironment', this.$props.editingEnvironment)
},
},
computed: {
editingEnvCopy() {
return this.$store.state.postwoman.editingEnvironment;
return this.$store.state.postwoman.editingEnvironment
},
variableString() {
const result = this.editingEnvCopy.variables;
return result === "" ? "" : JSON.stringify(result);
}
const result = this.editingEnvCopy.variables
return result === '' ? '' : JSON.stringify(result)
},
},
methods: {
clearContent(e) {
this.$store.commit("postwoman/removeVariables", []);
e.target.innerHTML = this.doneButton;
this.$toast.info(this.$t("cleared"), {
icon: "clear_all"
});
setTimeout(
() => (e.target.innerHTML = '<i class="material-icons">clear_all</i>'),
1000
);
this.$store.commit('postwoman/removeVariables', [])
e.target.innerHTML = this.doneButton
this.$toast.info(this.$t('cleared'), {
icon: 'clear_all',
})
setTimeout(() => (e.target.innerHTML = '<i class="material-icons">clear_all</i>'), 1000)
},
addEnvironmentVariable() {
let value = { key: "", value: "" };
this.$store.commit("postwoman/addVariable", value);
let value = { key: '', value: '' }
this.$store.commit('postwoman/addVariable', value)
},
removeEnvironmentVariable(index) {
let variableIndex = index;
const oldVariables = this.editingEnvCopy.variables.slice();
let variableIndex = index
const oldVariables = this.editingEnvCopy.variables.slice()
const newVariables = this.editingEnvCopy.variables.filter(
(variable, index) => variableIndex !== index
);
)
this.$store.commit("postwoman/removeVariable", newVariables);
this.$toast.error(this.$t("deleted"), {
icon: "delete",
this.$store.commit('postwoman/removeVariable', newVariables)
this.$toast.error(this.$t('deleted'), {
icon: 'delete',
action: {
text: this.$t("undo"),
text: this.$t('undo'),
onClick: (e, toastObject) => {
this.$store.commit("postwoman/removeVariable", oldVariables);
toastObject.remove();
}
}
});
this.$store.commit('postwoman/removeVariable', oldVariables)
toastObject.remove()
},
},
})
},
saveEnvironment() {
if (!this.$data.name) {
this.$toast.info(this.$t("invalid_environment_name"));
return;
this.$toast.info(this.$t('invalid_environment_name'))
return
}
const environmentUpdated = {
...this.editingEnvCopy,
name: this.$data.name
};
this.$store.commit("postwoman/saveEnvironment", {
name: this.$data.name,
}
this.$store.commit('postwoman/saveEnvironment', {
environment: environmentUpdated,
environmentIndex: this.$props.editingEnvironmentIndex
});
this.$emit("hide-modal");
environmentIndex: this.$props.editingEnvironmentIndex,
})
this.$emit('hide-modal')
},
hideModal() {
this.$data.name = undefined;
this.$emit("hide-modal");
}
}
};
this.$data.name = undefined
this.$emit('hide-modal')
},
},
}
</script>

View File

@@ -1,11 +1,7 @@
<template>
<div class="flex-wrap">
<div>
<button
class="icon"
@click="$emit('select-environment')"
v-tooltip="$t('use_environment')"
>
<button class="icon" @click="$emit('select-environment')" v-tooltip="$t('use_environment')">
<i class="material-icons">insert_drive_file</i>
<span>{{ environment.name }}</span>
</button>
@@ -16,19 +12,15 @@
</button>
<template slot="popover">
<div>
<button
class="icon"
@click="$emit('edit-environment')"
v-close-popover
>
<button class="icon" @click="$emit('edit-environment')" v-close-popover>
<i class="material-icons">create</i>
<span>{{ $t("edit") }}</span>
<span>{{ $t('edit') }}</span>
</button>
</div>
<div>
<button class="icon" @click="removeEnvironment" v-close-popover>
<i class="material-icons">delete</i>
<span>{{ $t("delete") }}</span>
<span>{{ $t('delete') }}</span>
</button>
</div>
</template>
@@ -53,13 +45,13 @@ ul li {
export default {
props: {
environment: Object,
environmentIndex: Number
environmentIndex: Number,
},
methods: {
removeEnvironment() {
if (!confirm("Are you sure you want to remove this environment?")) return;
this.$store.commit("postwoman/removeEnvironment", this.environmentIndex);
}
}
};
if (!confirm('Are you sure you want to remove this environment?')) return
this.$store.commit('postwoman/removeEnvironment', this.environmentIndex)
},
},
}
</script>

View File

@@ -14,18 +14,12 @@
<div class="flex-wrap">
<span
v-tooltip="{
content: !fb.currentUser
? $t('login_first')
: $t('replace_current')
content: !fb.currentUser ? $t('login_first') : $t('replace_current'),
}"
>
<button
:disabled="!fb.currentUser"
class="icon"
@click="syncEnvironments"
>
<button :disabled="!fb.currentUser" class="icon" @click="syncEnvironments">
<i class="material-icons">folder_shared</i>
<span>{{ $t("import_from_sync") }}</span>
<span>{{ $t('import_from_sync') }}</span>
</button>
</span>
<button
@@ -34,7 +28,7 @@
v-tooltip="$t('replace_current')"
>
<i class="material-icons">create_new_folder</i>
<span>{{ $t("replace_json") }}</span>
<span>{{ $t('replace_json') }}</span>
<input
type="file"
@change="replaceWithJSON"
@@ -49,7 +43,7 @@
v-tooltip="$t('preserve_current')"
>
<i class="material-icons">folder_special</i>
<span>{{ $t("import_json") }}</span>
<span>{{ $t('import_json') }}</span>
<input
type="file"
@change="importFromJSON"
@@ -70,14 +64,10 @@
<span></span>
<span>
<button class="icon" @click="hideModal">
{{ $t("cancel") }}
{{ $t('cancel') }}
</button>
<button
class="icon primary"
@click="exportJSON"
v-tooltip="$t('download_file')"
>
{{ $t("export") }}
<button class="icon primary" @click="exportJSON" v-tooltip="$t('download_file')">
{{ $t('export') }}
</button>
</span>
</div>
@@ -86,88 +76,85 @@
</template>
<script>
import { fb } from "../../functions/fb";
import { fb } from '../../functions/fb'
export default {
data() {
return {
fb
};
fb,
}
},
props: {
show: Boolean
show: Boolean,
},
components: {
modal: () => import("../../components/modal")
modal: () => import('../../components/modal'),
},
computed: {
environmentJson() {
return JSON.stringify(this.$store.state.postwoman.environments, null, 2);
}
return JSON.stringify(this.$store.state.postwoman.environments, null, 2)
},
},
methods: {
hideModal() {
this.$emit("hide-modal");
this.$emit('hide-modal')
},
openDialogChooseFileToReplaceWith() {
this.$refs.inputChooseFileToReplaceWith.click();
this.$refs.inputChooseFileToReplaceWith.click()
},
openDialogChooseFileToImportFrom() {
this.$refs.inputChooseFileToImportFrom.click();
this.$refs.inputChooseFileToImportFrom.click()
},
replaceWithJSON() {
let reader = new FileReader();
let reader = new FileReader()
reader.onload = event => {
let content = event.target.result;
let environments = JSON.parse(content);
this.$store.commit("postwoman/replaceEnvironments", environments);
};
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0]);
this.fileImported();
let content = event.target.result
let environments = JSON.parse(content)
this.$store.commit('postwoman/replaceEnvironments', environments)
}
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
this.fileImported()
},
importFromJSON() {
let reader = new FileReader();
let reader = new FileReader()
reader.onload = event => {
let content = event.target.result;
let environments = JSON.parse(content);
let confirmation = this.$t("file_imported")
this.$store.commit("postwoman/importAddEnvironments", {
let content = event.target.result
let environments = JSON.parse(content)
let confirmation = this.$t('file_imported')
this.$store.commit('postwoman/importAddEnvironments', {
environments,
confirmation
});
};
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0]);
confirmation,
})
}
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0])
},
exportJSON() {
let text = this.environmentJson;
text = text.replace(/\n/g, "\r\n");
let text = this.environmentJson
text = text.replace(/\n/g, '\r\n')
let blob = new Blob([text], {
type: "text/json"
});
let anchor = document.createElement("a");
anchor.download = "postwoman-environment.json";
anchor.href = window.URL.createObjectURL(blob);
anchor.target = "_blank";
anchor.style.display = "none";
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
this.$toast.success(this.$t("download_started"), {
icon: "done"
});
type: 'text/json',
})
let anchor = document.createElement('a')
anchor.download = 'postwoman-environment.json'
anchor.href = window.URL.createObjectURL(blob)
anchor.target = '_blank'
anchor.style.display = 'none'
document.body.appendChild(anchor)
anchor.click()
document.body.removeChild(anchor)
this.$toast.success(this.$t('download_started'), {
icon: 'done',
})
},
syncEnvironments() {
this.$store.commit(
"postwoman/replaceEnvironments",
fb.currentEnvironments
);
this.fileImported();
this.$store.commit('postwoman/replaceEnvironments', fb.currentEnvironments)
this.fileImported()
},
fileImported() {
this.$toast.info(this.$t("file_imported"), {
icon: "folder_shared"
});
}
}
};
this.$toast.info(this.$t('file_imported'), {
icon: 'folder_shared',
})
},
},
}
</script>

View File

@@ -1,10 +1,5 @@
<template>
<pw-section
class="green"
icon="history"
:label="$t('environment')"
ref="environment"
>
<pw-section class="green" icon="history" :label="$t('environment')" ref="environment">
<addEnvironment :show="showModalAdd" @hide-modal="displayModalAdd(false)" />
<editEnvironment
:show="showModalEdit"
@@ -20,12 +15,12 @@
<div>
<button class="icon" @click="displayModalAdd(true)">
<i class="material-icons">add</i>
<span>{{ $t("new") }}</span>
<span>{{ $t('new') }}</span>
</button>
</div>
<div>
<button class="icon" @click="displayModalImportExport(true)">
{{ $t("import_export") }}
{{ $t('import_export') }}
</button>
</div>
</div>
@@ -39,10 +34,7 @@
:remain="Math.min(5, environments.length)"
>
<ul>
<li
v-for="(environment, index) in environments"
:key="environment.name"
>
<li v-for="(environment, index) in environments" :key="environment.name">
<environment
:environmentIndex="index"
:environment="environment"
@@ -70,20 +62,20 @@ ul {
</style>
<script>
import environment from "./environment";
import { fb } from "../../functions/fb";
import environment from './environment'
import { fb } from '../../functions/fb'
const updateOnLocalStorage = (propertyName, property) =>
window.localStorage.setItem(propertyName, JSON.stringify(property));
window.localStorage.setItem(propertyName, JSON.stringify(property))
export default {
components: {
environment,
"pw-section": () => import("../section"),
addEnvironment: () => import("./addEnvironment"),
editEnvironment: () => import("./editEnvironment"),
importExportEnvironment: () => import("./importExportEnvironment"),
VirtualList: () => import("vue-virtual-scroll-list")
'pw-section': () => import('../section'),
addEnvironment: () => import('./addEnvironment'),
editEnvironment: () => import('./editEnvironment'),
importExportEnvironment: () => import('./importExportEnvironment'),
VirtualList: () => import('vue-virtual-scroll-list'),
},
data() {
return {
@@ -91,57 +83,55 @@ export default {
showModalAdd: false,
showModalEdit: false,
editingEnvironment: undefined,
editingEnvironmentIndex: undefined
};
editingEnvironmentIndex: undefined,
}
},
computed: {
environments() {
return this.$store.state.postwoman.environments;
}
return this.$store.state.postwoman.environments
},
},
async mounted() {
this._keyListener = function(e) {
if (e.key === "Escape") {
e.preventDefault();
this.showModalImportExport = false;
if (e.key === 'Escape') {
e.preventDefault()
this.showModalImportExport = false
}
};
document.addEventListener("keydown", this._keyListener.bind(this));
}
document.addEventListener('keydown', this._keyListener.bind(this))
},
methods: {
displayModalAdd(shouldDisplay) {
this.showModalAdd = shouldDisplay;
this.showModalAdd = shouldDisplay
},
displayModalEdit(shouldDisplay) {
this.showModalEdit = shouldDisplay;
this.showModalEdit = shouldDisplay
if (!shouldDisplay) this.resetSelectedData();
if (!shouldDisplay) this.resetSelectedData()
},
displayModalImportExport(shouldDisplay) {
this.showModalImportExport = shouldDisplay;
this.showModalImportExport = shouldDisplay
},
editEnvironment(environment, environmentIndex) {
this.$data.editingEnvironment = environment;
this.$data.editingEnvironmentIndex = environmentIndex;
this.displayModalEdit(true);
this.syncEnvironments;
this.$data.editingEnvironment = environment
this.$data.editingEnvironmentIndex = environmentIndex
this.displayModalEdit(true)
this.syncEnvironments
},
resetSelectedData() {
this.$data.editingEnvironment = undefined;
this.$data.editingEnvironmentIndex = undefined;
this.$data.editingEnvironment = undefined
this.$data.editingEnvironmentIndex = undefined
},
syncEnvironments() {
if (fb.currentUser !== null) {
if (fb.currentSettings[1].value) {
fb.writeEnvironments(
JSON.parse(JSON.stringify(this.$store.state.postwoman.environments))
);
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
}
}
}
},
},
beforeDestroy() {
document.removeEventListener("keydown", this._keyListener);
}
};
document.removeEventListener('keydown', this._keyListener)
},
}
</script>