Skip to content

Commit d3acfdd

Browse files
authored
Merge pull request #82 from ufrgs-hyman/group_domains_members_feature
Group domains members feature
2 parents 7932eb8 + 947c3d5 commit d3acfdd

File tree

15 files changed

+137
-34
lines changed

15 files changed

+137
-34
lines changed

config/db.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
<?php
23
/**
3-
* @copyright Copyright (c) 2016 RNP
4+
* @copyright Copyright (c) 2022 RNP
45
* @license http://github.com/ufrgs-hyman/meican#license
56
*/
67

@@ -11,4 +12,4 @@
1112
'password' => 'root',
1213
'charset' => 'utf8',
1314
'tablePrefix' => 'meican_',
14-
];
15+
];

docker_for_build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ COPY docker-entrypoint.sh $MEICAN_DIR/docker/
4848

4949
EXPOSE 80
5050

51-
ENTRYPOINT $MEICAN_DIR/docker/wait-for-mysql.sh 'db' "$MEICAN_DIR/docker/docker-entrypoint.sh"
51+
ENTRYPOINT $MEICAN_DIR/docker/wait-for-mysql.sh 'db' "$MEICAN_DIR/docker/docker-entrypoint.sh"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use yii\db\Migration;
4+
5+
class m220710_183534_added_grouped_nodes_column extends Migration
6+
{
7+
public function up()
8+
{
9+
$this->execute(
10+
"ALTER TABLE `meican_domain`
11+
ADD COLUMN `grouped_nodes` boolean NULL DEFAULT TRUE"
12+
);
13+
14+
}
15+
16+
public function down()
17+
{
18+
echo "m220710_183534_added_grouped_nodes_column cannot be reverted.\n";
19+
20+
return false;
21+
}
22+
}

modules/circuits/assets/connection/public/view.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @copyright Copyright (c) 2019 RNP
2+
* @copyright Copyright (c) 2022 RNP
33
* @license http://github.com/ufrgs-hyman/meican#license
44
* @author Mauricio Quatrin Guerreiro
55
*/

modules/circuits/assets/reservation/public/create/create.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @copyright Copyright (c) 2019 RNP
2+
* @copyright Copyright (c) 2022 RNP
33
* @license http://github.com/ufrgs-hyman/meican#license
44
* @author Maurício Quatrin Guerreiro
55
*/
@@ -45,8 +45,6 @@ $(document).ready(function() {
4545
});
4646

4747
lsidebar = L.control.lsidebar('lsidebar').addTo(meicanMap._map);
48-
//lsidebar.open("home");
49-
5048
});
5149

5250
function validatePath() {
@@ -607,9 +605,6 @@ function addWayPoint(nodeId) {
607605
}
608606

609607
function setPointByNode(position, nodeId) {
610-
console.log(position, nodeId);
611-
//var node = meicanMap.getMarker(nodeId);
612-
//var node = meicanGraph.getNode(nodeId);
613608
if(mode == 'map') {
614609
var marker = meicanMap.getNode(nodeId);
615610
setPoint(
@@ -754,6 +749,14 @@ function loadDomains() {
754749

755750
}
756751
});
752+
753+
// Expansion of locations of domains with this property
754+
var current = meicanMap;
755+
$( document ).ajaxStop(function() {
756+
while( current._stackDomainsToBeExpanded.length > 0 ){
757+
current.expandLocations( current._stackDomainsToBeExpanded.pop() );
758+
}
759+
});
757760
}
758761

759762
function loadProviders() {

modules/topology/assets/viewer/graph/meican-vgraph.js

-2
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,9 @@ VGraph.prototype.build = function(divId) {
234234
this._popup.set('visible', false);
235235
this._graph.on("click", function (params) {
236236
if(params['nodes'].length > 0) {
237-
//console.log(' click node:', params);
238237
$( "#"+currentGraph._canvasDivId ).trigger( "vgraph.nodeClick", currentGraph._nodes.get(params.nodes[0]).id);
239238
} else {
240239
currentGraph._popup.hide();
241-
//console.log('click fora');
242240
}
243241
});
244242
this._graph.on("zoom", function () {

modules/topology/assets/viewer/index/viewer2.js

-6
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ function loadProviders() {
184184
},
185185
success: function(response) {
186186
meicanTopo['prov'] = response;
187-
/*meicanGraph.addNodes(response, 'prov');
188-
for (var i = 0; i < response.length; i++) {
189-
meicanMap.addMarker(response[i], 'prov');
190-
};*/
191187
loadProviderLinks();
192188
}
193189
});
@@ -214,7 +210,6 @@ function loadNetworks() {
214210
}
215211

216212
function loadDevices() {
217-
//console.log("load devs")
218213
if(meicanTopo['dev']) return;
219214
$.ajax({
220215
url: baseUrl+'/topology/device/get-all',
@@ -293,7 +288,6 @@ function loadPortLinks() {
293288
//meicanGraph.addLinks(response, 'dev');
294289
for (var src in response) {
295290
for (var i = 0; i < response[src].length; i++) {
296-
//console.log(src, response[src][i]);
297291
meicanMap.addLink(src,response[src][i]);
298292
}
299293
}

modules/topology/assets/viewer/map/meican-lmap.js

+65-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A DCN topology viewer based on Leaflet Javascript library.
55
*
6-
* @copyright Copyright (c) 2019 RNP
6+
* @copyright Copyright (c) 2022 RNP
77
* @license http://github.com/ufrgs-hyman/meican#license
88
* @author Mauricio Quatrin Guerreiro
99
*/
@@ -15,6 +15,7 @@ function LMap(canvasDivId) {
1515
this._canvasDivId = canvasDivId;
1616
this._map; // Leaflet Map
1717
this._nodes = []; // markers/nodes container
18+
this._stackDomainsToBeExpanded = [];
1819
this._nodesL = [];
1920
this._nodesN = [];
2021
this._links = []; // polylines/links/edges container
@@ -26,6 +27,7 @@ function LMap(canvasDivId) {
2627
this._nodeAutoInc = 1;
2728
this._linkAutoInc = 1;
2829
this._expandedDomainNodes = [];
30+
this._lockRoutine = false;
2931
};
3032

3133
LMap.prototype.show = function(instantRefresh) {
@@ -128,6 +130,38 @@ LMap.prototype.getPortsByLocation = function(location_name) {
128130
return locations;
129131
}
130132

133+
LMap.prototype.getQtdPortsByDomain = function(domain_id) {
134+
let qtd_ports = 0;
135+
136+
for (let i = this._topology['ports'].length - 1; i >= 0; i--)
137+
if (this._topology['ports'][i].network.domain.id == domain_id)
138+
qtd_ports ++;
139+
140+
return qtd_ports;
141+
}
142+
143+
LMap.prototype.getQtdPortsWithLocationByDomain = function(domain_id) {
144+
let qtd_ports = 0;
145+
146+
for (let i = this._topology['ports'].length - 1; i >= 0; i--)
147+
if (this._topology['ports'][i].network.domain.id == domain_id)
148+
if( this._topology['ports'][i].lat != null )
149+
if( this._topology['ports'][i].lng != null )
150+
qtd_ports ++;
151+
152+
return qtd_ports;
153+
}
154+
155+
LMap.prototype.getQtdLocationsByDomain = function(domain_id) {
156+
let qtd_ports = 0;
157+
158+
for (let i = this._topology['locations'].length - 1; i >= 0; i--)
159+
if (this._topology['locations'][i].network.domain.id == domain_id)
160+
qtd_ports ++;
161+
162+
return qtd_ports;
163+
}
164+
131165
LMap.prototype.addIntraLink = function(location_link) {
132166
if(!location_link.source || !location_link.destination)
133167
return null;
@@ -383,6 +417,11 @@ LMap.prototype.addNode = function(port, color, mode) {
383417

384418
this._nodes.push(node);
385419
this._cluster.addLayer(node);
420+
if (!flagPortLocation) {
421+
if (port.network.domain.grouped_nodes == 0) {
422+
this._stackDomainsToBeExpanded.push(node.options.id);
423+
}
424+
}
386425

387426
var currentMap = this;
388427

@@ -410,7 +449,6 @@ LMap.prototype.addNode = function(port, color, mode) {
410449
className: 'marker-icon-svg',
411450
}));
412451
}
413-
414452
}
415453

416454
LMap.prototype.prepareLabels = function() {
@@ -808,7 +846,18 @@ LMap.prototype.focusNodes = function() {
808846
}
809847

810848
LMap.prototype.loadTopology = function(withLinks) {
849+
var current = this;
850+
811851
this._loadDomains(withLinks);
852+
853+
// Expansion of locations of domains with this property
854+
$( document ).ajaxStop(function() {
855+
while( current._stackDomainsToBeExpanded.length > 0 ){
856+
current.expandLocations( current._stackDomainsToBeExpanded.pop() );
857+
current.removeLinks();
858+
current._loadLinks();
859+
}
860+
});
812861
}
813862

814863
LMap.prototype._loadDomains = function(withLinks) {
@@ -891,8 +940,9 @@ LMap.prototype._loadPorts = function(withLinks) {
891940
}
892941

893942
for (var i = current._topology['ports'].length - 1; i >= 0; i--) {
894-
if(current._topology['ports'][i].type == 'NSI')
943+
if (current._topology['ports'][i].type == 'NSI') {
895944
current.addNode(current._topology['ports'][i]);
945+
}
896946
}
897947
current.prepareLabels();
898948
if(withLinks)
@@ -1044,17 +1094,21 @@ LMap.prototype.expandLocations = function(nodeId) {
10441094
let nodes = this.getNodes();
10451095
let ports = this.getTopology()['ports'];
10461096
let domainId = node.options.ports[0].network.domain_id;
1047-
1048-
this.addExpandedDomainNode(node);
10491097

1050-
for (var i = ports.length - 1; i >= 0; i--) {
1051-
if(ports[i].network.domain_id == domainId){
1052-
this.addNode(
1053-
ports[i]
1054-
);
1098+
if( this.getQtdPortsWithLocationByDomain(domainId) > 0 ){
1099+
this.addExpandedDomainNode(node);
1100+
1101+
for (var i = ports.length - 1; i >= 0; i--) {
1102+
if(ports[i].network.domain_id == domainId){
1103+
this.addNode(
1104+
ports[i]
1105+
);
1106+
}
10551107
}
1108+
this.hideNode(node);
10561109
}
1057-
this.hideNode(node);
1110+
1111+
flagPortLocation = false;
10581112
}
10591113

10601114
LMap.prototype.groupLocations = function(nodeId) {

modules/topology/controllers/DomainController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public function actionCreate(){
6868
}
6969
}
7070

71+
$dom->grouped_nodes = true;
7172
return $this->render('create',[
72-
'domain' => $dom,
73+
'domain' => $dom,
7374
]);
7475
}
7576

modules/topology/messages/pt-BR/topology.php

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'Description' => 'Descrição',
5050
'Delete' => 'Remover',
5151
'value' => 'valor',
52+
'Grouped Nodes' => 'Nodos Agrupados',
5253
'Map' => 'Mapa',
5354
'Mode' => 'Modo',
5455
'Node type' => 'Tipo de nodo',

modules/topology/models/Domain.php

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function rules()
4949
[['default_policy'], 'string'],
5050
[['name'], 'string', 'max' => 60],
5151
[['color'], 'string', 'max' => 10],
52+
[['grouped_nodes'],'boolean'],
5253
[['graph_x', 'graph_y'], 'integer'],
5354
[['name'], 'unique']
5455
];
@@ -63,6 +64,7 @@ public function attributeLabels()
6364
'id' => 'ID',
6465
'name' => Yii::t('topology', 'Name'),
6566
'color' => Yii::t('topology', 'Color'),
67+
'grouped_nodes' => Yii::t('topology', 'Grouped Nodes'),
6668
'default_policy' => Yii::t('topology', 'Default Policy'),
6769
];
6870
}

modules/topology/views/domain/_form.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use yii\bootstrap\Html;
99
use yii\helpers\Url;
1010
use yii\helpers\ArrayHelper;
11+
use meican\base\grid\Grid;
12+
use meican\base\grid\IcheckboxColumn;
1113

1214
use kartik\color\ColorInput;
1315

@@ -26,11 +28,16 @@
2628
<h3 class="box-title"><?= $this->params['box-title']; ?></h3>
2729
</div>
2830
<div class="box-body">
31+
<center> <h4> <em>General Settings</em> </h4> </center>
2932
<?= $form->field($domain,'name')->textInput(['size'=>30,'maxlength'=>60]); ?>
3033
<?= $form->field($domain,'default_policy')->dropDownList($domain->getPolicyOptions()); ?>
3134
<?= $form->field($domain, 'color')->widget(ColorInput::classname(), [
3235
'options' => ['placeholder' => 'Select color ...', 'readonly' => true],
3336
]); ?>
37+
<hr>
38+
39+
<center> <h4> <em>Default View Settings</em> </h4> </center>
40+
<?= $form->field($domain, 'grouped_nodes')->checkBox(['class'=>'icheck' , 'value' => true, 'label' => 'Display domain locations grouped by default']); ?>
3441
</div>
3542
<div class="box-footer">
3643
<div class="form-group">
@@ -41,4 +48,4 @@
4148
</div>
4249
</div>
4350

44-
<?php ActiveForm::end(); ?>
51+
<?php ActiveForm::end(); ?>

modules/topology/views/domain/index.php

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* @copyright Copyright (c) 2012-2016 RNP
3+
* @copyright Copyright (c) 2012-2022 RNP
44
* @license http://github.com/ufrgs-hyman/meican#license
55
*/
66

@@ -13,6 +13,7 @@
1313
use yii\helpers\Html;
1414
use yii\helpers\Url;
1515
use yii\widgets\Pjax;
16+
use yii\grid\checkboxCollumn;
1617

1718
\meican\topology\assets\domain\Index::register($this);
1819

@@ -35,7 +36,7 @@
3536
'enableClientValidation' => false,
3637
]);
3738

38-
Pjax::begin();
39+
Pjax::begin();
3940

4041
echo Grid::widget([
4142
'dataProvider' => $domains,
@@ -67,7 +68,26 @@
6768
'value' => function($dom){
6869
return $dom->getPolicy();
6970
},
70-
'headerOptions'=>['style'=>'width: 46%;'],
71+
'headerOptions'=>['style'=>'width: 30%;'],
72+
],
73+
[
74+
'attribute' => 'grouped_nodes',
75+
76+
'label' => 'Group domain locations by default',
77+
78+
'format' => ['html'],
79+
80+
'filter' => false,
81+
82+
'value' => function ($data) {
83+
84+
if ($data['grouped_nodes'])
85+
return Html::img('@web/images/green_checked2.png', ['width' => '25px']);
86+
87+
return Html::img('@web/images/red_unchecked.png', ['width' => '25px']);
88+
89+
},
90+
7191
],
7292
),
7393
]);

web/images/green_checked2.png

93.6 KB
Loading

web/images/red_unchecked.png

39.9 KB
Loading

0 commit comments

Comments
 (0)