From 014282dac9b9f998570a14d974b116adda74b29b Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 29 Aug 2008 20:31:08 +0000 Subject: [PATCH] vandelay ui round 1. supports queue create, marc file upload, queue process git-svn-id: svn://svn.open-ils.org/ILS/trunk@10482 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/vandelay/vandelay.html | 83 ++++++++++++++++++++ Open-ILS/web/vandelay/vandelay.js | 117 ++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 Open-ILS/web/vandelay/vandelay.html create mode 100644 Open-ILS/web/vandelay/vandelay.js diff --git a/Open-ILS/web/vandelay/vandelay.html b/Open-ILS/web/vandelay/vandelay.html new file mode 100644 index 0000000000..f98d063f1a --- /dev/null +++ b/Open-ILS/web/vandelay/vandelay.html @@ -0,0 +1,83 @@ + + + + Vandelay + + + + + + +
+

Evergreen MARC File Upload

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Queue Name + +
Record Type + +
Purpose + +
+ File to Upload:
+
+
+ +
+ +
+ +
+
+
+ + diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js new file mode 100644 index 0000000000..327a1bf679 --- /dev/null +++ b/Open-ILS/web/vandelay/vandelay.js @@ -0,0 +1,117 @@ +/* --------------------------------------------------------------------------- +# Copyright (C) 2008 Georgia Public Library Service +# Bill Erickson +# +# 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); +} -- 2.43.2