[TIC-Web] Apply generic resource pooling
[archive/20170607/tools/tic.git] / public / src / js / util.js
index c67dbec..2a6fcd5 100644 (file)
@@ -8,6 +8,55 @@ define([
     var socket = null;
     var config = null;
 
+    function showBigLogView(btn) {
+        var linkid, linkurl, logViewTop, logViewLeft, logViewWidth, logViewHeight;
+
+        if (config === null) {
+            getAppConfig();
+        }
+
+        function readLog () {
+            POST(config.EVENT.JOB.JOB_READ_LOG + linkid)
+            .then(function (line) {
+                 $('#log-view-content-body').append(line);
+            });
+        }
+
+        function getClientWidth () {
+            return (window.innerWidth) ? window.innerWidth : document.documentElement.clientWidth || document.body.clientWidth || 0;
+        }
+
+        function getClientHeight () {
+            return(window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight || document.body.clientHeight || 0;
+        }
+
+        linkid = $(btn).data('jobid');
+        linkurl = $(btn).data('link');
+
+        console.log('Util.showBigLogView: job_id="' + linkid + '", log_url="' + linkurl + '"');
+
+        // get value
+        logViewWidth = getClientWidth() - 18;
+        logViewHeight = getClientHeight() - 50;
+        logViewTop = 50;
+        logViewLeft = 0;
+
+        // set value
+        $('#log-view-content').width(logViewWidth);
+        $('#log-view-content').height(logViewHeight);
+        $('#log-view-content').offset({
+            top: logViewTop,
+            left: logViewLeft
+        });
+
+        // show
+        $('#log-view-content-body').empty();
+        $('#log-view-content-download').attr('href', linkurl);
+        $('#log-view-content').show();
+
+        readLog(linkid);
+    }
+
     function setAnimateScroll() {
         $('a.tic-page-scroll').bind('click', function(event) {
             var body = $('html, body');
@@ -148,6 +197,13 @@ define([
 
     return {
         /**
+         * Display the mic.log
+         * @method showBigLogView
+         * @param {object} btn for Log Button Element
+         */
+        showBigLogView: showBigLogView,
+
+        /**
          * Set smooth scrolling, one page websites
          * @method setAnimateScroll
          */