Created
July 13, 2015 20:30
-
-
Save baude/e662e10f3a821329e3fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <title>Docker Info</title> | |
| <meta charset="utf-8"> | |
| <link href="../base1/cockpit.css" type="text/css" rel="stylesheet"> | |
| <script src="../base1/jquery.js"></script> | |
| <script src="../base1/cockpit.js"></script> | |
| <script src="mustache.js"></script> | |
| </head> | |
| <body> | |
| <div id="test-dialog" tabindex="-1" role="dialog" data-backdrop="static"> | |
| <div class="modal-dialog"> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <h4 class="modal-title" translatable="yes">Image Scanner options</h4> | |
| </div> | |
| <div class="modal-body"> | |
| <table class="cockpit-form-table"> | |
| <tr> | |
| <td class="top"> | |
| <label class="control-label" for="control-2" translatable="yes"> | |
| Scan | |
| </label> | |
| </td> | |
| <td> | |
| <select id="control-2" class="form-control selectpicker"> | |
| <option translatable="yes" value="images">Images</option> | |
| <option translatable="yes" value="allimages">All images including intermediate</option> | |
| <option translatable="yes" value="onlyactive" selected>Only active containers</option> | |
| <option translatable="yes" value="allcontainers">All containers</option> | |
| </select> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td class="top"> | |
| <label class="control-label" for="control-1" translatable="yes"> | |
| Threads | |
| </label> | |
| </td> | |
| <td> | |
| <select id="threads" class="form-control selectpicker"> | |
| <option translatable="yes" value="2">2</option> | |
| <option translatable="yes" value="3">3</option> | |
| <option translatable="yes" value="4" selected>4</option> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| <div class="modal-footer"> | |
| <button class="btn btn-default" id="startscan" translatable="yes" data-dismiss="modal"> | |
| Scan | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="model" class="container-fluid"> | |
| <h1> Scan results </h1> | |
| </div> | |
| <div id="spinner" class="spinner spinner-lg"></div> | |
| <div id="sampleArea" class="container-fluid"> | |
| <script> | |
| function register_button() { | |
| var btn = $('#startscan'); | |
| btn.on('click', function() { | |
| alert("foo") | |
| //retrieve_info() | |
| }); | |
| } | |
| var scan = cockpit.http(5001, { superuser: "try" }); | |
| function retrieve_info() { | |
| var info = scan.request({body: JSON.stringify({'scan': ["bef54", "10acc"], 'number':4}), method: "GET", path: "/image-scanner/api/scan", headers: { "Content-Type": "application/json" }}); | |
| info.done(process_info); | |
| info.fail(print_failure); | |
| } | |
| function process_info(data) { | |
| var resp = JSON.parse(data); | |
| var rresults = resp.results | |
| var docker_ids = Object.keys(resp.results) | |
| var html = "" | |
| for (var key in resp.results) { | |
| var docker_id = "<h2>" + key + "</h2>" | |
| var value = resp.results[key] | |
| scan_result = "<P>" + value.critical | |
| tpl = "<ul><li>Critical:{{critical}}</li><li>Important:{{important}}</li><li>Moderate:{{moderate}}</li><li>Low:{{low}}</li><li>OS: {{os}}</li><li>Containers with same base image: {{value.cids}}</li></ul>" | |
| html = html + docker_id + Mustache.to_html(tpl, value) | |
| } | |
| $('#sampleArea').html(html); | |
| $("#spinner").hide("fast") | |
| } | |
| //retrieve_info(); | |
| function got_event() { | |
| retrieve_info(); | |
| } | |
| function print_failure(ex) { | |
| console.log(ex); | |
| } | |
| //var results = {name: "John Smith", skills: ['JavaScript', 'PHP', 'Java']}; | |
| //var tpl = "Docker ID{{results}} <ul>{{#skills}}<li>{{.}}</li>{{/skills}}</ul>"; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment