xmosaicframe: add url and xhr on context for view

authorSamuel Trégouët <samuel.tregouet@logilab.fr>
changeseta7a535fa6d95
branchdefault
phasepublic
hiddenno
parent revision#a142fc986d0c xmosaicframe: switch argument in done callback for ajax call
child revision#46d371948774 pdfview: add basic pdfview (closes #289639)
files modified by this revision
components/xmosaicframe/xmosaicframe.es6
# HG changeset patch
# User Samuel Trégouët <samuel.tregouet@logilab.fr>
# Date 1427976459 -7200
# Thu Apr 02 14:07:39 2015 +0200
# Node ID a7a535fa6d957769ed81165c7e818f34d6485d79
# Parent a142fc986d0cefeb7996354b631c334b87f344e2
xmosaicframe: add url and xhr on context for view

diff --git a/components/xmosaicframe/xmosaicframe.es6 b/components/xmosaicframe/xmosaicframe.es6
@@ -84,11 +84,13 @@
1 
2 
3      function queryUpdated(host, ownerDocument, registry) {
4          let sourceviews = registry.views[host.dataset.source],
5              frameContext = {
6 -                rset: null
7 +                rset: null,     // rset returned by the server
8 +                reqUrl: null,   // full url built from the data-query attribute
9 +                xhr: null       // request emited
10              };
11 
12          function neo4jFetch(baseurl, query) {
13              return $.ajax({
14                  url: baseurl,
@@ -138,10 +140,11 @@
15          }
16 
17          function httpFetch(baseurl, query) {
18              // join baseurl and query with a `/`
19              var url = baseurl.replace(/\/$/, '') + '/' + query.replace(/^\//, '');
20 +            frameContext.reqUrl = url;
21              return $.ajax({
22                  url: url,
23                  type: "HEAD"
24              });
25          }
@@ -198,10 +201,11 @@
26                  fetcher = httpFetch;
27              }
28              fetcher(host.dataset.baseurl, host.dataset.query)
29                  .done(function(data, status, xhr) {
30                      frameContext.rset = data;
31 +                    frameContext.xhr = xhr;
32                      let vid = host.dataset.vid || 'table';
33                      applyView(vid, frameContext);
34                  })
35                  .fail(function(xhr, err, msg) {
36                      console.log(xhr, err, msg);