Firebase sync
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fb } from "../../functions/fb";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean
|
||||
@@ -56,6 +58,15 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
syncEnvironments() {
|
||||
if (fb.currentUser !== null) {
|
||||
if (fb.currentSettings[1].value) {
|
||||
fb.writeEnvironments(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.environments))
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
addNewEnvironment() {
|
||||
if (!this.$data.name) {
|
||||
this.$toast.info($t("invalid_environment_name"));
|
||||
@@ -69,6 +80,7 @@ export default {
|
||||
];
|
||||
this.$store.commit("postwoman/importAddEnvironments", newEnvironment);
|
||||
this.$emit("hide-modal");
|
||||
this.syncEnvironments();
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal");
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-wrap">
|
||||
<!-- TODO db syncing
|
||||
button needs to be switchded to
|
||||
:disabled=="!fb.currentUser"
|
||||
-->
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: !fb.currentUser
|
||||
@@ -23,7 +19,11 @@
|
||||
: $t('replace_current')
|
||||
}"
|
||||
>
|
||||
<button :disabled="true" 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>
|
||||
</button>
|
||||
@@ -154,7 +154,11 @@ export default {
|
||||
});
|
||||
},
|
||||
syncEnvironments() {
|
||||
// TODO
|
||||
this.$store.commit(
|
||||
"postwoman/replaceEnvironments",
|
||||
fb.currentEnvironments
|
||||
);
|
||||
this.fileImported();
|
||||
},
|
||||
fileImported() {
|
||||
this.$toast.info(this.$t("file_imported"), {
|
||||
|
||||
@@ -71,7 +71,7 @@ ul {
|
||||
|
||||
<script>
|
||||
import environment from "./environment";
|
||||
// import { fb } from "../functions/fb";
|
||||
import { fb } from "../../functions/fb";
|
||||
|
||||
const updateOnLocalStorage = (propertyName, property) =>
|
||||
window.localStorage.setItem(propertyName, JSON.stringify(property));
|
||||
@@ -124,17 +124,24 @@ export default {
|
||||
this.$data.editingEnvironment = environment;
|
||||
this.$data.editingEnvironmentIndex = environmentIndex;
|
||||
this.displayModalEdit(true);
|
||||
this.syncEnvironments;
|
||||
},
|
||||
resetSelectedData() {
|
||||
this.$data.editingEnvironment = undefined;
|
||||
this.$data.editingEnvironmentIndex = undefined;
|
||||
},
|
||||
syncEnvironments() {
|
||||
// TODO
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
if (fb.currentUser !== null) {
|
||||
if (fb.currentSettings[1].value) {
|
||||
fb.writeEnvironments(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.environments))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user