Changeset 4
- Timestamp:
- Jan 17, 2011, 3:49:20 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 9 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BaseFilters.groovy
r3 r4 49 49 // If a user is already logged in, let him continue 50 50 if( session.user && session.user != null ) { 51 // If we don't refresh the user object, an old hiberante session could still be attached to the object 52 // raising errors later on (Lazy loading errors) 53 session.user.refresh(); 54 51 55 return true; 52 56 } … … 78 82 if (!session.user){ // when not found, create a new user 79 83 session.user = new User(identifier: user.id, username: user.username).save(flush: true) 80 } 81 84 } 82 85 } catch(Exception e) { 83 86 log.error("Unable to fetch user from GSCF", e) -
trunk/grails-app/controllers/nl/tno/metagenomics/AssayController.groovy
r3 r4 433 433 } 434 434 435 /**436 * Updates existing run437 */438 def updateRun = {439 // load study with id specified by param.id440 def assay = Assay.get(params.id as Long)441 442 if (!assay) {443 flash.message = "No assay found with id: $params.id"444 redirect('action': 'errorPage')445 return446 }447 448 if( !params.run_id ) {449 flash.message = "No run id given"450 redirect(action: 'show', id: params.id)451 return452 }453 454 def run455 456 try {457 run = Run.findById( params.run_id as Long )458 } catch( Exception e ) {459 throw e460 flash.message = "Incorrect run id given: "461 redirect(action: 'show', id: params.id)462 return463 }464 465 // Set properties to the run466 params.parameterFile = params.editParameterFile467 run.setPropertiesFromForm( params );468 469 if( run.save() ) {470 flash.message = "Run succesfully saved";471 } else {472 flash.error = "Run could not be saved: " + run.getErrors();473 }474 475 redirect( action: 'show', id: params.id)476 }477 478 435 def errorPage = { 479 436 render "An error has occured. $flash.message" -
trunk/grails-app/controllers/nl/tno/metagenomics/RunController.groovy
r2 r4 7 7 class RunController { 8 8 def fileService 9 10 /** 11 * Shows information about this run in dialog style 12 */ 13 def show = { 14 Run run = Run.get( params.id as long ); 15 Assay assay = Assay.get( params.assayId as long ); 16 17 if( !run ) { 18 render "Run not found"; 19 return 20 } 21 22 if( !assay ) { 23 render "Assay not found"; 24 return 25 } 26 27 [assay: assay, run: run] 28 } 29 30 /** 31 * Shows a form to edit the specified run in dialog mode 32 */ 33 def editForm = { 34 Run run = Run.get( params.id as long ); 35 Assay assay = Assay.get( params.assayId as long ); 36 37 if( !run ) { 38 render "Run not found"; 39 return 40 } 41 42 if( !assay ) { 43 render "Assay not found"; 44 return 45 } 46 47 [assay: assay, run: run] 48 } 9 49 10 50 def create = { … … 26 66 redirect( controller: "assay", action: "show", id: params.id ) 27 67 } 68 69 def update = { 70 if( !params.assayId ) { 71 flash.error = "No assay id given" 72 redirect(controller: 'assay', action: 'errorpage') 73 return 74 } 75 def assay = Assay.get(params.assayId as Long) 76 77 // load run with id specified by param.id 78 if (!assay) { 79 flash.message = "No assay found with id: ${params.assayId}" 80 redirect(controller: 'assay', 'action': 'errorPage') 81 return 82 } 83 84 85 def run 86 87 try { 88 run = Run.get( params.id as Long ); 89 } catch( Exception e ) { 90 throw e 91 flash.message = "Incorrect run id given: " 92 redirect(controller: 'assay', action: 'show', id: params.assayId) 93 return 94 } 95 96 // Set properties to the run 97 params.parameterFile = params.editParameterFile 98 run.setPropertiesFromForm( params ); 99 100 if( run.save() ) { 101 flash.message = "Run succesfully saved"; 102 } else { 103 flash.error = "Run could not be saved: " + run.getErrors(); 104 } 105 106 redirect( controller: 'assay', action: 'show', id: params.assayId) 107 } 108 109 def delete = { 110 Run run = Run.get( params.id as long ); 111 112 // Don't remove runs for which data exists 113 if( run.sequenceData?.size() ) { 114 flash.message = "Run could not be deleted because samples are associated with it."; 115 redirect( controller: "assay", action: "show", id: params.assayId ) 116 } 117 118 // Remove all associations 119 run.assays.each { 120 run.removeFromAssays( it ); 121 } 122 123 def name = run.name 124 run.delete(); 125 flash.message = "Run " + name + " has been deleted from the system." 126 127 redirect( controller: "assay", action: "show", id: params.assayId ) 128 129 } 28 130 } -
trunk/grails-app/controllers/nl/tno/metagenomics/StudyController.groovy
r3 r4 5 5 def gscfService 6 6 def fileService 7 def trashService 7 8 8 9 def index = { … … 16 17 fileService.cleanDirectory(); 17 18 19 // Clean the trash if needed 20 trashService.cleanTrash(); 21 18 22 // Filter studies for the ones the user is allowed to see 19 def studies = Study.findAll(); 20 [studies: studies.findAll { it.canRead( session.user ) }, gscfAddUrl: gscfService.urlAddStudy(), lastSynchronized: synchronizationService.lastFullSynchronization ] 23 def studies = Study.list(); 24 [studies: studies.findAll { it.canRead( session.user ) }, 25 gscfAddUrl: gscfService.urlAddStudy(), 26 lastSynchronized: synchronizationService.lastFullSynchronization ] 21 27 } 22 28 -
trunk/grails-app/controllers/nl/tno/metagenomics/integration/RestController.groovy
r3 r4 343 343 render url as JSON 344 344 } 345 } .metagenomics.baseURL345 } 346 346 347 347 /***************************************************/ -
trunk/grails-app/controllers/nl/tno/metagenomics/integration/SynchronizeController.groovy
r3 r4 17 17 // /synchronize -> fails with an error, redirects to /study 18 18 // etc... 19 synchronizationService.lastFullSynchronization = new Date();19 // synchronizationService.lastFullSynchronization = new Date(); 20 20 21 21 [ url: redirectUrl ] … … 27 27 28 28 synchronizationService.fullSynchronization(); 29 29 30 30 render ""; 31 31 } -
trunk/grails-app/domain/nl/tno/metagenomics/AssaySample.groovy
r3 r4 142 142 _averageQuality = -1; 143 143 } 144 145 /** 146 * Check whether this assay-sample combination contains information that should be saved in trash on a delete 147 * @return 148 */ 149 public boolean containsData() { 150 return tagSequence || oligoNumber || numFiles() > 0; 151 } 152 153 /** 154 * Move information that should be kept on delete to another assaySample object. 155 * 156 * N.B. The sequencedata objects are really moved, so removed from the original object! 157 * 158 * @param otherAssaySample Object to move 159 */ 160 public void moveValuableDataTo( AssaySample otherAssaySample ) { 161 // Copy properties 162 otherAssaySample.tagSequence = tagSequence; 163 otherAssaySample.oligoNumber = oligoNumber; 164 165 // Move attached data 166 def dataList = sequenceData?.toList() 167 def otherAssay = otherAssaySample.assay; 168 169 if( dataList && dataList.size() > 0 ) { 170 for( def j = dataList.size() - 1; j >= 0; j-- ) { 171 // Check whether the run of this sequenceData object is also connected to the assay 172 def run = dataList[j].run; 173 174 if( !otherAssay.runs || !otherAssay.runs.contains( run ) ) { 175 otherAssay.addToRuns( run ); 176 } 177 178 // Copy data 179 dataList[j].sample = otherAssaySample; 180 this.removeFromSequenceData( dataList[j] ); 181 otherAssaySample.addToSequenceData( dataList[j] ); 182 dataList[j].save(); 183 } 184 } 185 } 144 186 } -
trunk/grails-app/domain/nl/tno/metagenomics/Study.groovy
r2 r4 13 13 String studyToken 14 14 String name 15 16 // Set to true only on the specific study object that acts as 17 // a trash can for deleted objects. If objects are deleted in GSCF but still 18 // contain data in this module, they will be moved to the trashcan. 19 Boolean trashcan = false 15 20 16 21 // If a study is set to be dirty, it should be updated … … 31 36 static constraints = { 32 37 studyToken(unique:true) 38 trashcan(nullable:true) 39 isDirty(nullable:true) 33 40 } 34 41 … … 70 77 return authorization.isOwner 71 78 } 79 72 80 } -
trunk/grails-app/services/nl/tno/metagenomics/FastaService.groovy
r3 r4 131 131 132 132 // Best matching sample 133 // TODO: Implement method to search for sample matches in a provided excel sheet 133 134 def sampleIdx = fuzzySearchService.mostSimilarWithIndex( matchWith, samples.sample.name ); 134 135 def assaySample = null … … 316 317 lookingForFirstQualityScores = false; 317 318 318 quality = updateQuality( quality, line ); 319 // Don't compute average quality because it takes too much time 320 //quality = updateQuality( quality, line ); 319 321 } 320 322 } else { 321 quality = updateQuality( quality, line ); 323 // Don't compute average quality because it takes too much time 324 //quality = updateQuality( quality, line ); 322 325 } 323 326 -
trunk/grails-app/services/nl/tno/metagenomics/integration/GscfService.groovy
r3 r4 213 213 * @return ArrayList 214 214 */ 215 public HashMap getAuthorizationLevel(String sessionToken, String studyToken) {215 public HashMap getAuthorizationLevel(String sessionToken, String studyToken) throws ResourceNotFoundException { 216 216 ArrayList list 217 217 -
trunk/grails-app/services/nl/tno/metagenomics/integration/SynchronizationService.groovy
r3 r4 7 7 class SynchronizationService { 8 8 def gscfService 9 def trashService 9 10 10 11 String sessionToken = "" // Session token to use for communication … … 81 82 return 82 83 83 def previousEager = eager84 eager = true85 synchronizeStudies();86 eager = previousEager84 def previousEager = this.eager 85 this.eager = true 86 this.synchronizeStudies(); 87 this.eager = previousEager 87 88 88 89 SynchronizationService.lastFullSynchronization = new Date(); … … 95 96 public ArrayList<Study> synchronizeStudies() { 96 97 if( !performSynchronization() ) 97 return Study. findAll()98 return Study.list() 98 99 99 100 // When eager fetching is enabled, ask for all studies, otherwise only ask for studies marked dirty … … 102 103 def studies 103 104 if( eager ) { 104 studies = Study.findAll() 105 studies = Study.list().findAll { !it.trashcan }; 106 log.trace "Eager synchronization: " + studies.size(); 105 107 } else { 106 108 studies = Study.findAllWhere( [isDirty: true] ); 107 } 108 109 log.trace "Default synchronization: " + studies.size() 110 } 111 109 112 // Perform no synchronization if no studies have to be synchronized 110 113 // Perform synchronization on only one study directly, because otherwise … … 235 238 return null 236 239 240 // Trashcan should never be synchronized 241 if( study.trashcan ) 242 return study 243 237 244 // If the study hasn't changed, don't update anything 238 245 if( !eager && !study.isDirty ) … … 249 256 } catch( ResourceNotFoundException e ) { 250 257 // Study can't be found within GSCF. 251 // TODO: How to handle the data that remains 252 study.delete() 258 trashService.moveToTrash( study ); 253 259 return null 254 260 } catch( Exception e ) { // All other exceptions … … 335 341 for( int i = numStudyAssays - 1; i >= 0; i-- ) { 336 342 def existingAssay = studyAssays[i]; 337 338 existingAssay.delete()339 study.removeFromAssays( existingAssay );343 344 // Move data to trash 345 trashService.moveToTrash( existingAssay ); 340 346 } 341 347 … … 408 414 409 415 // The assay has been removed 410 // TODO: What to do with the data associated with this Assay (e.g. sequences)? See also GSCF ticket #255 411 existingAssay.delete(); 412 study.removeFromAssays( existingAssay ); 416 trashService.moveToTrash( existingAssay ); 413 417 } 414 418 } … … 446 450 } catch( ResourceNotFoundException e ) { 447 451 // Study has been deleted, remove all authorization on that study 448 // TODO: handle deletion449 452 log.trace( "Study " + study.studyToken + " has been deleted. Remove all authorization on that study") 450 451 Auth.findAllByStudy( study ).each { 452 it.delete() 453 } 453 trashService.moveToTrash( study ); 454 454 455 455 return null … … 501 501 } catch( ResourceNotFoundException e ) { 502 502 // Assay can't be found within GSCF. 503 // TODO: How to handle the data that remains 504 assay.delete() 503 trashService.moveToTrash( assay ); 505 504 return null 506 505 } catch( Exception e ) { // All other exceptions are thrown … … 511 510 } 512 511 513 // If new assay is empty, something went wrong512 // If new assay is empty, this means that the assay does exist, but now belongs to another module. Remove it from our system 514 513 if( newAssay.size() == 0 ) { 515 throw new Exception( "No data returned for assay " + assay.assayToken + " but no error has occurred either. Please contact your system administrator" ); 514 log.info( "No data is returned by GSCF for assay " + assay.assayToken + "; probably the assay is connected to another module." ) 515 trashService.moveToTrash( assay ); 516 516 return null; 517 517 } … … 577 577 } catch( ResourceNotFoundException e ) { 578 578 // Assay can't be found within GSCF. Samples will be removed 579 // TODO: How to handle the data that remains 580 assay.removeAssaySamples(); 579 trashService.moveToTrash( assay ); 581 580 582 581 return null … … 593 592 return [] 594 593 } 595 596 594 597 595 synchronizeAssaySamples( assay, newSamples ); … … 678 676 679 677 // The sample has been removed 680 // TODO: What to do with the data associated with this AssaySample (e.g. sequences)? See also GSCF ticket #255 681 existingSample.delete(); 682 assay.removeFromAssaySamples( existingSample ); 678 trashService.moveToTrash( existingSample.sample ); 683 679 } 684 680 } -
trunk/grails-app/taglib/nl/tno/metagenomics/UploadTagLib.groovy
r2 r4 23 23 out << '<script type="text/javascript">'; 24 24 out << ' $(document).ready( function() { '; 25 out << ' var filename = "' + attrs.value+ '";';25 out << ' var filename = "' + ( attrs.value ?: '' ) + '";'; 26 26 out << ' fileUploadField( "' + attrs.name + '", ' + ( multiple ? 'true' : 'false' ) + ( attrs.onUpload ? ', function(params) { ' + attrs.onUpload + '(params); }' : '' ) + ( attrs.onDelete ? ', function(params) { ' + attrs.onDelete + '(params); }' : '' ) + ');'; 27 27 out << ' if( filename != "" ) {'; -
trunk/grails-app/views/assay/_addRunDialog.gsp
r2 r4 31 31 <th nowrap>date</th> 32 32 <th nowrap>other assays</th> 33 <th class="nonsortable"></th> 33 34 </tr> 34 35 </thead> … … 49 50 </g:else> 50 51 </td> 52 <td> 53 <g:if test="${run.sequenceData?.size()}"> 54 <img src="${fam.icon(name: 'delete')}" class="disabled" title="You can't delete this run because samples are associated with this run." /> 55 </g:if> 56 <g:else> 57 <g:if test="${run.assays?.size() > 0}"> 58 <g:link onClick="return confirm( 'Are you sure you want to delete this run from the system? If you delete this run, it will also be deleted from the other assays it is associated to!' );" controller="run" action="delete" id="${run.id}" params="[assayId: assay.id]"><img src="${fam.icon(name: 'delete')}" /></g:link> 59 </g:if> 60 <g:else> 61 <g:link onClick="return confirm( 'Are you sure you want to delete this run from the system?' );" controller="run" action="delete" id="${run.id}" params="[assayId: assay.id]"><img src="${fam.icon(name: 'delete')}" /></g:link> 62 </g:else> 63 </g:else> 64 </td> 51 65 </tr> 52 66 </g:each> -
trunk/grails-app/views/assay/show.gsp
r3 r4 27 27 </g:each> 28 28 29 $(function() { 30 $('.uploadedFile').each( function( idx, el ) { 29 function initializeUploadedFiles( selector ) { 30 if( selector == undefined ) 31 selector = ""; 32 33 $( selector + ' .uploadedFile').each( function( idx, el ) { 31 34 $(el).html( createFileHTML( $(el).text(), 'getPermanent' ) ); 32 35 }); 33 }); 36 } 37 38 // Initializefiles on load 39 $(function() { initializeUploadedFiles(); }); 34 40 </script> 35 41 </head> … … 97 103 <g:render template="addFilesDialog" model="[assay: assay]" /> 98 104 </g:if> 99 < g:render template="showSampleDialog" model="[assay: assay]" />105 <div id="showSampleDialog" class="dialog"></div> 100 106 </g:else> 101 107 … … 140 146 </td> 141 147 <td class="button"><a href="#" onClick="showEditRunDialog( ${run.id}, '${run.name?.encodeAsJavaScript()}', '${run.date ? run.date.format( 'yyyy-mm-dd' ).encodeAsJavaScript() : ''}', '${run.machine?.encodeAsJavaScript()}', '${run.supplier?.encodeAsJavaScript()}', '${run.parameterFile?.encodeAsJavaScript()}' ); return false;"><img src="${fam.icon(name: 'application_edit')}" /></a></td> 142 <td class="button"><g:link onClick="return confirm( 'Are you sure you want to remove the selected run from this assay?' );" controller="assay" action="removeRun" id="${assay.id}" params="${[run_id: run.id]}" ><img src="${fam.icon(name: 'application_delete')}" /></g:link></td> 148 <td class="button"> 149 <g:if test="${run.samples(assay.id).size()}"> 150 <img src="${fam.icon(name: 'application_delete')}" class="disabled" title="You can't remove this assay because sequences from this assay are coupled to this run." /> 151 </g:if> 152 <g:else> 153 <g:link onClick="return confirm( 'Are you sure you want to remove the selected run from this assay?' );" controller="assay" action="removeRun" id="${assay.id}" params="${[run_id: run.id]}" ><img src="${fam.icon(name: 'application_delete')}" /></g:link> 154 </g:else> 155 </td> 143 156 </tr> 144 157 </g:each> … … 149 162 <input type="button" value="Add run" onClick="showAddRunDialog();"> 150 163 <g:render template="addRunDialog" model="[assay: assay]" /> 151 < g:render template="editRunDialog" model="[assay: assay]" />164 <div id="editRunDialog" class="dialog"></div> 152 165 </g:if> 153 <g:render template="showRunDialog" model="[assay: assay]" /> 154 166 <div id="showRunDialog" class="dialog"></div> 155 167 </body> 156 168 </html> -
trunk/web-app/css/metagenomics.css
r3 r4 473 473 display: none; 474 474 } 475 476 .disabled { 477 opacity: 0.5; 478 -moz-opacity:0.5; 479 -khtml-opacity:0.5; 480 filter:alpha(opacity=50); 481 } 482 483 .ui-dialog a:link, .ui-dialog a:visited, .ui-dialog a:hover { 484 color: #006dba; 485 text-decoration: none; 486 } -
trunk/web-app/js/assay.show.runDialogs.js
r2 r4 42 42 43 43 // Initialize date picker for add run dialog 44 $( "#run_date , #edit_run_date" ).datepicker({44 $( "#run_date" ).datepicker({ 45 45 changeMonth: true, 46 46 changeYear: true, … … 66 66 */ 67 67 function showEditRunDialog(id, name, date, machine, supplier, parameterFile) { 68 $( '#edit_run_id' ).val( id ); 69 70 $( '#edit_run_name' ).val( name ); 71 $( '#edit_run_date' ).val( date ); 72 $( '#edit_run_machine' ).val( machine ); 73 $( '#edit_run_supplier' ).val( supplier ); 74 75 editFile( 'editParameterFile', parameterFile) 76 $( "#editRunDialog" ).dialog( "open" ); 68 $( "#editRunDialog" ).load( baseUrl + "/run/editForm/" + id + "?assayId=" + assayId, [], function() { 69 // Initialize date picker for add run dialog 70 $( "#edit_run_date" ).datepicker({ 71 changeMonth: true, 72 changeYear: true, 73 dateFormat: 'yy-mm-dd' 74 }); 75 76 $( "#editRunDialog" ).dialog( "open" ); 77 } ); 77 78 } 78 79 -
trunk/web-app/js/assay.show.showRunDialog.js
r3 r4 15 15 */ 16 16 function showRun( id ) { 17 $( '#showRunDialog div.showRun' ).hide() 18 $( '#showRunDialog div#showRun_' + id ).show() 19 20 var titleEl = $( '#showRunDialog div#showRun_' + id + ' h2' ).first(); 21 titleEl.hide(); 22 $( "#showRunDialog" ).dialog( "option", "title", "Run " + titleEl.text() ); 23 $( "#showRunDialog" ).dialog( "open" ); 17 $( "#showRunDialog" ).load( baseUrl + "/run/show/" + id + "?assayId=" + assayId, [], function() { 18 var titleEl = $( '#showRunDialog h2' ).first(); 19 titleEl.hide(); 20 21 initializeUploadedFiles( '#showRunDialog' ); 22 initializePagination( '#showRunDialog' ); 23 24 $( "#showRunDialog" ).dialog( "option", "title", "Run " + titleEl.text() ); 25 $( "#showRunDialog" ).dialog( "open" ); 26 } ); 24 27 } -
trunk/web-app/js/assay.show.showSampleDialog.js
r3 r4 15 15 */ 16 16 function showSample( id ) { 17 $( '#showSampleDialog div.showSample' ).hide() 18 $( '#showSampleDialog div#showSample_' + id ).show() 19 20 var titleEl = $( '#showSampleDialog div#showSample_' + id + ' h2' ).first(); 21 titleEl.hide(); 22 $( "#showSampleDialog" ).dialog( "option", "title", "Sample " + titleEl.text() ); 23 $( "#showSampleDialog" ).dialog( "open" ); 17 $( "#showSampleDialog" ).load( baseUrl + "/assaySample/show/" + id, [], function() { 18 var titleEl = $( '#showSampleDialog h2' ).first(); 19 titleEl.hide(); 20 21 initializeUploadedFiles( "#showSampleDialog" ); 22 initializePagination( "#showSampleDialog" ); 23 24 $( "#showSampleDialog" ).dialog( "option", "title", "Sample " + titleEl.text() ); 25 $( "#showSampleDialog" ).dialog( "open" ); 26 } ); 24 27 } -
trunk/web-app/js/paginate.js
r2 r4 1 $(function() { 2 $('.paginate').each(function(idx, el) { 3 var $el = $(el); 4 $el.dataTable({ 5 bJQueryUI: true, 6 bFilter: false, 7 bLengthChange: false, 8 iCookieDuration: 86400, // Save cookie one day 9 sPaginationType: 'full_numbers', 10 iDisplayLength: 10, // Number of items shown on one page. 11 aoColumnDefs: [ 12 { "bSortable": false, "aTargets": ["nonsortable"] } // Disable sorting on all columns with th.nonsortable 13 ] 14 }); 15 }); 16 17 // Remove the top bar of the datatable and hide pagination with only one page 18 $(".dataTables_wrapper").each(function(idx, el) { 19 var $el = $(el); 20 21 // Hide pagination if only one page is present (that is: if no buttons can be clicked) 22 if($el.find('span span.ui-state-default:not(.ui-state-disabled)').size() == 0 ){ 23 $el.find('div.fg-toolbar').css( 'display', 'none' ); 24 } else { 25 $el.find('div.fg-toolbar').css( 'display', 'block' ); 26 $el.find( 'div.ui-toolbar' ).first().hide(); 27 28 // Check whether a h1, h2 or h3 is present above the table, and move it into the table 29 /* 30 var $previousElement = $el.prev(); 31 if( $previousElement != undefined && $previousElement.get(0) != undefined ) { 32 var tagName = $previousElement.get(0).tagName.toLowerCase(); 33 if( tagName == "h1" || tagName == "h2" || tagName == "h3" ) { 34 // Put the margin that was on the title onto the table 35 $el.css( "margin-top", $previousElement.css( "margin-top" ) ); 36 $previousElement.css( "margin-top", '4px' ); 37 $previousElement.css( "marginBottom", '4px' ); 38 39 // If so, move the element into the table 40 $previousElement.remove(); 41 $el.find( 'div.ui-toolbar' ).first().append( $previousElement ); 42 } 43 } 44 */ 45 } 1 function initializePagination( selector ) { 2 if( selector == undefined ) { 3 selector = '' 4 } 5 6 $( selector + ' .paginate').each(function(idx, el) { 7 var $el = $(el); 8 $el.dataTable({ 9 bJQueryUI: true, 10 bFilter: false, 11 bLengthChange: false, 12 iCookieDuration: 86400, // Save cookie one day 13 sPaginationType: 'full_numbers', 14 iDisplayLength: 10, // Number of items shown on one page. 15 aoColumnDefs: [ 16 { "bSortable": false, "aTargets": ["nonsortable"] } // Disable sorting on all columns with th.nonsortable 17 ] 46 18 }); 47 19 }); 20 21 // Remove the top bar of the datatable and hide pagination with only one page 22 $( selector + " .dataTables_wrapper").each(function(idx, el) { 23 var $el = $(el); 24 25 // Hide pagination if only one page is present (that is: if no buttons can be clicked) 26 if($el.find('span span.ui-state-default:not(.ui-state-disabled)').size() == 0 ){ 27 $el.find('div.fg-toolbar').css( 'display', 'none' ); 28 } else { 29 $el.find('div.fg-toolbar').css( 'display', 'block' ); 30 $el.find( 'div.ui-toolbar' ).first().hide(); 31 32 // Check whether a h1, h2 or h3 is present above the table, and move it into the table 33 /* 34 var $previousElement = $el.prev(); 35 if( $previousElement != undefined && $previousElement.get(0) != undefined ) { 36 var tagName = $previousElement.get(0).tagName.toLowerCase(); 37 if( tagName == "h1" || tagName == "h2" || tagName == "h3" ) { 38 // Put the margin that was on the title onto the table 39 $el.css( "margin-top", $previousElement.css( "margin-top" ) ); 40 $previousElement.css( "margin-top", '4px' ); 41 $previousElement.css( "marginBottom", '4px' ); 42 43 // If so, move the element into the table 44 $previousElement.remove(); 45 $el.find( 'div.ui-toolbar' ).first().append( $previousElement ); 46 } 47 } 48 */ 49 } 50 }); 51 52 } 53 54 $(function() { initializePagination(); });
Note: See TracChangeset
for help on using the changeset viewer.