[open-ils-commits] r10515 - trunk/Open-ILS/web/vandelay
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Sep 2 17:44:12 EDT 2008
Author: erickson
Date: 2008-09-02 17:44:07 -0400 (Tue, 02 Sep 2008)
New Revision: 10515
Modified:
trunk/Open-ILS/web/vandelay/vandelay.html
trunk/Open-ILS/web/vandelay/vandelay.js
Log:
plugged in bib import with progress bar. in a perfect world (with no collisions or holdings) you can import bibs
Modified: trunk/Open-ILS/web/vandelay/vandelay.html
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.html 2008-09-02 21:42:02 UTC (rev 10514)
+++ trunk/Open-ILS/web/vandelay/vandelay.html 2008-09-02 21:44:07 UTC (rev 10515)
@@ -29,6 +29,9 @@
<div id="vl-generic-progress" style='width:100%;text-align:center'>
<div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
</div>
+ <div id="vl-generic-progress-with-total" style='width:100%;text-align:center;display:none;'>
+ <div dojoType="dijit.ProgressBar" jsId='vlControlledProgressBar' style="width:200px"></div>
+ </div>
<!-- MARC upload form -->
<div id='vl-marc-upload-div' style='display:none;'>
@@ -87,13 +90,15 @@
<div id='vl-queue-div' style='display:none;height:100%;'>
<h1>Record Queue</h1><br/>
<script>
- var vlQueueGridLayout = [{
- cells : [[
- { name: 'Selected',
- get: vlQueueGridDrawSelectBox,
- }
- ]]
- }];
+ var vlQueueGridLayout;
+ function resetVlQueueGridLayout() {
+ vlQueueGridLayout = [{
+ cells : [[
+ {name: 'Selected', get: vlQueueGridDrawSelectBox },
+ {name: 'Import Time', field:'import_time'}
+ ]]
+ }];
+ }
</script>
<button dojoType='dijit.form.Button' onclick='vlSelectAllGridRecords'>Select All</button>
<button dojoType='dijit.form.Button' onclick='vlSelectNoGridRecords'>Select None</button>
Modified: trunk/Open-ILS/web/vandelay/vandelay.js
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.js 2008-09-02 21:42:02 UTC (rev 10514)
+++ trunk/Open-ILS/web/vandelay/vandelay.js 2008-09-02 21:44:07 UTC (rev 10515)
@@ -26,6 +26,13 @@
dojo.require('openils.User');
dojo.require('openils.Event');
+var globalDivs = [
+ 'vl-generic-progress',
+ 'vl-generic-progress-with-total',
+ 'vl-marc-upload-div',
+ 'vl-queue-div'
+];
+
var authtoken;
var VANDELAY_URL = '/vandelay';
var bibAttrDefs = [];
@@ -37,6 +44,7 @@
var attrMap = {};
var currentType;
var cgi = new openils.CGI();
+var currentQueueId = null;
/**
* Grab initial data
@@ -85,17 +93,16 @@
}
function displayGlobalDiv(id) {
- dojo.style(dojo.byId('vl-generic-progress'),"display","none");
- dojo.style(dojo.byId('vl-marc-upload-div'),"display","none");
- dojo.style(dojo.byId('vl-queue-div'),"display","none");
- dojo.style(dojo.byId(id),"display","block");
+ for(var i = 0; i < globalDivs.length; i++)
+ dojo.style(dojo.byId(globalDivs[i]), 'display', 'none');
+ dojo.style(dojo.byId(id),'display','block');
}
function runStartupCommands() {
- var queueParam = cgi.param('qid');
+ currentQueueId = cgi.param('qid');
currentType = cgi.param('qtype');
- if(queueParam)
- return retrieveQueuedRecords(currentType, queueParam, handleRetrieveRecords);
+ if(currentQueueId)
+ return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
displayGlobalDiv('vl-marc-upload-div');
}
@@ -149,14 +156,14 @@
* Tells vendelay to pull a batch of records from the cache and explode them
* out into the vandelay tables
*/
-function processSpool(key, queue, type, onload) {
+function processSpool(key, queueId, type, onload) {
fieldmapper.standardRequest(
['open-ils.vandelay', 'open-ils.vandelay.'+type+'.process_spool'],
{ async: true,
- params: [authtoken, key, queue.id()],
+ params: [authtoken, key, queueId],
oncomplete : function(r) {
- var queue = r.recv().content();
- if(e = openils.Event.parse(queue))
+ var resp = r.recv().content();
+ if(e = openils.Event.parse(resp))
return alert(e);
onload();
}
@@ -165,6 +172,9 @@
}
function retrieveQueuedRecords(type, queueId, onload) {
+ queuedRecords = [];
+ queuedRecordsMap = {};
+ resetVlQueueGridLayout();
fieldmapper.standardRequest(
['open-ils.vandelay', 'open-ils.vandelay.'+type+'_queue.records.retrieve.atomic'],
{ async: true,
@@ -180,7 +190,7 @@
*/
oncomplete: function(r){
var recs = r.recv().content();
- if(e = openils.Event.parse(recs))
+ if(e = openils.Event.parse(recs[0]))
return alert(e);
for(var i = 0; i < recs.length; i++) {
var rec = recs[i];
@@ -220,7 +230,7 @@
field:'attr.' + attr.code(),
get: getAttrValue
};
- if(attr.code().match(/title/i)) col.width = 'auto'; // this is hack.
+ //if(attr.code().match(/title/i)) col.width = 'auto'; // this is hack.
vlQueueGridLayout[0].cells[0].push(col);
}
@@ -258,18 +268,34 @@
dojo.byId(id).checked = false;
}
+var handleRetrieveRecords = function() {
+ buildRecordGrid(currentType);
+}
+
function vlImportSelectedRecords() {
+ displayGlobalDiv('vl-generic-progress-with-total');
+ var records = [];
for(var id in selectableGridRecords) {
- if(dojo.byId(id).checked) {
- var recId = selectableGridRecords[id];
- alert(recId);
+ if(dojo.byId(id).checked)
+ records.push(selectableGridRecords[id]);
+ }
+ fieldmapper.standardRequest(
+ ['open-ils.vandelay', 'open-ils.vandelay.'+currentType+'_record.list.import'],
+ { async: true,
+ params: [authtoken, records],
+ onresponse: function(r) {
+ var resp = r.recv().content();
+ if(e = openils.Event.parse(resp))
+ return alert(e);
+ vlControlledProgressBar.update({maximum:resp.total, progress:resp.progress});
+ },
+ oncomplete: function() {
+ return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+ }
}
- }
+ );
}
-var handleRetrieveRecords = function() {
- buildRecordGrid(currentType);
-}
/**
* Create queue, upload MARC, process spool, load the newly created queue
@@ -277,21 +303,20 @@
function batchUpload() {
var queueName = dijit.byId('vl-queue-name').getValue();
currentType = dijit.byId('vl-record-type').getValue();
- var currentQueue = null;
var handleProcessSpool = function() {
console.log('records uploaded and spooled');
- retrieveQueuedRecords(currentType, currentQueue.id(), handleRetrieveRecords);
+ retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
}
var handleUploadMARC = function(key) {
console.log('marc uploaded');
- processSpool(key, currentQueue, currentType, handleProcessSpool);
+ processSpool(key, currentQueueId, currentType, handleProcessSpool);
};
var handleCreateQueue = function(queue) {
console.log('queue created ' + queue.name());
- currentQueue = queue;
+ currentQueueId = queue.id();
uploadMARC(handleUploadMARC);
};
More information about the open-ils-commits
mailing list