Skip to content

Commit

Permalink
[pinpoint-apm#3390] add installation page in configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
denzelsN committed Sep 29, 2017
1 parent eb07f58 commit 8288c31
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 10 deletions.
2 changes: 2 additions & 0 deletions web/src/grunt/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ module.exports = function( grunt, options ) {
'/common/services/server-map-filter-vo.service.js',
'/common/services/alarm-ajax.service.js',
'/common/services/alarm-util.service.js',
'/common/services/installation-ajax.service.js',
'/common/services/server-map-hint-vo.service.js',
'/common/services/is-visible.service.js',
'/common/services/user-locales.service.js',
Expand Down Expand Up @@ -214,6 +215,7 @@ module.exports = function( grunt, options ) {
'/features/configuration/application/application-config.directive.js',
'/features/configuration/application/application-group.directive.js',
'/features/configuration/application/alarm-rule.directive.js',
'/features/configuration/installation/installation.directive.js',
'/features/configuration/help/help.directive.js',
'/features/threadDumpInfoLayer/thread-dump-info-layer.directive.js',
'/features/realtimeChart/realtime-chart.controller.js',
Expand Down
4 changes: 4 additions & 0 deletions web/src/main/webapp/common/help/help-content-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
desc: "Sends an alarm when deadlock condition is detected in application."
}]
}]
},
installation: {
desc: "* You can check whether the Application Name and Agent Id are duplicated.",
lengthGuide: "You can enter up to {{MAX_CHAR}} characters."
}
},
navbar : {
Expand Down
10 changes: 7 additions & 3 deletions web/src/main/webapp/common/help/help-content-ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@
desc: "heap의 사용률이 임계치를 초과한 경우 알람이 전송된다."
},{
name: "JVM CPU USAGE RATE",
desc: "applicaiton의 CPU 사용률이 임계치를 초과한 경우 알람이 전송된다."
desc: "application의 CPU 사용률이 임계치를 초과한 경우 알람이 전송된다."
},{
name: "DATASOURCE CONNECTION USAGE RATE",
desc: "applicaiton의 DataSource내의 Connection 사용률이 임계치를 초과한 경우 알람이 전송된다."
desc: "application의 DataSource내의 Connection 사용률이 임계치를 초과한 경우 알람이 전송된다."
}, {
name: "DEADLOCK OCCURRENCE",
desc: "applicaiton에서 데드락 상태가 탐지되면 알람이 전송된다."
desc: "application에서 데드락 상태가 탐지되면 알람이 전송된다."
}]
}]
},
installation: {
desc: "* Application Name 과 Agent Id의 중복 여부를 확인 할 수 있습니다.",
lengthGuide: "1 ~ {{MAX_CHAR}}자의 문자를 입력하세요."
}
},
navbar : {
Expand Down
22 changes: 22 additions & 0 deletions web/src/main/webapp/common/services/installation-ajax.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(function($) {
'use strict';

pinpointApp.service("InstallationAjaxService", [ "$http", function ($http) {
this.getAgentInstallationInfo = function(callback) {
retrieve("getAgentInstallationInfo.pinpoint", {}, callback);
};
this.isAvailableApplicationName = function(data, callback ) {
retrieve("isAvailableApplicationName.pinpoint", data, callback);
};
this.isAvailableAgentId = function(data, callback ) {
retrieve("isAvailableAgentId.pinpoint", data, callback);
};
function retrieve(url, data, callback) {
$http.get( url + "?" + $.param( data ) ).then(function(result) {
callback(result.data);
}, function(error) {
callback(error);
});
}
}]);
})(jQuery);
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
}, {
"view": "Application",
"value": "application"
}, {
"view": "Installation",
"value": "installation"
}, {
"view": "Help",
"value": "help"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h4 class="modal-title">Pinpoint Configuration</h4>
<general-directive name="general" init-state="show"></general-directive>
<user-group-container-directive name="userGroup" init-state="hide"></user-group-container-directive>
<application-config-directive name="application" init-state="hide"></application-config-directive>
<installation-directive name="installation" init-state="hide"></installation-directive>
<help-directive name="help" init-state="hide"></help-directive>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
(function( $ ) {
"use strict";

pinpointApp.directive( "installationDirective", [ "$http", "InstallationAjaxService", "helpContentService",
function ( $http, InstallationAjaxService, helpContentService ) {
return {
restrict: "EA",
replace: true,
templateUrl: "features/configuration/installation/installation.html?v=" + G_BUILD_TIME,
scope: {
namespace: "@"
},
link: function( scope, element, attr ) {
var MAX_CHAR = 24;
var $element = $(element);
var myName = attr["name"];
var $textarea = $element.find("textarea")[0];
var $applicationNameInput = $element.find(".application-name-input");
var $agentIdInput = $element.find(".agent-id-input");
var jvmArguments = [
"-Dpinpoint.applicationName=[Application Name]",
"-Dpinpoint.agentId=[AgentId]"
];
var successAppName = "";
var successAgentId = "";
var intallationArgument = "";

var lengthGuide = helpContentService.configuration.installation.lengthGuide.replace(/\{\{MAX\_CHAR\}\}/, MAX_CHAR);
scope.description = helpContentService.configuration.installation.desc;
scope.downloadLink = "";
scope.applicationNameMessage = "";
scope.agentIdMessage = "";
scope.inputApplicationName = "";
scope.inputAgentId = "";

$element[ attr["initState"] ]();

function loadInstallationInfo() {
InstallationAjaxService.getAgentInstallationInfo(function ( res ) {
if ( res.code === 0 ) {
scope.downloadLink = res.message["downloadUrl"];
intallationArgument = res.message["installationArgument"];
setArguments("", "");
}
});
}
function setArguments(appName, agentId) {
$textarea.value = intallationArgument + "\n"
+ jvmArguments[0].replace(/\[Application Name\]/, appName) + "\n"
+ jvmArguments[1].replace(/\[AgentId\]/, agentId);
}
function setClassName($el, className) {
$el.get(0).className = className;
}
function clearArea() {
successAppName = "";
successAgentId = "";
scope.inputAgentId = "";
scope.inputApplicationName = "";
scope.agentIdMessage = "";
scope.applicationNameMessage = "";
setClassName( $agentIdInput, "form-group has-feedback" );
setClassName( $applicationNameInput, "form-group has-feedback" );
setClassName( $agentIdInput.find("span").hide(), "glyphicon form-control-feedback" );
setClassName( $applicationNameInput.find("span").hide(), "glyphicon form-control-feedback" );
}
function setSuccess( $ele ) {
$ele.removeClass("has-error").addClass("has-success");
$ele.find("span").removeClass("glyphicon-remove").addClass("glyphicon-ok").show();
}
function setFail( $ele ) {
$ele.removeClass("has-success").addClass("has-error");
$ele.find("span").removeClass("glyphicon-ok").addClass("glyphicon-remove").show();
}
function isValidLength(query) {
return query.length === 0 || query.length > MAX_CHAR ? false : true;
}
scope.copyArguments = function() {
$textarea.select();
try {
document.execCommand("copy");
} catch (err) {
}
};
scope.onKeyDown = function($event, type) {
if ( $event.keyCode === 13 ) { // enter
if ( type === "applicationName" ) {
scope.searchApplicationName();
} else if ( type === "agentId" ) {
scope.searchAgentId();
}
}
};
scope.searchApplicationName = function() {
var query = scope.inputApplicationName.trim();
if ( isValidLength(query) === false ) {
scope.applicationNameMessage = lengthGuide;
setFail( $agentIdInput );
return;
}
InstallationAjaxService.isAvailableApplicationName({
applicationName: query
}, function ( res ) {
if ( res.code === 0 ) {
successAppName = query;
scope.applicationNameMessage = "";
setSuccess( $applicationNameInput );
setArguments( query, successAgentId );
} else if ( res.code === -1 ) {
successAppName = "";
scope.applicationNameMessage = res.message;
setFail( $applicationNameInput );
}
});

};
scope.searchAgentId = function() {
var query = scope.inputAgentId.trim();
if ( isValidLength(query) === false ) {
scope.agentIdMessage = lengthGuide;
setFail( $agentIdInput );
return;
}
InstallationAjaxService.isAvailableAgentId({
agentId: query
}, function ( res ) {
if ( res.code === 0 ) {
successAgentId = query;
scope.agentIdMessage = "";
setSuccess( $agentIdInput );
setArguments( successAppName, query );
} else if ( res.code === -1 ) {
successAgentId = "";
scope.agentIdMessage = res.message;
setFail( $agentIdInput );
}
});
};
scope.$on( "configuration.selectMenu", function( event, selectedName ) {
if ( myName === selectedName ) {
loadInstallationInfo();
$element.show();
} else {
$element.hide();
clearArea();
}
});

}
};
}
]);
})( jQuery );
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div id="config-installation">
<div class="description">{{description}}</div>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2 title">Application name</label>
<div class="col-sm-8">
<div class="form-group has-feedback application-name-input">
<input class="form-control" placeholder="input application name" ng-model="inputApplicationName" ng-keydown="onKeyDown($event, 'applicationName')">
<span class="glyphicon form-control-feedback" style="display:none;"></span>
</div>
</div>
<div class="col-sm-2" style="text-align:right">
<btn class="btn btn-default" ng-click="searchApplicationName()">Search</btn>
</div>
<div class="col-sm-12" style="text-align: center;">{{applicationNameMessage}}</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2 title">Agent ID</label>
<div class="col-sm-8" style="text-align:left">
<div class="form-group has-feedback agent-id-input">
<input class="form-control" placeholder="input agent id" ng-model="inputAgentId" ng-keydown="onKeyDown($event, 'agentId')">
<span class="glyphicon form-control-feedback" style="display:none;"></span>
</div>
</div>
<div class="col-sm-2" style="text-align:right">
<btn class="btn btn-default" ng-click="searchAgentId()">Search</btn>
</div>
<div class="col-sm-12" style="text-align: center;">{{agentIdMessage}}</div>
</div>
</form>
<div class="installation-guide">
<h4>Download Link</h4>
<p><a ng-href="{{downloadLink}}">{{downloadLink}}</a></p>
</div>
<div class="installation-guide">
<h4>JVM Argument Info <button class="btn btn-default btn-xs btn-success" ng-click="copyArguments()">copy</button></h4>
<textarea readonly></textarea>
</div>
</div>
2 changes: 2 additions & 0 deletions web/src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ <h4>To use PinPoint, enable cookies and JavaScript</h4>
<script src="common/services/server-map-filter-vo.service.js?v=${buildTime}"></script>
<script src="common/services/alarm-ajax.service.js?v=${buildTime}"></script>
<script src="common/services/alarm-util.service.js?v=${buildTime}"></script>
<script src="common/services/installation-ajax.service.js?v=${buildTime}"></script>
<script src="common/services/server-map-hint-vo.service.js?v=${buildTime}"></script>
<script src="common/services/is-visible.service.js?v=${buildTime}"></script>
<script src="common/services/user-locales.service.js?v=${buildTime}"></script>
Expand Down Expand Up @@ -367,6 +368,7 @@ <h4>To use PinPoint, enable cookies and JavaScript</h4>
<script src="features/configuration/application/application-group.directive.js?v=${buildTime}"></script>
<script src="features/configuration/application/alarm-rule.directive.js?v=${buildTime}"></script>
<script src="features/configuration/help/help.directive.js?v=${buildTime}"></script>
<script src="features/configuration/installation/installation.directive.js?v=${buildTime}"></script>
<script src="features/threadDumpInfoLayer/thread-dump-info-layer.directive.js?v=${buildTime}"></script>
<script src="features/realtimeChart/realtime-chart.controller.js?v=${buildTime}"></script>
<script src="features/statisticChart/statistic-chart.directive.js?v=${buildTime}"></script>
Expand Down
27 changes: 20 additions & 7 deletions web/src/main/webapp/styles/configuration.css
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,24 @@
animation-iteration-count: 2;
*/
}
/*
@keyframes back-blink {
0% {background-color: rgba( 255, 0, 0, 0.2 )}
50% {background-color: rgba( 255, 0, 0, 0.5 ) }
100% {background-color: rgba( 255, 0, 0, 0.2 ) }
#config-installation .description {
color: #C2C2C2;
margin-bottom: 20px;
}
*/

#config-installation .title {
font-size: 14px;
font-weight: bold;
}
#config-installation .installation-guide {
padding: 16px;
margin: 16px 0px;
border: 1px solid #EEE;
border-left-width: 5px;
border-left-color:#1B809E;
}
#config-installation textarea {
width: 100%;
height: 80px;
border: 0px solid black;
overflow: hidden;
}

0 comments on commit 8288c31

Please sign in to comment.