gui CHANGE link schemas from data
open schema in YANG explorer by clicking on schema name of the nodes
in configuration view
diff --git a/backend/connections.py b/backend/connections.py
index 94a05bb..fb0b13b 100644
--- a/backend/connections.py
+++ b/backend/connections.py
@@ -251,7 +251,11 @@
def _create_child(ctx, parent, child_def):
- module = ctx.get_module(child_def['info']['module'])
+ at = child_def['info']['module'].find('@')
+ if at == -1:
+ module = ctx.get_module(child_def['info']['module'])
+ else:
+ module = ctx.get_module(child_def['info']['module'][:at], child_def['info']['module'][at + 1:])
# print('child: ' + json.dumps(child_def))
# print('parent: ' + parent.schema().name())
# print('module: ' + module.name())
diff --git a/backend/data.py b/backend/data.py
index cfcfdbd..935d974 100644
--- a/backend/data.py
+++ b/backend/data.py
@@ -63,7 +63,10 @@
info = {}
info["type"] = schema.nodetype()
- info["module"] = schema.module().name()
+ if schema.module().rev_size():
+ info["module"] = schema.module().name() + '@' + schema.module().rev().date()
+ else:
+ info["module"] = schema.module().name()
info["name"] = schema.name()
info["dsc"] = schema.dsc()
info["config"] = True if schema.flags() & yang.LYS_CONFIG_W else False
diff --git a/frontend/config/tree.component.html b/frontend/config/tree.component.html
index ce7faee..7f26f83 100644
--- a/frontend/config/tree.component.html
+++ b/frontend/config/tree.component.html
@@ -90,7 +90,7 @@
</ng-container>
<!-- END nodetype-specific code -->
- <div class="module_name">{{node['info']['module']}}</div>
+ <div class="module_name" (click)="showSchema(node)" title="open schema {{node['info']['module']}} in YANG Explorer">{{moduleName(node)}}</div>
</div>
<!-- BEGIN nodetype-specific code -->
diff --git a/frontend/config/tree.component.scss b/frontend/config/tree.component.scss
index c88f210..7e7bcc2 100644
--- a/frontend/config/tree.component.scss
+++ b/frontend/config/tree.component.scss
@@ -90,6 +90,7 @@
}
.module_name {
+ cursor: pointer;
float: right;
text-align: right;
max-width: 25em;
diff --git a/frontend/config/tree.component.ts b/frontend/config/tree.component.ts
index 23c2c30..7cc941f 100644
--- a/frontend/config/tree.component.ts
+++ b/frontend/config/tree.component.ts
@@ -2,9 +2,11 @@
import {Router} from '@angular/router';
import {Session} from './session';
+import {Schema} from '../inventory/schema';
import {ModificationsService} from './modifications.service';
import {SessionsService} from './sessions.service';
import {TreeService} from './config.component';
+import {SchemasService} from '../yang/schemas.service';
@Directive({
selector: '[treeScrollTo]'
@@ -183,7 +185,9 @@
constructor(private modsService: ModificationsService,
private sessionsService: SessionsService,
private treeService: TreeService,
- private changeDetector: ChangeDetectorRef) {}
+ private schemasService: SchemasService,
+ private changeDetector: ChangeDetectorRef,
+ private router: Router) {}
ngOnInit(): void {
this.activeSession = this.sessionsService.getActiveSession();
@@ -292,6 +296,32 @@
return null;
}
+ moduleName(node): string {
+ let at = node['info']['module'].indexOf('@');
+ if (at == -1) {
+ return node['info']['module'];
+ } else {
+ return node['info']['module'].substring(0, at);
+ }
+ }
+
+ showSchema(node) {
+ let schema = new Schema;
+ let at = node['info']['module'].indexOf('@');
+ if (at == -1) {
+ schema.name = node['info']['module'];
+ } else {
+ schema.name = node['info']['module'].substring(0, at);
+ schema.revision = node['info']['module'].substring(at + 1);
+ }
+ let key = node['info']['module'] + '.yang';
+
+ schema.name = this.moduleName(node);
+ this.schemasService.show(key, schema);
+ this.schemasService.changeActiveSchemaKey(key);
+ this.router.navigateByUrl( '/netopeer/yang' );
+ }
+
newChildrenToShow(node) {
if ('newChildren' in node) {
return node['newChildren'];
diff --git a/frontend/yang/schemas.service.ts b/frontend/yang/schemas.service.ts
index 168ddac..1cf8a76 100644
--- a/frontend/yang/schemas.service.ts
+++ b/frontend/yang/schemas.service.ts
@@ -14,9 +14,11 @@
constructor( private http: Http ) {
this.loadData();
this.activeSchema = localStorage.getItem('activeSchema');
+ if (!this.schemas) {
+ this.schemas = {};
+ }
if (!this.activeSchema) {
this.activeSchema = "";
- this.schemas = [];
}
}
@@ -55,7 +57,7 @@
changeActiveSchemaKey(key: string): Schema {
if (key && (key in this.schemas)) {
this.activeSchema = key;
- localStorage.setItem('activeSession', this.activeSchema);
+ localStorage.setItem('activeSchema', this.activeSchema);
}
return this.schemas[key];
}
@@ -65,7 +67,7 @@
.map(( resp: Response ) => resp.json()).toPromise();
}
- show(key: string, schema: Schema) {
+ show( key: string, schema: Schema) {
let newSchema = true;
if (key in this.schemas) {
@@ -93,6 +95,22 @@
}
}
+ close( key: string ) {
+ let index = Object.keys( this.schemas ).indexOf( key );
+ if ( this.activeSchema == key ) {
+ if ( index > 0 ) {
+ this.changeActiveSchemaKey( Object.keys( this.schemas )[index - 1] )
+ } else if ( Object.keys( this.schemas ).length > 1 ) {
+ this.changeActiveSchemaKey( Object.keys( this.schemas )[1] )
+ } else {
+ this.activeSchema = null;
+ localStorage.removeItem('activeSchema');
+ }
+ }
+ delete this.schemas[key];
+ this.storeData();
+ }
+
addSchema( schema: File ) {
let headers = new Headers( { 'specific-content-type': '' } );
let options = new RequestOptions( { headers: headers } );
diff --git a/frontend/yang/yang.component.html b/frontend/yang/yang.component.html
index ed016e8..69fe3a3 100644
--- a/frontend/yang/yang.component.html
+++ b/frontend/yang/yang.component.html
@@ -3,7 +3,7 @@
(click)="schemasService.changeActiveSchemaKey(key)">{{schemasService.schemas[key].name}}@{{schemasService.schemas[key].revision}}
<img class="tab-icon tab-close tab-action-last" src="assets/netopeer/icons/close.svg" alt="x" title="close"
onmouseover="this.src='assets/netopeer/icons/close_active.svg'"
- onmouseout="this.src='assets/netopeer/icons/close.svg'" (click)="close(key)"/>
+ onmouseout="this.src='assets/netopeer/icons/close.svg'" (click)="schemasService.close(key)"/>
</a><a (click)="addSchema()" onmouseout="getElementById('tabadd').style.filter='invert(100%)'" onmouseover="getElementById('tabadd').style.filter='invert(0%)'">
<img id="tabadd" class="tab-icon tab-add tab-action-last" src="assets/netopeer/icons/add.svg" alt="+" title="open schema"
onmouseover="this.src='assets/netopeer/icons/add_active.svg'"
@@ -12,6 +12,5 @@
</nav>
<div class="netopeer-content" [style.padding-top]="'calc(' + subnav.offsetHeight + 'px - -0.7em)'">
<img *ngIf="!schemasService.activeSchema" (click)="addSchema()" src="assets/netopeer/starthere.svg" alt="Start here with that + sign."/>
-
<pre *ngIf="schemasService.activeSchema">{{schemasService.schemas[schemasService.activeSchema].data}}</pre>
</div>
diff --git a/frontend/yang/yang.component.ts b/frontend/yang/yang.component.ts
index eddcf7c..ba66af4 100644
--- a/frontend/yang/yang.component.ts
+++ b/frontend/yang/yang.component.ts
@@ -1,38 +1,23 @@
import { Component } from '@angular/core';
-import {Router} from '@angular/router';
+import { Router } from '@angular/router';
-import {SchemasService} from './schemas.service';
-import {Schema} from '../inventory/schema';
+import { SchemasService } from './schemas.service';
+import { Schema } from '../inventory/schema';
-@Component({
- selector : 'netopeer-yang',
- templateUrl : './yang.component.html',
- styleUrls : ['./yang.component.scss']
-})
+@Component( {
+ selector: 'netopeer-yang',
+ templateUrl: './yang.component.html',
+ styleUrls: ['./yang.component.scss']
+} )
export class YANGComponent {
- title = 'YANG Explorer';
+ title = 'YANG Explorer';
+ test = null;
- constructor(private schemasService: SchemasService,
- private router: Router) {}
+ constructor( private schemasService: SchemasService,
+ private router: Router ) { }
-
- addSchema() {
- this.router.navigateByUrl('/netopeer/inventory/schemas');
- }
-
- close(key: string) {
- let index = Object.keys(this.schemasService.schemas).indexOf(key);
- if (this.schemasService.activeSchema == key) {
- if (index > 0) {
- this.schemasService.changeActiveSchemaKey(Object.keys(this.schemasService.schemas)[index - 1])
- } else if (Object.keys(this.schemasService.schemas).length > 1) {
- this.schemasService.changeActiveSchemaKey(Object.keys(this.schemasService.schemas)[1])
- } else {
- this.schemasService.activeSchema = null;
- }
- }
- delete this.schemasService.schemas[key];
- this.schemasService.storeData();
- }
+ addSchema() {
+ this.router.navigateByUrl( '/netopeer/inventory/schemas' );
+ }
}