forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#3390] add installation page in configuration.
- Loading branch information
Showing
10 changed files
with
253 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
web/src/main/webapp/common/services/installation-ajax.service.js
This file contains 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
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); |
This file contains 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
This file contains 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
153 changes: 153 additions & 0 deletions
153
web/src/main/webapp/features/configuration/installation/installation.directive.js
This file contains 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
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 ); |
39 changes: 39 additions & 0 deletions
39
web/src/main/webapp/features/configuration/installation/installation.html
This file contains 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
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> |
This file contains 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
This file contains 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