diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-04-16 11:20:38 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-05-13 17:50:04 +0900 |
commit | 3b55d06b89bf64873e685c3d78fce5affbba3d17 (patch) | |
tree | 2adcff0087f4757107d2bf1e50c85ea649f04f94 /warehouse/src/main/webapp/WEB-INF/pages/app |
Add warehouse server source code.icefish_8.99.5icefish_8.99.4icefish_8.99.3icefish_8.99.2icefish_8.99.1icefish/8.99.5icefish/8.99.4icefish/8.99.3icefish/8.99.2icefish/8.99.1halibut_8.0.6halibut_8.0.5halibut_8.0.4halibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut_7.99.3halibut_7.99.2halibut_7.99.1halibut/8.0.6halibut/8.0.5halibut/8.0.4halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.0halibut/7.99.3halibut/7.99.2halibut/7.99.18.99.58.99.48.99.38.99.28.99.18.0.68.0.58.0.48.0.38.0.28.0.18.0.07.99.37.99.27.99.1halibut
[Patch Set 2] Add ReadMe.md
Change-Id: I6ade52d2490f5ca4ba107c1a27ed6d5b39048725
Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'warehouse/src/main/webapp/WEB-INF/pages/app')
6 files changed, 1341 insertions, 0 deletions
diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/checkAppInfo.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/checkAppInfo.jsp new file mode 100644 index 0000000..3e9e015 --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/checkAppInfo.jsp @@ -0,0 +1,115 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; +String ippath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); +%> +<style type="text/css"> + .triangle{width:0;height:0;border-right:25px solid transparent;border-left:25px solid #0080FF;border-bottom:25px solid transparent;border-top:25px solid transparent;} + .rectangle{height:50px;font-size:20px;background:#0080FF;color:white} + .box{height:50px;border-style:solid; border-width:1px; border-color:#F0F0F0;text-align:center;line-height:50px;color:white;} + .center_div{border-style:solid; border-width:1px; border-color:white;border-top:none;border-bottom:none;} + .space{background:#FFFFFF;width:5px;position:relative;margin-left:-5px;} + .create-schedule{border:2px solid #E0E0E0;} + .create-scheduling{border:2px solid #29e62d;} +</style> +<!-- navigationDialog dialog --> +<jsp:include page="../navigationDialog.jsp" flush="true"></jsp:include> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"> + ${modelErrors} + </div> + </c:when> + <c:otherwise> + <div id="page-content" style="height:auto;"> + <div class="col-md-12 box"> + <div class="form-group row"> + <img src="image/insertAppSubmit.PNG" style="height:100%;width:100%"/> + </div> + <div class="form-group row" style="margin-top:-15px"> + <div class="col-md-4 create-schedule"></div> + <div class="col-md-4 create-schedule"></div> + <div class="col-md-4 create-scheduling"></div> + </div> + </div> + <div class="row"> + <div class="col-md-12 col-md-offset-12"> + <div id="main-content" style="min-height:520px;height:100%;width:100%;"> + <article> + <div class="art-content" style="min-height:480px;height:100%;width:auto;margin-left:45px;margin-right:45px;word-break: break-all; word-wrap:break-word;"> + <input id="t_typeId" type="hidden" value="${appInfo.typeId}"> + <input id="t_appId" type="hidden" value="${appInfo.appId}"> + <input id="t_filePath" type="hidden" value="${appInfo.verFilePath}"> + <input id="t_developer" type="hidden" value="${appInfo.developer}"> + <input id="iconPath" type="hidden" value="${appInfo.imagePath}"> + <br> + <p style="font-size:25px;margin-left:-20px;margin-top:10px;">Submission of audit</p> + <h4>${appInfo.appName}</h4> + <table> + <tr> + <td rowspan="3" valign="top" style="width:130px"><img id="imagePath" src="${appInfo.imagePath}" style="width:120px;height:120px"/></td> + <td>By <a style="color:#00D096" href="#">${appInfo.developerName}</a> ${date}<br>${appInfo.versionName}<br>${appInfo.typeName}<br>${appInfo.appDeviceTypeName}<br>${appInfo.appIdCustom}</td> + </tr> + <tr><td></td></tr> + <tr><td></td></tr> + </table> + <div id="appAbstract" class="col-md-12" style="margin-left:-15px">${appInfo.appAbstract}</div> + <div style="float:right;margin-top:30px;" class="col-md-0"> + <button type="button" class="btn btn-primary" id="btn-save-edit" onclick="saveAppForm()">SUBMIT</button> + </div> + </div> + </article> + </div> + </div> + </div> + </div> + </c:otherwise> +</c:choose> +<script src="<%=basePath%>/js/constant.js"></script> +<script> +$(function() { + <%-- if($('#iconPath').val() == ''){ + $('#imagePath').attr("src",'<%=basePath%>/image/defaultAppIcon.png'); + } --%> + // TODO DJ 暂时放置,等上传功能好用之后再对应,猜想textarea上传后,数据库会把回车空格之类的给替换掉。 + var abstractSubStr = document.getElementById("appAbstract").innerHTML; + var reg=new RegExp("\r\n","g"); + var reg1=new RegExp("\n","g"); + var abstractSubStr= abstractSubStr.replace(reg,"<br>"); + abstractSubStr= abstractSubStr.replace(reg1,"<br>"); + document.getElementById("appAbstract").innerHTML = abstractSubStr; +}); +var saveAppForm = function(){ + var appId = $('#t_appId').val(); + $.ajax({ + url: '<%=basePath%>/app/check?appId='+appId, + cache: false, + type: 'GET', + async:true, + processData:false, + contentType:false, + data: '', + success: function (data) { + var json = JSON.parse(data); + if(200 == json.result) { + Commons.showContent('<%=basePath%>/' + json.forward); + } else if(401 == json.result) { + $errorArea.empty().append('<div>' + json.message[i] + '</div>'); + $errorArea.css("display", "block"); + } else { + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + /*错误信息处理*/ + } + }); +}; +</script>
\ No newline at end of file diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/createApp.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/createApp.jsp new file mode 100644 index 0000000..d323d2e --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/createApp.jsp @@ -0,0 +1,112 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; +%> +<style type="text/css"> + #e_appTypeId {height:auto;} + .box{height:50px;border-style:solid; border-width:1px; border-color:#F0F0F0;text-align:center;line-height:50px;color:white;} + .device_type{position: relative;left:7%;width:950px;} + .style_button{width:300px;height:100px;margin-top:10px;margin-left:10px;white-space: normal;font-size:20px;} + .file-btn{z-index:0;filter:alpha(opacity=1);opacity:0.8;} + #e_position{z-index:100;} + .create-schedule{border:2px solid #E0E0E0;} + .create-scheduling{border:2px solid #29e62d;} +</style> +<!-- navigationDialog dialog --> +<jsp:include page="../navigationDialog.jsp" flush="true"></jsp:include> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"> + ${modelErrors} + </div> + </c:when> + <c:otherwise> + <div class="card mb-3" style="height:auto;"> + <div class="col-md-12 box"> + <div class="form-group row" > + <img src="image/insertAppCreate.PNG" style="height:100%;width:100%"/> + </div> + <div class="form-group row" style="margin-top:-15px"> + <div class="col-md-4 create-scheduling"></div> + <div class="col-md-4 create-schedule"></div> + <div class="col-md-4 create-schedule"></div> + </div> + </div> + <div class="card-body card-change-password pt0"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"<c:choose> + <c:when test="${not empty modelErrors}">style="display: block"</c:when> + <c:otherwise>style="display: none"</c:otherwise> + </c:choose>> + <c:if test="${not empty modelErrors}"> + ${modelErrors} + </c:if> + </div> + <p style="font-size:25px;margin-top:10px;">Choose device type</p> + <div class="form-group row device_type"> + <c:forEach var="list" items="${appDeviceTypeList}"> + <div id="e_deviceTypeId" class="btn btn-info style_button" style="line-height:80px;" onclick="saveAppForm(${list.value})">${list.label}</div> + </c:forEach> + </div> + </div> + </div> + </c:otherwise> +</c:choose> + +<script src="<%=basePath%>/js/constant.js"></script> +<script> +var $errorArea = $('#modalErrorArea'); +var appForm = function() { + this.appDeviceTypeId = ''; +}; + +var saveAppForm = function(value) { + $("#e_deviceTypeId").attr('disabled',true); + var tf = new appForm(); + tf.appDeviceTypeId = value; + var formData = new FormData(); + formData.append("form", JSON.stringify(tf)); + + try { + $.ajax({ + url: '<%=basePath%>/app/createApp', + cache: false, + type: 'POST', + async:true, + processData:false, + contentType:false, + data: formData, + success: function (data) { + var json = JSON.parse(data); + if(200 == json.result) { + Commons.showContent('<%=basePath%>' + json.forward+'?appId='+json.message.appId+'&modifyFlag='+0); + } else if(401 == json.result) { + $("#btn-save-edit").attr('disabled',false); + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + } else{ + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + $("#btn-save-edit").attr('disabled',false); + } + + }, + error: function (jqXHR, textStatus, errorThrown) { + /*错误信息处理*/ + } + }); + } catch(e) { + console.log(e); + } +}; + +</script>
\ No newline at end of file diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/list.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/list.jsp new file mode 100644 index 0000000..c4064e9 --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/list.jsp @@ -0,0 +1,393 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<% + +String path = request.getContextPath(); +String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; +String ippath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); +%> +<style type="text/css"> + div.dataTables_wrapper div.dataTables_info { + padding-top: 0.3em; + white-space: nowrap; + margin-left:120px; +} + a.page-link{ + height:calc(1.8125rem + 4px); + margin-left:-5px; + } + +</style> +<div class="alert alert-secondary container" role="alert"> + <div style="display:inline-block">App</div> +</div> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"> + ${modelErrors} + </div> + </c:when> + <c:otherwise> + <div class="card mb-3"> + <div class="card-header"> + <div class=""> + <div class="alert alert-danger" id="modalErrorArea" role="alert"<c:choose> + <c:when test="${not empty modelErrors}">style="display: block"</c:when> + <c:otherwise>style="display: none"</c:otherwise> + </c:choose>> + <c:if test="${not empty modelErrors}"> + ${modelErrors} + </c:if> + </div> + <input type="text" class="form-control" id="t_filePath" size="16" name="t_filePath" style="display:none;"> + <div class="row" > + <div class="col"> + <div class="form-group"> + <label class="control-label" for="t_appTypeId">AppType</label> + <select id="t_appTypeId" class="form-control"> + <c:forEach var="list" items="${appTypeList}"> + <option value="${list.value}">${list.label}</option> + </c:forEach> + </select> + </div> + </div> + <div class="col" > + <div class="form-group"> + <label class="control-label" for="t_appDeveloper">DeviceType</label> + <select id="e_deviceTypeId" class="form-control"> + <c:forEach var="list" items="${appDeviceTypeList}"> + <option value="${list.value}">${list.label}</option> + </c:forEach> + </select> + </div> + </div> + <div class="col"> + <div style="position:absolute;right:20px;top:40px;cursor:pointer;display:none;" class="input_clear"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + </div> + <label class="control-label" for="t_keyWord">KeyWord</label> + <input type="text" class="form-control style-height" id="t_keyWord" size="16" name="t_keyWord" placeholder="please enter"> + </div> + <div class="col" style="visibility:hidden"> + <div style="position:absolute;right:20px;top:40px;cursor:pointer;display:none;" class="input_clear"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + </div> + <label class="control-label" for="t_appName">Developer</label> + <input type="text" class="form-control style-height" id="t_appDeveloper" name="t_appDeveloper" size="16" placeholder="please enter"> + </div> + </div> + </div> + <div class="row"> + <div class="col" style="text-align:right;"> + <c:if test="${fn:contains(menuPathString, 'app/insert')}"> + <button type="button" class="btn btn-primary pl20 pr20" id="btn-save-edit" onclick="Commons.showContent('<%=basePath%>/app/initCreate')">Create</button> + </c:if> + <button type="button" class="btn btn-success pl20 pr20 ml10" id="listSearch" onclick="search()">Search</button> + <button id="gridView" type="button" class="btn btn-info pl20 pr20 ml10" onclick="chageView(1)" style="float:right">gridView</button> + <button id="listView" type="button" class="btn btn-info pl20 pr20 ml10" onclick="chageView(0)" style="float:right">listView</button> + </div> + </div> + </div> + <div class="card-body" style="margin-left:12px;margin-right:12px;"> + <div class="table-responsive" id="div-table-container"> + <table id="example" cellspacing="0" style="width:100%;"> + <thead> + </thead> + </table> + <div style="height:20px;"></div> + </div> + <div id="grid"> + <div id="chunk" class="row"></div> + </div> + <div style="display: none;" id="page"> + <div class="row"> + <div class="col-md-6" style="text-align:right"> + <button id="last" type="button" class="btn btn-primary" + onclick="chunk(0)"><h4 style="color:white"><</h4></button> + </div> + <div class="col-md-6"> + <button id="next" type="button" class="btn btn-primary" + onclick="chunk(1)"><h4 style="color:white">></h4></button> + </div> + </div> + </div> + </div> + </div> + </c:otherwise> +</c:choose> +<script src="<%=basePath%>/js/main.js"></script> +<script src="<%=basePath%>/js/jquery.cookie.js"></script> +<script> + +$(function() { + $("#listView").css('display','none'); + $("input").focus(function(){ + $(this).parent().children(".input_clear").show(); + }); + $("input").blur(function(){ + if($(this).val()==''){ + $(this).parent().children(".input_clear").hide(); + } + }); + $(".input_clear").click(function(){ + $(this).parent().find('input').val(''); + $(this).hide(); + }); + + $(".card-body").css({ + minHeight:($(window).height()-500) + }) + Commons.bindDateControl(); + Commons.appendRedAsterisk(); + init(); +}); + +var $table = $('#example'); +var $errorArea = $('#modalErrorArea'); +var queryParam = function(param) { + param.orderColumn = param.order[0].column; + param.orderDir = param.order[0].dir; + param.keyWord = $('#t_keyWord').val(); + param.typeId = $('#t_appTypeId').val(); + param.deviceTypeId = $('#e_deviceTypeId').val(); + param.filepath = $('#t_filePath').val(); + return param; +}; + + var strSub = function(str, subLen){ + if(str == null){ + return ""; + } + var subStr = str; + var len = 0; + for (var i=0; i<str.length; i++) { + if (str.charCodeAt(i)>127 || str.charCodeAt(i)==94) { + len += 2; + } else { + len ++; + } + if(len >= subLen){ + subStr = str.substring(0, i); + break; + } + } + return subStr; +}; + +var strName = function(str, subLen){ + if (str == null){ + return ""; + } + if (str.length > subLen) { + str=str.substring(0,subLen-3); + var appName = str+"..."; + }else{ + var appName = str; + } + return appName; +}; +function init(){ + var flag = $.cookie('flag'); + if(flag == 1){ + chunk(); + }else{ + initTable(); + } +} + +function search(){ + var flag = getCookie("flag"); + if(flag == 1){ + chunk(); + }else{ + $table.DataTable().ajax.reload(); + } +} + +function setCookie(key,value){ + $.cookie(key, value, { expires: 7 ,path:'/'}); +} + +function getCookie(key){ + return $.cookie(key); +} + +function lastPageButton(start){ + if(start == 0){ + $("#last").attr('disabled',true); + }else{ + $("#last").attr('disabled',false); + } +} + +function nextPageButton(i,length){ + if(i < length){ + $("#next").attr('disabled',true); + }else{ + $("#next").attr('disabled',false); + } +} +var check = 0; +function chageView(value){ + if(value == 0){ + if(check == 1){ + $table.DataTable().ajax.reload(); + }else{ + initTable(); + } + }else{ + chunk(); + } +} + +//chunkList +var nowStart = 0; +function chunk(page){ + var start = 0; + var length = 48; + // last page + if(page == 0){ + start = nowStart - length; + } + // next page + if(page == 1){ + start = nowStart + length; + } + nowStart = start; + + $("#div-table-container").css('display','none'); + $("#gridView").css('display','none'); + $("#grid").css('display','block'); + $("#page").css('display','block'); + $("#listView").css('display','block'); + setCookie("flag",1); + var keyWord = $('#t_keyWord').val(); + var appTypeId = $('#t_appTypeId').val(); + var deviceTypeId = $('#e_deviceTypeId').val(); + + $.ajax({ + url: '<%=basePath%>/app/search', + data: { "draw":"1","length":length,"start":nowStart,"orderColumn":"1","orderDir":"asc","typeId":appTypeId,"deviceTypeId":deviceTypeId,"keyWord":keyWord}, + type: 'GET', + dataFilter: function(data){ + $errorArea.empty(); + $errorArea.css("display", "none"); + $("#chunk").empty(); + var json = $.parseJSON(data); + debugger; + if (json.statusCode && json.statusCode != null) { + $errorArea.empty().append('<div>' + json.statusText + '</div>'); + $errorArea.css("display", "block"); + } + var i = 0; + $.each(json.data, function(index, item){ + i++; + var imagePath = '<%=ippath%>'+item.imagePath; + if(item.imagePath == ''){ + imagePath = '<%=basePath%>/image/defaultAppIcon.png'; + } + var appName = strName(item.appName, 16); + var a = '<div class="col-md-3" style="height:340px;padding: 12px;">' + +'<div onclick="Commons.showContent(\'<%=basePath%>/app/more?appId='+ item.appId+ '\')" style="border-radius:3px;padding:18px; border:1px solid #BEBEBE;background:#F0F0F0; cursor:pointer;box-shadow: darkgrey 1px 1px 30px 0px">' + + '<div style="height:190px;width:100%;border:1px solid #BEBEBE">' + + '<img style="height:100%; width:100%;border-radius:3px;box-shadow:0px 0px 10px 0px darkgrey inset" src='+imagePath+'>' + +'</div>' + + '<h6 style="margin-bottom:5px; margin-top:10px">'+ appName + '</h5>' + + '<p style="margin-bottom:2px; color:#111">'+ item.appDeviceTypeName + '</p>' + + '<p style="margin-bottom:0px; color:#111">'+ item.typeName+ '</p>' + +'</div>' + +'</div>'; + $("#chunk").append(a); + }); + lastPageButton(start); + nextPageButton(i, length) + } + }) +} +function initTable() { + check = 1; + $table.DataTable({ + order: [[ 1 , 'asc' ]], + displayLength:50, + ajax: { + url: '<%=basePath%>/app/search', + data: queryParam, + type: 'GET', + dataFilter: function(data){ + $("#div-table-container").css('display','block'); + $("#gridView").css('display','block'); + $("#grid").css('display','none'); + $("#page").css('display','none'); + $("#listView").css('display','none'); + setCookie("flag",0); + + $errorArea.empty(); + $errorArea.css("display", "none"); + var json = $.parseJSON(data); + debugger; + if (json.statusCode && json.statusCode != null) { + $errorArea.empty().append('<div>' + json.statusText + '</div>'); + $errorArea.css("display", "block"); + } + return data; // return JSON string + } + }, + columns: [ + { + className : 'td-operation', + data: null, + defaultContent:'', + orderable : false, + width : '100%', + render: function(data, type, row, meta) + { + var deleteBtn = ''; + var modifyBtn = ''; + var imagePath = '<%=ippath%>' + data.imagePath; + if($('#auId').val() == 1 || ($('#auId').val() == 2 && data.developer == $('#userId').val())){ + deleteBtn = '<a href="javascript:void(0)" style="margin-left:0.5em" class="data-delete" data-data-id="'+data.appId+'">' + +'<button type="button" style="margin-right:auto;" class="btn btn-skin">    Delete    </button></a>'; + modifyBtn = '<a style="margin-left:0.5em" onclick="Commons.showContent(\'<%=basePath%>/app/initInfo?appId='+data.appId+'&modifyFlag='+1+'\')" >' + +'<button type="button" class="btn btn-skin"> Modify </button></a>'; + } + //default image + if(data.imagePath == ''){ + imagePath = '<%=basePath%>/image/defaultAppIcon.png'; + } + + var downloadBtn = '<a href="<%=basePath%>/app/download?appId=' + data.appId + '&typeId=' + data.typeId + '&filePath='+ data.verFilePath + '&token=' + $("#tokenAuthorization").val() + + '"onclick="">'+'<button type="button" style="margin-right:auto;" class="btn btn-skin">DownLoad</button></a>'; + var abstractSubStr = strSub(data.appAbstract, 300); + var date = new Date(data.createDate).format("yyyy-MM-dd"); + + var context = '<article><div style="width:100%; height:100%;border-bottom:1px solid black; word-break: break-all; word-wrap:break-word; padding:20px">' + +'<div class="art-header"><h2 style="margin-top:10px;">'+data.appName+'</h2></div>' + +'<div class="info" >By <a>'+data.developerName+'</a> '+ date +'</div>' + +'<div class="art-content">' + +'<img style="height:120px;width:120px" src=' + imagePath + '>' + +'<div class="ellipsis4" style="color:#272727">'+data.appAbstract+'</div>' + +'<a href="javascript:void(0)" style="color:#1ECD97; padding:8px" onclick="Commons.showContent(\'<%=basePath%>/app/more?appId='+data.appId+'\')">MORE</a>'+'</div>' + +'<div class="art-header" style="color:#ADADAD;"> MD5:<a>'+data.hashcode+'</a></div>' + +'<div class="art-footer">' + downloadBtn + deleteBtn + modifyBtn + ' </div>' + +'</div></article>'; + return context; + } + }, + { + data: null, + defaultContent:'', + orderable : false, + width : '1px', + render: function(data, type, row, meta) { + return null; + } + } + ], + drawCallback: function(settings) { + TableListDeletePlugin.init('example', '<%=basePath%>/app/search', '<%=basePath%>/app/delete'); + $(window).scrollTop(0); + } + }); +} +</script>
\ No newline at end of file diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/modify.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/modify.jsp new file mode 100644 index 0000000..57c8d20 --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/modify.jsp @@ -0,0 +1,85 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; +String ippath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); +%> +<style type="text/css"> +.btn-float{ + float:left; + margin-left:5px; +} +</style> + +<!-- navigationDialog dialog --> +<jsp:include page="../navigationDialog.jsp" flush="true"></jsp:include> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"> + ${modelErrors} + </div> + </c:when> + <c:otherwise> + <div id="page-content" class="index-page container" style="background:#F0F0F0;"> + <div class="row"> + <div class="col-md-12 col-md-offset-12"> + <div id="main-content" style="min-height:520px;height:100%;width:100%;"> + <article> + <div class="art-content" style="min-height:480px;height:100%;width:auto;margin-left:45px;margin-right:45px;word-break: break-all; word-wrap:break-word;"> + <input id="t_typeId" type="hidden" value="${appInfo.typeId}"> + <input id="t_appId" type="hidden" value="${appInfo.appId}"> + <input id="t_filePath" type="hidden" value="${appInfo.verFilePath}"> + <input id="iconPath" type="hidden" value="${appInfo.imagePath}"> + <div style="display:none"> + <input id="t_developer" type="text" value="${appInfo.developer}"> + </div> + + <h2>${appInfo.appName}</h2> + <table> + <tr> + <td rowspan="3" valign="top" style="width:130px"><img id="imagePath" src="${appInfo.imagePath}" style="width:120px;height:120px"/></td> + <td>By ${appInfo.developerName} ${date}<br>${appInfo.versionName}<br>${appInfo.typeName}<br>${appInfo.appDeviceTypeName}<br></td> + </tr> + <tr><td></td></tr> + <tr><td></td></tr> + </table><input id="iconPath" type="hidden" value="${appInfo.imagePath}"> + <div id="appAbstract" class="col-md-12" style="margin-left:-15px">${appInfo.appAbstract}</div><br> + <div style="color:#ADADAD; margin: 0px 0px 10px 0px;">MD5:<a>${appInfo.hashcode}</a></div> + <div class="btn-float"> + <a href="<%=basePath%>/app/download?appId=${appInfo.appId}&typeId=${appInfo.typeId}&filePath=${appInfo.verFilePath}&token=${token}"> + <button type="button" class="btn btn-skin"> DownLoad</button></a> + </div> + <div id="modifyBtn" style="display:none;" class="btn-float"> + <a onclick="Commons.showContent('<%=basePath%>/app/initInfo?appId=${appInfo.appId}&modifyFlag=2')" > + <button type="button" id="modify" class="btn btn-skin"> Modify </button></a> + </div> + </div> + </div> + </article> + </div> + </div> + </div> + </div> + </c:otherwise> +</c:choose> +<script src="<%=basePath%>/js/constant.js"></script> +<script> +$(function() { + var developer = $('#t_developer').val(); + if($('#auId').val() == 1 || developer == $('#userId').val()){ + $("#modifyBtn")[0].style.display='block'; + } + if($('#iconPath').val() == ''){ + $('#imagePath').attr("src",'<%=basePath%>/image/defaultAppIcon.png'); + } + // TODO DJ 暂时放置,等上传功能好用之后再对应,猜想textarea上传后,数据库会把回车空格之类的给替换掉。 + var abstractSubStr = document.getElementById("appAbstract").innerHTML; + var reg=new RegExp("\r\n","g"); + var reg1=new RegExp("\n","g"); + var abstractSubStr= abstractSubStr.replace(reg,"<br>"); + abstractSubStr= abstractSubStr.replace(reg1,"<br>"); + document.getElementById("appAbstract").innerHTML = abstractSubStr; +}); + +</script>
\ No newline at end of file diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/saveAppInfo.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/saveAppInfo.jsp new file mode 100644 index 0000000..51ca352 --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/saveAppInfo.jsp @@ -0,0 +1,348 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; +String ippath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); +%> +<style type="text/css"> + #e_appTypeId {height:auto;} + .box{height:50px;border-style:solid; border-width:1px; border-color:#F0F0F0;text-align:center;line-height:50px;color:white;} + .file-btn{z-index:0;filter:alpha(opacity=1);opacity:0.8;} + #e_position{z-index:100;} + .create-schedule{border:2px solid #E0E0E0;} + .create-scheduling{border:2px solid #29e62d;} +</style> +<!-- navigationDialog dialog --> +<jsp:include page="../navigationDialog.jsp" flush="true"></jsp:include> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"> + ${modelErrors} + </div> + </c:when> + <c:otherwise> + <div class="card mb-3" style="height:auto;"> + <!-- <div style="margin-left:10px;width:98%"> --> + <div class="col-md-12 box"> + <div class="form-group row"> + <img src="image/insertAppDetails.PNG" style="height:100%;width:100%"/> + </div> + <div class="form-group row" style="margin-top:-15px;"> + <div class="col-md-4 create-scheduling" ></div> + <div class="col-md-4 create-schedule" ></div> + <div class="col-md-4 create-schedule" ></div> + </div> + </div> + <div class="card-body card-change-password pt0"> + <div class="alert alert-danger" id="modalErrorArea" role="alert"<c:choose> + <c:when test="${not empty modelErrors}">style="display: block"</c:when> + <c:otherwise>style="display: none"</c:otherwise> + </c:choose>> + <c:if test="${not empty modelErrors}"> + ${modelErrors} + </c:if> + </div> + <p style="font-size:25px;margin-top:10px;">Fill in information</p> + <div class="card-body"> + <div class="alert alert-danger;"style="display:none" id="modalErrorArea" role="alert"></div> + <form id="registerForm" class="was-validated"> + <input type="hidden" id="e_deviceTypeId" value="${appInfo.appDeviceTypeId}"> + <input type="hidden" id="e_hashcode" value="${appInfo.hashcode}"> + <input type="hidden" id="e_verFilePath" value="${appInfo.verFilePath}"> + <input type="hidden" id="e_appSize" value="${appInfo.appSize}"> + <input type="hidden" id="e_appVersionId" value="${appInfo.appVersionId}"> + <input type="hidden" id="e_imagePath" value="${appInfo.imagePath}"> + <div class="form-group row"> + <div class="col-md-3"><label for="e_uuId" class="notNull">UUID</label></div> + <div class="col-md-9"> + <input class="form-control style-height" id="e_uuId" name="e_uuId" title="This field is required" maxlength="32" type="text" placeholder="" value="${appInfo.appId}" required disabled> + </div> + </div> + <c:if test="${empty appInfo.appIdCustom}"> + <div class="form-group row"> + <div class="col-md-3 "><label for="e_position" class="notNull">App File</label></div> + <div class="col-md-2 file-box" id="upload" style="display:block"> + <input type="button" class="btn btn-success" value="UPLOAD" style="height:50px;width:150px;padding:0px;position:absolute;top:-10px;"> + <input title="This field is required" id="path" name="position" type="file" style="height:50px;width:150px;padding:0px;position:absolute;top:-10px;opacity:0;" class="form-control file-btn" value="${appInfo.verFilePath}" accept=".wgt" onchange="change(event)" required> + </div> + + <div class="col-md-2 file-box" id="uploading" style="display:none"> + <input type="button" class="btn btn-success" value="UPLOADING......" style="height:50px;width:150px;padding:0px;position:absolute;top:-10px;background:#ADADAD"> + <input title="This field is required" id="path" name="position" type="file" style="height:50px;width:150px;padding:0px;position:absolute;top:-10px;opacity:0;" class="form-control file-btn" value="${appInfo.verFilePath}" accept=".wgt" onchange="change(event)" required> + </div> + </div> + </c:if> + <div class="form-group row"> + <div class="col-md-3"><label for="e_appId" class="notNull">App Id</label></div> + <div class="col-md-9"> + <input class="form-control style-height" id="e_appId" name="e_appId" title="This field is required" type="text" value="${appInfo.appIdCustom}" required disabled> + </div> + </div> + <div class="form-group row"> + <div class="col-md-3"><label for="e_versionName" class="notNull">Version</label></div> + <div class="col-md-9"> + <input class="form-control style-height" id="e_versionName" title="This field is required" name="e_versionName" type="text" value="${appInfo.versionName}" required disabled> + </div> + </div> + <div class="form-group row"> + <div class="col-md-3"><label for="e_appName" class="notNull">App Name</label></div> + <div class="col-md-9"> + <input class="form-control style-height" id="e_appName" name="e_appName" title="This field is required" type="text" placeholder="" value="${appInfo.appName}" required disabled> + </div> + </div> + <div class="form-group row"> + <div class="col-md-3"><label for="e_isPublicName" class="notNull">App Is Public</label></div> + <div class="col-md-9"> + <select id="e_isPublicName" class="form-control" required> + <c:forEach var="list" items="${appIsPublicList}"> + <option value="${list.value}" <c:if test="${list.value eq appInfo.appIsPublic}">selected="selected"</c:if>>${list.label}</option> + </c:forEach> + </select> + </div> + </div> + <div class="form-group row" > + <div class="col-md-3 "><label for="e_appTypeId" class="notNull">App Type</label></div> + <div class="col-md-9"> + <select id="e_appTypeId" class="form-control" required> + <c:forEach var="list" items="${appTypeList}"> + <option value="${list.value}" <c:if test="${list.value eq appInfo.typeId}">selected="selected"</c:if>>${list.label}</option> + </c:forEach> + </select> + </div> + </div> + <div class="form-group row"> + <div class="col-md-3" style="margin-top:65px;"><label for="e_appAbstract" class="notNull">App Description</label></div> + <div class="col-md-9"> + <textarea class="form-control" title="This field is required" maxlength="800" placeholder="Maximum length is 800 characters." id="e_appAbstract" name="e_appAbstract" style="height:150px;" rows="8" cols="40" required>${appInfo.appAbstract}</textarea> + </div> + </div> + <div class="form-group row"> + <div class="col-md-3"><label style="margin-top:35px;" for="e_thumbnail" class="notNull">App Icon</label></div> + <div class="col-md-9"> + <img id="e_iconPath" src="${appInfo.imagePath}" style="width: 150px; height:150px;border:#ADADAD 1px solid"/><br> + <input onchange="changeImg(event,'e_iconPath')" type="file" style="width:150px;height:150px;margin-top:-150px;position: absolute; opacity:0;"> + </div> + </div> + </form> + <div style="float:right;" class="col-md-0"> + <button type="button" class="btn btn-primary form-btn-w-70" id="btn-save-edit" onclick="saveAppForm()">Save</button> + </div> + </div> + </div> + </div> + </c:otherwise> +</c:choose> + +<script src="<%=basePath%>/js/constant.js"></script> +<script> +$(function(){ + Commons.bindDateControl(); + Commons.appendRedAsterisk(); + blobData=null; + filename=null; + if($('#e_imagePath').val() == ''){ + $('#e_iconPath').attr("src",'<%=basePath%>/image/addPic.png'); + } +}); +var load = function(event){ + var load = document.getElementById("path"); + var index=load.value.lastIndexOf("\_"); + load.value=load.value.substring(index+1,load.value.length); + return load.value; +} + +var blobData, filename; +var change = function (event) { + file = event.target.files[0]; + var fileReader = new FileReader(); + fileReader.readAsArrayBuffer(file); + var toBlob = function(a){ + return new Blob([a],{type:file.type}) + } + + fileReader.onload = function(){ + var result = this.result; + var blob = new Blob([result],{type:file.type}); + blobData = blob; + filename = file.name; + saveUpload(); + } +} + +var $errorArea = $('#modalErrorArea'); +var appForm = function() { + this.developer = ''; + this.typeId = ''; + this.appName = ''; + this.verFilePath = ''; + this.versionName = ''; + this.appAbstract = ''; + this.appId = ''; + this.appVersionId = ''; + this.appIsPublic = ''; +}; +var saveUpload = function() { + $("#btn-save-edit").attr('disabled',true); + $("#upload")[0].style.display = "none"; + $("#uploading")[0].style.display = "block"; + var tf = new appForm(); + tf.appId = $('#e_uuId').val(); + tf.appDeviceTypeId = $('#e_deviceTypeId').val(); + if( filename == null){ + tf.verFilePath = load(); + }else{ + tf.verFilePath = filename; + } + var formData = new FormData(); + formData.append("file", blobData); + formData.append("form", JSON.stringify(tf)); + + try { + $.ajax({ + url: '<%=basePath%>/app/uploadFile', + cache: false, + type: 'POST', + async:true, + processData:false, + contentType:false, + data: formData, + success: function (data) { + $("#btn-save-edit").attr('disabled',false); + var json = JSON.parse(data); + if(200 == json.result) { + Commons.showContent('<%=basePath%>' + json.forward); + $('#e_hashcode').attr("value",json.message.fileHashCode); + $('#e_appId').attr("value",json.message.configAppId); + $('#e_versionName').attr("value",json.message.configVersionName); + $('#e_verFilePath').attr("value",json.message.filePath); + $('#e_appName').attr("value",json.message.configAppName); + $('#e_iconPath').attr("src",'<%=ippath%>'+json.message.iconPath); + $('#e_imagePath').attr("value",json.message.iconPath); + $('#e_appSize').attr("value",json.message.fileSize); + if($('#e_imagePath').val() == ''){ + $('#e_iconPath').attr("src",'<%=basePath%>/image/addPic.png'); + } + blobData=""; + filename=""; + $errorArea.css("display", "none"); + } else if(401 == json.result) { + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + $("#btn-save-edit").attr('disabled',true); + } else if(500 == json.result) { + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + $("#btn-save-edit").attr('disabled',true); + } + $("#upload")[0].style.display = "block"; + $("#uploading")[0].style.display = "none"; + }, + error: function (jqXHR, textStatus, errorThrown) { + /*错误信息处理*/ + } + }); + } catch(e) { + console.log(e); + } +}; +//image +function changeImg(e,name) { + $errorArea.empty(); + $errorArea.css("display", "none"); + for (var i = 0; i < e.target.files.length; i++) { + var file = e.target.files.item(i); + if (!(/^image\/.*$/i.test(file.type))) { + //isImage + $errorArea.empty().append('<div>' + 'You can upload pictures only.' + '</div>'); + $errorArea.css("display", "block"); + } else if(file.size > (500*1024)){ + //image size + $errorArea.empty().append('<div>' + 'The picture sizes should not exceed 500KB.' + '</div>'); + $errorArea.css("display", "block"); + } else{ + //FileReader API + var freader = new FileReader(); + blobData = file; + freader.readAsDataURL(file); + freader.onload = function (e) { + var result = this.result; + var blob = new Blob([result],{type:file.type}); + $("#e_iconPath").attr("src",e.target.result); + } + } + } +} +var saveAppForm = function() { + $("#btn-save-edit").attr('disabled',true); + var tf = new appForm(); + tf.appId = $('#e_uuId').val(); + tf.appDeviceTypeId = $('#e_deviceTypeId').val(); + tf.versionName = $('#e_versionName').val(); + tf.typeId = $('#e_appTypeId').val(); + tf.appName = $('#e_appName').val(); + tf.appAbstract = $('#e_appAbstract').val(); + tf.appIsPublic = $('#e_isPublicName').val(); + tf.hashcode = $('#e_hashcode').val(); + tf.verFilePath = $('#e_verFilePath').val(); + tf.imagePath = $('#e_imagePath').val(); + tf.appIdCustom = $('#e_appId').val(); + tf.appSize = $('#e_appSize').val(); + tf.appVersionId = $('#e_appVersionId').val(); + var formData = new FormData(); + formData.append("file", blobData); + formData.append("form", JSON.stringify(tf)); + + try { + $.ajax({ + url: '<%=basePath%>/app/saveInfo', + cache: false, + type: 'POST', + async:true, + processData:false, + contentType:false, + data: formData, + success: function (data) { + var json = JSON.parse(data); + if(200 == json.result) { + Commons.showContent('<%=basePath%>/' + json.forward+'?appId='+json.message.appId); + blobData=null; + } else if(401 == json.result) { + $("#btn-save-edit").attr('disabled',false); + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + } else { + $("#btn-save-edit").attr('disabled',false); + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + $errorArea.empty().append(errorContent); + $errorArea.css("display", "block"); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + /*错误信息处理*/ + } + }); + } catch(e) { + console.log(e); + } +}; +var upload = function() { + $('#path').click(); +}; +</script>
\ No newline at end of file diff --git a/warehouse/src/main/webapp/WEB-INF/pages/app/type.jsp b/warehouse/src/main/webapp/WEB-INF/pages/app/type.jsp new file mode 100644 index 0000000..b06ea2e --- /dev/null +++ b/warehouse/src/main/webapp/WEB-INF/pages/app/type.jsp @@ -0,0 +1,288 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + + path; + String ippath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); +%> +<style type="text/css"> +.vBtn { + font-size: 30px; + margin-top: -40px; + float: right; + text-align: center; + background: none; + border: none; + color: gray; +} + +.div3D { + box-shadow: 0px 0px 4px #000; + background: #FFFFFF; + border-radius: 5px; +} + +.hr { + height: 1px; + border: none; + border-top: 1px solid #E0E0E0; +} + +.cr-link-row { + cr-link-row-icon-width: 40px; + border-top: var(- -settings-separator-line); +} +</style> + +<div class="alert alert-secondary container" role="alert"> + <div style="display: inline-block">Setting</div> +</div> +<c:choose> + <c:when test="${not empty modelErrors}"> + <div class="alert alert-danger" id="modalErrorArea" role="alert">${modelErrors}</div> + </c:when> + <c:otherwise> + <input type="hidden" id="appTypeList" value="${appTypeList}"> + <div id="page-content" class="index-page container"> + <div style="margin-left: 100px;"> + <div class="col-md-4" style="margin-left: -50px; font-size: 25px;"> + <p>Application Type</p> + <button id="downShwoBtn" class="vBtn fa fa-chevron-circle-up" type="button" onclick="typeBtn()"></button> + <button id="downCloseBtn" style="display: none" class="vBtn fa fa-chevron-circle-down" type="button" onclick="typeBtn()"></button> + </div> + <br> + <ul> + <div id="type" class="col-md-9 div3D"> + <hr style="height: 1px; border: none; border-top: 1px solid #FFFFFF;" /> + <c:forEach var="list" items="${appTypeList}"> + <option value="${list.value}">${list.label}</option> + <div style="float: right; margin-top: -27px;"> + <button type="button" style="color: #1a73e8; background: #FFFFFF; border: solid 1px #D0D0D0; border-radius: 5px;" + data-toggle="modal" data-target="#popTypeModal" onclick="setValues('0100', '${list.value}', '${list.label}')">Modify</button> + </div> + <hr class="hr" /> + </c:forEach> + <button type="button" class="btn btn-info" data-toggle="modal" + data-target="#popTypeModal" onclick="setValues('0100', '', '')">Add Type</button> + <br> + <br> + </div> + </ul> + </div> + <br> + <br> + <div style="margin-left: 100px;"> + <div class="col-md-5" style="margin-left: -50px; font-size: 25px;"> + <p>Application Device Type</p> + <button id="downDeviceCloseBtn" style="display: none" class="vBtn fa fa-chevron-circle-down" type="button" onclick="deviceTypeBtn()"></button> + <button id="downDeviceShwoBtn" class="vBtn fa fa-chevron-circle-up" type="button" onclick="deviceTypeBtn()"></button> + </div> + <br> + <ul> + <div id="deviceType" class="col-md-9 div3D"> + <hr style="height: 1px; border: none; border-top: 1px solid #FFFFFF;" /> + <c:forEach var="list" items="${appDeviceTypeList}"> + <option value="${list.value}">${list.label}</option> + <div style="float: right; margin-top: -27px;"> + <button type="button" + style="color: #1a73e8; background: #FFFFFF; border: solid 1px #D0D0D0; border-radius: 5px;" + data-toggle="modal" data-target="#popTypeModal" + onclick="setValues('0101', '${list.value}', '${list.label}')">Modify</button> + </div> + <hr class="hr"> + </c:forEach> + <button type="button" class="btn btn-info" data-toggle="modal" data-target="#popTypeModal" onclick="setValues('0101', '', '')"> + Add Device Type</button> + <br> + <br> + </div> + </ul> + </div> + <%-- <br><a href="" onclick="Commons.showContent('<%=basePath%>/app/')" style="margin-left: 780px;"> + <button type="button" class="btn btn-primary">Back</button> + </a><br> --%> + <br> + </div> + <!-- show window --> + <!-- modal --> + <div class="modal fade" id="popTypeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title" id="typeModalTitle">AddType</h4> + </div> + <div class="modal-body"> + <div class="alert alert-danger" style="display:none" id="typeModalErrorArea" role="alert"></div> + <label id="typeModalDescribe">Please input the type name you want to add.</label> + <input type="hidden" id="m_type" name="m_type" value=""></input> + <input type="hidden" id="m_value" name="m_value" value=""></input> + <input type="hidden" id="m_label" name="m_label" value=""></input> + <div class="form-group fond-size"> + <!-- <label id="typeLabel">Type</label> --> + <input class="form-control login-input style-input" id="typeName" name="s_typeLabel" type="text"> + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" style="width: 100px;" data-dismiss="modal">Close</button> + <button type="button" id="submitBtn" class="btn btn-primary" style="width: 100px;" onclick="submitType()">Submit</button> + </div> + </div> + </div> + </div> + </c:otherwise> +</c:choose> + +<script src="<%=basePath%>/js/constant.js"></script> +<script> +$(function() { + $("#submitBtn").attr('disabled',true); + $("#popTypeModal").on("hide.bs.modal", function() { + $(this).removeData("bs.modal"); + var div = document.getElementById("typeModalErrorArea"); + div.innerHTML = ""; + div.style.display="none"; + }); + /* $("#type").parent().parent().find("ul").toggle(); + $("#deviceType").parent().parent().find("ul").toggle(); */ + + $('#typeName').bind('input propertychange', function() { + $("#submitBtn").attr('disabled',false); + }); + $('#typeName').bind('input propertychange', function() { + $("#submitBtn").attr('disabled',false); + }); +}); + +/* A function to show a modal window and set the detail style of this modal window. + type:0100(type),0101(deviceType) + typeValue: label name, null(add), value exists(modify) + typeLabel: label name */ +function setValues(type, typeValue, typeLabel){ + document.getElementById("m_type").value = type; + document.getElementById("m_value").value = typeValue; + document.getElementById("m_label").value = typeLabel; + + var m_type = document.getElementById("m_type").value; + var m_typeValue = document.getElementById("m_value").value; + var m_typeLabel = document.getElementById("m_label").value; + + var typeModalTitle = document.getElementById("typeModalTitle"); + var typeModalDescribe = document.getElementById("typeModalDescribe"); + var typeLabel = document.getElementById("typeLabel"); + var typeName = document.getElementById("typeName"); + + //type + if('0100' == m_type){ + //type-modify + //typeLabel.innerHTML = "Type"; + if("" != m_typeValue){ + typeModalTitle.innerHTML = "Modify Type"; + typeModalDescribe.innerHTML = "Please input the type you want to modify."; + typeName.value = m_typeLabel; + } + //type-add + else if("" == m_typeValue) { + typeModalTitle.innerHTML = "Add Type"; + typeModalDescribe.innerHTML = "Please input the type you want to add."; + typeName.value = ""; + } + } + //device type + else if('0101' == m_type){ + //device type-modify + //typeLabel.innerHTML = "DeviceType"; + if("" != m_typeValue){ + typeModalTitle.innerHTML = "Modify Device Type"; + typeModalDescribe.innerHTML = "Please input the device type you want to modify."; + typeName.value = m_typeLabel; + } + //device type-add + else if("" == m_typeValue) { + typeModalTitle.innerHTML = "Add Device Type"; + typeModalDescribe.innerHTML = "Please input the device type you want to add."; + typeName.value = ""; + } + } +} + +function submitType(){ + var type = document.getElementById("m_type").value; + var typeValue = document.getElementById("m_value").value; + var typeLabel = document.getElementById("typeName").value; + var div = document.getElementById("typeModalErrorArea"); + + if("" == typeLabel || null == typeLabel) + { + var errorContent = ''; + errorContent = "Type name is required."; + div.innerHTML = errorContent; + div.style.display="block"; + return; + } + try { + $.ajax({ + url: '<%=basePath%>/app/saveType', + type: 'POST', + data: { "type":type, "typeValue":typeValue, "typeLabel":typeLabel}, + success: function (data) { + var json = JSON.parse(data); + if(200 == json.result) { + $('#popTypeModal').modal('hide'); + $('.modal-backdrop').remove(); + $('body').removeClass('modal-open'); + Commons.showContent('<%=basePath%>/app/type'); + } else if(401 == json.result) { + $("#submitBtn").attr('disabled',true); + var errorContent = ''; + for (var i in json.message) { + errorContent += json.message[i]; + } + div.innerHTML = errorContent; + div.style.display="block"; + } else { + $("#submitBtn").attr('disabled',true); + var errorContent = ''; + for (var i in json.message) { + errorContent += '<div>' + json.message[i] + '</div>'; + } + div.innerHTML = errorContent; + div.style.display="block"; + } + }, + error: function (jqXHR, textStatus, errorThrown) { + /*错误信息处理*/ + } + }); + } catch(e) { + console.log(e); + } +} + +var typeNum = 0; +function typeBtn(){ + $("#type").parent().parent().find("ul").slideToggle(); + typeNum++; + if(typeNum%2 == 1){ + $("#downShwoBtn").css("display","none"); + $("#downCloseBtn").css("display","block"); + }else{ + $("#downShwoBtn").css("display","block"); + $("#downCloseBtn").css("display","none"); + } +} + +var deviceTypeNum = 0; +function deviceTypeBtn(){ + $("#deviceType").parent().parent().find("ul").slideToggle(); + deviceTypeNum++; + if(deviceTypeNum%2 == 1){ + $("#downDeviceShwoBtn").css("display","none"); + $("#downDeviceCloseBtn").css("display","block"); + }else{ + $("#downDeviceShwoBtn").css("display","block"); + $("#downDeviceCloseBtn").css("display","none"); + } +} +</script> |