resolve merge conflicts
This commit is contained in:
12
README.md
12
README.md
@@ -69,8 +69,8 @@ _Customized themes are synced with local session storage_
|
||||
- Instant loading with [Service Workers](https://developers.google.com/web/fundamentals/primers/service-workers)
|
||||
- Offline support
|
||||
- Low RAM/memory and CPU usage
|
||||
- [Add to Home Screen](https://developers.google.com/web/fundamentals/app-install-banners) (button in footer)
|
||||
- [Desktop PWA](https://developers.google.com/web/progressive-web-apps/desktop) support (button in footer)
|
||||
- Add to Home Screen
|
||||
- Desktop PWA
|
||||
- ([full features](https://developers.google.com/web/progressive-web-apps))
|
||||
|
||||
🚀 **Request**: Retrieve response from endpoint instantly.
|
||||
@@ -220,11 +220,13 @@ _**All `i18n` contributions are welcome to `i18n` [branch](https://github.com/li
|
||||
|
||||
- **[Proxy β](https://github.com/postwoman-io/postwoman-proxy)** - A simple proxy server created for Postwoman
|
||||
- **[CLI β](https://github.com/postwoman-io/postwoman-cli)** - A CLI solution for Postwoman
|
||||
- **[Browser Extensions](https://github.com/AndrewBastin/postwoman-firefox)** - Browser extensions that simplifies access to Postwoman
|
||||
- **Browser Extensions** - Browser extensions that simplifies access to Postwoman
|
||||
|
||||
> [ **Firefox**](https://addons.mozilla.org/en-US/firefox/addon/postwoman) |  **Chrome (coming soon)**
|
||||
[ **Firefox**](https://addons.mozilla.org/en-US/firefox/addon/postwoman) ([GitHub](https://github.com/AndrewBastin/postwoman-firefox)) | [ **Chrome**](https://chrome.google.com/webstore/detail/postwoman-extension-for-c/amknoiejhlmhancpahfcfcfhllgkpbld) ([GitHub](https://github.com/AndrewBastin/postwoman-chrome))
|
||||
|
||||
_Add-ons are developed and maintained under **[Official Postwoman Organization](https://github.com/postwoman-io)**_
|
||||
>**Extensions fixes `CORS` issues.**
|
||||
|
||||
_Add-ons are developed and maintained under **[Official Postwoman Organization](https://github.com/postwoman-io)**._
|
||||
|
||||
**To find out more, please check out [Postwoman Wiki](https://github.com/liyasthomas/postwoman/wiki).**
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
-webkit-font-feature-settings: "liga";
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-feature-settings: "liga";
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
/* poppins-500 - latin */
|
||||
|
||||
@@ -698,6 +698,7 @@ ol li {
|
||||
|
||||
.show-on-large-screen {
|
||||
display: inline-flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.info-response {
|
||||
@@ -852,10 +853,7 @@ input[type="radio"]:checked + label + .tab {
|
||||
}
|
||||
|
||||
@media (max-width: $responsiveWidth) {
|
||||
.content {
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
.content,
|
||||
.columns {
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
addNewCollection() {
|
||||
if (!this.$data.name) {
|
||||
this.$toast.info('Please provide a valid name for the collection')
|
||||
return;
|
||||
}
|
||||
this.$store.commit("postwoman/addNewCollection", {
|
||||
name: this.$data.name
|
||||
});
|
||||
|
||||
@@ -59,6 +59,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
saveCollection() {
|
||||
if (!this.$data.name) {
|
||||
this.$toast.info('Please provide a valid name for the collection');
|
||||
return;
|
||||
}
|
||||
const collectionUpdated = {
|
||||
...this.$props.editingCollection,
|
||||
name: this.$data.name
|
||||
|
||||
85
components/firebase/feeds.vue
Normal file
85
components/firebase/feeds.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<virtual-list
|
||||
v-if="fb.currentFeeds.length !== 0"
|
||||
class="virtual-list"
|
||||
:class="{ filled: fb.currentFeeds.length }"
|
||||
:size="56"
|
||||
:remain="Math.min(8, fb.currentFeeds.length)"
|
||||
>
|
||||
<ul v-for="feed in fb.currentFeeds" :key="feed.id">
|
||||
<div class="show-on-large-screen">
|
||||
<li>
|
||||
<input
|
||||
:aria-label="$t('label')"
|
||||
type="text"
|
||||
readonly
|
||||
:value="feed.label"
|
||||
:placeholder="$t('no_label')"
|
||||
class="bg-color"
|
||||
/>
|
||||
</li>
|
||||
<button class="icon" @click="saveFeed(feed)">
|
||||
<i class="material-icons">get_app</i>
|
||||
</button>
|
||||
<button class="icon" @click="deleteFeed(feed)">
|
||||
<i class="material-icons">delete</i>
|
||||
</button>
|
||||
</div>
|
||||
</ul>
|
||||
</virtual-list>
|
||||
<ul v-else>
|
||||
<li>
|
||||
<label class="info">{{ $t("empty") }}</label>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.virtual-list {
|
||||
max-height: calc(100vh - 288px);
|
||||
}
|
||||
|
||||
.bg-color {
|
||||
background-color: transparent;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { fb } from "../../functions/fb";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
VirtualList: () => import("vue-virtual-scroll-list")
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fb
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
deleteFeed(feed) {
|
||||
fb.deleteFeed(feed.id);
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete"
|
||||
});
|
||||
},
|
||||
saveFeed(feed) {
|
||||
const dataToWrite = JSON.stringify(feed.message, null, 2);
|
||||
const file = new Blob([dataToWrite], { type: "application/json" });
|
||||
const a = document.createElement("a"),
|
||||
url = URL.createObjectURL(file);
|
||||
a.href = url;
|
||||
a.download = (feed.label + " on " + Date()).replace(/\./g, "[dot]");
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
this.$toast.success(this.$t("download_started"), {
|
||||
icon: "done"
|
||||
});
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
55
components/firebase/inputform.vue
Normal file
55
components/firebase/inputform.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div>
|
||||
<ul>
|
||||
<li>
|
||||
<input
|
||||
:aria-label="$t('label')"
|
||||
type="text"
|
||||
autofocus
|
||||
v-model="message"
|
||||
:placeholder="$t('paste_a_collection')"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>
|
||||
<input
|
||||
:aria-label="$t('label')"
|
||||
type="text"
|
||||
autofocus
|
||||
v-model="label"
|
||||
:placeholder="$t('label')"
|
||||
/>
|
||||
</li>
|
||||
<button
|
||||
class="icon"
|
||||
:disabled="!(this.message && this.label)"
|
||||
value="Save"
|
||||
@click="formPost"
|
||||
>
|
||||
<i class="material-icons">add</i>
|
||||
<span>Add</span>
|
||||
</button>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fb } from "../../functions/fb";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
message: null,
|
||||
label: null
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
formPost() {
|
||||
fb.writeFeeds(this.message, this.label);
|
||||
this.message = null;
|
||||
this.label = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
115
components/firebase/login.vue
Normal file
115
components/firebase/login.vue
Normal file
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<v-popover>
|
||||
<button class="icon" v-tooltip="$t('login_with')">
|
||||
<i class="material-icons">vpn_key</i>
|
||||
</button>
|
||||
<template slot="popover">
|
||||
<div>
|
||||
<button class="icon" @click="signInWithGoogle" v-close-popover>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
class="material-icons"
|
||||
>
|
||||
<path
|
||||
d="M12.24 10.285V14.4h6.806c-.275 1.765-2.056 5.174-6.806 5.174-4.095 0-7.439-3.389-7.439-7.574s3.345-7.574 7.439-7.574c2.33 0 3.891.989 4.785 1.849l3.254-3.138C18.189 1.186 15.479 0 12.24 0c-6.635 0-12 5.365-12 12s5.365 12 12 12c6.926 0 11.52-4.869 11.52-11.726 0-.788-.085-1.39-.189-1.989H12.24z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Google</span>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" @click="signInWithGithub" v-close-popover>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
class="material-icons"
|
||||
>
|
||||
<path
|
||||
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
|
||||
/>
|
||||
</svg>
|
||||
<span>GitHub</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</v-popover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import firebase from "firebase/app";
|
||||
import { fb } from "../../functions/fb";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
fb
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
signInWithGoogle() {
|
||||
const provider = new firebase.auth.GoogleAuthProvider();
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(provider)
|
||||
.then(res => {
|
||||
if (res.additionalUserInfo.isNewUser) {
|
||||
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), {
|
||||
icon: "sync",
|
||||
duration: null,
|
||||
closeOnSwipe: false,
|
||||
action: {
|
||||
text: this.$t("yes"),
|
||||
onClick: (e, toastObject) => {
|
||||
fb.writeSettings("syncHistory", false);
|
||||
fb.writeSettings("syncCollections", true);
|
||||
this.$router.push({ path: "/settings" });
|
||||
toastObject.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
},
|
||||
signInWithGithub() {
|
||||
const provider = new firebase.auth.GithubAuthProvider();
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(provider)
|
||||
.then(res => {
|
||||
if (res.additionalUserInfo.isNewUser) {
|
||||
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), {
|
||||
icon: "sync",
|
||||
duration: null,
|
||||
closeOnSwipe: false,
|
||||
action: {
|
||||
text: this.$t("yes"),
|
||||
onClick: (e, toastObject) => {
|
||||
fb.writeSettings("syncHistory", false);
|
||||
fb.writeSettings("syncCollections", true);
|
||||
this.$router.push({ path: "/settings" });
|
||||
toastObject.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
136
components/graphql/queryeditor.vue
Normal file
136
components/graphql/queryeditor.vue
Normal file
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<pre ref="editor"></pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const DEFAULT_THEME = "twilight";
|
||||
|
||||
import ace from "ace-builds";
|
||||
import * as gql from "graphql";
|
||||
import "ace-builds/webpack-resolver";
|
||||
import debounce from "../../functions/utils/debounce";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
default: "json"
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
cacheValue: "",
|
||||
validationSchema: null
|
||||
};
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(value) {
|
||||
if (value !== this.cacheValue) {
|
||||
this.editor.session.setValue(value, 1);
|
||||
this.cacheValue = value;
|
||||
}
|
||||
},
|
||||
theme() {
|
||||
this.editor.setTheme("ace/theme/" + this.defineTheme());
|
||||
},
|
||||
lang(value) {
|
||||
this.editor.getSession().setMode("ace/mode/" + value);
|
||||
},
|
||||
options(value) {
|
||||
this.editor.setOptions(value);
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
const editor = ace.edit(this.$refs.editor, {
|
||||
theme: "ace/theme/" + this.defineTheme(),
|
||||
mode: "ace/mode/" + this.lang,
|
||||
...this.options
|
||||
});
|
||||
|
||||
if (this.value) editor.setValue(this.value, 1);
|
||||
|
||||
this.editor = editor;
|
||||
this.cacheValue = this.value;
|
||||
|
||||
editor.on("change", () => {
|
||||
const content = editor.getValue();
|
||||
this.$emit("input", content);
|
||||
this.parseContents(content);
|
||||
this.cacheValue = content;
|
||||
});
|
||||
|
||||
this.parseContents(this.value);
|
||||
},
|
||||
|
||||
methods: {
|
||||
defineTheme() {
|
||||
if (this.theme) {
|
||||
return this.theme;
|
||||
} else {
|
||||
return (
|
||||
this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
setValidationSchema(schema) {
|
||||
this.validationSchema = schema;
|
||||
this.parseContents(this.cacheValue);
|
||||
},
|
||||
|
||||
parseContents: debounce(function(content) {
|
||||
if (content !== "") {
|
||||
try {
|
||||
const doc = gql.parse(content);
|
||||
|
||||
if (this.validationSchema) {
|
||||
this.editor.session.setAnnotations(
|
||||
gql.validate(this.validationSchema, doc)
|
||||
.map((err) => {
|
||||
return {
|
||||
row: err.locations[0].line - 1,
|
||||
column: err.locations[0].column - 1,
|
||||
text: err.message,
|
||||
type: "error"
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
} catch (e) {
|
||||
this.editor.session.setAnnotations([
|
||||
{
|
||||
row: e.locations[0].line - 1,
|
||||
column: e.locations[0].column - 1,
|
||||
text: e.message,
|
||||
type: "error"
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
this.editor.session.setAnnotations([]);
|
||||
}
|
||||
}, 2000)
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy();
|
||||
this.editor.container.remove();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -21,7 +21,7 @@
|
||||
<button
|
||||
class="icon"
|
||||
:class="{ stared: entry.star }"
|
||||
@click="toggleStar(index)"
|
||||
@click="toggleStar(entry)"
|
||||
v-tooltip="{
|
||||
content: !entry.star ? $t('add_star') : $t('remove_star')
|
||||
}"
|
||||
@@ -331,6 +331,7 @@ ol li {
|
||||
|
||||
<script>
|
||||
import { findStatusGroup } from "../pages/index";
|
||||
import { fb } from "../functions/fb";
|
||||
|
||||
const updateOnLocalStorage = (propertyName, property) =>
|
||||
window.localStorage.setItem(propertyName, JSON.stringify(property));
|
||||
@@ -341,11 +342,11 @@ export default {
|
||||
VirtualList: () => import("vue-virtual-scroll-list")
|
||||
},
|
||||
data() {
|
||||
const localStorageHistory = JSON.parse(
|
||||
window.localStorage.getItem("history")
|
||||
);
|
||||
return {
|
||||
history: localStorageHistory || [],
|
||||
history:
|
||||
fb.currentUser !== null
|
||||
? fb.currentHistory
|
||||
: JSON.parse(window.localStorage.getItem("history")) || [],
|
||||
filterText: "",
|
||||
showFilter: false,
|
||||
isClearingHistory: false,
|
||||
@@ -359,6 +360,10 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
filteredHistory() {
|
||||
this.history =
|
||||
fb.currentUser !== null
|
||||
? fb.currentHistory
|
||||
: JSON.parse(window.localStorage.getItem("history")) || [];
|
||||
return this.history.filter(entry => {
|
||||
const filterText = this.filterText.toLowerCase();
|
||||
return Object.keys(entry).some(key => {
|
||||
@@ -371,6 +376,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
clearHistory() {
|
||||
if (fb.currentUser !== null) {
|
||||
fb.clearHistory();
|
||||
}
|
||||
this.history = [];
|
||||
this.filterText = "";
|
||||
this.disableHistoryClearing();
|
||||
@@ -391,6 +399,9 @@ export default {
|
||||
);
|
||||
},
|
||||
deleteHistory(entry) {
|
||||
if (fb.currentUser !== null) {
|
||||
fb.deleteHistory(entry);
|
||||
}
|
||||
this.history.splice(this.history.indexOf(entry), 1);
|
||||
if (this.history.length === 0) {
|
||||
this.filterText = "";
|
||||
@@ -497,8 +508,11 @@ export default {
|
||||
toggleCollapse() {
|
||||
this.showMore = !this.showMore;
|
||||
},
|
||||
toggleStar(index) {
|
||||
this.history[index]["star"] = !this.history[index]["star"];
|
||||
toggleStar(entry) {
|
||||
if (fb.currentUser !== null) {
|
||||
fb.toggleStar(entry, !entry.star);
|
||||
}
|
||||
entry.star = !entry.star;
|
||||
updateOnLocalStorage("history", this.history);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
service cloud.firestore {
|
||||
match /databases/{database}/documents {
|
||||
match /{document=**} {
|
||||
allow read, write;
|
||||
allow read, write: if request.auth.uid != null;
|
||||
}
|
||||
// Make sure the uid of the requesting user matches name of the user
|
||||
// document. The wildcard expression {userId} makes the userId variable
|
||||
// available in rules.
|
||||
match /users/{userId} {
|
||||
allow read, update, delete: if request.auth.uid == userId;
|
||||
allow create: if request.auth.uid != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
173
functions/fb.js
Normal file
173
functions/fb.js
Normal file
@@ -0,0 +1,173 @@
|
||||
import firebase from "firebase/app";
|
||||
import "firebase/firestore";
|
||||
import "firebase/auth";
|
||||
|
||||
// Initialize Firebase, copied from cloud console
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyCMsFreESs58-hRxTtiqQrIcimh4i1wbsM",
|
||||
authDomain: "postwoman-api.firebaseapp.com",
|
||||
databaseURL: "https://postwoman-api.firebaseio.com",
|
||||
projectId: "postwoman-api",
|
||||
storageBucket: "postwoman-api.appspot.com",
|
||||
messagingSenderId: "421993993223",
|
||||
appId: "1:421993993223:web:ec0baa8ee8c02ffa1fc6a2",
|
||||
measurementId: "G-ERJ6025CEB"
|
||||
};
|
||||
firebase.initializeApp(firebaseConfig);
|
||||
|
||||
// a reference to the users collection
|
||||
const usersCollection = firebase.firestore().collection("users");
|
||||
|
||||
// the shared state object that any vue component
|
||||
// can get access to
|
||||
export const fb = {
|
||||
currentUser: {},
|
||||
currentFeeds: [],
|
||||
currentSettings: [],
|
||||
currentHistory: [],
|
||||
writeFeeds: async (message, label) => {
|
||||
const dt = {
|
||||
createdOn: new Date(),
|
||||
author: fb.currentUser.uid,
|
||||
author_name: fb.currentUser.displayName,
|
||||
author_image: fb.currentUser.photoURL,
|
||||
message,
|
||||
label
|
||||
};
|
||||
try {
|
||||
return usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("feeds")
|
||||
.add(dt);
|
||||
} catch (e) {
|
||||
return console.error("error inserting", dt, e);
|
||||
}
|
||||
},
|
||||
deleteFeed: id => {
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("feeds")
|
||||
.doc(id)
|
||||
.delete()
|
||||
.catch(e => console.error("error deleting", id, e));
|
||||
},
|
||||
writeSettings: async (setting, value) => {
|
||||
const st = {
|
||||
updatedOn: new Date(),
|
||||
author: fb.currentUser.uid,
|
||||
author_name: fb.currentUser.displayName,
|
||||
author_image: fb.currentUser.photoURL,
|
||||
name: setting,
|
||||
value
|
||||
};
|
||||
try {
|
||||
return usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("settings")
|
||||
.doc(setting)
|
||||
.set(st);
|
||||
} catch (e) {
|
||||
return console.error("error updating", st, e);
|
||||
}
|
||||
},
|
||||
writeHistory: async entry => {
|
||||
const hs = entry;
|
||||
try {
|
||||
return usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("history")
|
||||
.add(hs);
|
||||
} catch (e) {
|
||||
return console.error("error inserting", hs, e);
|
||||
}
|
||||
},
|
||||
deleteHistory: entry => {
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("history")
|
||||
.doc(entry.id)
|
||||
.delete()
|
||||
.catch(e => console.error("error deleting", entry, e));
|
||||
},
|
||||
clearHistory: () => {
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("history")
|
||||
.get()
|
||||
.then(({ docs }) => {
|
||||
docs.forEach(e => fb.deleteHistory(e));
|
||||
});
|
||||
},
|
||||
toggleStar: (entry, value) => {
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("history")
|
||||
.doc(entry.id)
|
||||
.update({ star: value })
|
||||
.catch(e => console.error("error deleting", entry, e));
|
||||
}
|
||||
};
|
||||
|
||||
// When a user logs in or out, save that in the store
|
||||
firebase.auth().onAuthStateChanged(user => {
|
||||
if (user) {
|
||||
fb.currentUser = user;
|
||||
fb.currentUser.providerData.forEach(profile => {
|
||||
let us = {
|
||||
updatedOn: new Date(),
|
||||
provider: profile.providerId,
|
||||
name: profile.displayName,
|
||||
email: profile.email,
|
||||
photoUrl: profile.photoURL,
|
||||
uid: profile.uid
|
||||
};
|
||||
try {
|
||||
usersCollection.doc(fb.currentUser.uid).set(us);
|
||||
} catch (e) {
|
||||
console.error("error updating", us, e);
|
||||
}
|
||||
});
|
||||
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("feeds")
|
||||
.orderBy("createdOn", "desc")
|
||||
.onSnapshot(feedsRef => {
|
||||
const feeds = [];
|
||||
feedsRef.forEach(doc => {
|
||||
const feed = doc.data();
|
||||
feed.id = doc.id;
|
||||
feeds.push(feed);
|
||||
});
|
||||
fb.currentFeeds = feeds;
|
||||
});
|
||||
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("settings")
|
||||
.onSnapshot(settingsRef => {
|
||||
const settings = [];
|
||||
settingsRef.forEach(doc => {
|
||||
const setting = doc.data();
|
||||
setting.id = doc.id;
|
||||
settings.push(setting);
|
||||
});
|
||||
fb.currentSettings = settings;
|
||||
});
|
||||
|
||||
usersCollection
|
||||
.doc(fb.currentUser.uid)
|
||||
.collection("history")
|
||||
.onSnapshot(historyRef => {
|
||||
const history = [];
|
||||
historyRef.forEach(doc => {
|
||||
const entry = doc.data();
|
||||
entry.id = doc.id;
|
||||
history.push(entry);
|
||||
});
|
||||
fb.currentHistory = history;
|
||||
});
|
||||
} else {
|
||||
fb.currentUser = null;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,19 @@
|
||||
import AxiosStrategy from "./strategies/AxiosStrategy";
|
||||
import ProxyStrategy from "./strategies/ProxyStrategy";
|
||||
import FirefoxStrategy from "./strategies/FirefoxStrategy";
|
||||
|
||||
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy";
|
||||
|
||||
const runAppropriateStrategy = (req, store) => {
|
||||
// Chrome Provides a chrome object for scripts to access
|
||||
// Check its availability to say whether you are in Google Chrome
|
||||
if (window.chrome && hasChromeExtensionInstalled()) {
|
||||
return ChromeStrategy(req, store);
|
||||
}
|
||||
// The firefox plugin injects a function to send requests through it
|
||||
// If that is available, then we can use the FirefoxStrategy
|
||||
if (window.firefoxExtSendRequest) {
|
||||
return FirefoxStrategy(req, store);
|
||||
}
|
||||
|
||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
||||
return ProxyStrategy(req, store);
|
||||
}
|
||||
|
||||
return AxiosStrategy(req, store);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
import axios from "axios";
|
||||
|
||||
const axiosStrategy = async (req, _store) => {
|
||||
const axiosWithProxy = async (req, { state }) => {
|
||||
const { data } = await axios.post(
|
||||
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
|
||||
req
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
const axiosWithoutProxy = async (req, _store) => {
|
||||
const res = await axios(req);
|
||||
return res;
|
||||
};
|
||||
|
||||
const axiosStrategy = (req, store) => {
|
||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
||||
return axiosWithProxy(req, store);
|
||||
}
|
||||
return axiosWithoutProxy(req, store);
|
||||
};
|
||||
|
||||
export default axiosStrategy;
|
||||
|
||||
56
functions/strategies/ChromeStrategy.js
Normal file
56
functions/strategies/ChromeStrategy.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld";
|
||||
|
||||
// Check if the Chrome Extension is present
|
||||
// The Chrome extension injects an empty span to help detection.
|
||||
// Also check for the presence of window.chrome object to confirm smooth operations
|
||||
export const hasChromeExtensionInstalled = () => {
|
||||
return document.getElementById("chromePWExtensionDetect") !== null;
|
||||
}
|
||||
|
||||
const chromeWithoutProxy = (req, _store) => new Promise((resolve, reject) => {
|
||||
chrome.runtime.sendMessage(
|
||||
EXTENSION_ID, {
|
||||
messageType: "send-req",
|
||||
data: {
|
||||
config: req
|
||||
}
|
||||
}, (message) => {
|
||||
if (message.data.error) {
|
||||
reject(message.data.error);
|
||||
} else {
|
||||
resolve(message.data.response);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const chromeWithProxy = (req, { state }) => new Promise((resolve, reject) => {
|
||||
chrome.runtime.sendMessage(
|
||||
EXTENSION_ID, {
|
||||
messageType: "send-req",
|
||||
data: {
|
||||
config: {
|
||||
method: "post",
|
||||
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
|
||||
data: req
|
||||
}
|
||||
}
|
||||
}, (message) => {
|
||||
if (message.data.error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(message.data.response.data);
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
const chromeStrategy = (req, store) => {
|
||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
||||
return chromeWithProxy(req, store);
|
||||
} else {
|
||||
return chromeWithoutProxy(req, store);
|
||||
}
|
||||
}
|
||||
|
||||
export default chromeStrategy;
|
||||
@@ -1,15 +1,50 @@
|
||||
const firefoxStrategy = (req, _store) => new Promise((resolve, reject) => {
|
||||
const firefoxWithProxy = (req, { state }) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const eventListener = event => {
|
||||
window.removeEventListener("firefoxExtSendRequestComplete", event);
|
||||
|
||||
const eventListener = (event) => {
|
||||
window.removeEventListener("firefoxExtSendRequestComplete", eventListener);
|
||||
if (event.detail.error) {
|
||||
reject(JSON.parse(event.detail.error));
|
||||
} else {
|
||||
resolve(JSON.parse(event.detail.response).data);
|
||||
}
|
||||
};
|
||||
|
||||
if (event.detail.error) reject(JSON.parse(event.detail.error));
|
||||
else resolve(JSON.parse(event.detail.response));
|
||||
};
|
||||
window.addEventListener("firefoxExtSendRequestComplete", eventListener);
|
||||
|
||||
window.addEventListener("firefoxExtSendRequestComplete", eventListener);
|
||||
window.firefoxExtSendRequest({
|
||||
method: "post",
|
||||
url:
|
||||
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
|
||||
data: req
|
||||
});
|
||||
});
|
||||
|
||||
window.firefoxExtSendRequest(req);
|
||||
});
|
||||
const firefoxWithoutProxy = (req, _store) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const eventListener = ({ detail }) => {
|
||||
window.removeEventListener(
|
||||
"firefoxExtSendRequestComplete",
|
||||
eventListener
|
||||
);
|
||||
|
||||
if (detail.error) {
|
||||
reject(JSON.parse(detail.error));
|
||||
} else {
|
||||
resolve(JSON.parse(detail.response));
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("firefoxExtSendRequestComplete", eventListener);
|
||||
|
||||
window.firefoxExtSendRequest(req);
|
||||
});
|
||||
|
||||
const firefoxStrategy = (req, store) => {
|
||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
||||
return firefoxWithProxy(req, store);
|
||||
}
|
||||
return firefoxWithoutProxy(req, store);
|
||||
};
|
||||
|
||||
export default firefoxStrategy;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import axios from "axios";
|
||||
|
||||
const proxyStrategy = async (req, store) => {
|
||||
const { data } = await axios.post(
|
||||
store.state.postwoman.settings.PROXY_URL ||
|
||||
"https://postwoman.apollotv.xyz/",
|
||||
req
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export default proxyStrategy;
|
||||
15
functions/utils/debounce.js
Normal file
15
functions/utils/debounce.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// Debounce is a higher order function which makes its enclosed function be executed
|
||||
// only if the function wasn't called again till 'delay' time has passed, this helps reduce impact of heavy working
|
||||
// functions which might be called frequently
|
||||
// NOTE : Don't use lambda functions as this doesn't get bound properly in them, use the 'function (args) {}' format
|
||||
const debounce = (func, delay) => {
|
||||
let inDebounce
|
||||
return function() {
|
||||
const context = this
|
||||
const args = arguments
|
||||
clearTimeout(inDebounce)
|
||||
inDebounce = setTimeout(() => func.apply(context, args), delay)
|
||||
}
|
||||
}
|
||||
|
||||
export default debounce;
|
||||
@@ -249,5 +249,15 @@ export default {
|
||||
extensions: "Extensions",
|
||||
extensions_info1: "Browser extension that simplifies access to Postwoman",
|
||||
extensions_info2: "Get Postwoman browser extension!",
|
||||
installed: "Installed"
|
||||
installed: "Installed",
|
||||
login_with: "Login with",
|
||||
logged_out: "Logged out",
|
||||
logout: "Logout",
|
||||
account: "Account",
|
||||
sync: "Sync",
|
||||
syncHistory: "History",
|
||||
syncCollections: "Collections",
|
||||
turn_on: "Turn on",
|
||||
login_first: "Login first",
|
||||
paste_a_collection: "Paste a Collection"
|
||||
};
|
||||
|
||||
@@ -237,6 +237,11 @@
|
||||
<div v-else-if="$route.path === '/settings'">
|
||||
<nav class="secondary-nav">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#account" v-tooltip.right="$t('account')">
|
||||
<i class="material-icons">person</i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#theme" v-tooltip.right="$t('theme')">
|
||||
<i class="material-icons">brush</i>
|
||||
@@ -288,6 +293,46 @@
|
||||
>
|
||||
<i class="material-icons">offline_bolt</i>
|
||||
</button>
|
||||
<login v-if="!fb.currentUser" />
|
||||
<span v-if="fb.currentUser">
|
||||
<v-popover>
|
||||
<button
|
||||
class="icon"
|
||||
v-tooltip="
|
||||
(fb.currentUser.displayName ||
|
||||
'<label><i>Name not found</i></label>') +
|
||||
'<br>' +
|
||||
(fb.currentUser.email ||
|
||||
'<label><i>Email not found</i></label>')
|
||||
"
|
||||
>
|
||||
<img
|
||||
v-if="fb.currentUser.photoURL"
|
||||
:src="fb.currentUser.photoURL"
|
||||
class="material-icons"
|
||||
/>
|
||||
<i v-else class="material-icons">account_circle</i>
|
||||
</button>
|
||||
<template slot="popover">
|
||||
<div>
|
||||
<nuxt-link :to="localePath('settings')" v-close-popover>
|
||||
<button class="icon">
|
||||
<i class="material-icons">settings</i>
|
||||
<span>
|
||||
{{ $t("settings") }}
|
||||
</span>
|
||||
</button>
|
||||
</nuxt-link>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" @click="logout" v-close-popover>
|
||||
<i class="material-icons">exit_to_app</i>
|
||||
<span>{{ $t("logout") }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</v-popover>
|
||||
</span>
|
||||
<v-popover>
|
||||
<button class="icon" v-tooltip="$t('more')">
|
||||
<i class="material-icons">more_vert</i>
|
||||
@@ -352,15 +397,7 @@
|
||||
<div class="flex-wrap">
|
||||
<span v-if="version.name" class="mono">
|
||||
<a
|
||||
href="https://liyasthomas.web.app"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<button class="icon" v-tooltip="'Liyas Thomas'">
|
||||
🦄
|
||||
</button>
|
||||
</a>
|
||||
<a
|
||||
class="link"
|
||||
:href="
|
||||
'https://github.com/liyasthomas/postwoman/releases/tag/' +
|
||||
version.name
|
||||
@@ -371,6 +408,14 @@
|
||||
>
|
||||
{{ version.name }}
|
||||
</a>
|
||||
<a
|
||||
class="link"
|
||||
href="https://www.netlify.com"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
Powered by Netlify
|
||||
</a>
|
||||
<!-- <span v-if="version.hash">
|
||||
-
|
||||
<a
|
||||
@@ -382,6 +427,15 @@
|
||||
<!-- <span v-if="version.variant">({{version.variant}})</span> -->
|
||||
</span>
|
||||
<span>
|
||||
<a
|
||||
href="https://liyasthomas.web.app"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<button class="icon" v-tooltip="'Liyas Thomas'">
|
||||
🦄
|
||||
</button>
|
||||
</a>
|
||||
<a
|
||||
href="mailto:liyascthomas@gmail.com"
|
||||
target="_blank"
|
||||
@@ -461,27 +515,33 @@
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" disabled>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M2.897 4.181c2.43-2.828 5.763-4.181 9.072-4.181 4.288 0 8.535 2.273 10.717 6.554-2.722.001-6.984 0-9.293 0-1.674.001-2.755-.037-3.926.579-1.376.724-2.415 2.067-2.777 3.644l-3.793-6.596zm5.11 7.819c0 2.2 1.789 3.99 3.988 3.99s3.988-1.79 3.988-3.99-1.789-3.991-3.988-3.991-3.988 1.791-3.988 3.991zm5.536 5.223c-2.238.666-4.858-.073-6.293-2.549-1.095-1.891-3.989-6.933-5.305-9.225-1.33 2.04-1.945 4.294-1.945 6.507 0 5.448 3.726 10.65 9.673 11.818l3.87-6.551zm2.158-9.214c1.864 1.734 2.271 4.542 1.007 6.719-.951 1.641-3.988 6.766-5.46 9.248 7.189.443 12.752-5.36 12.752-11.972 0-1.313-.22-2.66-.69-3.995h-7.609z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Chrome (coming soon)</span>
|
||||
<span
|
||||
class="icon"
|
||||
v-if="chromeExtInstalled"
|
||||
v-tooltip="$t('installed')"
|
||||
>
|
||||
<i class="material-icons">done</i>
|
||||
</span>
|
||||
</button>
|
||||
<a
|
||||
href="https://chrome.google.com/webstore/detail/postwoman-extension-for-c/amknoiejhlmhancpahfcfcfhllgkpbld"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<button class="icon">
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M2.897 4.181c2.43-2.828 5.763-4.181 9.072-4.181 4.288 0 8.535 2.273 10.717 6.554-2.722.001-6.984 0-9.293 0-1.674.001-2.755-.037-3.926.579-1.376.724-2.415 2.067-2.777 3.644l-3.793-6.596zm5.11 7.819c0 2.2 1.789 3.99 3.988 3.99s3.988-1.79 3.988-3.99-1.789-3.991-3.988-3.991-3.988 1.791-3.988 3.991zm5.536 5.223c-2.238.666-4.858-.073-6.293-2.549-1.095-1.891-3.989-6.933-5.305-9.225-1.33 2.04-1.945 4.294-1.945 6.507 0 5.448 3.726 10.65 9.673 11.818l3.87-6.551zm2.158-9.214c1.864 1.734 2.271 4.542 1.007 6.719-.951 1.641-3.988 6.766-5.46 9.248 7.189.443 12.752-5.36 12.752-11.972 0-1.313-.22-2.66-.69-3.995h-7.609z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Chrome</span>
|
||||
<span
|
||||
class="icon"
|
||||
v-if="chromeExtInstalled"
|
||||
v-tooltip="$t('installed')"
|
||||
>
|
||||
<i class="material-icons">done</i>
|
||||
</span>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer"></div>
|
||||
@@ -588,16 +648,31 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped lang="scss">
|
||||
.link {
|
||||
margin: 8px 16px;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.link {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import intializePwa from "../assets/js/pwa";
|
||||
import * as version from "../.postwoman/version.json";
|
||||
import { hasChromeExtensionInstalled } from "../functions/strategies/ChromeStrategy";
|
||||
|
||||
import firebase from 'firebase/app';
|
||||
import { fb } from '../functions/fb';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
logo: () => import("../components/logo"),
|
||||
modal: () => import("../components/modal")
|
||||
modal: () => import("../components/modal"),
|
||||
login: () => import("../components/firebase/login")
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -606,6 +681,21 @@ export default {
|
||||
"nuxt-link-exact-active": this.$route.path === path,
|
||||
"nuxt-link-active": this.$route.path === path
|
||||
};
|
||||
},
|
||||
|
||||
logout() {
|
||||
fb.currentUser = null;
|
||||
firebase
|
||||
.auth()
|
||||
.signOut()
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
this.$toast.info(this.$t("logged_out"), {
|
||||
icon: "vpn_key"
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -619,9 +709,9 @@ export default {
|
||||
showExtensions: false,
|
||||
showShortcuts: false,
|
||||
showSupport: false,
|
||||
firefoxExtInstalled:
|
||||
window.firefoxExtSendRequest !== undefined ? true : false,
|
||||
chromeExtInstalled: false
|
||||
firefoxExtInstalled: window.firefoxExtSendRequest,
|
||||
chromeExtInstalled: window.chrome && hasChromeExtensionInstalled(),
|
||||
fb
|
||||
};
|
||||
},
|
||||
|
||||
@@ -742,7 +832,7 @@ export default {
|
||||
|
||||
watch: {
|
||||
$route() {
|
||||
this.$toast.clear();
|
||||
// this.$toast.clear();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
994
package-lock.json
generated
994
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -26,11 +26,13 @@
|
||||
"@nuxtjs/sitemap": "^2.0.1",
|
||||
"@nuxtjs/toast": "^3.3.0",
|
||||
"ace-builds": "^1.4.8",
|
||||
"firebase": "^7.7.0",
|
||||
"graphql": "^14.5.8",
|
||||
"nuxt": "^2.11.0",
|
||||
"nuxt-i18n": "^6.4.1",
|
||||
"v-tooltip": "^2.0.2",
|
||||
"vue-virtual-scroll-list": "^1.4.4",
|
||||
"vuefire": "^2.2.1",
|
||||
"vuejs-auto-complete": "^0.9.0",
|
||||
"vuex-persist": "^2.2.0",
|
||||
"yargs-parser": "^16.1.0"
|
||||
|
||||
@@ -175,7 +175,8 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<Editor
|
||||
<QueryEditor
|
||||
ref="queryEditor"
|
||||
v-model="gqlQueryString"
|
||||
:options="{
|
||||
maxLines: responseBodyMaxLines,
|
||||
@@ -391,6 +392,7 @@ import axios from "axios";
|
||||
import * as gql from "graphql";
|
||||
import textareaAutoHeight from "../directives/textareaAutoHeight";
|
||||
import AceEditor from "../components/ace-editor";
|
||||
import QueryEditor from "../components/graphql/queryeditor";
|
||||
import { sendNetworkRequest } from "../functions/network";
|
||||
|
||||
export default {
|
||||
@@ -402,7 +404,8 @@ export default {
|
||||
"gql-field": () => import("../components/graphql/field"),
|
||||
"gql-type": () => import("../components/graphql/type"),
|
||||
autocomplete: () => import("../components/autocomplete"),
|
||||
Editor: AceEditor
|
||||
Editor: AceEditor,
|
||||
QueryEditor: QueryEditor
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -543,6 +546,7 @@ export default {
|
||||
responseBodyMaxLines: 16
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
url: {
|
||||
get() {
|
||||
@@ -808,6 +812,8 @@ export default {
|
||||
}
|
||||
}
|
||||
this.gqlTypes = types;
|
||||
|
||||
this.$refs.queryEditor.setValidationSchema(schema);
|
||||
|
||||
this.$nuxt.$loading.finish();
|
||||
const duration = Date.now() - startTime;
|
||||
@@ -816,7 +822,7 @@ export default {
|
||||
});
|
||||
} catch (error) {
|
||||
this.$nuxt.$loading.finish();
|
||||
this.schemaString = `${error}. ${check_console_details}`;
|
||||
this.schemaString = `${error}. ${this.$t("check_console_details")}`;
|
||||
this.$toast.error(`${error} ${this.$t("f12_details")}`, {
|
||||
icon: "error"
|
||||
});
|
||||
|
||||
3222
pages/index.vue
3222
pages/index.vue
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,88 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<pw-section class="green" :label="$t('account')" ref="account">
|
||||
<ul>
|
||||
<li>
|
||||
<div v-if="fb.currentUser">
|
||||
<button class="icon">
|
||||
<img
|
||||
v-if="fb.currentUser.photoURL"
|
||||
:src="fb.currentUser.photoURL"
|
||||
class="material-icons"
|
||||
/>
|
||||
<i v-else class="material-icons">account_circle</i>
|
||||
<span>
|
||||
{{ fb.currentUser.displayName || "Name not found" }}
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
<button class="icon">
|
||||
<i class="material-icons">email</i>
|
||||
<span>
|
||||
{{ fb.currentUser.email || "Email not found" }}
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
<button class="icon" @click="logout">
|
||||
<i class="material-icons">exit_to_app</i>
|
||||
<span>{{ $t("logout") }}</span>
|
||||
</button>
|
||||
<br />
|
||||
<p v-for="setting in fb.currentSettings" :key="setting.id">
|
||||
<pw-toggle
|
||||
:key="setting.name"
|
||||
:on="setting.value"
|
||||
@change="toggleSettings(setting.name, setting.value)"
|
||||
>
|
||||
{{ $t(setting.name) + " " + $t("sync") }}
|
||||
{{ setting.value ? $t("enabled") : $t("disabled") }}
|
||||
</pw-toggle>
|
||||
</p>
|
||||
<p v-if="fb.currentSettings.length == 0">
|
||||
<button class="" @click="writeSettings">
|
||||
<i class="material-icons">sync</i>
|
||||
<span>{{ $t("turn_on") + " " + $t("sync") }}</span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<label>{{ $t("login_with") }}</label>
|
||||
<p>
|
||||
<button class="icon" @click="signInWithGoogle">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
class="material-icons"
|
||||
>
|
||||
<path
|
||||
d="M12.24 10.285V14.4h6.806c-.275 1.765-2.056 5.174-6.806 5.174-4.095 0-7.439-3.389-7.439-7.574s3.345-7.574 7.439-7.574c2.33 0 3.891.989 4.785 1.849l3.254-3.138C18.189 1.186 15.479 0 12.24 0c-6.635 0-12 5.365-12 12s5.365 12 12 12c6.926 0 11.52-4.869 11.52-11.726 0-.788-.085-1.39-.189-1.989H12.24z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Google</span>
|
||||
</button>
|
||||
<br />
|
||||
<button class="icon" @click="signInWithGithub">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
class="material-icons"
|
||||
>
|
||||
<path
|
||||
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
|
||||
/>
|
||||
</svg>
|
||||
<span>GitHub</span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</pw-section>
|
||||
|
||||
<pw-section class="cyan" :label="$t('theme')" ref="theme">
|
||||
<ul>
|
||||
<li>
|
||||
@@ -137,6 +220,9 @@
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
<script>
|
||||
import firebase from "firebase/app";
|
||||
import { fb } from "../functions/fb";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
"pw-section": () => import("../components/section"),
|
||||
@@ -238,7 +324,9 @@ export default {
|
||||
this.$store.state.postwoman.settings.PROXY_URL ||
|
||||
"https://postwoman.apollotv.xyz/",
|
||||
PROXY_KEY: this.$store.state.postwoman.settings.PROXY_KEY || ""
|
||||
}
|
||||
},
|
||||
|
||||
fb
|
||||
};
|
||||
},
|
||||
|
||||
@@ -289,8 +377,88 @@ export default {
|
||||
toggleSetting(key) {
|
||||
this.settings[key] = !this.settings[key];
|
||||
this.$store.commit("postwoman/applySetting", [key, this.settings[key]]);
|
||||
},
|
||||
logout() {
|
||||
fb.currentUser = null;
|
||||
firebase
|
||||
.auth()
|
||||
.signOut()
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
this.$toast.info(this.$t("logged_out"), {
|
||||
icon: "vpn_key"
|
||||
});
|
||||
},
|
||||
signInWithGoogle() {
|
||||
const provider = new firebase.auth.GoogleAuthProvider();
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(provider)
|
||||
.then(res => {
|
||||
if (res.additionalUserInfo.isNewUser) {
|
||||
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), {
|
||||
icon: "sync",
|
||||
duration: null,
|
||||
closeOnSwipe: false,
|
||||
action: {
|
||||
text: this.$t("yes"),
|
||||
onClick: (e, toastObject) => {
|
||||
fb.writeSettings("syncHistory", false);
|
||||
fb.writeSettings("syncCollections", true);
|
||||
this.$router.push({ path: "/settings" });
|
||||
toastObject.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
},
|
||||
signInWithGithub() {
|
||||
const provider = new firebase.auth.GithubAuthProvider();
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(provider)
|
||||
.then(res => {
|
||||
if (res.additionalUserInfo.isNewUser) {
|
||||
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), {
|
||||
icon: "sync",
|
||||
duration: null,
|
||||
closeOnSwipe: false,
|
||||
action: {
|
||||
text: this.$t("yes"),
|
||||
onClick: (e, toastObject) => {
|
||||
fb.writeSettings("syncHistory", false);
|
||||
fb.writeSettings("syncCollections", true);
|
||||
this.$router.push({ path: "/settings" });
|
||||
toastObject.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.show(err.message || err, {
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
},
|
||||
toggleSettings(s, v) {
|
||||
fb.writeSettings(s, !v);
|
||||
},
|
||||
writeSettings() {
|
||||
fb.writeSettings("syncHistory", false);
|
||||
fb.writeSettings("syncCollections", true);
|
||||
}
|
||||
},
|
||||
|
||||
beforeMount() {
|
||||
this.settings.THEME_COLOR = this.getActiveColor();
|
||||
},
|
||||
|
||||
@@ -111,6 +111,12 @@ export const mutations = {
|
||||
},
|
||||
|
||||
addNewCollection({ collections }, collection) {
|
||||
const { name } = collection
|
||||
const duplicateCollection = collections.some(item => item.name === name)
|
||||
if (duplicateCollection) {
|
||||
this.$toast.info('Duplicate collection');
|
||||
return;
|
||||
}
|
||||
collections.push({
|
||||
name: "",
|
||||
folders: [],
|
||||
@@ -126,6 +132,12 @@ export const mutations = {
|
||||
|
||||
editCollection({ collections }, payload) {
|
||||
const { collection, collectionIndex } = payload;
|
||||
const { name } = collection
|
||||
const duplicateCollection = collections.some(item => item.name === name)
|
||||
if (duplicateCollection) {
|
||||
this.$toast.info('Duplicate collection');
|
||||
return;
|
||||
}
|
||||
collections[collectionIndex] = collection;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user