| 
									
										
										
										
											2018-03-25 20:52:38 -04:00
										 |  |  | import server from './services/server.js'; | 
					
						
							| 
									
										
										
										
											2017-11-04 19:38:50 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-09 16:50:36 -04:00
										 |  |  | $(document).ready(() => { | 
					
						
							| 
									
										
										
										
											2017-11-30 19:58:00 -05:00
										 |  |  |     server.get('migration').then(result => { | 
					
						
							| 
									
										
										
										
											2017-10-09 16:50:36 -04:00
										 |  |  |         const appDbVersion = result.app_db_version; | 
					
						
							|  |  |  |         const dbVersion = result.db_version; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (appDbVersion === dbVersion) { | 
					
						
							|  |  |  |             $("#up-to-date").show(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $("#need-to-migrate").show(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $("#app-db-version").html(appDbVersion); | 
					
						
							|  |  |  |             $("#db-version").html(dbVersion); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 20:52:38 -05:00
										 |  |  | $("#run-migration").click(async () => { | 
					
						
							| 
									
										
										
										
											2017-10-09 16:50:36 -04:00
										 |  |  |     $("#run-migration").prop("disabled", true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#migration-result").show(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-30 19:58:00 -05:00
										 |  |  |     const result = await server.post('migration'); | 
					
						
							| 
									
										
										
										
											2017-11-28 20:52:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (const migration of result.migrations) { | 
					
						
							|  |  |  |         const row = $('<tr>') | 
					
						
							|  |  |  |             .append($('<td>').html(migration.db_version)) | 
					
						
							|  |  |  |             .append($('<td>').html(migration.name)) | 
					
						
							|  |  |  |             .append($('<td>').html(migration.success ? 'Yes' : 'No')) | 
					
						
							|  |  |  |             .append($('<td>').html(migration.success ? 'N/A' : migration.error)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!migration.success) { | 
					
						
							|  |  |  |             row.addClass("danger"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $("#migration-table").append(row); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-10-09 16:50:36 -04:00
										 |  |  | }); |