Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#123 first cut of a nicer Add wizard that has an Endpoints tab that l…
…ets you pick from the available list of endpoints
- Loading branch information
Showing
8 changed files
with
176 additions
and
108 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
81 changes: 81 additions & 0 deletions
81
hawtio-web/src/main/webapp/app/camel/js/endpointChooser.ts
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,81 @@ | ||
module Camel { | ||
|
||
export function initEndpointChooserScope($scope, workspace:Workspace, jolokia) { | ||
$scope.selectedComponentName = null; | ||
$scope.endpointParameters = {}; | ||
$scope.schema = { | ||
definitions: { | ||
} | ||
}; | ||
|
||
var silentOptions = {silent: true}; | ||
|
||
$scope.$watch('workspace.selection', function () { | ||
workspace.moveIfViewInvalid(); | ||
$scope.loadEndpointNames(); | ||
}); | ||
|
||
$scope.$watch('selectedComponentName', () => { | ||
if ($scope.selectedComponentName !== $scope.loadedComponentName) { | ||
$scope.endpointParameters = {}; | ||
$scope.loadEndpointSchema($scope.selectedComponentName); | ||
$scope.loadedComponentName = $scope.selectedComponentName; | ||
} | ||
}); | ||
|
||
$scope.endpointCompletions = () => { | ||
var answer = []; | ||
var mbean = Camel.getSelectionCamelContextMBean(workspace); | ||
var componentName = $scope.selectedComponentName; | ||
var endpointParameters = {}; | ||
var completionText = $scope.endpointPath || ""; | ||
if (mbean && componentName && completionText) { | ||
answer = jolokia.execute(mbean, 'completeEndpointPath', componentName, endpointParameters, completionText, onSuccess(null, silentOptions)); | ||
} | ||
return answer; | ||
}; | ||
|
||
$scope.loadEndpointNames = () => { | ||
$scope.componentNames = null; | ||
var mbean = Camel.getSelectionCamelContextMBean(workspace); | ||
if (!mbean && $scope.findProfileCamelContext) { | ||
// TODO as a hack for now lets just find any camel context we can | ||
var folder = Core.getMBeanTypeFolder(workspace, Camel.jmxDomain, "context"); | ||
mbean = Core.pathGet(folder, ["objectName"]); | ||
} | ||
if (mbean) { | ||
jolokia.execute(mbean, 'findComponentNames', onSuccess(onComponents, silentOptions)); | ||
} else { | ||
console.log("WARNING: No camel context mbean so cannot load component names"); | ||
} | ||
}; | ||
|
||
function onComponents(response) { | ||
$scope.componentNames = response; | ||
$scope.hasComponentNames = $scope.componentNames ? true : false; | ||
Core.$apply($scope); | ||
} | ||
|
||
$scope.loadEndpointSchema = (componentName) => { | ||
var mbean = Camel.getSelectionCamelContextMBean(workspace); | ||
if (mbean && componentName) { | ||
jolokia.execute(mbean, 'componentParameterJsonSchema', componentName, onSuccess(onEndpointSchema, silentOptions)); | ||
} | ||
}; | ||
|
||
function onEndpointSchema(response) { | ||
if (response) { | ||
try { | ||
//console.log("got JSON: " + response); | ||
var json = JSON.parse(response); | ||
$scope.endpointSchema = json; | ||
$scope.schema.definitions[$scope.selectedComponentName] = json; | ||
Core.$apply($scope); | ||
} catch (e) { | ||
console.log("Failed to parse JSON " + e); | ||
console.log("JSON: " + response); | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -970,5 +970,4 @@ module Camel { | |
} | ||
return doc; | ||
} | ||
|
||
} |
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
Oops, something went wrong.