최고관리자 메인화면 수정(서버 파일 현황 추가)

main
이범준 1 year ago
parent bee5040363
commit a172e08629

@ -1,5 +1,7 @@
package cokr.xit.fims.base;
import java.io.File;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
@ -7,6 +9,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.user.ManagedUser;
import cokr.xit.fims.cmmn.DirectoryStructureToJson;
import cokr.xit.fims.cmmn.DirectoryStructureToJson.Node;
import cokr.xit.interfaces.smg.service.bean.SmgServiceBean;
@Controller
@ -48,4 +52,15 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
mav.setViewName("jsonView");
return mav;
}
@RequestMapping(name="파일 현황 조회",value="/superUser/getFileTree.do")
public ModelAndView getFileTree() throws Exception {
ModelAndView mav = new ModelAndView();
mav.setViewName("jsonView");
Node tree = DirectoryStructureToJson.getNode(new File("files"));
mav.addObject("tree", tree);
return mav;
}
}

@ -0,0 +1,63 @@
package cokr.xit.fims.cmmn;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class DirectoryStructureToJson {
public static Node getNode(File fileNode){
if(fileNode.isDirectory()){
return new Node(fileNode.getName(),fileNode.getAbsolutePath(),"directory", getDirList(fileNode));
}else{
return new Node(fileNode.getName(),fileNode.getAbsolutePath(),"file",null);
}
}
public static List<Node> getDirList(File node){
List<Node> children=new ArrayList<>();
for(File n : node.listFiles()){
children.add(getNode(n));
}
return children;
}
public static class Node {
private String text;
private String type;
private List<Node> children;
public Node() { }
public Node(String text, String location, String type, List<Node> children) {
this.text = text;
this.type = type;
this.children = children;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Node> getChildren() {
return children;
}
public void setChildren(List<Node> children) {
this.children = children;
}
}
}

@ -1,13 +1,14 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<!-- inner page html -->
<link rel="stylesheet" href="<c:url value="/resources/3rd-party/sneat/libs/jstree/jstree.css"/>" />
<div class="content-wrapper">
<div class="container-xxl flex-grow-1 px-0">
<c:set var="pageKorName" scope="request">최고관리자 메뉴</c:set>
<div class="card">
<div class="wrapper-list">
<div class="doc-example">
<div class="doc-example mt-4">
<div class="doc-example-content fs-big" data-label="배치 수동 실행">
<button type="button" class="btn btn-primary" onclick="exceuteBatch('smgReceive');">국민신문고 수신</button>
<button type="button" class="btn btn-primary" onclick="exceuteBatch('smgSend');">국민신문고 답변 송신</button>
@ -16,25 +17,104 @@
</div>
</div>
<div class="doc-example mt-4">
<div class="doc-example-content fs-big" data-label="파일 현황">
<div class="card-datatable text-nowrap">
<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper dt-bootstrap5 no-footer">
<div class="d-flex flex-row justify-content-evenly" style="max-height:400px;">
<div style="width:49%;overflow-y:auto">
<h5 class="mt-3">파일트리</h5>
<div id="menu-tree" class="main-left d-flex flex-column flex-grow-1">
<div class="d-flex justify-content-between"
style="padding-top:.5em; padding-bottom:.5em; border-top:1px solid #dfdfdf; border-bottom:1px solid #dfdfdf;">
<button type="button" class="btn btn-primary"
onclick="getFileTree();">갱신</button>
</div>
<div id="fileTree" style="padding-top:1em; min-height:26em; overflow:auto;">
</div>
</div>
</div>
<div style="width:49%;">
<h5 class="mt-3">기타</h5>
<div class="d-flex flex-row justify-content-end p-3">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<jsp:include page="/WEB-INF/jsp/include/bottom.jsp" />
<div class="content-backdrop fade"></div>
</div>
<script src="<c:url value="/resources/3rd-party/sneat/libs/jstree/jstree.js"/>"></script>
<script>
function exceuteBatch(batch){
ajax.get({
url : wctx.url("/user/executeBatch.do"),
url : wctx.url("/user/superUser/executeBatch.do"),
data : { batch : batch},
success : resp => {
dialog.alert("실행되었습니다.");
}
});
}
$('#fileTree').jstree({
"core" : {
"data": {}
},
"plugins": ["types"],
"types" : {
"directory" : { "icon" : "fa fa-folder" },
"file" : { "icon" : "fa fa-file" }
},
trace: true,
core:{check_callback:true,
multiple:false
},
checkbox:{
whole_node:false,
tie_selection:false
}
});
$("#fileTree").bind("refresh.jstree", function(){
$(this).jstree("open_all");
});
function getFileTree(){
ajax.get({
url : wctx.url("/user/superUser/getFileTree.do"),
data : {},
headers: { Accept: "application/json; charset=utf-8" },
success : resp => {
$('#fileTree').jstree(true).settings.core.data = resp.tree;
$('#fileTree').jstree(true).refresh();
}
});
}
$(document).ready(function(){
getFileTree();
});
</script>
Loading…
Cancel
Save