import { showError } from "@nextcloud/dialogs"; import { LoadDT, baseUrl, showDone } from "../modules/mainFunction.mjs"; export class Bibliotheque { /** * * @param myresp instantiate client object */ constructor(myresp) { this.id = myresp.id; this.contenu = ((myresp.contenu.length === 0) ? '-' : myresp.contenu); } /** * Get datatable row for biblio */ getDTRow() { let myrow = [ '
' + this.id + '
', '
' + this.contenu + '
', '
' ]; return myrow; } /** * * @param {*} biblioDT */ static loadBibliothequeDT(biblioDT) { var oReq = new XMLHttpRequest(); oReq.open('PROPFIND', baseUrl + '/getBibliotheques', true); oReq.setRequestHeader("Content-Type", "application/json"); oReq.onload = function(e){ if (this.status == 200) { LoadDT(biblioDT, JSON.parse(this.response), Bibliotheque); }else{ showError(this.response); } }; oReq.send(); } /** * * @param {*} dt */ static newBibliotheque(dt) { var oReq = new XMLHttpRequest(); oReq.open('POST', baseUrl + '/bibliotheque/insert', true); oReq.onload = function(e){ if (this.status == 200) { showDone() Bibliotheque.loadBibliothequeDT(dt); }else{ showError(this.response); } }; oReq.send(); } }