portier/source/static/js/pull-list.js

35 lines
785 B
JavaScript
Raw Permalink Normal View History

2024-04-01 16:27:31 +02:00
var app = new Vue({
2024-05-04 14:06:46 +02:00
el: "#app",
2024-04-01 16:27:31 +02:00
data: {
cfgs: [],
2024-05-04 14:06:46 +02:00
isLoading: true,
2024-04-01 16:27:31 +02:00
},
methods: {
detailLink(id) {
2024-05-04 14:06:46 +02:00
return `${id}/`;
2024-04-01 16:27:31 +02:00
},
deleteLink(id) {
2024-05-04 14:06:46 +02:00
return `${id}/delete`;
2024-04-01 16:27:31 +02:00
},
toggleActive(cfg) {
axios
2024-05-04 14:06:46 +02:00
.patch("/api/v2/config/pull/" + cfg.id, { active: !cfg.active })
.then((response) => {
i = this.cfgs.findIndex((obj) => obj.id == cfg.id);
Vue.set(this.cfgs, i, response.data);
});
2024-04-01 16:27:31 +02:00
},
fetchData() {
2024-05-04 14:06:46 +02:00
axios.get("/api/v2/config/pull").then((response) => {
this.cfgs = response.data;
this.isLoading = false;
});
},
},
mounted() {
axios.defaults.xsrfCookieName = "csrftoken";
axios.defaults.xsrfHeaderName = "X-CSRFTOKEN";
this.fetchData();
2024-04-01 16:27:31 +02:00
},
2024-05-04 14:06:46 +02:00
});