Repository: incubator-eagle
Updated Branches:
  refs/heads/master db28ae2b2 -> 1da8dc4f1


[EAGLE-759] Policy detail support alert list

* Policy detail support alert list
* update site application logic

Author: zombieJ <smith3...@gmail.com>

Closes #635 from zombieJ/EAGLE-759.


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/1da8dc4f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/1da8dc4f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/1da8dc4f

Branch: refs/heads/master
Commit: 1da8dc4f1fbb46c5ce76cd3b2af7f680f6f8cc29
Parents: db28ae2
Author: zombieJ <smith3...@gmail.com>
Authored: Wed Nov 9 21:20:02 2016 +0800
Committer: Hao Chen <h...@apache.org>
Committed: Wed Nov 9 21:20:02 2016 +0800

----------------------------------------------------------------------
 .../webapp/app/apps/jpm/ctrl/statisticCtrl.js   |  2 +-
 .../src/main/webapp/app/apps/jpm/index.js       |  6 +-
 .../webapp/app/dev/partials/alert/list.html     | 24 +++++++-
 .../app/dev/partials/alert/policyDetail.html    | 59 +++++++++++++++++---
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 18 +++++-
 .../app/dev/public/js/ctrls/integrationCtrl.js  | 25 ++++++---
 6 files changed, 110 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/ctrl/statisticCtrl.js
----------------------------------------------------------------------
diff --git 
a/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/ctrl/statisticCtrl.js 
b/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/ctrl/statisticCtrl.js
index 6dff7a1..e74a22c 100644
--- a/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/ctrl/statisticCtrl.js
+++ b/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/ctrl/statisticCtrl.js
@@ -354,7 +354,7 @@
                                         * @param {[]} res.data.jobTypes
                                         * @param {[]} res.data.jobCounts
                                         */
-                                       JPM.jobDistribution($scope.site, 
$scope.type, DURATION_BUCKETS.join(","), startTime, endTime).then(function 
(res) {
+                                       JPM.jobDistribution($scope.site, 
DURATION_BUCKETS.join(","), startTime, endTime).then(function (res) {
                                                var data = res.data;
                                                var jobTypes = {};
                                                $.each(data.jobTypes, function 
(i, type) {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/index.js
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/index.js 
b/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/index.js
index fafe699..7348853 100644
--- a/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/index.js
+++ b/eagle-jpm/eagle-jpm-web/src/main/webapp/app/apps/jpm/index.js
@@ -75,7 +75,7 @@
                JPM.QUERY_METRICS_INTERVAL = 
'${baseURL}/rest/entities?query=GenericMetricService[${condition}]<${groups}>{${field}}${order}${top}&metricName=${metric}&pageSize=${limit}&startTime=${startTime}&endTime=${endTime}&intervalmin=${intervalMin}&timeSeries=true';
                JPM.QUERY_MR_JOBS = '${baseURL}/rest/mrJobs/search';
                JPM.QUERY_JOB_LIST = 
'${baseURL}/rest/mrJobs?query=%s[${condition}]{${fields}}&pageSize=${limit}&startTime=${startTime}&endTime=${endTime}';
-               JPM.QUERY_JOB_STATISTIC = 
'${baseURL}/rest/mrJobs/jobCountsByDuration?site=${site}&timeDistInSecs=${times}&startTime=${startTime}&endTime=${endTime}&jobType=${jobType}';
+               JPM.QUERY_JOB_STATISTIC = 
'${baseURL}/rest/mrJobs/jobCountsByDuration?site=${site}&timeDistInSecs=${times}&startTime=${startTime}&endTime=${endTime}';
                JPM.QUERY_TASK_STATISTIC = 
'${baseURL}/rest/mrTasks/taskCountsByDuration?jobId=${jobId}&site=${site}&timeDistInSecs=${times}&top=${top}';
 
                JPM.QUERY_MR_JOB_COUNT = 
'${baseURL}/rest/mrJobs/runningJobCounts';
@@ -354,15 +354,13 @@
                /**
                 * Fetch job duration distribution
                 * @param {string} site
-                * @param {string} jobType
                 * @param {string} times
                 * @param {{}} startTime
                 * @param {{}} endTime
                 */
-               JPM.jobDistribution = function (site, jobType, times, 
startTime, endTime) {
+               JPM.jobDistribution = function (site, times, startTime, 
endTime) {
                        var url = common.template(getQuery("JOB_STATISTIC"), {
                                site: site,
-                               jobType: jobType,
                                times: times,
                                startTime: Time.format(startTime),
                                endTime: Time.format(endTime)

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html 
b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
index 395e24b..e518fa7 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
@@ -22,6 +22,18 @@
                <h3 class="box-title">
                        Alert List
                </h3>
+               <div class="box-tools pull-right" >
+                       <div class="btn-group">
+                               <button class="btn btn-default btn-sm" 
ng-class="{active: displayType === 'raw'}"
+                                               tooltip-append-to-body="true" 
uib-tooltip="raw data" ng-click="displayType = 'raw'">
+                                       <i class="fa fa-keyboard-o"></i>
+                               </button>
+                               <button class="btn btn-default btn-sm" 
ng-class="{active: displayType === 'format'}"
+                                               tooltip-append-to-body="true" 
uib-tooltip="format data" ng-click="displayType = 'format'">
+                                       <i class="fa fa-list"></i>
+                               </button>
+                       </div>
+               </div>
        </div>
        <div class="box-body">
                <div sort-table="alertList" is-sorting="isSorting">
@@ -55,7 +67,17 @@
                                                                </li>
                                                        </ul>
                                                </td>
-                                               <td 
class="text-break">{{item.alertData}}</td>
+                                               <td class="text-break">
+                                                       <span 
ng-if="displayType === 'raw'" na-block="item.alertData"></span>
+                                                       <div ng-if="displayType 
=== 'format'" na-block="!!item.alertData">
+                                                               <ul>
+                                                                       <li 
ng-repeat="(key, value) in item.alertData track by $index">
+                                                                               
<strong>{{key}}:</strong>
+                                                                               
{{value}}
+                                                                       </li>
+                                                               </ul>
+                                                       </div>
+                                               </td>
                                                <td>
                                                        <a 
ui-sref="alertDetail({alertId: item.alertId})">Detail</a>
                                                </td>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
----------------------------------------------------------------------
diff --git 
a/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html 
b/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
index fb7be0c..65721ac 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
@@ -54,10 +54,22 @@
 
 <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
-               <!--li><a href="#statistic" data-toggle="tab">Statistic</a></li>
-               <li><a href="#alerts" data-toggle="tab">Alerts</a></li-->
-               <li class="active"><a href="#setting" 
data-toggle="tab">Setting</a></li>
-               <li><a href="#assignments" 
data-toggle="tab">Assignments</a></li>
+               <!--li><a href="#statistic" 
data-toggle="tab">Statistic</a></li-->
+               <li class="active"><a href="#setting" data-toggle="tab" 
ng-click="setTab('setting')">Setting</a></li>
+               <li><a href="#assignments" data-toggle="tab" 
ng-click="setTab('assignments')">Assignments</a></li>
+               <li><a href="#alerts" data-toggle="tab" 
ng-click="setTab('alerts')">Alerts</a></li>
+               <li class="pull-right box-tools" ng-show="tab === 'alerts'">
+                       <div class="btn-group">
+                               <button class="btn btn-default btn-sm" 
ng-class="{active: displayType === 'raw'}"
+                                               tooltip-append-to-body="true" 
uib-tooltip="raw data" ng-click="displayType = 'raw'">
+                                       <i class="fa fa-keyboard-o"></i>
+                               </button>
+                               <button class="btn btn-default btn-sm" 
ng-class="{active: displayType === 'format'}"
+                                               tooltip-append-to-body="true" 
uib-tooltip="format data" ng-click="displayType = 'format'">
+                                       <i class="fa fa-list"></i>
+                               </button>
+                       </div>
+               </li>
        </ul>
        <div class="tab-content">
                <div class="tab-pane active" id="setting">
@@ -133,8 +145,6 @@
                </div>
                <div class="tab-pane" id="statistic">statistic
                </div>
-               <div class="tab-pane" id="alerts">alerts
-               </div>
                <div class="tab-pane" id="assignments">
                        <table class="table">
                                <tbody>
@@ -147,7 +157,7 @@
                                                <td>{{assignment.queueId}}</td>
                                        </tr>
                                        <tr>
-                                               <th 
class="text-no-break">working Slots</th>
+                                               <th class="text-no-break" 
width="120">working Slots</th>
                                                <td>
                                                        <div 
na-block="queue.workingSlots.length > 0">
                                                                <ul 
class="no-margin">
@@ -162,5 +172,40 @@
                                </tbody>
                        </table>
                </div>
+               <div class="tab-pane" id="alerts">
+                       <div sort-table="alertList">
+                               <table class="table table-bordered">
+                                       <thead>
+                                       <tr>
+                                               <th sortpath="alertTimestamp" 
width="135">
+                                                       Alert Time
+                                                       <span class="fa 
fa-refresh fa-spin no-animate" ng-show="!alertList._done || isSorting"></span>
+                                               </th>
+                                               <th>Alert Data</th>
+                                               <th width="10"></th>
+                                       </tr>
+                                       </thead>
+                                       <tbody>
+                                       <tr>
+                                               
<td>{{Time.format(item.alertTimestamp)}}</td>
+                                               <td class="text-break">
+                                                       <span 
ng-if="displayType === 'raw'" na-block="item.alertData"></span>
+                                                       <div ng-if="displayType 
=== 'format'" na-block="!!item.alertData">
+                                                               <ul>
+                                                                       <li 
ng-repeat="(key, value) in item.alertData track by $index">
+                                                                               
<strong>{{key}}:</strong>
+                                                                               
{{value}}
+                                                                       </li>
+                                                               </ul>
+                                                       </div>
+                                               </td>
+                                               <td>
+                                                       <a 
ui-sref="alertDetail({alertId: item.alertId})">Detail</a>
+                                               </td>
+                                       </tr>
+                                       </tbody>
+                               </table>
+                       </div>
+               </div>
        </div>
 </div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js 
b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
index 5d20960..b82f88e 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
@@ -27,6 +27,7 @@
        eagleControllers.controller('alertListCtrl', function ($scope, 
$wrapState, $interval, PageConfig, Entity) {
                PageConfig.title = "Alerts";
 
+               $scope.displayType = "raw";
                $scope.alertList = Entity.queryMetadata("alerts", {size: 
10000});
 
                // 
================================================================
@@ -76,7 +77,6 @@
 
                $scope.showDataSource = function (stream) {
                        var dataSource = $scope.dataSources[stream.dataSource];
-                       console.log(">>>", dataSource);
                        $.dialog({
                                title: dataSource.name,
                                content: $("<pre 
class='text-break'>").html(JSON.stringify(dataSource, null, "\t")),
@@ -114,7 +114,7 @@
                };
        });
 
-       eagleControllers.controller('policyDetailCtrl', function ($scope, 
$wrapState, PageConfig, Entity, Policy) {
+       eagleControllers.controller('policyDetailCtrl', function ($scope, 
$wrapState, $interval, PageConfig, Entity, Policy) {
                PageConfig.title = "Policy";
                PageConfig.subTitle = "Detail";
                PageConfig.navPath = [
@@ -122,6 +122,13 @@
                        {title: "Detail"}
                ];
 
+               $scope.tab = "setting";
+               $scope.displayType = "raw";
+
+               $scope.setTab = function (tab) {
+                       $scope.tab = tab;
+               };
+
                function updatePolicy() {
                        var policyName = $wrapState.param.name;
                        var encodePolicyName = encodeURIComponent(policyName);
@@ -159,6 +166,8 @@
                }
                updatePolicy();
 
+               $scope.alertList = Entity.queryMetadata("policies/" + 
encodeURIComponent($wrapState.param.name) + "/alerts", {size: 1000});
+
                $scope.deletePolicy = function() {
                        Policy.delete($scope.policy).then(function () {
                                $wrapState.go("policyList");
@@ -172,5 +181,10 @@
                $scope.stopPolicy = function() {
                        Policy.stop($scope.policy).then(updatePolicy);
                };
+
+               var refreshInterval = $interval($scope.alertList._refresh, 1000 
* 60);
+               $scope.$on('$destroy', function() {
+                       $interval.cancel(refreshInterval);
+               });
        });
 }());

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1da8dc4f/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
----------------------------------------------------------------------
diff --git 
a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js 
b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
index a16c889..95e4584 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
@@ -92,12 +92,18 @@
                        Site.getPromise().then(function () {
                                $scope.site = Site.find($wrapState.param.id);
                                var uninstalledApplicationList = 
common.array.minus(Application.providerList, $scope.site.applicationList, 
"type", "descriptor.type");
-                               $scope.applicationList = 
$.map($scope.site.applicationList, function (app) {
-                                       app.installed = true;
-                                       return app;
-                               }).concat($.map(uninstalledApplicationList, 
function (oriApp) {
-                                       return { origin: oriApp };
-                               }));
+                               $scope.applicationList = common.array.doSort(
+                                       $.map($scope.site.applicationList, 
function (app) {
+                                               app.installed = true;
+                                               return app;
+                                       }), ["origin", "name"]
+                               ).concat(
+                                       common.array.doSort(
+                                               
$.map(uninstalledApplicationList, function (oriApp) {
+                                                       return {origin: oriApp};
+                                               }), ["origin", "name"]
+                                       )
+                               );
                        });
                }
                mapApplications();
@@ -261,10 +267,11 @@
                        $scope.installLock = true;
 
                        var uuid = $scope.tmpApp.uuid;
-                       delete $scope.tmpApp.uuid;
+                       var app = $.extend({}, $scope.tmpApp);
+                       delete app.uuid;
 
                        if(uuid) {
-                               Entity.create("apps/" + uuid, 
$scope.tmpApp)._then(function () {
+                               Entity.create("apps/" + uuid, 
app)._then(function () {
                                        refreshApplications();
                                        $("#installMDL").modal("hide");
                                }, function (res) {
@@ -275,7 +282,7 @@
                                        $scope.installLock = false;
                                });
                        } else {
-                               Entity.create("apps/install", 
$scope.tmpApp)._then(function () {
+                               Entity.create("apps/install", 
app)._then(function () {
                                        refreshApplications();
                                        $("#installMDL").modal("hide");
                                }, function (res) {

Reply via email to