vandelay ui round 1. supports queue create, marc file upload, queue process
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 29 Aug 2008 20:31:08 +0000 (20:31 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 29 Aug 2008 20:31:08 +0000 (20:31 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10482 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/vandelay/vandelay.html [new file with mode: 0644]
Open-ILS/web/vandelay/vandelay.js [new file with mode: 0644]

diff --git a/Open-ILS/web/vandelay/vandelay.html b/Open-ILS/web/vandelay/vandelay.html
new file mode 100644 (file)
index 0000000..f98d063
--- /dev/null
@@ -0,0 +1,83 @@
+<!--
+# Copyright (C) 2008  Georgia Public Library Service
+# Bill Erickson <erickson@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>
diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js
new file mode 100644 (file)
index 0000000..327a1bf
--- /dev/null
@@ -0,0 +1,117 @@
+/* ---------------------------------------------------------------------------
+# Copyright (C) 2008  Georgia Public Library Service
+# Bill Erickson <erickson@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);
+}