Skip to content

Commit

Permalink
merged in feature/#181-layer-upgrade-ui-update
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed May 19, 2021
1 parent bd9acda commit 9e14436
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 27 deletions.
4 changes: 0 additions & 4 deletions nav-app/src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export class DataService {
public subtechniquesEnabled: boolean = true;
public versionChangelog?: VersionChangelog<Technique>;

private _sidebarOpened: boolean;
public get sidebarOpened(): boolean { return this._sidebarOpened; };
public set sidebarOpened(newVal: boolean) { this._sidebarOpened = newVal; };

/**
* Callback functions passed to this function will be called after data is loaded
* @param {*} callback callback function to call when data is done loading
Expand Down
24 changes: 12 additions & 12 deletions nav-app/src/app/datatable/data-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,12 @@
o88o 8 o88o o88o o888o o888o o888o 88o8 o888o o88o o888o
-->
<div class="matrices">
<mat-drawer-container autosize>
<mat-drawer-content>
<div oncontextmenu="return false">
<div class="spinner" *ngIf="!dataService.getDomain(viewModel.domainID).dataLoaded">
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
</div>
<div oncontextmenu="return false">
<div class="spinner" *ngIf="!dataService.getDomain(viewModel.domainID).dataLoaded">
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
</div>
<mat-drawer-container autosize>
<mat-drawer-content>
<div class="matrices-columns">
<div class="matrix-column" *ngFor="let matrix of dataService.getDomain(viewModel.domainID).matrices">
<div *ngIf="dataService.getDomain(viewModel.domainID).matrices.length > 1" class="matrix-name">{{matrix.name}}</div>
Expand All @@ -546,12 +546,12 @@
</div>
</div>
</div>
</div>
</mat-drawer-content>
<mat-drawer mode="side" position="end" #sidebar [opened]="dataService.sidebarOpened">
<sidebar></sidebar>
</mat-drawer>
</mat-drawer-container>
</mat-drawer-content>
<mat-drawer mode="side" position="end" #sidebar [opened]="viewModel.sidebarOpened">
<sidebar [viewModel]="viewModel"></sidebar>
</mat-drawer>
</mat-drawer-container>
</div>
</div>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ViewModel } from '../../viewmodels.service';
import { BaseStix, DataService, Technique, VersionChangelog } from '../../data.service';

@Component({
Expand All @@ -8,6 +9,7 @@ import { BaseStix, DataService, Technique, VersionChangelog } from '../../data.s
})
export class LayerUpgradeComponent implements OnInit {
@Input() changelog: VersionChangelog<BaseStix>;
@Input() viewModel: ViewModel;
public showUnannotated: boolean = false;
public sections: string[] = [
"additions", "changes", "minor_changes",
Expand All @@ -31,7 +33,7 @@ export class LayerUpgradeComponent implements OnInit {

public upgradeLayer(): void {
// close sidebar
this.dataService.sidebarOpened = !this.dataService.sidebarOpened;
this.viewModel.sidebarOpened = !this.viewModel.sidebarOpened;
}

public getIDs(object: Technique) {
Expand Down
2 changes: 1 addition & 1 deletion nav-app/src/app/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="sidebar">
<div *ngIf="dataService.versionChangelog">
<layer-upgrade [changelog]="dataService.versionChangelog"></layer-upgrade>
<layer-upgrade [viewModel]="viewModel" [changelog]="dataService.versionChangelog"></layer-upgrade>
</div>
</div>
16 changes: 9 additions & 7 deletions nav-app/src/app/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { DataService } from '../data.service';
import { ViewModel } from '../viewmodels.service';

@Component({
selector: 'sidebar',
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.scss']
selector: 'sidebar',
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent implements OnInit {
@Input() viewModel?: ViewModel;

constructor(public dataService: DataService) { }
constructor(public dataService: DataService) { }

ngOnInit(): void {
}
ngOnInit(): void {
}

}
4 changes: 2 additions & 2 deletions nav-app/src/app/tabs/tabs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,15 @@ export class TabsComponent implements AfterContentInit, AfterViewInit {
let dataSubscription = forkJoin(loads).subscribe({
next: () => {
this.dataService.compareVersions(versions.previous, versions.latest);
this.dataService.sidebarOpened = true;
viewModel.sidebarOpened = true;
viewModel.deSerialize(string);
viewModel.loadVMData();
},
complete: () => { dataSubscription.unsubscribe(); }
});
} else {
this.dataService.compareVersions(versions.previous, versions.latest);
this.dataService.sidebarOpened = true;
viewModel.sidebarOpened = true;
viewModel.deSerialize(string);
viewModel.loadVMData();
}
Expand Down
4 changes: 4 additions & 0 deletions nav-app/src/app/viewmodels.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ export class ViewModel {
techIDtoUIDMap: Object = {};
techUIDtoIDMap: Object = {};

private _sidebarOpened: boolean;
public get sidebarOpened(): boolean { return this._sidebarOpened; };
public set sidebarOpened(newVal: boolean) { this._sidebarOpened = newVal; };

constructor(name: string, uid: string, domainID: string, private dataService: DataService) {
this.domainID = domainID;
console.log("initializing ViewModel '" + name + "'");
Expand Down

0 comments on commit 9e14436

Please sign in to comment.