From 43bf12d6ab7bcaea16dc75ed4ccbe3895cf51da3 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Wed, 9 Aug 2017 03:23:58 +0000 Subject: Add real time log view in GUI JIRA: YARDSTICK-775 We have GUI now, but we can't see real time log in GUI view. So I add real time log view in GUI. Change-Id: Ie83f327ef0a94302afa6b3def764fec6ef5818d1 Signed-off-by: chenjiankun --- gui/app/index.html | 1 + .../controllers/projectDetail.controller.js | 20 +++-------- gui/app/scripts/controllers/taskLog.controller.js | 34 +++++++++++++++++++ gui/app/scripts/factory/main.factory.js | 8 +++++ gui/app/scripts/router.config.js | 10 ++++++ gui/app/views/projectdetail.html | 1 + gui/app/views/taskLog.html | 39 ++++++++++++++++++++++ 7 files changed, 97 insertions(+), 16 deletions(-) create mode 100644 gui/app/scripts/controllers/taskLog.controller.js create mode 100644 gui/app/views/taskLog.html (limited to 'gui') diff --git a/gui/app/index.html b/gui/app/index.html index 5592656cc..d959b14d2 100644 --- a/gui/app/index.html +++ b/gui/app/index.html @@ -100,6 +100,7 @@ + diff --git a/gui/app/scripts/controllers/projectDetail.controller.js b/gui/app/scripts/controllers/projectDetail.controller.js index 4ab4a055a..a616f3ee7 100644 --- a/gui/app/scripts/controllers/projectDetail.controller.js +++ b/gui/app/scripts/controllers/projectDetail.controller.js @@ -671,20 +671,8 @@ angular.module('yardStickGui2App') }) } - - - - - - - - - - - - - - - + $scope.gotoLog = function gotoLog(task_id) { + $state.go('app2.taskLog', { taskId: task_id }); + } } - ]); \ No newline at end of file + ]); diff --git a/gui/app/scripts/controllers/taskLog.controller.js b/gui/app/scripts/controllers/taskLog.controller.js new file mode 100644 index 000000000..17722b7da --- /dev/null +++ b/gui/app/scripts/controllers/taskLog.controller.js @@ -0,0 +1,34 @@ +'use strict'; + +angular.module('yardStickGui2App').controller('TaskLogController', ['$scope', '$stateParams', '$http', '$interval', 'mainFactory', function ($scope, $stateParams, $http, $interval, mainFactory) { + $scope.logLines = []; + $scope.getLog = getLog; + $scope.taskId = $stateParams.taskId; + $scope.taskStatus = 0; + $scope.index = 0; + + $scope.goBack = function goBack() { + window.history.back(); + } + + function getLog(){ + + function get_data(){ + mainFactory.getTaskLog().get({'taskId': $scope.taskId, 'index': $scope.index}).$promise.then(function(data){ + angular.forEach(data.result.data, function(ele){ + $scope.logLines.push(ele); + $scope.index = data.result.index; + }); + + if(data.status == 1){ + $interval.cancel($scope.intervalTask); + $scope.taskStatus = 1; + } + }); + } + + $scope.intervalTask = $interval(get_data, 2000); + } + + getLog(); +}]); diff --git a/gui/app/scripts/factory/main.factory.js b/gui/app/scripts/factory/main.factory.js index f8e9df9a1..44fbeb39f 100644 --- a/gui/app/scripts/factory/main.factory.js +++ b/gui/app/scripts/factory/main.factory.js @@ -178,6 +178,14 @@ angular.module('yardStickGui2App') }) }, + getTaskLog: function(){ + return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId/log?index=:index', { taskId: "@taskId", index: "@index" }, { + 'get': { + method: 'GET' + } + }) + }, + taskAddEnv: function() { return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, { 'put': { diff --git a/gui/app/scripts/router.config.js b/gui/app/scripts/router.config.js index b42954272..9d3c045bd 100644 --- a/gui/app/scripts/router.config.js +++ b/gui/app/scripts/router.config.js @@ -142,6 +142,16 @@ angular.module('yardStickGui2App') label: 'Task' } + }) + .state('app2.taskLog', { + url: '/task/:taskId/log', + templateUrl: 'views/taskLog.html', + controller: 'TaskLogController', + params: { taskId: null }, + ncyBreadcrumb: { + label: 'TaskLog' + } + }) .state('app2.report', { url: '/report/:taskId', diff --git a/gui/app/views/projectdetail.html b/gui/app/views/projectdetail.html index 357a26add..405ff5af0 100644 --- a/gui/app/views/projectdetail.html +++ b/gui/app/views/projectdetail.html @@ -47,6 +47,7 @@
  • run
  • modify
  • +
  • log
  • reporting
  • delete
  • diff --git a/gui/app/views/taskLog.html b/gui/app/views/taskLog.html new file mode 100644 index 000000000..f90eb22b8 --- /dev/null +++ b/gui/app/views/taskLog.html @@ -0,0 +1,39 @@ +
    + +

    Log

    +
    +
    +
    +
    Task: {{ taskId }}
    +
    +
    +
    +
    +
    + + +
    +
    +
    + {{ line }} +
    +
    +
    + + -- cgit 1.2.3-korg