From 3b55d06b89bf64873e685c3d78fce5affbba3d17 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Tue, 16 Apr 2019 11:20:38 +0900 Subject: Add warehouse server source code. [Patch Set 2] Add ReadMe.md Change-Id: I6ade52d2490f5ca4ba107c1a27ed6d5b39048725 Signed-off-by: zheng_wenlong --- warehouse/src/main/webapp/js/deviceList.js | 199 +++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 warehouse/src/main/webapp/js/deviceList.js (limited to 'warehouse/src/main/webapp/js/deviceList.js') diff --git a/warehouse/src/main/webapp/js/deviceList.js b/warehouse/src/main/webapp/js/deviceList.js new file mode 100644 index 0000000..2602b5e --- /dev/null +++ b/warehouse/src/main/webapp/js/deviceList.js @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2019 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var queryParam = function(param) { + //debugger; + param.orderColumn = param.order[0].column; + param.orderDir = param.order[0].dir; + param.keyWord = $('#t_keyWord').val(); + param.typeId = TypeId; + param.deviceTypeId = deviceTypeId; + param.filepath = $('#t_filePath').val(); + return param; +}; + +function initAppList(localStr, isListDev) { + debugger; + localAppList = eval(localStr); + $table.DataTable({ + order : [ [ 1, 'asc' ] ], + lengthChange : false, + displayLength : 50, + retrieve: true, + ajax : { + url : $("#basePath").val() + '/appDev/search', + data : queryParam, + type : 'GET', + dataFilter : function(data) { + $errorArea.empty(); + $errorArea.css("display", "none"); + var json = $.parseJSON(data); + if (json.statusCode && json.statusCode != null) { + $errorArea.empty().append( + '
' + json.statusText + '
'); + $errorArea.css("display", "block"); + } + return data; // return JSON string + } + }, + columns : [ + { + className : 'td-operation', + data : null, + orderable : false, + defaultContent : '', + width : '80px', + render : function(data, type, row, meta) { + + //button show (install update launch) S + var appStatus = 0; //button word(install:0,update:2,launch:1) + var localApp = ""; + if (typeof(localAppList) != "undefined"){ + for (var i = 0; i < localAppList.length; i++) { + var appInfo = localAppList[i]; + if (appInfo.id.indexOf(data.appIdCustom) == 0){ + if(appInfo.version.indexOf(data.versionName) == 0){ + appStatus = 1; //launch + }else{ + appStatus = 2; //update + } + localApp = appInfo; + break; + } + } + } + if(appStatus == 2){ + downloadBtnOnclick = 'onclick=updateApp(this,"'+data.appId+'","'+data.typeId+'","'+data.verFilePath+'","'+localApp.id+'")>update'; + }else if(appStatus == 1){ + downloadBtnOnclick = 'onclick=launchApp("'+localApp.id+'")>launch'; + }else{ + downloadBtnOnclick = 'onclick=doDownload(this,"'+data.appId+'","'+data.typeId+'","'+data.verFilePath+'")>install'; + } + + var downloadBtn = '