Skip to content

Commit

Permalink
Merge branch 'feature/#204-consolidate-search-and-multiselect' into f…
Browse files Browse the repository at this point in the history
…eature/#181-layer-upgrade-ui-update
  • Loading branch information
iguannalin committed May 19, 2021
2 parents 8e35a26 + 13cb570 commit 1a463d5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
8 changes: 8 additions & 0 deletions nav-app/src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export class DataService {
public subtechniquesEnabled: boolean = true;
public versionChangelog?: VersionChangelog<Technique>;å

public readonly sidebarContentTypes = ['layerUpgrade', 'search'];
private _sidebarContentType: string;
public get sidebarContentType(): string { return this._sidebarContentType; };
public set sidebarContentType(newVal: string) {
if (this.sidebarContentTypes.includes(newVal)) this._sidebarContentType = newVal;
else this._sidebarContentType = '';
};

/**
* 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
21 changes: 1 addition & 20 deletions nav-app/src/app/datatable/data-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,13 @@
<div *ngIf="configService.getFeature('search')" class="control-row-item">

<div class="control-row-button dropdown noselect"
(click)="currentDropdown = currentDropdown !== 'search' ? 'search' : null;"
(click)="(dataService.sidebarOpened = (dataService.sidebarContentType !== 'search') ? true : !dataService.sidebarOpened) && (dataService.sidebarContentType = 'search')"
matTooltipPosition="below"
matTooltip="search">
<img src="assets/icons/ic_search_black_24px.svg"/>
</div>

<div class="dropdown-container search" *ngIf="currentDropdown === 'search'" #dropdown [class.left]="checkalign(dropdown)">
<app-techniques-search [viewModel]="viewModel"></app-techniques-search>
</div>
</div>


<!-- Multi-select -->
<div *ngIf="configService.getFeature('multiselect')" class="control-row-item">
<div class="control-row-button dropdown noselect"
(click)="currentDropdown = currentDropdown !== 'multiselect' ? 'multiselect' : null;"
matTooltipPosition="below"
matTooltip="multi-select">
<img src="assets/icons/ic_playlist_add_black_24px.svg"/>
</div>
<div class="dropdown-container multiselect" *ngIf="currentDropdown === 'multiselect'" #dropdown [class.left]="checkalign(dropdown)">
<app-multiselect [viewModel]="viewModel"></app-multiselect>
</div>
</div>


<!-- deselect all -->
<div *ngIf="configService.getFeature('deselect_all')" class="control-row-item">
<div class="control-row-button noselect"
Expand Down
6 changes: 6 additions & 0 deletions nav-app/src/app/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
<div *ngIf="dataService.versionChangelog">
<layer-upgrade [viewModel]="viewModel" [changelog]="dataService.versionChangelog"></layer-upgrade>
</div>
<div *ngIf="viewModel">
<div *ngIf="dataService.sidebarContentType === 'search'">
<app-techniques-search [viewModel]="viewModel"></app-techniques-search>
<app-multiselect [viewModel]="viewModel"></app-multiselect>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion nav-app/src/app/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ViewModel } from '../viewmodels.service';
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent implements OnInit {
@Input() viewModel?: ViewModel;
@Input() viewModel: ViewModel;

constructor(public dataService: DataService) { }

Expand Down
3 changes: 2 additions & 1 deletion nav-app/src/app/tabs/tabs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ export class TabsComponent implements AfterContentInit, AfterViewInit {
let dataSubscription = forkJoin(loads).subscribe({
next: () => {
this.dataService.compareVersions(versions.previous, versions.latest);
viewModel.sidebarOpened = true;
this.dataService.sidebarOpened = true;
this.dataService.sidebarContentType = 'layerUpgrade';
viewModel.deSerialize(string);
viewModel.loadVMData();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TechniquesSearchComponent implements OnInit {
for (let field of self.fields) {
if (field.enabled) {
// query in this field
if (technique[field.field].toLowerCase().includes(self._query.trim().toLowerCase())) return true;
if (technique[field.field]?.toLowerCase().includes(self._query.trim().toLowerCase())) return true;
}
}
return false;
Expand Down

0 comments on commit 1a463d5

Please sign in to comment.