Pinboard Groupings
-
@@ -24,9 +24,33 @@
{{ error }}
-
- {{ pin.hash }}
+
+
+
+
+
+
+
@@ -44,52 +68,69 @@ export default {
form: {
apiKey: null
},
- pins: [],
+ newGrouping: {
+ tags: []
+ },
error: null
}
},
methods: {
- getPins() {
- axios.get("https://api.pinboard.in/v1/posts/all?format=json&results=10&auth_token=" + this.apiKey)
+ refreshGroupings(event) {
+ for(var key in this.groupings) {
+ var grouping = this.groupings[key];
+ grouping.loading = true;
+ grouping.pins = [];
+
+ this.getPinsForGroup(grouping);
+ }
+ },
+ getPinsForGroup(grouping) {
+ var url = "https://api.pinboard.in/v1/posts/all?format=json&results=30";
+ url += "&auth_token=" + this.apiKey;
+ url += "&tag=" + grouping.tags;
+
+ axios.get(url)
.then(response => {
- console.log(response.data);
- this.pins = response.data;
- var data = { pins: this.pins };
- chrome.storage.sync.set(data, () => {
- console.log('done');
- })
+ grouping.pins = response.data;
+ grouping.loading = false;
+ var data = { groupings: this.groupings };
+ chrome.storage.sync.set(data, () => { });
})
.catch(error => {
this.error = error;
});
},
+ saveNewGrouping(event) {
+ this.groupings.push({
+ tags: this.newGrouping.tags,
+ pins: [],
+ loading: true
+ });
+ var data = { groupings: this.groupings };
+ chrome.storage.sync.set(data, () => { });
+ this.newGrouping = { tags: [] };
+
+ this.getPinsForGroup(this.groupings[this.groupings.length - 1]);
+ },
save(event) {
var data = {
apiKey: this.form.apiKey,
- pins: []
+ groupings: this.apiKey !== this.form.apiKey ? [] : this.groupings
};
chrome.storage.sync.set(data, () => {
this.apiKey = data.apiKey;
- this.pins = data.pins;
- if (this.apiKey) {
- this.getPins();
- }
+ this.groupings = data.groupings;
});
},
- edit(event) {
+ editApiKey(event) {
this.form.apiKey = this.apiKey;
this.apiKey = null;
}
},
mounted() {
- chrome.storage.sync.get(['apiKey', 'groupings','pins'], result => {
+ chrome.storage.sync.get(['apiKey','groupings'], result => {
this.apiKey = result.apiKey;
this.groupings = result.groupings;
- this.pins = result.pins;
-
- if (this.apiKey && this.pins.length == 0) {
- this.getPins();
- }
});
}
}
@@ -105,10 +146,10 @@ export default {
h1 {
font-size: 1rem;
}
-.api-key * {
+.api-key-form *, .tags-form * {
font-size: 0.8rem;
}
-.api-key input.form-control {
+.api-key-form input.form-control {
width: 17rem;
}