[open-ils-commits] r10482 - in trunk/Open-ILS/web: . vandelay

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Aug 29 16:31:12 EDT 2008


Author: erickson
Date: 2008-08-29 16:31:08 -0400 (Fri, 29 Aug 2008)
New Revision: 10482

Added:
   trunk/Open-ILS/web/vandelay/
   trunk/Open-ILS/web/vandelay/vandelay.html
   trunk/Open-ILS/web/vandelay/vandelay.js
Log:
vandelay ui round 1.  supports queue create, marc file upload, queue process

Added: trunk/Open-ILS/web/vandelay/vandelay.html
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.html	                        (rev 0)
+++ trunk/Open-ILS/web/vandelay/vandelay.html	2008-08-29 20:31:08 UTC (rev 10482)
@@ -0,0 +1,83 @@
+<!--
+# Copyright (C) 2008  Georgia Public Library Service
+# Bill Erickson <erickson at esilibrary.com>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+-->
+<html>
+    <head>
+        <title>Vandelay</title>
+        <style type="text/css">
+            @import "/js/dojo/dojo/resources/dojo.css";
+            @import "/js/dojo/dijit/themes/tundra/tundra.css";
+            @import "/js/dojo/dijit/tests/css/dijitTests.css"; 
+            td { padding: 6px; }
+        </style>
+        <script type="text/javascript" djConfig="parseOnLoad: true" src="/js/dojo/dojo/dojo.js"></script>
+        <script type="text/javascript" src='vandelay.js'></script>
+    </head>
+    <body class="tundra">
+        <!-- MARC upload form -->
+        <div id='vl-marc-upload-div'>
+            <h1>Evergreen MARC File Upload</h1>
+            <form id="vl-marc-upload-form" enctype="multipart/form-data">
+                <input type='hidden' name='ses' id='vl-ses-input'/>
+                <br>
+                <table>
+                    <tr>
+                        <td>Queue Name</td>
+                        <td>
+                            <input type='text' dojoType='dijit.form.TextBox' id='vl-queue-name' size='32'></input>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>Record Type</td>
+                        <td>
+                            <select id='vl-record-type' dojoType='dijit.form.FilteringSelect'>
+                                <option value='bib'>Bibliographic Records</option>
+                                <option value='auth'>Authority Records</option>
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>Purpose</td>
+                        <td>
+                            <select name='purpose' dojoType='dijit.form.FilteringSelect'>
+                                <option value='import'>Import</option>
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>
+                            <span id="vl-file-label">File to Upload:</span><br>
+                            <span id="vl-file-uploading" style='display:none;'>Uploading...</span><br>
+                        </td>
+                        <td id='vl-input-td'>
+                            <input size='48' type="file" name="marc_upload">
+                        </td>
+                    </tr>
+                    <tr>
+                        <td colspan='2'>
+                            <span id="vl-upload-progress-span" style="display:none;">
+                                <div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
+                            </span>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td colspan='2' align='center'>
+                            <button dojoType="dijit.form.Button" onclick="batchUpload()">Upload</button>
+                        </td>
+                    </tr>
+                </table>
+            </form>
+        </div>
+    </body>
+</html>

Added: trunk/Open-ILS/web/vandelay/vandelay.js
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.js	                        (rev 0)
+++ trunk/Open-ILS/web/vandelay/vandelay.js	2008-08-29 20:31:08 UTC (rev 10482)
@@ -0,0 +1,117 @@
+/* ---------------------------------------------------------------------------
+# Copyright (C) 2008  Georgia Public Library Service
+# Bill Erickson <erickson at esilibrary.com>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# --------------------------------------------------------------------------- */
+dojo.require("dojo.parser");
+dojo.require("dojo.io.iframe"); 
+dojo.require("dijit.ProgressBar"); 
+dojo.require("dijit.form.Button"); 
+dojo.require("dijit.form.FilteringSelect"); 
+dojo.require("dojo.cookie");
+dojo.require("fieldmapper.Fieldmapper");
+dojo.require('openils.CGI');
+dojo.require('openils.User');
+dojo.require('openils.Event');
+
+var authtoken = dojo.cookie('ses') || new openils.CGI().param('ses');
+var VANDELAY_URL = '/vandelay';
+
+/**
+  * asynchronously upload a file of MARC records
+  */
+function uploadMARC(onload){
+    dojo.byId('vl-ses-input').value = authtoken;
+    dojo.style(dojo.byId('vl-input-td'),"display","none");
+    dojo.style(dojo.byId('vl-upload-progress-span'),"display","inline"); 
+
+    dojo.style(dojo.byId('vl-file-label'), 'display', 'none');
+    dojo.style(dojo.byId('vl-file-uploading'), 'display', 'inline');
+
+    dojo.io.iframe.send({
+        url: VANDELAY_URL,
+        method: "post",
+        handleAs: "html",
+        form: dojo.byId('vl-marc-upload-form'),
+        handle: function(data,ioArgs){
+            var content = data.documentElement.textContent;
+            var key = content.split(/\n/)[2]; /* XXX have to strip the headers.. (why?) */
+            dojo.style(dojo.byId('vl-input-td'),"display","inline");
+            dojo.style(dojo.byId('vl-upload-progress-span'),"display","none");
+            dojo.style(dojo.byId('vl-file-label'), 'display', 'inline');
+            dojo.style(dojo.byId('vl-file-uploading'), 'display', 'none');
+            onload(key);
+        }
+    });
+}	
+
+/**
+  * Creates a new vandelay queue
+  */
+function createQueue(queueName, type, onload) {
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.'+type+'_queue.create'],
+        {   async: true,
+            params: [authtoken, queueName, null, type],
+            oncomplete : function(r) {
+                var queue = r.recv().content();
+                if(e = openils.Event.parse(queue)) 
+                    return alert(e);
+                onload(queue.id());
+            }
+        }
+    );
+}
+
+/**
+  * Tells vendelay to pull a batch of records from the cache and explode them
+  * out into the vandelay tables
+  */
+function processSpool(key, queueId, type, onload) {
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.'+type+'.process_spool'],
+        {   async: true,
+            params: [authtoken, key, queueId],
+            oncomplete : function(r) {
+                var queue = r.recv().content();
+                if(e = openils.Event.parse(queue)) 
+                    return alert(e);
+                onload();
+            }
+        }
+    );
+}
+
+/**
+  * Create queue, upload MARC, process spool, load the newly created queue 
+  */
+function batchUpload() {
+    var queueName = dijit.byId('vl-queue-name').getValue();
+    var recordType = dijit.byId('vl-record-type').getValue();
+
+    var currentQueueId = null;
+
+    var handleProcessSpool = function() {
+        alert('records uploaded and spooled');
+    }
+
+    var handleUploadMARC = function(key) {
+        processSpool(key, currentQueueId, recordType, handleProcessSpool);
+    };
+
+    var handleCreateQueue = function(queueId) {
+        currentQueueId = queueId;
+        uploadMARC(handleUploadMARC);
+    };
+
+    createQueue(queueName, recordType, handleCreateQueue);
+}



More information about the open-ils-commits mailing list