Skip to content
Snippets Groups Projects
collaboraapi-iframe.js 812 B
Newer Older
  • Learn to ignore specific revisions
  • Alexey Lunin's avatar
    Alexey Lunin committed
    const axios = require("axios");
    
    
    function CollaboraAPI() {}
    
    
    Alexey Lunin's avatar
    Alexey Lunin committed
    CollaboraAPI.prototype.discovery = function() {
    
      const requestConfig = {
        url: `${window.COLLABORA_URL}hosting/discovery`,
    
    Alexey Lunin's avatar
    Alexey Lunin committed
        method: "GET"
    
      };
    
      return axios(requestConfig).then(response => {
    
    Alexey Lunin's avatar
    Alexey Lunin committed
        const apps = response.request.responseXML.querySelectorAll(
          "net-zone[name='external-http'] app"
        );
    
    
        const results = [];
        for (let i = 0; i < apps.length; i++) {
          const app = apps[i];
    
    Alexey Lunin's avatar
    Alexey Lunin committed
          const action = app.querySelector("action");
          const mimeType = app.getAttribute("name");
          const ext = action.getAttribute("ext");
          const urlsrc = action.getAttribute("urlsrc");
    
          results.push({
            mimeType,
            ext,
            urlsrc
          });
        }
    
    Alexey Lunin's avatar
    Alexey Lunin committed
        return results;
    
      });
    };
    
    module.exports = CollaboraAPI;