Changeset 5618


Ignore:
Timestamp:
09/01/14 11:33:31 (10 years ago)
Author:
olof.olsson@snd.gu.se
Message:

adding info dialog for error reports from backend

Location:
DASISH/t5.6/client/trunk
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/client/trunk

    • Property svn:global-ignores set to
      nbproject
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotation-service.js

    r5274 r5618  
    138138                },
    139139                complete: function(jqXHR, status, responseText) {
    140                     var response = jqXHR.responseText.match(/URI="(.+?)"/)[1].split('/');
    141                     var aid = response[response.length - 1];
    142 
     140                   
    143141                    annotationProxy.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
    144142                    annotationProxy.log("Status Code POST annotation request: " + jqXHR.status);
    145143                    annotationProxy.log("Response Body: " + jqXHR.responseText);
    146                     annotationProxy.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
    147 
    148                     annotationProxy.log("OID: " + oid);
    149                     annotationProxy.log("AID: " + aid);
    150                     // Firebug.Console.log(bitsObjectMng.Database.getObject({oid: oid}));
    151 
    152                     var aSql = 'UPDATE om_object SET dasish_aid = "' + aid + '" WHERE oid="' + oid + '"';
    153                     annotationProxy.log(aSql);
    154                     // insert request to local sqlite database where aid gets inserted
    155                     if(bitsObjectMng.Database._idExists('local', oid, true)){
    156                         var rtn = bitsObjectMng.Database.cmd('local', aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
    157                         annotationProxy.log('UPDATE of AID done in local');
    158                     }else if(bitsObjectMng.Database._idExists('_uncategorized', oid, true)){
    159                          var rtn = bitsObjectMng.Database.cmd('_uncategorized', aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
    160                          annotationProxy.log('UPDATE of AID done in _uncategorized');
     144                    annotationProxy.log("+ + + + + + + + + + + + + + + + + + + + + + + +");                   
     145                   
     146                    if(jqXHR.status === "200") {
     147                        var response = jqXHR.responseText.match(/URI="(.+?)"/)[1].split('/');
     148                        var aid = response[response.length - 1];
     149
     150
     151
     152                        annotationProxy.log("OID: " + oid);
     153                        annotationProxy.log("AID: " + aid);
     154                        // Firebug.Console.log(bitsObjectMng.Database.getObject({oid: oid}));
     155
     156                        var aSql = 'UPDATE om_object SET dasish_aid = "' + aid + '" WHERE oid="' + oid + '"';
     157                        annotationProxy.log(aSql);
     158                        // insert request to local sqlite database where aid gets inserted
     159                        if(bitsObjectMng.Database._idExists('local', oid, true)){
     160                            var rtn = bitsObjectMng.Database.cmd('local', aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
     161                            annotationProxy.log('UPDATE of AID done in local');
     162                        }else if(bitsObjectMng.Database._idExists('_uncategorized', oid, true)){
     163                             var rtn = bitsObjectMng.Database.cmd('_uncategorized', aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
     164                             annotationProxy.log('UPDATE of AID done in _uncategorized');
     165                        }
     166
     167                        // Database insert request is true if successful
     168                        // Firebug.Console.log(rtn);
     169                        annotationProxy.log('called cache stuff');
     170                        callback.call(undefined, aid); 
     171                    }else{
     172                        annotationProxy.showError({title:"Error posting annotation",info:jqXHR.responseText});
    161173                    }
    162                    
    163                     // Database insert request is true if successful
    164                     // Firebug.Console.log(rtn);
    165                     annotationProxy.log('called cache stuff');
    166                     callback.call(undefined, aid); 
    167                    
    168174                }
    169175            });
     
    184190                    annotationProxy.log("Error : " + thrownError);
    185191                   
     192                    annotationProxy.showError(jqXHR.responseText);
     193                   
    186194                },
    187195                complete: function(jqXHR, status, responseText) {
     
    212220                    annotationProxy.log("Error : " + thrownError);
    213221                   
     222                    annotationProxy.showError({title:"HTTP: "+jqXHR.status+" - Update annotation error", info:thrownError});
    214223                },
    215224                complete: function(jqXHR, status, responseText) {
     
    244253                           cache+'\n\n' +
    245254                           '--'+boundary+'--';
    246             annotationProxy.log(postBody);       
     255            annotationProxy.log(postBody);   
     256           
     257            xhr.addEventListener("error", function(errorSendingEvent) {
     258                annotationProxy.showError({title:"Cache Error", info:"Error sending cached representation to backend"});
     259            }, false);
     260           
    247261            xhr.send(postBody);
    248262        },
     
    264278                    });
    265279                    callback.call(undefined, targets);               
     280                },
     281                error: function(jqXHR, status, thrownError) {
     282                    annotationProxy.showError({title:"Resolving targets", info:"Error resolving targets for\n AID "+aid});
    266283                }
    267284            });         
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotations.wired.marker.js

    r5274 r5618  
    171171             });
    172172             */
     173        },
     174        showError: function(message) {
     175           
     176            if(typeof message != 'object') {
     177                var tmp = new Object();
     178                tmp.info = message;
     179                message = tmp;
     180            }
     181           
     182            message.info = message.info.substring(message.info.lastIndexOf("<body>")+6,message.info.lastIndexOf("</body>"));
     183            message.info = message.info.replace("<p>", "\n");
     184            message.info = message.info.replace("<h1>", "\n");
     185            message.info = message.info.replace("<h3>", "\n");
     186            message.info = message.info.replace("</p>", "\n");
     187            message.info = message.info.replace(/<(?:.|\n)*?>/gm, '');
     188           
     189            window.openDialog("chrome://markingcollection/content/infoDialog.xul", "",
     190                              "chrome,centerscreen,modal",
     191                              message);
     192           
     193            //alert(body);
    173194        }
    174195    }
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/infoDialog.xul

    r5586 r5618  
    11<?xml version="1.0" encoding="UTF-8" ?>
    22<?xml-stylesheet href="chrome://global/skin/" type="text/css" ?>
    3 <?xml-stylesheet href="chrome://markingcollection/skin/property.css" type="text/css" ?>
    4 <?xml-stylesheet href="chrome://markingcollection/skin/setting.css" type="text/css" ?>
    5 <!DOCTYPE wizard [
    6 <!ENTITY % overlayDTD   SYSTEM "chrome://markingcollection/locale/markingcollection.dtd" >
    7 %overlayDTD;
    8 <!ENTITY % markerCustomDTD SYSTEM "chrome://markingcollection/locale/markerCustom.dtd" >
    9 %markerCustomDTD;
    10 ]>
     3<!DOCTYPE overlay SYSTEM "chrome://markingcollection/locale/markingcollection.dtd">
    114<dialog
    12         id="mcImportTagDialog"
    13         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    14         title="&markingcollection.importTagAll;"
    15         buttons="accept,cancel"
    16         onload="mcImportTagService.init();"
    17         ondialogaccept="mcImportTagService.accept();"
    18         ondialogcancel="mcImportTagService.cancel();">
    19         <script type="application/x-javascript" src="chrome://global/content/nsUserSettings.js" />
    20         <script type="application/x-javascript" src="chrome://markingcollection/content/importtagDialog.js" />
    21         <stringbundleset id="mcStringBundles">
    22                 <stringbundle id="mcImportTagString" src="chrome://markingcollection/locale/markingcollection.properties" />
    23         </stringbundleset>
    24         <radiogroup id="mcImportTagRadiogroup">
    25                 <hbox>
    26                         <radio id="mcImportTagRadioH" label="HTML Tag" value="html" selected="true" align="start" oncommand="mcImportTagService.command(event);"/>
    27                         <listbox id="mcImportTagHtmlListbox" flex="1" rows="3" onselect="mcImportTagService.select(event);"/>
    28                 </hbox>
    29                 <hbox>
    30                         <radio id="mcImportTagRadioN" label="Other Tag" value="nohtml" align="start" oncommand="mcImportTagService.command(event);"/>
    31                         <listbox id="mcImportTagNohtmlListbox" flex="1" rows="3" disabled="true"/>
    32                 </hbox>
    33         </radiogroup>
     5    id="infoDialog"
     6    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     7    xmlns:html="http://www.w3.org/1999/xhtml"
     8    title="Info from annotator backend"
     9    buttons="accept"
     10    defaultButton="false"
     11    onload="infoDialogLoad()">
     12    <script type="application/x-javascript">
     13            <![CDATA[       
     14                function infoDialogLoad() {
     15                    //set info
     16                    document.getElementById("info").value = window.arguments[0].info; 
     17                   
     18                    if(window.arguments[0].title){
     19                        document.title = window.arguments[0].title;
     20                    }                 
     21                }
     22               
     23            ]]>
     24    </script>
     25    <textbox  id="info" width="350" height="400" style="background-color: transparent;" flex="1"
     26        multiline="true" readonly="true"
     27        onoverflow="this.height = this.inputField.scrollHeight;" />
    3428</dialog>
Note: See TracChangeset for help on using the changeset viewer.