This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #576 from hawkular/topology
HAWKULAR-676 - Topology view
- Loading branch information
Showing
9 changed files
with
917 additions
and
0 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
89 changes: 89 additions & 0 deletions
89
console/src/main/scripts/plugins/topology/directives/hawkularTopologyGraph.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,89 @@ | ||
/// | ||
/// Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
|
||
/// <reference path='../../includes.ts'/> | ||
/// <reference path='../ts/topologyGlobals.ts'/> | ||
|
||
module HawkularTopology { | ||
_module.directive('hawkularTopologyGraph', | ||
() => { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
items: '=', | ||
relations: '=', | ||
kinds: '=', | ||
selection: '=', | ||
force: '=' | ||
}, | ||
link: ($scope, element, attributes) => { | ||
element.css('display', 'block'); | ||
|
||
var graph; | ||
function notify(item) { | ||
var event = $scope.$emit('select', item); | ||
if (attributes['selection'] === undefined && !event.defaultPrevented) { | ||
graph.select(item); | ||
} | ||
} | ||
|
||
function icon(d) { | ||
var text; | ||
var kinds = $scope.kinds; | ||
if (kinds) { | ||
text = kinds[d.item.kind]; | ||
} | ||
return text || ''; | ||
} | ||
|
||
function weak(d) { | ||
var status = d.item.status; | ||
return status && status.phase && status.phase !== 'Running'; | ||
} | ||
|
||
function title(d) { | ||
return d.item.metadata.name; | ||
} | ||
|
||
function render(args) { | ||
var vertices = args[0]; | ||
var added = args[1]; | ||
var event = $scope.$emit('render', vertices, added); | ||
if (!event.defaultPrevented) { | ||
added.attr('class', (d) => d.item.kind); | ||
added.append('use').attr('xlink:href', icon); | ||
added.append('title'); | ||
vertices.selectAll('title') | ||
.text((d) => d.item.metadata.name); | ||
vertices.classed('weak', weak); | ||
} | ||
} | ||
|
||
graph = HawkularTopology.initGraph(element[0], $scope.force, notify); | ||
|
||
$scope.$watchCollection('kinds', (value) => render(graph.kinds(value))); | ||
|
||
$scope.$watchGroup(['items', 'relations'], (values) => render(graph.data(values[0], values[1]))); | ||
|
||
$scope.$watch('selection', (item) => graph.select(item)); | ||
|
||
element.on('$destroy', () => graph.close()); | ||
} | ||
}; | ||
} | ||
); | ||
} |
51 changes: 51 additions & 0 deletions
51
console/src/main/scripts/plugins/topology/directives/hawkularTopologyIcon.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,51 @@ | ||
/// | ||
/// Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
|
||
/// <reference path='../../includes.ts'/> | ||
/// <reference path='../ts/topologyGlobals.ts'/> | ||
|
||
module HawkularTopology { | ||
_module.directive('hawkularTopologyIcon', () => { | ||
return { | ||
restrict: 'E', | ||
transclude: true, | ||
template: '<ng-transclude></ng-transclude>', | ||
link: ($scope, element, attrs) => { | ||
var kind = attrs.kind; | ||
var value = $scope.vm.kinds[kind]; | ||
|
||
$scope.$watchCollection('kinds', () => element.toggleClass('active', kind in $scope.vm.kinds)); | ||
|
||
element.on('click', () => { | ||
if (kind in $scope.vm.kinds) { | ||
value = $scope.vm.kinds[kind]; | ||
delete $scope.vm.kinds[kind]; | ||
} else { | ||
$scope.vm.kinds[kind] = value; | ||
} | ||
if ($scope.$parent) { | ||
$scope.$parent.$digest(); | ||
} | ||
if ($scope.$root) { | ||
$scope.$root.$digest(); | ||
} | ||
$scope.$digest(); | ||
}); | ||
} | ||
}; | ||
}); | ||
} |
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,72 @@ | ||
<div class="hk-application-servers" data-ng-controller="HawkularTopology.TopologyController as vm"> | ||
|
||
<hawkular-topology-graph items="vm.data.items" relations="vm.data.relations" kinds="vm.kinds"> | ||
</hawkular-topology-graph> | ||
|
||
<div class="controls"> | ||
<label id="selected"></label> | ||
<!--<button ng-click="vm.poke()" >Random Data</button>--> | ||
<!--<button ng-click="vm.testClick()">test</button>--> | ||
|
||
<div class="iconWithLabel"> | ||
<hawkular-topology-icon kind="Server"> | ||
<svg class="hawkular-topology"> | ||
<use xlink:href="#vertex-Server" x="15" y="15"></use> | ||
</svg> | ||
</hawkular-topology-icon> | ||
<label>Servers</label> | ||
<br/> | ||
</div> | ||
|
||
<div class="iconWithLabel"> | ||
<hawkular-topology-icon kind="App"> | ||
<svg class="hawkular-topology"> | ||
<use xlink:href="#vertex-App" x="15" y="15"></use> | ||
</svg> | ||
</hawkular-topology-icon> | ||
<label>Apps</label> | ||
<br/> | ||
</div> | ||
|
||
<!--<hawkular-topology-icon kind="Database"> | ||
<svg class="hawkular-topology"> | ||
<use xlink:href="#vertex-Database" x="15" y="15"></use> | ||
</svg> | ||
</hawkular-topology-icon> | ||
<label>Databases</label>--> | ||
|
||
<div class="iconWithLabel"> | ||
<hawkular-topology-icon kind="DataSource"> | ||
<svg class="hawkular-topology"> | ||
<use xlink:href="#vertex-DataSource" x="15" y="15"></use> | ||
</svg> | ||
</hawkular-topology-icon> | ||
<label>Datasources</label> | ||
<br/> | ||
</div> | ||
</div> | ||
|
||
<svg class="hawkular-topology" hidden> | ||
<defs><!-- | ||
<g class="Database" id="vertex-Database"> | ||
<circle r="15"></circle> | ||
<text y="6"></text> | ||
</g>--> | ||
<g class="Server" id="vertex-Server"> | ||
<circle r="15"></circle> | ||
<!-- <text y="6" x="0.5"></text> --> | ||
<text y="6" x="0.5"></text> | ||
</g> | ||
<g class="App" id="vertex-App"> | ||
<circle r="15"></circle> | ||
<!-- <text y="10" x="1"></text> --> | ||
<text y="7" x="0"></text> | ||
</g> | ||
<g class="DataSource" id="vertex-DataSource"> | ||
<circle r="15"></circle> | ||
<!-- <text y="7.5"></text> --> | ||
<text y="5"></text> | ||
</g> | ||
</defs> | ||
</svg> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// | ||
/// Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
|
||
/// <reference path="../includes.ts"/> | ||
/// <reference path="../../libs/hawtio-utilities/defs.d.ts"/> | ||
/// <reference path="../../libs/hawtio-core-dts/defs.d.ts"/> |
Oops, something went wrong.