summaryrefslogtreecommitdiffstats
path: root/warehouse/src/main/webapp/WEB-INF/pages/appDev/localListDev.jsp
blob: bafa8f893869c3c575e2e00ff028a13d5ee491f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<%@ 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;
%>
<style type="text/css">
	a.page-link{height:calc(1.8125rem + 4px);margin-left:-5px;}
   .div{font-size:18px; color:#000;line-height:24px;white-space:nowrap;text-overflow:ellipsis;word-break:break-all;overflow:hidden;}
		.item,.carousel-caption{
			width: 100%;
			height: 300px;
		}
		.carousel-caption{
			left: 0;
			top: 0;
			padding: 0;
		}
</style>
<c:choose>
	<c:when test="${not empty modelErrors}">
		<div class="alert alert-danger" id="modalErrorArea" role="alert">
			&nbsp;${modelErrors}</div>
	</c:when>
	<c:otherwise>
		<div class="card mb-3"
			style="BACKGROUND-COLOR: transparent; color: white">
			<div class="card-body">
				<div id="appHeight" style="overflow-x: hidden;" class="test1">
					<div>
						<hr>
						<div id="localList" style="padding-left: 15px; padding-right: 15px;"></div>
					</div>
				</div>
			</div>
		</div>
	</c:otherwise>
</c:choose>
<script>
$(function() {
	$("#appHeight").height($(document).height()-250);
	$("#page-content").css("background-image","url(<%=basePath%>/image/AGL_HMI_Blue_Background_Car-01.png)");
	Commons.bindDateControl();
	Commons.appendRedAsterisk();
	
	initLocalData();
}); 

var $errorArea = $('#modalErrorArea');

function initLocalData(){
	debugger;
	console.log("localapp" + "initLocalData");
	this.listReplyok = this.listReplyok.bind(this);
	aglSocket.listInstalledApps(initLocalDataReplyok, initLocalDatareplyerr);
};

function initLocalDataReplyok(obj){
	debugger;
	console.log("localapp" + "listReplyok\n");
	var appListStr = obj["response"];
	checkLocalUpdate(appListStr);
	console.log(appListStr);
};

function initLocalDatareplyerr(obj){
	debugger;
	alert("get local app failed");
};

function checkLocalUpdate(appListStr){
	debugger;
	$.ajax({
		url:"<%=basePath%>/appDev/CheckUpdateInfoDev",
		type: "POST",
		dataType: "json",
		contentType:"application/json;charset=utf-8",
		data: JSON.stringify(appListStr),
		success:function(data){
			debugger;
			initTable(data,appListStr);
			} 
	})
};

/* 
author:"↵     Loïc Collignon <loic.collignon@iot.bzh>↵     Matt Porter <mporter@konsulko.com>↵   "
author-email:"info@automotivelinux.org"
description:"AGL Default Mixer"
height:""
http-port:1024
icon:"/var/local/lib/afm/applications/mixer/6.90/icon.svg"
id:"mixer@6.90"
name:"mixer"
shortname:""
version:"6.90.0-04990a8"
width:"" 
*/
/***
 * applist: local list
 * appListStr:local app package(afm-util list)
 */
function initTable(applist,appListStr){
	console.log(TAG_LOG + "applist.length" + applist.length);
	for (var i = 0; i < applist.length; i++) {
		var data = applist[i];
		var localdata = appListStr[i];
		var appStatusButton = "";  
		
/* 		if(data.updateFlag){
			var appStatusButton = '<button class="btn btn-skin button-size" type="button" style="margin-right:auto;padding-left:0px;padding-right:0px;width:150px;color:white"' 
                               +'onclick=updateApp(this,"'+data.appId+'","'+data.typeId+'","'+data.verFilePath+'","'+localdata.id+'")>update</button>'
		}
		else */{
			var appStatusButton = '<a href="javascript:void(0);" onclick=launchApp("'+localdata.id+'")><button class="btn btn-skin button-size" type="button" style="margin-right:auto;width:150px;color:white" >launch</button></a>';
		}
		
		if(data.systemApp){
			var uninstall = '<a href="javascript:void(0);"><button class="btn btn-skin button-size" type="button" style="display:none;" >uninstall</button></a>';
		}
		else{
			var uninstall = '<a href="javascript:void(0);" onclick=uninstallApp("'+localdata.id+'")><button class="btn btn-skin button-size" type="button" style="margin-right:auto;width:150px;color:white" >uninstall</button></a>';
		}
		
		var date = null;
		if(data.createDate == null){
			date = "----/--/--";
		}
		else{
			date = new Date(data.createDate).format("yyyy-MM-dd");
		}
		
	    if(data.imagePath == null){
	    	data.imagePath = '<%=basePath%>/image/defaultAppIcon.png';
		}
	    
	    if(data.typeName == null){
	    	data.typeName = "--";
	    }
	    
		var context =
			   '<div class="row">'						    
				  +'<div class="col-md-2" style="text-align:center;">'
				  	+'<img style="height:auto;width:100%;" src = "'+data.imagePath+'">'
				  +'</div>'
				  
				  +'<div class="col-md-7">'
				  	+'<h4 style="color:#00AEAE;">' + localdata.name + '</h3>'
				  	+'<div class="font-size"> <strong>Version</strong>:&nbsp'+ localdata.version + '</div>'
				  	+'<p class="font-size ellipsis" style="color:white;"> <strong>Description</strong>:&nbsp' + data.appAbstract + '</p>'
				  +'</div>'
				  
				  +'<div class="col-md-3">'
				    +'<div style="float:right">'+ appStatusButton + '</div>'
				    +'<div style="float:right;margin-top:10px;">' + uninstall + '</div>'
				  +'</div>'
			 +'</div>'			
			+ '<hr>';
/* 	    var context = '<div style="height:120px width:100%; margin-right:210px;""><div><img style="height:120px;width:120px" src = "'+data.imagePath+'"></div>'
	        +'<div class="margin-left"style="margin-top:-120px;"><div style="color:#00AEAE;font-size:30px;">'+localdata.name+'</div></div><div style="height:20px;"></div>'
	        +'<div class="font-size margin-left">'+ 'Version:&nbsp' + localdata.version +'</div>'
	        +'<div class="font-size margin-left" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; max-width:400px; height:50px;">'+ 'Description:&nbsp' + data.appAbstract+'</div></div>'
	        +'<div style="float:right; width:200px;"><div style="margin-top:-105px;">'+appStatusButton+'</div>'
	        +'<div style="padding-top:10px;">'+uninstall+'</div></div><hr>'; */
	    $("#localList").append(context);
	}
}

function uninstallApp(appId) {
	debugger;
	aglSocket.uninstallApp(appId);
	Commons.showContent('<%=basePath%>/appDev/localApp');	
}
</script>