Skip to content

Commit

Permalink
Add edit view in new tab for System Admin (#559)
Browse files Browse the repository at this point in the history
* Added option to open admin edit view in new tab for system admins

* Bug fix

* Updated cli to v13

* Merge with dev package-lock.json fix

* Fixed package-lock.json

* Fix for package-lock.json

* Fix for package-lock.json

* Fix for package-lock.json

* package-lock.json merge

* package-lock version update
  • Loading branch information
sei-chershberger authored Sep 21, 2022
1 parent dbcafb9 commit 2b35fb1
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 20,838 deletions.
20,937 changes: 122 additions & 20,815 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Carnegie Mellon University. All Rights Reserved.
// Copyright 2022 Carnegie Mellon University. All Rights Reserved.
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.

import { OverlayContainer } from '@angular/cdk/overlay';
Expand Down Expand Up @@ -139,6 +139,12 @@ export class AppComponent implements OnDestroy {
'assets/svg-icons/ic_add_24px.svg'
)
);
this.iconRegistry.addSvgIcon(
'ic_open_tab',
this.sanitizer.bypassSecurityTrustResourceUrl(
'assets/svg-icons/ic_open_tab.svg'
)
);
}

setTheme(theme: Theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatSort, MatSortable } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';
import { View, ViewService, ViewStatus } from '../../../generated/player-api';
import { DialogService } from '../../../services/dialog/dialog.service';
import { LoggedInUserService } from '../../../services/logged-in-user/logged-in-user.service';
Expand Down Expand Up @@ -38,7 +39,8 @@ export class AdminViewSearchComponent implements OnInit {
constructor(
private viewService: ViewService,
public loggedInUserService: LoggedInUserService,
public dialogService: DialogService
public dialogService: DialogService,
public route: ActivatedRoute
) {}

/**
Expand All @@ -58,6 +60,12 @@ export class AdminViewSearchComponent implements OnInit {
this.loggedInUserService.loggedInUser$.subscribe((user) => {
this.refreshViews();
});

// Check to see if a view was specified in the URL
const viewId = this.route.snapshot.queryParamMap.get('view');
if (viewId) {
this.executeViewAction('edit', viewId);
}
}

/**
Expand Down
35 changes: 23 additions & 12 deletions src/app/components/player/player.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Carnegie Mellon University. All Rights Reserved.
// Copyright 2022 Carnegie Mellon University. All Rights Reserved.
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.

// TODO: Set sidnav status in query string.
Expand Down Expand Up @@ -164,17 +164,28 @@ export class PlayerComponent implements OnInit, OnDestroy {
* Called to open the edit view dialog window
*/
editViewFn(event) {
const dialogRef = this.dialog.open(AdminViewEditComponent);
this.data$.subscribe((data) => {
dialogRef.componentInstance.resetStepper();
dialogRef.componentInstance.updateApplicationTemplates();
dialogRef.componentInstance.updateView();
dialogRef.componentInstance.view = data.view;
});

dialogRef.componentInstance.editComplete.subscribe(() => {
dialogRef.close();
});
if (event.isNewBrowserTab === true) {
const url = this.router.serializeUrl(
this.router.createUrlTree(
['/admin'],
{ queryParams: { section: 'admin-views', view: this.routerQuery.getParams('id') }}
)
);
console.log('url', url);
window.open(url, '_blank');
} else {
const dialogRef = this.dialog.open(AdminViewEditComponent);
this.data$.subscribe((data) => {
dialogRef.componentInstance.resetStepper();
dialogRef.componentInstance.updateApplicationTemplates();
dialogRef.componentInstance.updateView();
dialogRef.componentInstance.view = data.view;
});

dialogRef.componentInstance.editComplete.subscribe(() => {
dialogRef.close();
});
}
}

sidenavToggleFn() {
Expand Down
28 changes: 21 additions & 7 deletions src/app/components/shared/top-bar/topbar.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2021 Carnegie Mellon University. All Rights Reserved.
Copyright 2022 Carnegie Mellon University. All Rights Reserved.
Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.
-->
<mat-toolbar
Expand Down Expand Up @@ -71,13 +71,27 @@
<mat-icon svgIcon="ic_expand_more_white_24px"></mat-icon>
</button>
<mat-menu #menu="matMenu" [overlapTrigger]="false">
<button
*ngIf="team && team.canManage"
(click)="editFn($event)"
<div fxLayout="row" fxLayoutAlign="start center">
<button
*ngIf="team && team.canManage"
(click)="editFn($event)"
[ngClass]="(currentUser.profile.isSystemAdmin !== null &&
currentUser.profile.isSystemAdmin) ? big-button : ''"
mat-menu-item
>
Edit View
</button>
<button
title="Open in Browser Tab"
*ngIf="team && currentUser.profile.isSystemAdmin !== null &&
currentUser.profile.isSystemAdmin"
(click)="editFnNewTab($event)"
class="small-button"
mat-menu-item
>
Edit View
</button>
>
<mat-icon svgIcon="ic_open_tab"></mat-icon>
</button>
</div>
<button
*ngIf="
currentUser.profile.isSystemAdmin !== null &&
Expand Down
9 changes: 8 additions & 1 deletion src/app/components/shared/top-bar/topbar.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Carnegie Mellon University. All Rights Reserved.
// Copyright 2022 Carnegie Mellon University. All Rights Reserved.
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.
.margin-auto {
margin: auto;
Expand All @@ -19,3 +19,10 @@
margin-left: 50px;
margin-right: 40px;
}
.big-button {
width: 75%;
}
.small-button {
width: 25%;
padding-right: 40px;
}
10 changes: 9 additions & 1 deletion src/app/components/shared/top-bar/topbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Carnegie Mellon University. All Rights Reserved.
// Copyright 2022 Carnegie Mellon University. All Rights Reserved.
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.

import {
Expand Down Expand Up @@ -75,6 +75,14 @@ export class TopbarComponent implements OnInit, OnDestroy {
this.editView.emit(event);
}

editFnNewTab(event) {
const newTabEvent = {
...event,
isNewBrowserTab: true,
};
this.editView.emit(newTabEvent);
}

sidenavToggleFn() {
this.sidenavToggle.emit(!this.sidenav.opened);
}
Expand Down
4 changes: 4 additions & 0 deletions src/assets/svg-icons/ic_open_tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b35fb1

Please sign in to comment.