luhanzhl 6 лет назад
Родитель
Сommit
2f10027447
51 измененных файлов с 3020 добавлено и 0 удалено
  1. 34 0
      test-tools/IoT-APP-Store-Demo/README.md
  2. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3
  3. 0 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py
  4. 3 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py
  5. 5 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py
  6. 0 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py
  7. 3 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py
  8. 152 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html
  9. 106 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html
  10. 119 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html
  11. 110 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html
  12. 99 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html
  13. 3 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py
  14. 284 0
      test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py
  15. 21 0
      test-tools/IoT-APP-Store-Demo/wasm_django/manage.py
  16. 0 0
      test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py
  17. 136 0
      test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py
  18. 41 0
      test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py
  19. 16 0
      test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py
  20. 616 0
      test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py
  21. 411 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css
  22. 227 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css
  23. 208 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css
  24. 228 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js
  25. 136 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js
  26. 62 0
      test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js
  27. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png
  28. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png
  29. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png
  30. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png
  31. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png
  32. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg
  33. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png
  34. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png
  35. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png
  36. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm
  37. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm
  38. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm
  39. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm
  40. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm
  41. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm
  42. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm
  43. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm
  44. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm
  45. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm
  46. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm
  47. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm
  48. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm
  49. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm
  50. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/vgl_wasm_runtime
  51. BIN
      test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl

+ 34 - 0
test-tools/IoT-APP-Store-Demo/README.md

@@ -0,0 +1,34 @@
+# IoT Application Store
+Wasm application management portal for WAMR
+
+# Requirement
+Install django with pip3  
+```
+pip3 install django
+```
+
+# Run 
+1. Start wasm server  
+    ```
+    cd wasm_django/server
+    python3 wasm_server.py
+    ```
+
+2. Start IoT application management web portal  
+    ```
+    cd wasm_django
+    python3 manage.py runserver 0.0.0.0:80
+    ```
+
+3. Download WAMR runtime from [help](http://localhost/help/) page
+    > NOTE: You need to start web server according to *step 2* before accessing this link!
+
+4. Start a WAMR runtime from localhost  
+    ```
+    ./simple
+    ```
+    or from other computers
+    ```
+    ./simple -a [your.server.ip.address]
+    ```
+

BIN
test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3


+ 0 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py


+ 3 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class DevicesConfig(AppConfig):
+    name = 'devices'

+ 0 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py


+ 3 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 152 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html

@@ -0,0 +1,152 @@
+<!-- /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/ -->
+{% load static %}
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0,shrink-to-fit=no">
+    <title> Wasm-Micro-Runtime </title>
+    <link rel="stylesheet" type="text/css" href="{%static 'css/application.css'%}"/> 
+    
+<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
+<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
+<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
+<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
+</head>
+
+<body  style="background-image: linear-gradient(to right, rgb(248, 248, 248) , rgb(194, 194, 190))">
+                				
+<div id="container" style="background-image: url('{%static 'photo//totalblack.png'%}')">
+    <div id="content">
+        <div id= "mainnav">
+            <ul>
+                <li ><a href="https://github.com/intel/wasm-micro-runtime">GitHub</a></li>
+                <li ><a href="/">Devices</a></li>
+                <li ><a href="/appstore/">App Store</a></li>
+                <li ><a href="/help/">Help</a></li>
+            </ul>  
+        </div>
+    </div>
+    <div class="headers" style="background-image: url('{%static 'photo/milky-way-2695569_1280.jpg'%}')">
+        <h1 id="maintitle">WebAssembly Micro Runtime - APP Store Demo</h1>
+    </div>
+</div>
+					
+
+    
+<div class="row">
+        <div class="col-sm-2 col-md-2 col-lg-2 col-xl-2"></div>
+        <div class="col-sm-8 col-md-8 col-lg-8 col-xl-8" id="section">
+            <div id="photo"> 
+            <p>
+                <img src="{%static 'photo/net_device.png'%}" ;height="65" width="65" />
+            </p>
+            </div>
+            <div id="IPs">IP : </div>
+            <div id="ports">Port : </div>
+            <div id="installs">Installed apps : </div>
+        </div>
+        <div class="col-sm-2 col-md-2 col-lg-2 col-xl-2"></div>
+</div>
+
+    <div class="middlebox" style="display:none;">
+        <div class="warning">Dialog Box</div>
+        <div class="findapp"> APP </div>
+        <button class="surebtn" type="button" value="sure">OK</button>
+    </div>
+
+    <div class="deletebox" style="display:none;">
+            <div class="warning2">Dialog Box</div>
+            <div class="findapp"> APP </div>
+            <button class="suresbtn" type="button" value="sure">OK</button>
+            <button class="cancelsbtn" type="button" value="Cancel">Cancel</button>
+    </div>
+
+    <div id="loading">
+        <p class="loadapp"> app is downloading now </p>
+        <div id="preloader">
+            <div id="loader"></div>
+        </div>
+    </div>
+
+    
+<div class="main">
+    <div class="mainbox">
+        <div class= "close"> × </div>
+        <div class="hotapps">HOT Applications</div>
+        <div class="col-sm-6" id="searchbar">
+                <form method="post" action="/apps/" id="form_addServiceInfoAll">
+                    {% csrf_token %}
+                    <div class="input-group">
+                        <input type="text" name="mykey" class="form-control" placeholder="Input the product name" required />
+                        <input type="hidden" name="voip" id="aa" value="">
+                        <input type="hidden" name="voport" id="bb" value="">
+                        <span class="input-group-btn">
+                            <input type="submit" class="btn btn-default" value="Search" />
+                        </span>
+                    </div>
+                </form>
+        </div>
+        <div id="scrollba">
+            <div id="Dapplications">
+                <div id="appslogo" style="width:45px; height:25px; float:left; "><img src="{%static 'photo/application.png'%}" ;height="35" width="35" /></div> 
+                <p id="appsinfo1" style="font-size:15px;font-family:'sansationlight';width:310px; height:25px; float:left; ">    Product Name:   </p>
+                <p id="appsinfo2" style="font-size:15px;font-family:'sansationlight';width:120px; height:25px; float:left; ">    Current Version:   </p>
+                <button class="mybtn2" type="button" onclick="getthis(this)" value="downloadit"> ↓ Install</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+
+    <div class="col-sm-8 col-md-8 col-lg-8 col-xl-8" id="download">
+            <p class = "explain pull-left" >List of Installed Apps:</p>
+            <button id="btn" class="btn btn-outline-primary pull-right" style="float:right" type="button" value="add">Install Application</button>
+    </div>
+
+
+    <div id="APPS" class="sourceapp">
+        <div id="applications">
+            <div id="applogo"><img src="{%static 'photo/app(1).png'%}" ;height="35" width="35" /></div>
+            <div id="appinfo1"> Product Name: </div>
+            <div id="appinfo2"> Staus: </div>
+            <div id="appinfo3"> Current Version: </div>
+        </div>
+        <div id="delete" ><img class="mybtn" style="cursor:pointer" src="{%static 'photo/delete.png'%}" ;height="35" width="35" /></div> 
+    </div>
+
+<footer class="footer">  Copyright&copy; intel.com</footer>
+                    
+
+
+<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
+<script>
+var alist = {{alist|safe}}; /*alist is a list of downloaded apps under the current device*/
+var dlist = {{dlist|safe}}; /*dlist saves the device info that includes its IP, Port and number of apps*/
+var llist = {{llist|safe}}; /*llist is a list of apps avaliable for installing that are synchronously updated with appstore*/
+var open_status ={{open_status|safe}};/*check is the search bar working&searching,otherwise, close window and return to the main page*/
+var search_node ={{search_node|safe}};/*THe queried app node*/
+</script>
+<script type="text/javascript" src="{%static 'js/application.js'%}"></script>
+
+</body>				
+
+</html>
+
+
+
+    

+ 106 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html

@@ -0,0 +1,106 @@
+<!-- /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/ -->
+{% load static %}
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0,shrink-to-fit=no">
+
+    <title> Wasm-Micro-Runtime </title>
+    <link rel="stylesheet" type="text/css" href="{%static 'css/appstore.css'%}"/> 
+
+<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
+<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
+<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
+<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
+</head>
+
+<body  style="background-color:rgb(240, 240, 240)">
+                				
+<div id="container" style="background-image: url('{%static 'photo//totalblack.png'%}')">
+    <div id="content">
+        <div id= "mainnav">
+            <ul>
+                <li ><a href="https://github.com/intel/wasm-micro-runtime">GitHub</a></li>
+                <li ><a href="/">Devices</a></li>
+                <li ><a href="/appstore/">App Store</a></li>
+                <li ><a href="/help/">Help</a></li>
+            </ul>  
+        </div>
+    </div>
+    <div class="headers" style="background-image: url('{%static 'photo/milky-way-2695569_1280.jpg'%}')">
+        <h1 id="maintitle">WebAssembly Micro Runtime - APP Store Demo</h1>
+    </div>
+</div>
+<!-- <div id="introinfo"></div> -->
+<!-- <div class="style-one"></div> -->
+
+<div class="deletebox" style="display:none;">
+        <div class="warning2">Dialog Box</div>
+            <div class="findapp"> APP </div>
+        <button class="suresbtn" type="button" value="sure">OK</button>
+        <button class="delsbtn" type="button" value="Cancel">Cancel</button>
+</div>
+
+ <div id = "introstore">
+    <div id="applicationlist">
+        <div class="bar">
+            <div class="leftpart">The products </div>
+            <div style="position:relative; float:left; left:50px; font-size:14px; height:50px; top:10px;">Application List</div>
+            <div class="rightpart">
+                <form action="/upload" method = "POST" enctype="multipart/form-data">
+                    {%csrf_token%}
+                    <div class="stylehere">
+                        <input type ="file" required name="myfile" class = "file">
+                        <a href="#" class="choosestyle">Choose File</a>
+                    </div>                
+                    <div class="stylehere">
+                        <input type="submit" value = "upload" class="btn btn-info">
+                    </div>
+                </form>
+            </div>
+        </div>
+        <div class = "appbook">
+                <div id="applications">
+                    <div id="appimage" ><img class="mysoftware" src="{%static 'photo/software-icon-32081.png'%}" ;height="50" width="40"/></div>
+                    <p id="appinfo1" style="position:relative; font-size:15px;width:35%; height:25px; float:left; left:5%;">    Product Name:   </p>
+                    <p id="appinfo2" style="position:relative; font-size:15px;width:30%; height:25px; float:left; left:5%;">   Product Version:   </p>
+                    <p id="lable" style="position:relative;font-size:11px;font-family:'logo';width:10%; height:25px; float:left; left:5%;">   Preloaded Apps   </p>  
+                    <button id="delbutton" type="button" style="position: relative; height:25px; float:left; left:5%;" onclick="deleteClick(this)" method = "get" name="delete">Remove</button>                        
+                </div>
+            </div>
+            <br>
+        </div>
+    </div>
+</div> 
+
+<footer class="footer">
+    Copyright&copy; intel.com
+</footer>
+
+<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>  
+<script>
+var elist = {{staticlist|safe}}/*saves all the apps that preloaded and are not able to be removed from applestore*/
+var flist = {{flist|safe}} /*a list of locally uploaded apps installed by users*/
+var ulist = {{ulist|safe}} /*Declare about is the app avaliable for uploading to the appstore: wasm_file OR preloaded already*/
+</script>
+<script type="text/javascript" src="{%static 'js/appstore.js'%}"></script>
+
+</body>
+
+</html>
+

+ 119 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html

@@ -0,0 +1,119 @@
+<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+<title>wasm-micro-runtime</title>
+
+<style type="text/css">
+html, body{overflow:hidden;margin:0;background:#000;}
+body{font-family:'Open Sans', 'Helvetica Neue', 'Hiragino Sans GB', 'LiHei Pro', Arial, sans-serif;color:#333;}
+#wrapper{position:absolute;left:0;width:320px;text-align:center;top:50%;left:50%;margin-left:-160px;margin-top:-160px;-webkit-user-select:none;-moz-user-select:none;user-select:none;}
+h1{font-family:'Montserrat', 'Helvetica Neue', Arial, sans-serif;font-weight:700;font-size:50px;letter-spacing:9px;text-transform:uppercase;color:#eee;margin:12px 0;left:4px;}
+h2{color:#999;font-weight:normal;font-size:20px;letter-spacing:.200em;margin-bottom:30px;left:3px;}
+h1, h2{position:relative;}
+p{font-size:14px;line-height:2em;margin:0;letter-spacing:2px;}
+canvas{position:absolute;top:0;left:0;z-index:0;width:100%;height:100%;pointer-events:none;}
+a{color:#999;text-decoration:none;transition:color .2s ease;}
+a:hover{color:#f33;}
+</style>
+
+
+
+</head>
+<body>
+
+<script type="text/javascript" src="./js/jquery.min.js"></script>
+
+<div id="wrapper">
+	<h1>404</h1>
+	<h2>Server Not Found</h2>
+	<p><a href="https://github.com/intel/wasm-micro-runtime" target="_blank">Github</a></p>
+</div>
+
+
+<canvas width="1920" height="917"></canvas>
+
+<script type="text/javascript">
+document.addEventListener('touchmove', function (e) {
+	e.preventDefault()
+})
+var c = document.getElementsByTagName('canvas')[0],
+	x = c.getContext('2d'),
+	pr = window.devicePixelRatio || 1,
+	w = window.innerWidth,
+	h = window.innerHeight,
+	f = 90,
+	q,
+	m = Math,
+	r = 0,
+	u = m.PI*2,
+	v = m.cos,
+	z = m.random
+c.width = w*pr
+c.height = h*pr
+x.scale(pr, pr)
+x.globalAlpha = 0.6
+function i(){
+	x.clearRect(0,0,w,h)
+	q=[{x:0,y:h*.7+f},{x:0,y:h*.7-f}]
+	while(q[1].x<w+f) d(q[0], q[1])
+}
+function d(i,j){   
+	x.beginPath()
+	x.moveTo(i.x, i.y)
+	x.lineTo(j.x, j.y)
+	var k = j.x + (z()*2-0.25)*f,
+		n = y(j.y)
+	x.lineTo(k, n)
+	x.closePath()
+	r-=u/-50
+	x.fillStyle = '#'+(v(r)*127+128<<16 | v(r+u/3)*127+128<<8 | v(r+u/3*2)*127+128).toString(16)
+	x.fill()
+	q[0] = q[1]
+	q[1] = {x:k,y:n}
+}
+function y(p){
+	var t = p + (z()*2-1.1)*f
+	return (t>h||t<0) ? y(p) : t
+}
+document.onclick = i
+document.ontouchstart = i
+i()
+</script>
+
+<script type="text/javascript">
+var snow = function() {
+if(1==1) {
+$("body").append('<canvas id="christmasCanvas" style="top: 0px; left: 0px; z-index: 5000; position: fixed; pointer-events: none;"></canvas>');
+var b = document.getElementById("christmasCanvas"), a = b.getContext("2d"), d = window.innerWidth, c = window.innerHeight;
+b.width = d;
+b.height = c;
+for(var e = [], b = 0;b < 70;b++) {
+e.push({x:Math.random() * d, y:Math.random() * c, r:Math.random() * 4 + 1, d:Math.random() * 70})
+}
+var h = 0;
+window.intervral4Christmas = setInterval(function() {
+a.clearRect(0, 0, d, c);
+a.fillStyle = "rgba(255, 255, 255, 0.6)";
+a.shadowBlur = 5;
+a.shadowColor = "rgba(255, 255, 255, 0.9)";
+a.beginPath();
+for(var b = 0;b < 70;b++) {
+var f = e[b];
+a.moveTo(f.x, f.y);
+a.arc(f.x, f.y, f.r, 0, Math.PI * 2, !0)
+}
+a.fill();
+h += 0.01;
+for(b = 0;b < 70;b++) {
+if(f = e[b], f.y += Math.cos(h + f.d) + 1 + f.r / 2, f.x += Math.sin(h) * 2, f.x > d + 5 || f.x < -5 || f.y > c) {
+e[b] = b % 3 > 0 ? {x:Math.random() * d, y:-10, r:f.r, d:f.d} : Math.sin(h) > 0 ? {x:-5, y:Math.random() * c, r:f.r, d:f.d} : {x:d + 5, y:Math.random() * c, r:f.r, d:f.d}
+}
+}
+}, 70)
+}
+}
+snow();
+</script><canvas id="christmasCanvas" style="top: 0px; left: 0px; z-index: 5000; position: fixed; pointer-events: none;" width="1920" height="917"></canvas>
+
+
+</body></html>

+ 110 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html

@@ -0,0 +1,110 @@
+<!-- /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/ -->
+{% load static %}
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title> Wasm-Micro-Runtime </title>
+    <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
+    <!-- <link rel="stylesheet" type="text/css" href="{%static%/css/index.css"/>  -->
+    <!-- <link rel="stylesheet" type="text/css" href="/home/xujun/mysite/static/css/index.css"/> -->
+
+    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
+    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
+    <script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
+    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
+
+    <head>
+
+    <body>
+        <div class="container">
+            <div class="row clearfix">
+                <div class="col-md-12 column">
+                    <div class="jumbotron">
+                        <h1>
+                            How to use?
+                        </h1>
+                        <p>
+                            1. Download a simple runtime (build for ubuntu 16.04 64 bits, other platforms please build
+                            from the <a href="https://github.com/intel/wasm-micro-runtime">source code</a>)
+                        </p>
+                        <p>
+                            2. In the terminal: <code>cd ~/Download && ./simple -a 39.106.110.7</code>
+                        </p>
+                        <div class="span12">
+                            <div class="alert alert-info">
+                                <!-- <button class="close" type="button" data-dismiss="alert">×</button> -->
+                                <h5>
+                                    Notes:
+                                </h5> We also have a <strong>UI-enabled runtime</strong>, please <a
+                                    href="../static/upload/simple">download here</a> and enjoy.</strong> It may require
+                                a few more setups.
+                                <p>Before running the UI-enabled runtime, please install some required softwares:</p>
+                                <p><code>sudo apt-get install libsdl2-2.0-0:i386</code> </p>
+                                <p>For more details please refer to this <a
+                                        href="https://github.com/intel/wasm-micro-runtime/tree/master/samples/littlevgl">guide</a>
+                                </p>
+                                <p><code>cd ~/Download && ./wasm_runtime_wgl -a 39.106.110.7</code></p>
+                            </div>
+                        </div>
+                        <p>
+                            3. Return to device page, find your device according to the IP address and click it, you
+                            will enter application installation page
+                        </p>
+                        <p>
+                            4. In the application installation page, click the Install Application button, and chose an
+                            app to install. (The "ui_app" is only for UI_enabled_runtimes, simple runtime can't install
+                            this app)
+                        </p>
+                        <p>
+                            5. If you want to upload a new application, go to App Store page, choose a file and click
+                            upload
+                        </p>
+                        <p>
+                            <a class="btn btn-primary btn-large" href="/">Go Back</a>
+                            <a class="btn btn-primary btn-large" href="../static/upload/simple">Download
+                                simple_runtime</a>
+                            <a class="btn btn-primary btn-large" href="../static/upload/wasm_runtime_wgl">Download
+                                UI_enabled_runtime</a>
+                        </p>
+                    </div>
+                    <div class="container">
+                        <div class="card">
+                            <div class="card-body">
+                                <h4 class="card-title">Like this project?</h4>
+                                <p class="card-text">Join us and build a powerful and interesting world for embedded
+                                    devices!</p>
+                                <iframe
+                                    src="https://ghbtns.com/github-btn.html?user=intel&repo=wasm-micro-runtime&type=star&count=true&size=large"
+                                    frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
+                                <iframe
+                                    src="https://ghbtns.com/github-btn.html?user=intel&repo=wasm-micro-runtime&type=fork&count=true&size=large"
+                                    frameborder="0" scrolling="0" width="158px" height="30px"></iframe>
+                                <p>
+                                    <a href="https://github.com/intel/wasm-micro-runtime" class="btn btn-success">View
+                                        on GitHub</a>
+                                </p>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+
+</html>

+ 99 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html

@@ -0,0 +1,99 @@
+<!-- /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/ -->
+{% load static %}
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta charset="utf-8" />
+	<meta name="viewport" content="width=device-width, initial-scale=1.0,shrink-to-fit=no">
+    <title> Wasm-Micro-Runtime </title>
+	<link rel="stylesheet" type="text/css" href="{%static 'css/index.css'%}"/> 
+    
+<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
+<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
+<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
+<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
+</head>
+
+
+<body>
+<div id="container" style="background-image: url('{%static 'photo/totalblack.png'%}')">
+    <div id="content">
+        <div id= "mainnav">
+            <ul>
+                <li ><a href="https://github.com/intel/wasm-micro-runtime">GitHub</a></li>
+                <li ><a href="/">Devices</a></li>
+                <li ><a href="/appstore/">App Store</a></li>
+                <li ><a href="/help/">Help</a></li>
+            </ul>  
+        </div>
+    </div>
+    <div class="headers" style="background-image: url('{%static 'photo/milky-way-2695569_1280.jpg'%}')">
+        <h1 id="maintitle">WebAssembly Micro Runtime - APP Store Demo</h1>
+    </div>
+</div>  
+        
+<div class="row">
+    <div class="col-sm-1 col-md-1 col-lg-1 col-xl-1"></div>
+    <div class="col-sm-4 col-md-4 col-lg-4 col-xl-4">
+        <div id="photo2">
+            <p>
+                <img src="{%static 'photo/net_device.png'%}" ;height="45" width="45" />
+            </p>
+        </div>
+        <div id="devic"><p style="font-size:22px;">The devices</p></div>
+    </div>
+</div>
+ 
+<div id="dividebar"></div>
+
+
+<div id="devices" class="devics">
+    <div class="deviceClick" style="cursor:pointer" onclick="deviceClick(this)">
+        <div id="section">
+            <div id="photo">
+                <p>
+                    <img src="{%static 'photo/net_device.png'%}" ;height="60" width="60" />
+                </p>
+            </div>
+            <div id="IPs">IP : </div>
+            <div id="ports">Port : </div>
+            <div id="installs">Installed apps : </div>
+        </div>
+        <div class="smenu">
+            <p id="del" style="cursor:pointer">
+                <img class = "toapps" src="{%static 'photo/menu.png'%}" href= "javascript:void(0);" height="30" width="30" />
+            </p>
+        </div>
+    </div>
+</div>
+
+<!-- <button class="prev" type="button" value="prev" onclick="prevpage(this)">Previous</button>-->
+<!-- <button class="next" type="button" value="next" onclick="nextpage(this)">Next</button> -->
+
+<footer class="footer">
+    Copyright&copy; intel.com
+</footer>
+
+
+<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
+<script>
+var dlist = {{dlist|safe}};/*Devices List that render to the current page*/
+</script>        
+<script type="text/javascript" src="{%static 'js/index.js'%}"></script>
+</body>
+
+</html>

+ 3 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 284 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py

@@ -0,0 +1,284 @@
+'''
+ /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+ *
+ * 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.
+ */
+'''
+
+# _*_
+from django.shortcuts import render, render_to_response
+from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
+import json
+import socket
+import os
+
+# Create your views here.
+
+
+avaliable_list = [
+    {'ID': 'timer', 'Version': '1.0'}, 
+    {'ID': 'connection', 'Version': '1.0'}, 
+    {'ID': 'event_publisher', 'Version': '3.0'}, 
+    {'ID': 'event_subscriber', 'Version': '1.0'}, 
+    {'ID': 'request_handler', 'Version': '1.0'}, 
+    {'ID': 'sensor', 'Version': '1.0'}, 
+    {'ID': 'ui_app', 'Version': '1.0'}
+]
+
+# Help
+def help(req):
+# return "Help" page 
+    return render(req, "help.html")
+
+# View
+def index(req):
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+    host = '127.0.0.1'
+    port = 8889
+    msg = ""
+    err = ""
+
+    try:
+        s.connect((host, port))
+        s.send(bytes("query:all", encoding='utf8'))
+        s.settimeout(10)
+        msg = s.recv(1024)
+    except socket.timeout as e:
+        err = "empty"
+        print("no client connected")
+    except socket.error as e:
+        err = "refused"
+        print("server not started")
+
+    s.close()
+
+    device_list = []
+    if msg != "":
+        devices = msg.decode('utf-8').split("*")
+        for dev in devices:
+            dev_info = eval(dev)
+            addr = dev_info['addr']
+            port = dev_info['port']
+            apps = dev_info['num']
+            device_list.append({'IP': addr, 'Port': port, 'apps': apps})    
+    else:
+        if err == "refused":
+            return render(req, "empty.html")
+
+    dlist = device_list
+
+    return render(req, 'mysite.html', {'dlist': json.dumps(dlist)})
+
+
+def apps(req):
+    open_status = ''
+    search_node = []
+    if req.method == "POST":
+            dev_search = req.POST['mykey']
+            dev_addr = req.POST['voip']
+            dev_port = req.POST['voport']
+            open_status = 'open'
+            for i in avaliable_list:
+                if i['ID'] == dev_search:
+                    search_node = [{'ID':dev_search, 'Version': '1.0'}]
+                    print("search_node:",search_node)
+                    break
+                else:
+                    search_node = ["Nothing find"]
+                    print( "final:",search_node)
+    else:
+        dev_addr = req.GET['ip']
+        dev_port = req.GET['port']
+        open_status = 'close'
+
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    host = '127.0.0.1'
+    port = 8889
+    msg = ""
+    err = ""    
+
+    try:
+        s.connect((host, port))
+        s.send(bytes("query:"+dev_addr+":"+str(dev_port), encoding='utf8'))
+        msg = s.recv(1024)
+    except socket.error as e:
+        print("unable to connect to server")
+        msg = b"fail"
+    s.close()
+
+    app_list = []
+
+    if msg != "":
+        if msg.decode() == "fail":
+            return render(req, "empty.html")
+        else:
+            dic = eval(msg.decode(encoding='utf8'))
+            app_num = dic["num"]
+            for i in range(app_num):
+                app_list.append(
+                    {'pname': dic["applet"+str(i+1)], 'status': 'Installed', 'current_version': '1.0'})
+
+    alist = app_list
+    device_info = []
+    device_info.append(
+        {'IP': dev_addr, 'Port': str(dev_port), 'apps': app_num})
+
+    print(device_info)
+    return render(req, 'application.html', {'alist': json.dumps(alist), 'dlist': json.dumps(device_info), 'llist': json.dumps(avaliable_list),
+    "open_status":json.dumps(open_status),"search_node": json.dumps(search_node),})
+
+
+def appDownload(req):
+    dev_addr = req.GET['ip']
+    dev_port = req.GET['port']
+    app_name = req.GET['name']
+
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+    host = '127.0.0.1'
+    port = 8889
+    msg = ""
+
+    app_path = os.path.abspath(os.path.join(os.getcwd(), "static", "upload"))
+    if app_path[-1] != '/':
+        app_path += '/'
+
+    try:
+        s.connect((host, port))
+        s.send(bytes("install:"+dev_addr+":"+str(dev_port)+":"+app_name +
+                     ":"+app_path + app_name + ".wasm", encoding='utf8'))
+        msg = s.recv(1024)
+    except socket.error as e:
+        print("unable to connect to server")
+    s.close()
+
+    success = "ok"
+    fail = "Fail!"
+    status = [success, fail]
+    print(msg)
+    if msg == b"fail":
+        return HttpResponse(json.dumps({
+            "status": fail
+        }))
+    elif msg == b"success":
+        return HttpResponse(json.dumps({
+            "status": success
+        }))
+    else:
+        return HttpResponse(json.dumps({
+            "status": eval(msg.decode())["error message"].split(':')[1]
+        }))
+
+
+def appDelete(req):
+    dev_addr = req.GET['ip']
+    dev_port = req.GET['port']
+    app_name = req.GET['name']
+
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+    host = '127.0.0.1'
+    port = 8889
+    s.connect((host, port))
+    s.send(bytes("uninstall:"+dev_addr+":" +
+                 str(dev_port)+":"+app_name, encoding='utf8'))
+    msg = s.recv(1024)
+    s.close()
+    r = HttpResponse("ok")
+    return r
+
+static_list = [{'ID': 'timer', 'Version': '1.0'}, {'ID': 'connection', 'Version': '1.0'}, {'ID': 'event_publisher', 'Version': '3.0'}, {
+         'ID': 'event_subscriber', 'Version': '1.0'}, {'ID': 'reuqest_handler', 'Version': '1.0'}, {'ID': 'sensor', 'Version': '1.0'}, {'ID': 'ui_app', 'Version': '1.0'}]
+
+def store(req):
+
+    store_path = os.path.join('static', 'upload')
+    status = []
+
+    print(user_file_list)
+    return render(req, 'appstore.html', {'staticlist': json.dumps(static_list), 'flist': json.dumps(user_file_list),'ulist':json.dumps(status)})
+
+user_file_list = []
+files_list = []
+def uploadapps(req):
+    status = []
+    local_list = ['timer','connection','event_publisher','event_subscriber','reuqest_handler','sensor']
+    req.encoding = 'utf-8'
+    if req.method == 'POST':
+        myfile = req.FILES.get("myfile", None)
+        obj = req.FILES.get('myfile')
+        store_path = os.path.join('static', 'upload')
+        file_path = os.path.join('static', 'upload', obj.name)
+
+        if not os.path.exists(store_path):
+            os.makedirs(store_path)
+        
+        file_name = obj.name.split(".")[0]
+        file_prefix = obj.name.split(".")[-1]
+
+
+        if file_prefix != "wasm":
+            status = ["Not a wasm file"]
+        elif file_name in local_list:
+            status = ["This App is preloaded"]   
+        elif file_name in files_list:
+            status = ["This App is already uploaded"]        
+        else:
+            status = []
+            avaliable_list.append({'ID': file_name, 'Version': '1.0'})
+            user_file_list.append({'ID': file_name, 'Version': '1.0'})
+            files_list.append(file_name)   
+       
+        print(user_file_list)
+        f = open(file_path, 'wb')
+        for chunk in obj.chunks():
+            f.write(chunk)
+        f.close()
+        return render(req, 'appstore.html', {'staticlist': json.dumps(static_list), 'flist': json.dumps(user_file_list),'ulist':json.dumps(status)})
+
+appname_list = []
+
+def addapps(request):
+    types = ''
+    print("enter addapps")
+    request.encoding = 'utf-8'
+    app_dic = {'ID': '', 'Version': ''}
+
+    # if request.method == 'get':
+    if "NAME" in request.GET:
+        a_name = request.GET['NAME']
+        if a_name != "" and a_name not in appname_list:
+            appname_list.append(a_name)
+            message = request.GET['NAME'] + request.GET['Version']
+            app_dic['ID'] = request.GET['NAME']
+            app_dic['Version'] = request.GET['Version']
+            avaliable_list.append(app_dic)
+        else:
+            types = "Exist"
+    print(avaliable_list)
+    return render(request, 'appstore.html', {'alist': json.dumps(avaliable_list)})
+
+def removeapps(req):
+    app_name = req.GET['name']
+    app_version = req.GET['version']
+    remove_app = {'ID': app_name, 'Version': app_version}
+    avaliable_list.remove(remove_app)
+    user_file_list.remove(remove_app)
+    files_list.remove(app_name)
+    return render(req, 'appstore.html', {'alist': json.dumps(avaliable_list),'flist': json.dumps(user_file_list)})
+
+# Test
+if __name__ == "__main__":
+    print(device_list[0]['IP'])
+    print(device['IP'])

+ 21 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/manage.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
+    try:
+        from django.core.management import execute_from_command_line
+    except ImportError as exc:
+        raise ImportError(
+            "Couldn't import Django. Are you sure it's installed and "
+            "available on your PYTHONPATH environment variable? Did you "
+            "forget to activate a virtual environment?"
+        ) from exc
+    execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+    main()

+ 0 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py


+ 136 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py

@@ -0,0 +1,136 @@
+"""
+Django settings for mysite project.
+
+Generated by 'django-admin startproject' using Django 2.2.2.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/2.2/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/2.2/ref/settings/
+"""
+
+import os
+from django.conf.global_settings import STATIC_ROOT
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '8m05#6yx5wcygj*a+v6+=-y(#o+(z58-3!epq$u@5)64!mmu8q'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = ['*']
+
+
+# Application definition
+
+INSTALLED_APPS = [
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+
+ 
+    'devices',
+]
+
+MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'mysite.urls'
+
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [],
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+
+WSGI_APPLICATION = 'mysite.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+    }
+}
+
+
+# Password validation
+# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+    {
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+    },
+]
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/2.2/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+APPEND_SLASH = False
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/2.2/howto/static-files/
+
+STATIC_URL = '/static/'
+HERE = os.path.dirname(os.path.abspath(__file__))
+HERE = os.path.join(HERE,'../')
+STATICFILES_DIRS = (os.path.join(HERE,'static/'),)
+#STATICFILES_DIRS = (os.path.join(BASE_DIR,'static'),)
+#STATIC_ROOT = (os.path.join(os.path.dirname(_file_),'static')
+#templates
+TEMPLATE_DIRS=[
+   '/home/xujun/mysite/templates', 
+]
+

+ 41 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py

@@ -0,0 +1,41 @@
+#config:utf-8
+
+"""mysite URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/2.2/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.contrib import admin
+#from django.conf.urls import include,url
+from django.urls import path,include
+from devices import views as devices_views
+#from login import views as login_views
+
+
+urlpatterns = [
+
+    path('admin/', admin.site.urls),
+    path('',devices_views.index),
+    path('apps/',devices_views.apps),
+    path('appDownload/', devices_views.appDownload),
+    path('appDelete/', devices_views.appDelete),
+    path('appstore/',devices_views.store),
+##    path('apps/appstore/',devices_views.storeofdevic),
+##    path('search/',devices_views.search),
+    path('upload',devices_views.uploadapps),
+    path('removeapps/',devices_views.removeapps),
+    path('help/',devices_views.help),
+    
+]
+
+

+ 16 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for mysite project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
+
+application = get_wsgi_application()

+ 616 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py

@@ -0,0 +1,616 @@
+'''
+ /* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+ *
+ * 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.
+ */
+'''
+import select
+import socket
+import queue
+from time import sleep
+import struct
+import threading
+import time
+from ctypes import *
+import json
+import logging
+import os
+
+attr_type_list =  [
+    "ATTR_NONE",
+    "ATTR_TYPE_SHORT",
+    "ATTR_TYPE_INT",
+    "ATTR_TYPE_INT64",
+    "ATTR_TYPE_BYTE",
+    "ATTR_TYPE_UINT16",
+    "ATTR_TYPE_FLOAT",
+    "ATTR_TYPE_DOUBLE",
+    "ATTR_TYPE_BOOLEAN",
+    "ATTR_TYPE_STRING",
+    "ATTR_TYPE_BYTEARRAY"
+]
+
+
+Phase_Non_Start = 0
+Phase_Leading = 1
+Phase_Type = 2
+Phase_Size = 3
+Phase_Payload = 4
+
+
+
+class imrt_link_message(object):
+    def __init__(self):
+        self.leading = bytes([0x12, 0x34])
+        self.phase = Phase_Non_Start
+        self.size_in_phase = 0
+        self.message_type = bytes()
+        self.message_size = bytes()
+        self.payload = bytes()
+        self.msg = bytes()
+
+    def set_recv_phase(self, phase):
+        self.phase = phase
+
+    def on_imrt_link_byte_arrive(self, ch):
+        self.msg += ch
+        if self.phase == Phase_Non_Start:
+            if ch == b'\x12':
+                self.set_recv_phase(Phase_Leading)
+            else:
+                return -1
+        elif self.phase == Phase_Leading:
+            if ch == b'\x34':
+                self.set_recv_phase(Phase_Type)
+            else:
+                self.set_recv_phase(Phase_Non_Start)
+                return -1
+        elif self.phase == Phase_Type:
+            self.message_type += ch
+            self.size_in_phase += 1
+
+            if self.size_in_phase == 2:
+                (self.message_type, ) = struct.unpack('!H', self.message_type)
+                self.size_in_phase = 0
+                self.set_recv_phase(Phase_Size)
+        elif self.phase == Phase_Size:
+            self.message_size += ch
+            self.size_in_phase += 1
+
+            if self.size_in_phase == 4:
+                (self.message_size, ) = struct.unpack('!I', self.message_size)
+                self.size_in_phase = 0
+                self.set_recv_phase(Phase_Payload)
+
+                if self.message_size == b'\x00':
+                    self.set_recv_phase(Phase_Non_Start)
+                    return 0
+
+                self.set_recv_phase(Phase_Payload)
+
+        elif self.phase == Phase_Payload:
+            self.payload += ch
+            self.size_in_phase += 1
+
+            if self.size_in_phase == self.message_size:
+                self.set_recv_phase(Phase_Non_Start)
+                return 0
+
+            return 2
+
+        return 1
+
+
+
+def read_file_to_buffer(file_name):
+    file_object = open(file_name, 'rb')
+    buffer = None
+
+    if not os.path.exists(file_name):
+        logging.error("file {} not found.".format(file_name))
+        return "file not found"
+
+    try:
+        buffer = file_object.read()
+    finally:
+        file_object.close()
+
+    return buffer
+
+def decode_attr_container(msg):
+
+    attr_dict = {}
+
+    buf = msg[26 : ]
+    (total_len, tag_len) = struct.unpack('@IH', buf[0 : 6])
+    tag_name = buf[6 : 6 + tag_len].decode()
+    buf = buf[6 + tag_len : ]
+    (attr_num, ) = struct.unpack('@H', buf[0 : 2])
+    buf = buf[2 : ]
+
+    logging.info("parsed attr:")
+    logging.info("total_len:{}, tag_len:{}, tag_name:{}, attr_num:{}"
+            .format(str(total_len), str(tag_len), str(tag_name), str(attr_num)))
+
+    for i in range(attr_num):
+        (key_len, ) = struct.unpack('@H', buf[0 : 2])
+        key_name = buf[2 : 2 + key_len - 1].decode()
+        buf = buf[2 + key_len : ]
+        (type_index, ) = struct.unpack('@c', buf[0 : 1])
+
+        attr_type = attr_type_list[int(type_index[0])]
+        buf = buf[1 : ]
+
+        if attr_type == "ATTR_TYPE_SHORT":
+            (attr_value, ) = struct.unpack('@h', buf[0 : 2])
+            buf = buf[2 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_INT":
+            (attr_value, ) = struct.unpack('@I', buf[0 : 4])
+            buf = buf[4 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_INT64":
+            (attr_value, ) = struct.unpack('@q', buf[0 : 8])
+            buf = buf[8 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_BYTE":
+            (attr_value, ) = struct.unpack('@c', buf[0 : 1])
+            buf = buf[1 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_UINT16":
+            (attr_value, ) = struct.unpack('@H', buf[0 : 2])
+            buf = buf[2 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_FLOAT":
+            (attr_value, ) = struct.unpack('@f', buf[0 : 4])
+            buf = buf[4 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_DOUBLE":
+            (attr_value, ) = struct.unpack('@d', buf[0 : 8])
+            buf = buf[8 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_BOOLEAN":
+            (attr_value, ) = struct.unpack('@?', buf[0 : 1])
+            buf = buf[1 : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_STRING":
+            (str_len, ) = struct.unpack('@H', buf[0 : 2])
+            attr_value = buf[2 : 2 + str_len - 1].decode()
+            buf = buf[2 + str_len : ]
+            # continue
+        elif attr_type == "ATTR_TYPE_BYTEARRAY":
+            (byte_len, ) = struct.unpack('@I', buf[0 : 4])
+            attr_value = buf[4 : 4 + byte_len]
+            buf = buf[4 + byte_len : ]
+            # continue
+
+        attr_dict[key_name] = attr_value
+
+    logging.info(str(attr_dict))
+    return attr_dict
+
+class Request():
+    mid = 0
+    url = ""
+    action = 0
+    fmt = 0
+    payload = ""
+    payload_len = 0
+    sender = 0
+
+    def __init__(self, url, action, fmt, payload, payload_len):
+        self.url = url
+        self.action = action
+        self.fmt = fmt
+        # if type(payload) == bytes:
+        #     self.payload = bytes(payload, encoding = "utf8")
+        # else:
+        self.payload_len = payload_len
+        if self.payload_len > 0:
+            self.payload = payload
+        
+    
+    def pack_request(self):
+        url_len = len(self.url) + 1
+        buffer_len = url_len + self.payload_len
+
+        req_buffer = struct.pack('!2BH2IHI',1, self.action, self.fmt, self.mid, self.sender, url_len, self.payload_len)
+        for i in range(url_len - 1):
+            req_buffer += struct.pack('!c', bytes(self.url[i], encoding = "utf8"))
+        req_buffer += bytes([0])
+        for i in range(self.payload_len):
+            req_buffer += struct.pack('!B', self.payload[i])    
+
+        return req_buffer, len(req_buffer)
+
+
+    def send(self, conn, is_install):
+        leading = struct.pack('!2B', 0x12, 0x34)
+        
+        if not is_install:
+            msg_type = struct.pack('!H', 0x0002)
+        else:
+            msg_type = struct.pack('!H', 0x0004)
+        buff, buff_len = self.pack_request()
+        lenth = struct.pack('!I', buff_len)
+
+        try:
+            conn.send(leading)
+            conn.send(msg_type)
+            conn.send(lenth)
+            conn.send(buff)
+        except socket.error as e:
+            logging.error("device closed")
+            for dev in tcpserver.devices:
+                if dev.conn == conn:
+                    tcpserver.devices.remove(dev)
+            return -1
+            
+
+def query(conn):
+    req = Request("/applet", 1, 0, "", 0)
+    if req.send(conn, False) == -1:
+        return "fail"
+    time.sleep(0.05)
+    try:
+        receive_context = imrt_link_message()
+        start = time.time()
+        while True:
+            if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0:
+                break
+            elif time.time() - start >= 5.0:
+                return "fail"
+        query_resp = receive_context.msg
+        print(query_resp)
+    except OSError as e:
+        logging.error("OSError exception occur")
+        return "fail"
+
+    res = decode_attr_container(query_resp)
+
+    logging.info('Query device infomation success')
+    return res
+
+def install(conn, app_name, wasm_file):
+    wasm = read_file_to_buffer(wasm_file)
+    if wasm == "file not found":
+        return "failed to install: file not found"
+        
+    print("wasm file len:")
+    print(len(wasm))
+    req = Request("/applet?name=" + app_name, 3, 98, wasm, len(wasm))
+    if req.send(conn, True) == -1:
+        return "fail"
+    time.sleep(0.05)
+    try:
+        receive_context = imrt_link_message()
+        start = time.time()
+        while True:
+            if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0:
+                break
+            elif time.time() - start >= 5.0:
+                return "fail"
+        msg = receive_context.msg
+    except OSError as e:
+        logging.error("OSError exception occur")
+    # TODO: check return message
+
+    if len(msg) == 24 and msg[8 + 1] == 65:
+        logging.info('Install application success')
+        return "success"
+    else:
+        res = decode_attr_container(msg)
+        logging.warning('Install application failed: %s' % (str(res)))
+        print(str(res))
+
+        return str(res)
+    
+
+def uninstall(conn, app_name):
+    req = Request("/applet?name=" + app_name, 4, 99, "", 0)
+    if req.send(conn, False) == -1:
+        return "fail"
+    time.sleep(0.05)
+    try:
+        receive_context = imrt_link_message()
+        start = time.time()
+        while True:
+            if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0:
+                break
+            elif time.time() - start >= 5.0:
+                return "fail"
+        msg = receive_context.msg
+    except OSError as e:
+        logging.error("OSError exception occur")
+    # TODO: check return message
+
+    if len(msg) == 24 and msg[8 + 1] == 66:
+        logging.info('Uninstall application success')
+        return "success"
+    else:
+        res = decode_attr_container(msg)
+        logging.warning('Uninstall application failed: %s' % (str(res)))
+        print(str(res))
+
+        return str(res)
+
+class Device:
+    def __init__(self, conn, addr, port):
+        self.conn = conn
+        self.addr = addr
+        self.port = port
+        self.app_num = 0
+        self.apps = []
+
+cmd = []
+
+class TCPServer:
+    def __init__(self, server, server_address, inputs, outputs, message_queues):
+        # Create a TCP/IP
+        self.server = server
+        self.server.setblocking(False)
+
+        # Bind the socket to the port
+        self.server_address = server_address
+        print('starting up on %s port %s' % self.server_address)
+        self.server.bind(self.server_address)
+
+        # Listen for incoming connections
+        self.server.listen(10)
+
+        self.cmd_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.cmd_sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
+
+        self.cmd_sock.bind(('127.0.0.1', 8889))
+        self.cmd_sock.listen(5)
+
+
+        # Sockets from which we expect to read
+        self.inputs = inputs
+        self.inputs.append(self.cmd_sock)
+
+        # Sockets to which we expect to write
+        # 处理要发送的消息
+        self.outputs = outputs
+        # Outgoing message queues (socket: Queue)
+        self.message_queues = message_queues
+
+        self.devices = []
+        self.conn_dict = {}
+
+    def handler_recever(self, readable):
+        # Handle inputs
+        for s in readable:
+            if s is self.server:
+                # A "readable" socket is ready to accept a connection
+                connection, client_address = s.accept()
+                self.client_address = client_address
+                print('connection from', client_address)
+                # this is connection not server
+                # connection.setblocking(0)
+                self.inputs.append(connection)
+
+                # Give the connection a queue for data we want to send
+                # self.message_queues[connection] = queue.Queue()
+
+                res = query(connection)
+                
+                if res != "fail":
+                    dev = Device(connection, client_address[0], client_address[1])
+                    self.devices.append(dev)
+                    self.conn_dict[client_address] = connection
+
+                    dev_info = {}
+                    dev_info['addr'] = dev.addr
+                    dev_info['port'] = dev.port
+                    dev_info['apps'] = 0
+
+                    logging.info('A new client connected from ("%s":"%s")' % (dev.conn, dev.port))
+
+            elif s is self.cmd_sock:
+                connection, client_address = s.accept()
+                print("web server socket connected")
+                logging.info("Django server connected")
+                self.inputs.append(connection)
+                self.message_queues[connection] = queue.Queue()
+
+            else:
+                data = s.recv(1024)
+                if data != b'':
+                    # A readable client socket has data
+                    logging.info('received "%s" from %s' % (data, s.getpeername()))
+                    
+                    # self.message_queues[s].put(data)
+                    # # Add output channel for response
+                   
+                    # if s not in self.outputs:
+                    #     self.outputs.append(s)
+                    
+                    if(data.decode().split(':')[0] == "query"):
+                        if data.decode().split(':')[1] == "all":
+                            resp = []
+                            print('start query all devices')
+                            for dev in self.devices:
+                                dev_info = query(dev.conn)
+                                if dev_info == "fail":
+                                    continue
+                                dev_info["addr"] = dev.addr
+                                dev_info["port"] = dev.port
+                                resp.append(str(dev_info))
+                                
+                                print(resp)
+
+                            if self.message_queues[s] is not None:
+                                # '*' is used in web server to sperate the string
+                                self.message_queues[s].put(bytes("*".join(resp), encoding = 'utf8'))
+                                if s not in self.outputs:
+                                    self.outputs.append(s)
+                        else:
+                            client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2]))
+
+                            if client_addr in self.conn_dict.keys():
+                                print('start query device from (%s:%s)' % (client_addr[0], client_addr[1]))
+                                resp = query(self.conn_dict[client_addr])
+                                print(resp)
+
+                                if self.message_queues[s] is not None:
+                                    self.message_queues[s].put(bytes(str(resp), encoding = 'utf8'))
+                                    if s not in self.outputs:
+                                        self.outputs.append(s)
+                            else:   # no connection
+                                if self.message_queues[s] is not None:
+                                    self.message_queues[s].put(bytes(str("fail"), encoding = 'utf8'))
+                                    if s not in self.outputs:
+                                        self.outputs.append(s)
+                    elif(data.decode().split(':')[0] == "install"):
+                        client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2]))
+                        app_name = data.decode().split(':')[3]
+                        app_file = data.decode().split(':')[4]
+
+                        if client_addr in self.conn_dict.keys():
+                            print('start install application %s to ("%s":"%s")' % (app_name, client_addr[0], client_addr[1]))
+                            res = install(self.conn_dict[client_addr], app_name, app_file)
+                            if self.message_queues[s] is not None:
+                                logging.info("response {} to cmd server".format(res))
+                                self.message_queues[s].put(bytes(res, encoding = 'utf8'))
+                                if s not in self.outputs:
+                                    self.outputs.append(s)
+                    elif(data.decode().split(':')[0] == "uninstall"):
+                        client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2]))
+                        app_name = data.decode().split(':')[3]
+
+                        if client_addr in self.conn_dict.keys():
+                            print("start uninstall")
+                            res = uninstall(self.conn_dict[client_addr], app_name)
+                            if self.message_queues[s] is not None:
+                                logging.info("response {} to cmd server".format(res))
+                                self.message_queues[s].put(bytes(res, encoding = 'utf8'))
+                                if s not in self.outputs:
+                                    self.outputs.append(s)
+
+
+                    # if self.message_queues[s] is not None:
+                    #     self.message_queues[s].put(data)
+                    #     if s not in self.outputs:
+                    #         self.outputs.append(s)
+                else:
+                    logging.warning(data)
+                    
+                    # Interpret empty result as closed connection
+                    try:
+                        for dev in self.devices:
+                            if s == dev.conn:
+                                self.devices.remove(dev)
+                        # Stop listening for input on the connection
+                        if s in self.outputs:
+                            self.outputs.remove(s)
+                        self.inputs.remove(s)
+
+                        # Remove message queue
+                        if s in self.message_queues.keys():
+                            del self.message_queues[s]
+                        s.close()
+                    except OSError as e:
+                        logging.error("OSError raised, unknown connection")
+            return "got it"
+
+    def handler_send(self, writable):
+        # Handle outputs
+        for s in writable:
+            try:
+                message_queue = self.message_queues.get(s)
+                send_data = ''
+                if message_queue is not None:
+                    send_data = message_queue.get_nowait()
+            except queue.Empty:
+                self.outputs.remove(s)
+            else:
+                # print "sending %s to %s " % (send_data, s.getpeername)
+                # print "send something"
+                if message_queue is not None:
+                    s.send(send_data)
+                else:
+                    print("client has closed")
+                # del message_queues[s]
+                # writable.remove(s)
+                # print "Client %s disconnected" % (client_address)
+            return "got it"
+
+    def handler_exception(self, exceptional):
+        # # Handle "exceptional conditions"
+        for s in exceptional:
+            print('exception condition on', s.getpeername())
+            # Stop listening for input on the connection
+            self.inputs.remove(s)
+            if s in self.outputs:
+                self.outputs.remove(s)
+            s.close()
+
+            # Remove message queue
+            del self.message_queues[s]
+            return "got it"
+
+
+def event_loop(tcpserver, inputs, outputs):
+    while inputs:
+        # Wait for at least one of the sockets to be ready for processing
+        print('waiting for the next event')
+        readable, writable, exceptional = select.select(inputs, outputs, inputs)
+        if readable is not None:
+            tcp_recever = tcpserver.handler_recever(readable)
+            if tcp_recever == 'got it':
+                print("server have received")
+        if writable is not None:
+            tcp_send = tcpserver.handler_send(writable)
+            if tcp_send == 'got it':
+                print("server have send")
+        if exceptional is not None:
+            tcp_exception = tcpserver.handler_exception(exceptional)
+            if tcp_exception == 'got it':
+                print("server have exception")
+
+
+        sleep(0.1)
+
+def run_wasm_server():
+    server_address = ('localhost', 8888)
+    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
+    inputs = [server]
+    outputs = []
+    message_queues = {}
+    tcpserver = TCPServer(server, server_address, inputs, outputs, message_queues)
+    
+    task = threading.Thread(target=event_loop,args=(tcpserver,inputs,outputs))
+    task.start()
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG,
+                    filename='wasm_server.log',
+                    filemode='a',
+                    format=
+                    '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'
+                    )
+    server_address = ('0.0.0.0', 8888)
+    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
+    inputs = [server]
+    outputs = []
+    message_queues = {}
+    tcpserver = TCPServer(server, server_address, inputs, outputs, message_queues)
+    logging.info("TCP Server start at {}:{}".format(server_address[0], "8888"))
+    
+    task = threading.Thread(target=event_loop,args=(tcpserver,inputs,outputs))
+    task.start()
+    
+    # event_loop(tcpserver, inputs, outputs)    

+ 411 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css

@@ -0,0 +1,411 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+
+{% load static %}
+<style>
+#container{  
+    position:relative;  
+    margin:0px; 
+    height:110px; 
+}  
+#content {  
+    margin:0px 20% 0px 18%;  
+    border:solid 1.5px; 
+    border-color: white black white black;
+    height:50%;  
+}  
+#mainnav{
+     display:table;
+     margin: 0 auto;
+}
+#mainnav li{
+    display: table-cell;
+    padding-left:10px;
+}
+#mainnav ul li a{
+    width:120px;
+    height:30px;
+    background:black;
+    color:white;
+    margin:0px 50px;
+    font-size:21px;
+    font-family:'sansationlight';
+    display:block;
+    text-align:center;
+    text-decoration:none;
+}
+#mainnav ul li a:hover{
+    width:120px;
+    height:33px;
+    line-height:30px;
+    border:solid 1.5px;  
+    border-color: black black white black;
+    color:#3FC3DF;
+    background:black;
+}
+.headers{
+    background-image: url("{%static 'photo/milky-way-2695569_1280.jpg'%}");
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    color:white;
+    clear:both;    
+    height:50%;
+    text-align:center;
+    padding:10px;
+    margin:0px;
+}
+#maintitle{
+    font-size:25px;
+    font-family:'sansationlight';
+}
+
+#section {
+    position:relative;
+    top:5px;
+    width:100%;
+    float:left;
+    height:120px;
+    border-style:double solid;
+    border-color:black rgb(194, 194, 190) black rgb(248, 248, 248) ;
+    border-width:0.5px;
+    padding:10px;	 	 
+}
+#photo{
+    position: relative;
+    float: left;
+    top:18%;
+    left:10%;
+    widows: 60px;
+}
+#IPs{
+    position: relative;
+    left: 20%;
+    top:10%;
+    width:35%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+#ports{
+    position: relative;
+    left: 20%;
+    top:30%;
+    bottom: 5%;
+    width:35%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+#installs{
+    position: relative;
+    float: left;
+    left:55%;
+    bottom:40%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+
+#download{
+    position:relative;
+    text-align: center;   
+    left:15%;
+    width:70%;
+    top:40px;
+    height:40px;
+    /*border-color:#192C4F;*/
+}
+.explain{
+    width:250px;
+    height:40px;
+    top:50%;
+    float:left;
+    font-size:18px;
+}
+#btn{
+    float:right;
+}
+
+
+#APPS {
+    position:relative;
+    top:30px;
+    left:16.67%;
+    width:75%;
+}
+#applications{
+    position:relative;
+    float:left;
+    background-color:white;    
+    width:88.9%;
+    height:45px;
+    padding:2px;	
+    margin:5px 0px;
+    border-style:double solid;
+    border-color:black;
+    border-width:0.5px;
+}
+#applogo{
+    position:relative;
+    float:left;
+    top:10%
+}
+#appinfo1{ position:relative; float:left; left:40px; width:34%;font-size:15px;height:25px;top:33%}
+#appinfo2{ position:relative; float:left; left:20px; width:24%;font-size:15px;height:25px;top:33%}
+#appinfo3{ position:relative; float:left; left:20px; width:34%;font-size:15px;height:25px;top:33%}
+
+#delete{
+    position:relative;
+    margin:8px 0px;
+    float:right; 
+    right:7%;
+}
+.main{
+    position: absolute;
+    float:left; 
+    width:650px;
+    height:350px;
+    z-index: 9999;
+    background-color: white;
+    display:none;
+    border:solid 1px rgb(4, 30, 66);
+    border-width: 1.5px;
+    border-radius: 10px;
+}
+.close{  
+    background-color: black;
+    color:white;
+    border-top-right-radius: 10px;
+    border-top-left-radius: 10px;
+}
+.hotapps{
+    background-color:rgb(202, 202, 202);
+    font-size: 16px;
+    font-family:'days';
+    height:30px;
+    text-align: justify;
+    border:solid 2px;
+    border-color:  rgb(202, 202, 202) rgb(202, 202, 202) rgb(202, 202, 202) black;
+}
+#scrollba{
+    overflow-x: None;
+    overflow-y: scroll;
+    height: 270px;
+    width:650px;
+}
+#Dapplications{
+    width:630px;
+    margin:4px 10px 0px 10px;
+    height:45px;
+    border:solid 1px;
+    border-color: rgb(221, 221, 221) white white white;
+    /* background-color: rgb(233, 233, 233); */
+}
+.mybtn2{
+    position: relative;
+    float:left;
+    left:45px;
+    top:3px;
+    height:33px;
+    border-radius: 10px;
+    background-color: rgb(22, 109, 121);
+    color:white;
+}
+#types{
+  background-color: rgb(3, 90, 90);
+  color:white;
+  text-align: left
+}
+
+
+#loading{
+    position:relative;
+    float:left;
+    width: 100%;    
+    display:None; 
+    height:40px;  
+    top:10px; 
+    z-index:1010;
+}
+.loadapp{
+    font-size:20px;
+    text-align: center;
+    color:rgb(24, 77, 24);
+}
+#preloader {
+    position: fixed;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+}
+#loader {
+    display: block;
+    position: relative;
+    left: 50%;
+    top: 50%;
+    width: 150px;
+    height: 150px;
+    margin: -75px 0 0 -75px;
+    border-radius: 50%;
+    border: 3px solid transparent;
+    border-top-color: rgb(135, 155, 241);
+    -webkit-animation: spin 2s linear infinite;
+    animation: spin 2s linear infinite;
+}
+#loader:before {
+    content: "";
+    position: absolute;
+    top: 5px;
+    left: 5px;
+    right: 5px;
+    bottom: 5px;
+    border-radius: 50%;
+    border: 3px solid transparent;
+    border-top-color: rgb(23, 62, 146);
+    -webkit-animation: spin 3s linear infinite;
+    animation: spin 3s linear infinite;
+}
+#loader:after {
+    content: "";
+    position: absolute;
+    top: 15px;
+    left: 15px;
+    right: 15px;
+    bottom: 15px;
+    border-radius: 50%;
+    border: 3px solid transparent;
+    border-top-color: rgb(21, 44, 87);
+    -webkit-animation: spin 1.5s linear infinite;
+    animation: spin 1.5s linear infinite;
+}
+@-webkit-keyframes spin {
+    0%   {
+        -webkit-transform: rotate(0deg);
+        -ms-transform: rotate(0deg);
+        transform: rotate(0deg);
+    }
+    100% {
+        -webkit-transform: rotate(360deg);
+        -ms-transform: rotate(360deg);
+        transform: rotate(360deg);
+    }
+}
+@keyframes spin {
+    0%   {
+        -webkit-transform: rotate(0deg);
+        -ms-transform: rotate(0deg);
+        transform: rotate(0deg);
+    }
+    100% {
+        -webkit-transform: rotate(360deg);
+        -ms-transform: rotate(360deg);
+        transform: rotate(360deg);
+    }
+}
+
+.middlebox{
+   position:absolute;
+   z-index:1003;
+   height:180px;
+   width:340px;
+   background-color: white;
+   border-radius: 7px;
+   border-style:double;
+   border-color:rgb(2, 37, 11) solid;
+   border-width: 0.8px;
+   display: none;
+}
+.warning{
+    position: absolute;
+    left:10%;
+    top:6%;
+    FONT-size:18px;
+    color:rgb(0, 85, 0);
+    height:20%;
+    width:80%;
+    border-style:none none dashed none;
+    border-width: 1px; 
+    border-color:rgb(0, 85, 0);
+}
+.surebtn{
+    position:relative;
+    float:left;
+    left:44%;
+    top:75%;
+}
+.findapp{
+    position:absolute;
+    left:10%;
+    height:25%;
+    top:40%;
+    width:80%;
+    font-size:15px;
+    text-align: center;
+    border-style:none none solid none;
+    border-color:rgb(182, 182, 182);
+    border-width:0.5px;
+}
+
+.deletebox{
+   position:absolute;
+   z-index:1003;
+   height:180px;
+   width:340px;
+   background-color: white;
+   border-radius: 7px;
+   border-style:double;
+   border-color:rgb(43, 9, 1) solid;
+   border-width: 0.8px;
+   display: none;
+}
+.warning2{
+    position: absolute;
+    left:10%;
+    top:6%;
+    FONT-size:18px;
+    color:rgb(185, 0, 0);
+    height:20%;
+    width:80%;
+    border-style:none none dashed none;
+    border-width: 1px; 
+    border-color:rgb(185, 0, 0);
+}
+.suresbtn{
+    position:relative;
+    float:left;
+    left:24%;
+    top:75%;
+    color:green
+}
+.cancelsbtn{
+    position:relative;
+    float:right;
+    right:20%;
+    top:75%;
+    color:red
+}
+.footer {
+    position:absolute;
+    bottom:0px;
+    left:0px;
+    background-color:black;
+    color:white;
+    clear:both;
+    text-align:center;
+    padding:1px;
+    width:100%; 
+    height:4%;
+    z-index: 999;	 	 
+}
+
+

+ 227 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css

@@ -0,0 +1,227 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+{% load static %}
+<style>
+#container{  
+    position:relative;  
+    margin:0px; 
+    height:110px; 
+}  
+#content {  
+    margin:0px 20% 0px 18%;  
+    border:solid 1.5px; 
+    border-color: white black white black;
+    height:50%;  
+}  
+#mainnav{
+     display:table;
+     margin: 0 auto;
+}
+#mainnav li{
+    display: table-cell;
+    padding-left:10px;
+}
+#mainnav ul li a{
+    width:120px;
+    height:30px;
+    background:black;
+    color:white;
+    margin:0px 50px;
+    font-size:21px;
+    font-family:'sansationlight';
+    display:block;
+    text-align:center;
+    text-decoration:none;
+}
+#mainnav ul li a:hover{
+    width:120px;
+    height:33px;
+    line-height:30px;
+    border:solid 1.5px;  
+    border-color: black black white black;
+    color:#3FC3DF;
+    background:black;
+}
+.headers{
+    background-image: url("{%static 'photo/milky-way-2695569_1280.jpg'%}");
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    color:white;
+    clear:both;    
+    height:50%;
+    text-align:center;
+    padding:10px;
+    margin:0px;
+}
+#maintitle{
+    font-size:25px;
+    font-family:'sansationlight';
+}
+
+#introstore{
+   z-index:1003;
+   top:10px;
+   margin:10px 220px 10px 220px;
+   height:108px;
+}
+#applicationlist{
+    margin:26px 0px 0px 0px;  
+    height:100%;  
+}
+.bar{
+    height:50px;
+    top:2px;
+}
+.leftpart{
+    position:relative;
+    float:left;
+    left:30px;
+    font-size:22px;
+    display:inline-block;
+    height:30px;
+    border:solid 1px black; 
+    border-style: none none solid none;
+}
+.rightpart{
+    position:relative;
+    float:right;
+    height:50px;
+    right:20px;
+    font-size:17px;
+}
+.rightpart .file{
+    width: 120px;
+    height: 35px;
+    position: absolute;
+    left: 0px;
+    top: 0px;
+    opacity: 0;
+    z-index: 2;
+} 
+.stylehere{
+    position: relative;
+    display: inline-block;
+    width: 120px;
+    overflow: hidden;
+    height: 35px;
+    line-height: 35px;
+}
+.choosestyle{
+    position: absolute;
+    width: 120px;height: 35px;
+    background-color: rgb(0, 121, 202);color:white;
+    text-align: center;
+    left: 0px;top: 0px;
+    font-size:14px;
+    border-radius: 4px
+}
+.appbook{
+    margin:0px;  
+    border:solid;  
+    border-width: 1.5px;
+    border-color: white rgb(194, 194, 194) white rgb(194, 194, 194);
+    background-image:linear-gradient(to right, rgb(245, 243, 240),white)
+}
+#applications{
+    margin:1px;
+    left:0px;
+    width:100%;
+    height:50px;
+    border-style:none none solid none;
+    border-color:rgb(172, 172, 172);
+    border-width:0.5px;
+    padding:5px;	
+}
+#delbutton{
+    width:100px;
+    height:40px;
+}
+#appimage{
+    float:left;
+    left:5%;
+}
+#lable{
+    color: red;
+    opacity:50}
+    .suresbtn{
+    position:relative;
+    float:left;
+    left:50px;
+    top:135px;
+    color:green
+}
+.deletebox{
+    position:absolute;
+    z-index:1003;
+    height:180px;
+    width:340px;
+    background-color: white;
+    border-radius: 7px;
+    border-style:double;
+    border-color:rgb(43, 9, 1) solid;
+    border-width: 0.8px;
+    display: none;
+}
+.warning2{
+    position: absolute;
+    left:10%;
+    top:6%;
+    FONT-size:18px;
+    color:rgb(185, 0, 0);
+    height:20%;
+    width:80%;
+    border-style:none none dashed none;
+    border-width: 1px; 
+    border-color:rgb(185, 0, 0);
+}
+.findapp{
+    position:absolute;
+    left:10%;
+    height:25%;
+    top:40%;
+    width:80%;
+    font-size:15px;
+    text-align: center;
+    border-style:none none solid none;
+    border-color:rgb(182, 182, 182);
+    border-width:0.5px;
+}
+.suresbtn{
+    position:relative;
+    float:left;
+    left:24%;
+    top:75%;
+    color:green
+}
+.delsbtn{
+    position:relative;
+    float:right;
+    right:20%;
+    top:75%;
+    color:red
+}
+.footer {
+    position:absolute;
+    bottom:0px;
+    left:0px;
+    background-color:black;
+    color:white;
+    clear:both;
+    text-align:center;
+    padding:1px;
+    width:100%; 
+    height:4%;
+    z-index: 999;	 	 
+}

+ 208 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css

@@ -0,0 +1,208 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+{% load static %}
+<style>
+#container{  
+    position:relative;  
+    margin:0px; 
+    height:110px; 
+}  
+#content {  
+    margin:0px 20% 0px 18%;  
+    border:solid 1.5px; 
+    border-color: white black white black;
+    height:50%;  
+}  
+#mainnav{
+     display:table;
+     margin: 0 auto;
+}
+#mainnav li{
+    display: table-cell;
+    padding-left:10px;
+}
+#mainnav ul li a{
+    width:120px;
+    height:30px;
+    background:black;
+    color:white;
+    margin:0px 50px;
+    font-size:21px;
+    font-family:'sansationlight';
+    display:block;
+    text-align:center;
+    text-decoration:none;
+}
+#mainnav ul li a:hover{
+    width:120px;
+    height:33px;
+    line-height:30px;
+    border:solid 1.5px;  
+    border-color: black black white black;
+    color:#3FC3DF;
+    background:black;
+}
+.headers{
+    background-image: url("{%static 'photo/milky-way-2695569_1280.jpg'%}");
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    color:white;
+    clear:both;    
+    height:50%;
+    text-align:center;
+    padding:10px;
+    margin:0px;
+}
+#maintitle{
+    font-size:25px;
+    font-family:'sansationlight';
+}
+
+#photo2{
+    position: relative;
+    float: left;
+    top:10%;
+    left:20%;
+}
+#devic{
+    position: relative;
+    font-size:22px;
+    float: left;
+    left:25%;
+    top:30%;
+    width:40%;
+}
+#dividebar{
+    position: absolute;
+    top:210px;
+    margin:10px;
+    width:100%;
+    height:1px
+}
+
+#devices {
+    position:relative;
+    bottom: 2px;
+    background-color: #F2F2F2;
+    height:125px;
+    width:80%;
+    margin:8px 10%;
+}
+#section {
+    position:relative;
+    background-color:white;
+    top:14px;
+    left:13%;
+    width: 70%;
+    float:left;
+    height:96px;
+    border-style:double solid;
+    border-color:black;
+    border-width:0.5px;
+    padding:10px;	 	 
+}
+#photo{
+    position: relative;
+    float: left;
+    top:0px;
+    left:6%;
+}
+#ID{
+    position:relative;
+    float:left;
+    left:12%;
+    height:20px;
+    width:8%;
+    top:75%;
+    z-index:9999;
+    /* display:none; */
+    font-size:15px;
+    color:rgba(7, 38, 85, 0.87);  
+}
+#IPs{
+    position: relative;
+    left: 14%;
+    top:10%;
+    width:30%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+#ports{
+    position: relative;
+    left: 14%;
+    top:25%;
+    bottom: 5px;
+    width:30%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+#installs{
+    position: relative;
+    float: right;
+    right: 20%;
+    bottom:57%;
+    font-size:17px;
+    font-family:'sansationlight';
+}
+.smenu{
+    position: relative;
+    float: right;
+    top:45px;
+    right: 5%;
+    width: 6%;
+}
+
+.prev{
+    position:absolute;
+    left:72%;
+    clear:both;
+    text-align:center;
+    padding:1px;
+    width:100px; 
+    height:30px;
+    color:grey;
+    background-color:white;
+    border-radius:5px;
+    z-index: 996;	 
+}
+
+.next{
+    position:absolute;
+    left:80%;
+    clear:both;
+    text-align:center;
+    padding:1px;
+    width:100px; 
+    height:30px;
+    color:grey;
+    background-color:white;
+    border-radius:5px;
+    z-index: 996;		 
+}
+
+.footer {
+    position:absolute;
+    bottom:0px;
+    left:0px;
+    background-color:black;
+    color:white;
+    clear:both;
+    text-align:center;
+    padding:1px;
+    width:100%; 
+    height:4%;
+    z-index: 999;	 	 
+}
+</style>

+ 228 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js

@@ -0,0 +1,228 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+
+/*
+ *  Dom Location
+ *
+ */
+
+ function setDivCenter(divname)
+// make qn element center aligned
+ {
+   var Top =($(window).height()-$(divname).height())/2;
+   var Left = ($(window).width()-$(divname).width())/2;
+   var scrollTop = $(document).scrollTop();
+   var scrollLeft = $(document).scrollLeft();
+   $(divname).css({posisiton:'absolute','top':Top+scrollTop,'left':Left+scrollLeft});
+
+};
+
+setDivCenter(".middlebox");
+setDivCenter(".deletebox");
+
+function setmain(divname){
+// Set the pop-up window of apps for download at the right place
+    var x = $('#btn').offset().top;
+    var Top = x + $('#btn').height()+15;
+    var y = $('#btn').offset().left;
+    var Left = y + ($('#btn').width()/2)-($(divname).width()/2);
+    console.log(Top,Left)
+    $(divname).css({'top':Top,'left':Left});
+}
+setmain(".main")
+
+/*
+ * download apps
+ *
+ */
+
+function getthis(val)
+//Telling background which app to be loaded from appstore_list and to be installed in the current device.
+{
+
+    /* Get the ip adress and the port of a device, as well as the application ID to be downloaded on this device*/ 
+    var ip,port,name,version;
+    var ipArr=$("#IPs").text().split(":");
+    ip=ipArr[1];
+    var portArr=$("#ports").text().split(":");
+    port=portArr[1];
+    name = $(val).parent().find("#appsinfo1").text().split(":")[1];
+    version = $(val).parent().find("#appsinfo2").text().split(":")[1];
+    $(".main").fadeOut();
+
+    for (num in alist){
+           if (alist[num]['pname'].trim() == name.trim())
+                {alert("This app has been downloaded.");
+                 return;}};            
+    $("#loading").fadeIn();
+    var sNode = document.getElementById("APPS");
+    var tempNode= sNode.cloneNode(true);
+    sNode.parentNode.appendChild(tempNode);
+    $("#appinfo1").html("Product Name : "+ name);
+    $("#appinfo2").html("Status : "+"Installing");
+    $("#appinfo3").html("Current_Version : "+ version);
+
+    $.get("/appDownload/",{'ip':ip.trim(),'port':port.trim(),'name':name.trim(),},function (ret) {
+        var status = $.trim(ret.split(":")[1].split("}")[0]);
+        $(".loadapp").html(name+" is downloading now");
+        var msg = JSON.parse(status)
+        console.log(msg)
+        if (JSON.parse(status)=="ok"){
+            $(".middlebox").fadeIn();
+            $(".sourceapp").fadeOut();
+            $("#loading").fadeOut();
+            $(".findapp").html("Download "+name +" successfully");
+            $(".surebtn").click(function (){
+                $(".middlebox").fadeOut();
+                 window.location.reload();
+                 })}
+        else if (JSON.parse(status)=="Fail!"){
+            alert("Download failed!");
+            $("#loading").fadeOut();
+            sNode.remove();
+        }
+        else {
+            alert("Install app failed:" + msg)
+            $("#loading").fadeOut();
+            sNode.remove();
+        }
+    })
+};
+
+window.onload = function clone()
+//Add & Delete apps to the device.
+{
+   /*Install Apps*/
+   var sourceNode = document.getElementById("APPS");
+   if (alist.length != 0)
+   {
+   $("#appinfo1").html("Product Name : "+ alist[0]['pname']);
+   $("#appinfo2").html("Status : "+ alist[0]['status']);
+   $("#appinfo3").html("Current_Version : "+ alist[0]['current_version']);
+   $("#delete").attr('class','delet0');
+   $("#APPS").attr('class','app0');
+   
+   for (var i=1; i<alist.length; i++)
+     {
+       var cloneNode= sourceNode.cloneNode(true);
+       sourceNode.parentNode.appendChild(cloneNode);
+       $("#appinfo1").html("Product Name : "+ alist[i]['pname']);
+       $("#appinfo2").html("Status : "+ alist[i]['status']);
+       $("#appinfo3").html("Current_Version : "+ alist[i]['current_version']);
+       $("#delete").attr('class','delet'+i);
+       $("#APPS").attr('class','app'+i);
+     }
+    }
+    $("#IPs").html("IP : "+ dlist[0]['IP']);
+    $("#ports").html("Port : "+ dlist[0]['Port']);
+    $("#installs").html("Installed Apps : "+ dlist[0]['apps']);
+    
+
+
+    $(".mybtn").click(function ()
+    {
+    /*uninstall apps*/
+        var thisitem = $(this).parent().attr('class');
+        var indexa = thisitem.match(/\d+\b/);
+        var pname = $(".app"+indexa).find('#appinfo1').text();
+
+        var ip,port;
+        var ipArr=$("#IPs").text().split(":");
+        ip=ipArr[1];
+        var portArr=$("#ports").text().split(":");
+        port=portArr[1];
+    
+        var name = pname.split(':')[1].trim();
+        $(".deletebox").fadeIn();
+        $(".findapp").html("Are you sure to delete "+name);
+        $(".suresbtn").click(function (){
+                $(".app"+indexa).remove();
+                $.get("/appDelete/",{'ip':ip.trim(),'port':port.trim(),"name":pname.split(':')[1].trim()},function (ret) {
+            console.log(ret);});
+                $(".deletebox").fadeOut();
+                 window.location.reload();
+                 })
+        $(".cancelsbtn").click(function (){
+                $(".deletebox").fadeOut(); })
+    });
+
+};
+
+function getdownloadapps()
+{
+/*Acquire apps for download from Appstore simultaneously whenever appstore is updated*/
+   if (search_node[0] == "Nothing find"){
+       alert(search_node[0])
+   }
+   if (search_node.length == 1 && search_node[0] != "Nothing find" ){
+    $("#appsinfo1").html("Product Name : "+ search_node[0]['ID']);
+    $("#appsinfo2").html("Version : "+ search_node[0]['Version']);
+   }
+   else{
+       var sourceNode = document.getElementById("Dapplications");
+        if (llist.length != 0)
+        {
+        $("#appsinfo1").html("Product Name : "+ llist[0]['ID']);
+        $("#appsinfo2").html("Version : "+ llist[0]['Version']);
+        $("#Dapplications").attr('class','dapp0');
+        
+        for (var i=1; i<llist.length; i++)
+            {
+            var cloneNode= sourceNode.cloneNode(true);
+            sourceNode.parentNode.appendChild(cloneNode);
+            $("#appsinfo1").html("Product Name : "+ llist[i]['ID']);
+            $("#appsinfo2").html("Version : "+ llist[i]['Version']);
+            $("#Dapplications").attr('class','dapp'+i);
+            }
+        }};
+};
+
+getdownloadapps();
+
+function givevalue(){
+    var ip=dlist[0]['IP'].trim();
+    var port=dlist[0]['Port'].trim();
+    document.getElementById("aa").value = ip;
+    document.getElementById("bb").value = port;
+    if (open_status == "open"){
+        $(".main").fadeIn();
+        $(".close").click(function(){
+            $(".main").fadeOut();
+            var newurl = "?"+"ip="+ip+"&port="+port;
+            window.location.href= newurl;});
+        $(".mybtn2").click(function(){
+            if (alist.length >=3){
+                alert("Install app failed: exceed max app installations.")
+            }
+            $(".main").fadeOut();
+            getthis(".mybtn2");
+            var newurl = "?"+"ip="+ip+"&port="+port;
+            window.location.href= newurl;
+   });
+
+    }
+}
+givevalue();
+
+function popbox(){
+/*Open and close the "install apps" window*/
+   $(".btn").click(function(){
+       $(".main").fadeIn();
+   });
+   $(".close").click(function(){
+       $(".main").fadeOut();
+   });
+};
+popbox();

+ 136 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js

@@ -0,0 +1,136 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+
+function setDivCenter(divname)
+//Center a dom
+{
+   var Top =($(window).height()-$(divname).height())/2;
+   var Left = ($(window).width()-$(divname).width())/2;
+   var scrollTop = $(document).scrollTop();
+   var scrollLeft = $(document).scrollLeft();
+   $(divname).css({posisiton:'absolute','top':Top+scrollTop,'left':Left+scrollLeft});
+
+};
+setDivCenter(".deletebox");
+
+function setDivheight(divname)
+//set the height of "appbook" to contain all its child elements.
+{
+   var leng = elist.length + flist.length;
+   var heig = 51 * leng;
+   $(divname).css({height:'heig'});
+};
+setDivheight(".appbook");
+
+function setfooterposition(divname)
+//Locate footer on the right place
+{
+   var Top = flist.length* $("#devices").height()+300;
+   var scrollTop = $(document).scrollTop();
+    if (flist.length >=4){
+        $(divname).css({posisiton:'absolute','top':Top+scrollTop});
+    }
+}
+setfooterposition(".footer");
+
+function deleteClick (obj)
+//Remove an app from apppstore if clicks the "OK" button
+{
+    var indexapp = $(obj).attr('class').match(/\d+\b/);
+    var removeitem = $(".applic"+indexapp);
+    var name=removeitem.find('#appinfo1').text().split(":")[1].trim();
+    var version=removeitem.find('#appinfo2').text().split(":")[1].trim();
+
+    if (flist.length >= 1){
+        $(".deletebox").fadeIn();
+        $(".findapp").html("Are you sure to delete "+name);
+        $(".suresbtn").click(function (){
+            removeitem.remove();
+            $.get("/removeapps/",{'name':name,'version':version},function (ret) {
+            console.log(ret);});
+            $(".deletebox").fadeOut();
+            window.location.href="/appstore/";
+                 })
+        $(".delsbtn").click(function (){
+            $(".deletebox").fadeOut(); })}
+};
+
+function upload_file()
+//Make sure the uploading file is eligible 
+{
+    var type = ulist[0];
+    console.log(type);
+    if (type == "Not a wasm file"){
+            alert(type);
+            window.location.href="/appstore/";  
+            }
+    if (type == "This App is preloaded"){
+            alert(type);
+            window.location.href="/appstore/";  
+    }
+    if (type == "This App is already uploaded"){
+            alert(type);
+            window.location.href="/appstore/";  
+    }
+};
+upload_file();
+
+
+function clone()
+//Render a interface that shows all the apps for installing in appstore,
+//including preloaded ones and locally uploaded ones.
+{
+    
+    var sourceNode = document.getElementById("applications");
+    $("#appinfo1").html("product name : "+ elist[0]['ID']);
+    $("#appinfo2").html("product Version : "+ elist[0]['Version']);
+    $("#delbutton").attr('class','del0');
+    $("#applications").attr('class','applic0');
+
+    
+        for (var i=1; i<elist.length; i++)
+        {
+        var cloneNode= sourceNode.cloneNode(true);
+        sourceNode.parentNode.appendChild(cloneNode);
+        $("#appinfo1").html("product name : "+ elist[i]['ID']);
+        $("#appinfo2").html("product Version : "+ elist[i]['Version']);
+        $("#delbutton").attr('class','del'+i);
+        $("#applications").attr('class','applic'+i);
+
+        }
+
+        for (var i = elist.length; i< elist.length + flist.length; i++)
+        {
+        var cloneNode= sourceNode.cloneNode(true);
+        sourceNode.parentNode.appendChild(cloneNode);
+        $("#appinfo1").html("product name : "+ flist[i - elist.length]['ID']);
+        $("#appinfo2").html("product Version : "+ flist[i - elist.length]['Version']);
+        $("#lable").html("Custom Apps").css("color","green");
+        $("#delbutton").attr('class','del'+i);
+        $("#applications").attr('class','applic'+i);
+
+        }
+
+        for(var i = 0; i < elist.length; i++)
+        {
+            var tmp_node = document.getElementsByClassName("del" + i)[0]
+            tmp_node.disabled = true
+        }
+        
+};
+
+clone();
+
+   

+ 62 - 0
test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js

@@ -0,0 +1,62 @@
+/* Copyright (C) 2019 Intel Corporation.  All rights reserved.
+*
+* 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.
+*/
+
+function setfooterposition(divname)
+//Locate footer on the right place
+{
+   var Top = dlist.length* $("#devices").height()+300;
+   var scrollTop = $(document).scrollTop();
+    if (dlist.length >=4){
+        $(divname).css({posisiton:'absolute','top':Top+scrollTop});
+    }
+}
+setfooterposition(".footer");
+
+window.onload = function clone()
+//Show the list of connected devices
+{  
+   var sourceNode = document.getElementById("devices");
+   $("#IPs").html("IP : "+ dlist[0]['IP']);
+   $("#ports").html("Port : "+ dlist[0]['Port']);
+   $("#installs").html("Installed Apps : "+ dlist[0]['apps']);
+   $("#devices").attr('class','devic0');
+   $("#dbutton").attr('class','bt0');
+   $("#choose").attr('class','chos0');
+   
+    for (var i=1; i<dlist.length; i++)
+     {
+       var cloneNode= sourceNode.cloneNode(true);
+       sourceNode.parentNode.appendChild(cloneNode);
+       $("#IPs").html("IP : "+ dlist[i]['IP']);
+       $("#ports").html("Port : "+ dlist[i]['Port']);
+       $("#installs").html("Installed Apps : "+ dlist[i]['apps']);
+       $("#devices").attr('class','devic'+i);
+       $("#dbutton").attr('class','bt'+i);
+       $("#choose").attr('class','chos'+i);       
+     }
+     
+};
+
+function deviceClick(obj){
+//Render to the application.html 
+    var deviceObj=$(obj);
+    var ip=deviceObj.find('#IPs').text();
+    ip=ip.split(':')[1].split(' ')[1]
+    var port=deviceObj.find('#ports').text();
+    port=port.split(':')[1].split(' ')[1]
+    var newurl = "apps/?"+"ip="+ip+"&port="+port;
+    window.location.href= newurl;
+}
+

BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/vgl_wasm_runtime


BIN
test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl