Skip to content

Commit

Permalink
Merge pull request #435 from kytos-ng/ui/not_ownership
Browse files Browse the repository at this point in the history
UI/not ownership
  • Loading branch information
viniarck authored Feb 19, 2024
2 parents 88e65f5 + 76d5ae4 commit 62c6258
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Added
- Usage of special vlans ``"untagged"`` and ``"any"`` now send an event to each Interface.
- Added ``UNI_STATE_CHANGE_DELAY`` which configures the time for ``mef_eline`` to wait on link state flaps and update EVCs with last updated event.
- Added support for ``not_ownership`` to dynamic path constraints.
- Added support for ``not_ownership`` on main UI interface.

Changed
=======
Expand Down
32 changes: 26 additions & 6 deletions ui/k-info-panel/show_circuit.kytos
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,15 @@ module.exports = {
'mandatory_metrics.delay': 'Delay',
'mandatory_metrics.reliability': 'Reliability',
'mandatory_metrics.ownership': 'Ownership',
'mandatory_metrics.not_wnership': 'Not ownership',
'flexible_metrics': 'Flexible metrics',
'flexible_metrics.bandwidth': 'Bandwidth',
'flexible_metrics.utilization': 'Utilization',
'flexible_metrics.priority': 'Priority',
'flexible_metrics.delay': 'Delay',
'flexible_metrics.reliability': 'Reliability',
'flexible_metrics.ownership': 'Ownership',
'flexible_metrics.not_ownership': 'Not ownership',
};

let _constraint = {};
Expand All @@ -690,12 +692,14 @@ module.exports = {
'priority': data['mandatory_metrics']['priority'],
'delay': data['mandatory_metrics']['delay'],
'reliability': data['mandatory_metrics']['reliability'],
'ownership': data['mandatory_metrics']['ownership']
'ownership': data['mandatory_metrics']['ownership'],
'not_ownership': JSON.stringify(data['mandatory_metrics']['not_ownership']),
};
} else {
_constraint.mandatory_metrics = {
'bandwidth': '', 'utilization': '', 'priority': '',
'delay': '', 'reliability': '', 'ownership': '',
'not_ownership': [],
};
}
if(data['flexible_metrics']) {
Expand All @@ -705,12 +709,14 @@ module.exports = {
'priority': data['flexible_metrics']['priority'],
'delay': data['flexible_metrics']['delay'],
'reliability': data['flexible_metrics']['reliability'],
'ownership': data['flexible_metrics']['ownership']
'ownership': data['flexible_metrics']['ownership'],
'not_ownership': JSON.stringify(data['flexible_metrics']['not_ownership']),
};
} else {
_constraint.flexible_metrics = {
'bandwidth': '', 'utilization': '', 'priority': '',
'delay': '', 'reliability': '', 'ownership': '',
'not_ownership': [],
};
}

Expand Down Expand Up @@ -782,7 +788,7 @@ module.exports = {
*/
var _this = this;
let id = this.basics["ID"]["value"];

var parse_error = ""
let payload = {
name: this.basics["Name"]["value"],
enable: this.flags["Enabled"]["value"],
Expand Down Expand Up @@ -848,6 +854,18 @@ module.exports = {
if(metric['ownership'] !== undefined) { // can be empty
_result_metrics['ownership'] = metric['ownership'];
}
if(metric['not_ownership'] !== undefined && metric['not_ownership'] !== '') {
try{_result_metrics['not_ownership'] = JSON.parse(metric['not_ownership'])}
catch(e){
if (e instanceof SyntaxError){
_result_metrics['not_ownership'] = metric['not_ownership']
parse_error = " Detected error with " + metric['not_ownership'] + ", it could not be parsed."
}
else{
throw e
}
}
}
if(!$.isEmptyObject(_result_metrics)) {
_constraint_payload[_metric_type] = _result_metrics;
} else {
Expand Down Expand Up @@ -876,7 +894,7 @@ module.exports = {
request.fail(function(data) {
let notification = {
title: 'Update EVC failed',
description: 'Error updating EVC ' + id +'. ' + data.responseJSON.description
description: 'Error updating EVC ' + id +'. ' + data.responseJSON.description + parse_error
}
_this.$kytos.$emit("setNotification" , notification);
});
Expand Down Expand Up @@ -911,15 +929,17 @@ module.exports = {
'priority': '',
'delay': '',
'reliability': '',
'ownership': ''
'ownership': '',
'not_ownership': [],
},
'flexible_metrics': {
'bandwidth': '',
'utilization': '',
'priority': '',
'delay': '',
'reliability': '',
'ownership': ''
'ownership': '',
'not_ownership': [],
}
};
});
Expand Down
42 changes: 35 additions & 7 deletions ui/k-toolbar/main.kytos
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@
:action="function(val) {form_constraints[constraint].metrics.ownership = val}"></k-input>
</div>
</div>

<div class="metric">
<div class="metric-dropdown">
<k-dropdown :options="metric_options"
:title="constraint_titles['not_ownership']"
:value.sync="form_constraints[constraint].is_flexible.not_ownership"
ref="is_flexible"></k-dropdown>
</div>
<div class="metric-field">
<k-input icon="arrow-right"
placeholder='["blue", "red"]'
:value.sync="form_constraints[constraint].not_ownership"
:action="function(val){
try{form_constraints[constraint].metrics.not_ownership = JSON.parse(val)}
catch(e){
if(e instanceof SyntaxError){form_constraints[constraint].metrics.not_ownership=val}
else{throw e}}}"></k-input>
</div>
</div>
</k-accordion-item>
</span>
<k-button tooltip="Request Circuit" title="Request Circuit"
Expand Down Expand Up @@ -244,14 +263,16 @@ module.exports = {
metrics: {
bandwidth: '', utilization: '', priority: '',
delay: '', reliability: '', ownership: '',
not_ownership: [],
},
is_flexible: {
bandwidth: false,
reliability: false,
delay: false,
utilization: false,
priority: false,
ownership: false
ownership: false,
not_ownership: false,
},
},
secondary_constraints: {
Expand All @@ -262,14 +283,16 @@ module.exports = {
metrics: {
bandwidth: '', utilization: '', priority: '',
delay: '', reliability: '', ownership: '',
not_ownership: [],
},
is_flexible: {
bandwidth: false,
reliability: false,
delay: false,
utilization: false,
priority: false,
ownership: false
ownership: false,
not_ownership: false,
},
}
},
Expand Down Expand Up @@ -340,6 +363,7 @@ module.exports = {
'delay': 'Delay',
'reliability': 'Reliability',
'ownership': 'Ownership',
'not_ownership': 'Not ownership',
};

this.form_constraints = {
Expand All @@ -351,14 +375,16 @@ module.exports = {
metrics: {
bandwidth: '', utilization: '', priority: '',
delay: '', reliability: '', ownership: '',
not_ownership: [],
},
is_flexible: {
bandwidth: false,
reliability: false,
delay: false,
utilization: false,
priority: false,
ownership: false
ownership: false,
not_ownership: false,
},
},
secondary_constraints: {
Expand All @@ -369,14 +395,16 @@ module.exports = {
metrics: {
bandwidth: '', utilization: '', priority: '',
delay: '', reliability: '', ownership: '',
not_ownership: [],
},
is_flexible: {
bandwidth: false,
reliability: false,
delay: false,
utilization: false,
priority: false,
ownership: false
ownership: false,
not_ownership: false,
},
}
};
Expand Down Expand Up @@ -480,7 +508,7 @@ module.exports = {
// mandatory and flexible metrics. Filter empty values.
let _flexible_metrics = {};
let _mandatory_metrics = {};
['bandwidth', 'utilization', 'priority', 'delay', 'reliability', 'ownership'].forEach(_m => {
['bandwidth', 'utilization', 'priority', 'delay', 'reliability', 'ownership', 'not_ownership'].forEach(_m => {
if(this.form_constraints[_type].metrics[_m] !== '') {
if (this.form_constraints[_type].is_flexible[_m]) {
_flexible_metrics[_m] = this.form_constraints[_type].metrics[_m];
Expand Down Expand Up @@ -624,8 +652,8 @@ module.exports = {
}
.metric-dropdown {width:100%;}
.metric-dropdown .k-dropdown {height: 20px; width:100%; display:flex;flex-wrap: wrap;}
.metric-dropdown .k-dropdown .k-dropdown__title {width:35%;}
.metric-dropdown .k-dropdown .k-dropdown__select {width:60%;}
.metric-dropdown .k-dropdown .k-dropdown__title {width:42%;}
.metric-dropdown .k-dropdown .k-dropdown__select {width:53%;}
.metric-field {width:100%; display:flex; }
.metric-field label {width:60%; }
.metric-field label ~.k-input-wrap {width:40%; }
Expand Down

0 comments on commit 62c6258

Please sign in to comment.