view src/main/webapp/pages/branchPage.jsp @ 62:824b808a7481

improvements and bug fixed
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 18 Jul 2016 17:35:32 +0200
parents 90d5e86c157d
children b27a99201cbe
line wrap: on
line source

<%@page import="de.mpiwg.gazetteer.dataverse.bo.VDCUser"%>
<%@page import="de.mpiwg.gazetteer.bo.LGBranch"%>
<%@page import="de.mpiwg.gazetteer.bo.LGFile"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="de.mpiwg.gazetteer.db.DBSection"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />

<html>
<head>

	<jsp:include page="../componentes/headContent.jsp"/>	
	<%
		sessionBean.getBranchPage().loadParameters(request, response);
		if(request.getParameter("branchId") != null){
			sessionBean.getBranchPage().loadBranch(request.getParameter("branchId"));
		}
	%>
	<script>
		  $(function() {
			  
			    $( "#dialogDataverse" ).dialog({
			        autoOpen: false,
			        modal: true,
			        width: 600,
			        position: { my: "center", at: "top", of: window },
			        hide: {
			          effect: "explode",
			          duration: 1000
			        }
				});			
				
				$( ".get-studies" ).click(function() {
					var fileId = $( this ).data('file-id');
					
					var url0 = "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/getDataverseForm.jsp?fileId=" + fileId;

					$.ajax( url0 )
					.done(function(data) {
						$( "#dialogDataverseTable" ).replaceWith(data);
						$( "#dialogDataverse" ).dialog( "open" );
					})
				  	.fail(function() {
				    	console.error("Error calling: " + query);
				  	})
					
			    });					  
			  
			  
			 var dialog = $( "#dialogAddContributors" ).dialog(
					{autoOpen: false}
		  	);	  
			 
			$( "#addContributors" ).button().on( "click", function() {
			        dialog.dialog( "open" );
			});	 
		  });
		  
		  
		  function updatePage() {
				var text = getCookie();
			    
			    if (text == "1") {
			        setCookie("0");
			        setAction('forceReloadBranch', 'branchForm');

			        document.forms['branchForm'].submit();
			    }
				
			    setTimeout(updatePage, 1000);
			}
			updatePage();
			
		  
	</script>
	
</head>

<body>
	<jsp:include page="../componentes/template.jsp"/>
	
	<div id="dialogDataverse" title="Select a Dataset to publish your File" >
	  <div id="dialogDataverseTable"></div>
	</div>		

	<div id="page">
		
		<% if(sessionBean.getUser() == null) { %>
			<label class="subTitel">You must login!</label>
		<% } else { %>
		
			<% if(sessionBean.getBranchPage().getBranch() != null) { %>
			<div class="subTitel">Task Details
				<form name="branchForm" action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
					method="post">
					<input name="bean" type="hidden" value="branchBean" />
					<input type="image"
						onclick="setAction('forceReloadBranch', 'branchForm')"
						src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/>
											
				</form>
				
			</div>		
						
			<div id="dialogAddContributors" title="Select a new Contributors:">
				<form name="contributorsForm" id="contributorsForm"
						action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
						method="post">
						<input name="bean" type="hidden" value="branchBean" /> 
					<table>
						<% for(VDCUser user : sessionBean.getBranchPage().getSuggestionUserList()) { %>
							<tr>
								<td><a href="#" onclick="setAction0('addContributor', 'contributorsForm', 'userId', <%=user.getId() %>);document.getElementById('contributorsForm').submit();"><%=user.getUserName()%></a></td>
							</tr>
						<% } %>
					</table>
				</form>
			</div>		
			<% } %>
		
				<% if(sessionBean.getBranchPage().getBranch() == null) { %>
					<label>Task not found!</label>
				<% } else { %>
				
					<table>
						<tr>
							<td><label class="subTitel">General Information</label></td>
							<td>
								<table class="tableComponent">
									<tr>
										<td><label>Task Id</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getId() %></label></td>
									</tr>
									<tr>
										<td><label>Label</label></td>
										<td>
											<form name="branchForm1" id="branchForm1"
												action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
												method="post">
												<input name="bean" type="hidden" value="branchBean" />
												<input type="text" name="branchLabel" size="60" maxlength="250" value="<%=sessionBean.getBranchPage().getBranch().getLabel() %>" />
												<input type="image" onclick="setAction('updateLabel', 'branchForm1');" 
													src="<%=sessionBean.getApplicationBean().getSaveImage()%>" width="15" height="15"/>	
											
											</form>
											
										</td>
									</tr>
									
									<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
									<tr>
										<td><label>Book Id</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getId() %></label></td>
									</tr>
									<tr>
										<td><label>Book Name</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getName() %></label></td>
									</tr>
									<tr>
										<td><label>Level 1</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getLevel1() %></label></td>
									</tr>
									<tr>
										<td><label>Level 2</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getLevel2() %></label></td>
									</tr>
									<tr>
										<td><label>Dynasty</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getDynasty() %></label></td>
									</tr>
									<tr>
										<td><label>Period</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getPeriod() %></label></td>
									</tr>
									<tr>
										<td><label>Admin Type</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getAdmin_type() %></label></td>
									</tr>
									<tr>
										<td><label>Volume</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getVolume() %></label></td>
									</tr>
									<tr>
										<td><label>Author</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getAuthor() %></label></td>
									</tr>
									<tr>
										<td><label>Edition</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getBook().getEdition() %></label></td>
									</tr>
									
									<!-- %%%%%%%%%%%%%%%%%%%%%%%% -->
									<tr>
										<td><label>Section Id</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getSectionId() %></label></td>
									</tr>
									<tr>
										<td><label>Section Name</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getSection().getName() %></label></td>
									</tr>
									<tr>
										<td><label>Pages</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getSection().getPages()%></label></td>
									</tr>
									
									
									<tr>
										<td><label>Created</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getFomattedCreation() %></label></td>
									</tr>
									<tr>
										<td><label>Creator</label></td>
										<td><label><%=sessionBean.getBranchPage().getBranch().getUsername() %></label></td>
									</tr><tr>
										<td><label>Contributors</label></td>
										<td>
											<table>
												<tr>
													<td>
														<form name="contributorForm"
															action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
															method="post">
															<input name="bean" type="hidden" value="branchBean" /> 
															<table style="width: 300px;" class="pageTable">
																<% for(VDCUser contr : sessionBean.getBranchPage().getContributors()) { %>
																	<tr>
																		<td><label><%=contr.getUserName() %></label></td>
																		<td>
																			<input type="image" 
																				onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> setAction0('removeContributor', 'contributorForm', 'userId',  <%=contr.getId() %>);" 
																				src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/>																	
																		</td>
																	</tr>
																<% } %>
															</table>
														</form>
													</td>
													<td>
														<button id="addContributors" type="button" class="lgButton">Add Contributors</button>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td><label class="subTitel">Current Version</label></td>
							<td>
								<table class="tableComponent">
									<tr>
										<td><label>File Id</label></td>
										<td><label><%=sessionBean.getBranchPage().getLastFile().getId() %></label></td>
									</tr>
									<tr>
										<td><label>File Version</label></td>
										<td><label><%=sessionBean.getBranchPage().getLastFile().getVersion() %></label></td>
									</tr>
									<tr>
										<td><label>User</label></td>
										<td><label><%=sessionBean.getBranchPage().getLastFile().getUsername() %></label></td>
									</tr>
									<tr>
										<td><label>File Name</label></td>
										<td><label><%=sessionBean.getBranchPage().getLastFile().getFileName() %></label></td>
									</tr>
									<tr>
										<td><label>Created</label></td>
										<td><label><%=sessionBean.getBranchPage().getLastFile().getFomattedCreation() %></label></td>
									</tr>									
									<tr>
										<td><label>Tagged Text</label>
											<% LGBranch branch = sessionBean.getBranchPage().getBranch(); %>
											<a onclick="branchInExtractionInterface('<%=branch.getId() %>', '<%=branch.getCurrentLastFileId() %>', '<%=branch.getSectionId() %>', '<%=branch.getSection().getName() %>', '<%=branch.getBook().getId() %>', '<%=branch.getBook().getName() %>', '<%=sessionBean.getUser().getId() %>', '<%=sessionBean.getApplicationBean().getExtractionInterfaceUrl()%>');">
												<img title="Show Task in Extraction Interface" src="<%=sessionBean.getApplicationBean().getEditImage()%>"/>
											</a>
										
										</td>
										
										<td>
											<textarea rows=20" cols="70">
												<%=sessionBean.getBranchPage().getText() %>
											</textarea>	
											<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/downloadFileText?fileId=<%=branch.getCurrentLastFileId() %>"
														target="_blank">
													<img title="Download text (XML)" src="<%=sessionBean.getApplicationBean().getDownloadImage()%>"/>
											</a>											
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td><label class="subTitel">All Versions</label></td>
							<td>
								<form name="filesForm"
									action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
									method="post">
									<input name="bean" type="hidden" value="branchBean" /> 							
							
								
									<table class="pageTable tableComponent">
										<tr>
											<th><label class="tableTitle">File Id</label></th>
											<th><label class="tableTitle">Version</label></th>
											<th><label class="tableTitle">User</label></th>
											<th><label class="tableTitle">Created</label></th>
											<th><label class="tableTitle">Tagged text (XML)</label></th>
											<th><label class="tableTitle">View table</label></th>
											<th><label class="tableTitle">Table in CSV (tab-delimited)</label></th>
											<th><label class="tableTitle">Upload to LGDataverse</label><br>
												
												<% LGFile lastFile = sessionBean.getBranchPage().getLastFile();
													if(lastFile.getDvId() == null) {%>
														<button type="button" class="get-studies" data-file-id="<%=lastFile.getId()%>">Upload the latest version</button>
													<% } else if (lastFile.getFileIdInDv() == null) { %>
														<label><i>Uploaded, but it's been deleted from <a href="<%=lastFile.getDatasetUrl() %>" target="_blank"><%= lastFile.getDatasetTitle() %></a></i></label>	
														<button type="button" class="get-studies" data-file-id="<%=lastFile.getId()%>">Re-upload it</button>
													
													<% } else { %>		
														<label>Already uploaded in <a href="<%=lastFile.getDatasetUrl() %>" target="_blank"><%= lastFile.getDatasetTitle() %></a></label>	
														
													<% } %>		
		
											</th>
											
											<th><label class="tableTitle">Delete</label></th>
										</tr>	
										
										<% for(LGFile file : sessionBean.getBranchPage().getAllFiles()) { %>
											<tr>
												<td><label><%= file.getId() %></label></td>
												<td><label><%= file.getVersion() %></label></td>
												<td><label><%= file.getUsername() %></label></td>
												<td><label><%= file.getFomattedCreation() %></label></td>
												<td>
													<!-- action change to download the file, instead of open file in a new tab -->
													
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/downloadFileText?fileId=<%=file.getId() %>"
														target="_blank">
														<img title="Download XML file" src="<%=sessionBean.getApplicationBean().getDownloadImage()%>"/>
													</a>
													<!-- 
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/getFileText?fileId=<%=file.getId() %>"
														target="_blank">
														<img title="Show text" src="<%=sessionBean.getApplicationBean().getShowImage()%>"/>
													</a>
													-->
												</td>
												<td>
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/getTable4File?fileId=<%=file.getId() %>"
														target="_blank">
														<img title="Show table (html)" src="<%=sessionBean.getApplicationBean().getShowImage()%>"/>
													</a>												
												</td>	
												
												<!-- add to get tab-delimited file -->
												<!-- Taction change to download the csv file, instead of open file in a new tab -->
												<td>
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/downloadTabDelimited4File?fileId=<%=file.getId() %>"
														target="_blank">
														<img title="Download CSV file (tab-delimited)" src="<%=sessionBean.getApplicationBean().getDownloadImage()%>"/>
													</a>
													<!-- 
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/getTabDelimited4File?fileId=<%=file.getId() %>"
														target="_blank">
														<img title="Show text" src="<%=sessionBean.getApplicationBean().getShowImage()%>"/>
													</a>
													 -->												
												</td>	
														
												<td>
													<% if(file.getDvId() == null) {%>
														
													<% } else if (file.getFileIdInDv() == null) { %>
														<label><i>(uploaded, then deleted)</i></label>	
														
													<% } else { %>		
														<label>uploaded in <a href="<%=file.getDatasetUrl() %>" target="_blank"><%= file.getDatasetTitle() %></a></label>	
														
													<% } %>		
												</td>												
												<td>
													<input type="image" title="Delete this version"
														onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> setAction0('deleteFile', 'filesForm', 'fileId', <%=file.getId() %>);" 
														src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/>
												</td>
											</tr>
										<% } %>				
									</table>
									
								</form>
							</td>
						</tr>
					
					</table>
				
				<% } %>
				
		
		<% } %>
	
	</div>
	
</body>