Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

707 add print button to pair dialog #718

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/webapp/app/layouts/main/main.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<div [ngClass]="(this.isPrintLocked$ | async) ? 'not-print' : ''">
<jhi-page-ribbon></jhi-page-ribbon>
<div>
<router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
<div class="card jh-card">
<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
<div>
<router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
<div class="card jh-card">
<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
</div>
<jhi-footer></jhi-footer>
</div>
<jhi-footer></jhi-footer>
</div>
8 changes: 6 additions & 2 deletions src/main/webapp/app/layouts/main/main.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';
import { Component, OnInit} from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';

import { JhiLanguageHelper } from '../../shared';
import {PrintService} from "../../shared/util/print.service";

@Component({
selector: 'jhi-main',
Expand All @@ -12,10 +13,13 @@ export class JhiMainComponent implements OnInit {

constructor(
private jhiLanguageHelper: JhiLanguageHelper,
private printService: PrintService,
private router: Router,
) {
}

isPrintLocked$= this.printService.isPrintLocked$;

ngOnInit() {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<span class="fa fa-save"></span> <span
[translate]="'managementPortalApp.subject.generatePersistentToken'"></span>
</button>
<button type="button" class="btn btn-default" data-dismiss="modal" (click)="exportHtmlToPDF()">
<span class="fa fa-print"></span><span>Print</span>
</button>
</div>

<div class="form-group" *ngIf="pairInfo !== null">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Component, Inject, OnDestroy, OnInit} from '@angular/core';
import { DatePipe, DOCUMENT } from '@angular/common';
import { HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Params } from '@angular/router';
Expand All @@ -14,6 +14,7 @@ import { SubjectPopupService } from './subject-popup.service';
import { Subject } from './subject.model';
import { ObservablePopupComponent } from '../util/observable-popup.component';
import { map, switchMap, tap } from 'rxjs/operators';
import { PrintService } from '../util/print.service';

@Component({
selector: 'jhi-subject-pair-dialog',
Expand All @@ -35,20 +36,29 @@ export class SubjectPairDialogComponent implements OnInit, OnDestroy {
private oauthClientService: OAuthClientService,
private pairInfoService: OAuthClientPairInfoService,
private datePipe: DatePipe,
private printService: PrintService,
@Inject(DOCUMENT) private doc) {
this.authorities = ['ROLE_USER', 'ROLE_SYS_ADMIN'];
}

exportHtmlToPDF() {
window.print();
}

ngOnInit() {
if (this.subject.project && this.subject.project.persistentTokenTimeout) {
this.allowPersistentToken = true;
}
this.loadInconsolataFont();
this.subscriptions.add(this.fetchOAuthClients());

// Add print-lock to exclude the background from being included in print commands
this.printService.setPrintLockTo(true);
}

ngOnDestroy() {
this.subscriptions.unsubscribe();
this.printService.setPrintLockTo(false);
}

private fetchOAuthClients(): Subscription {
Expand Down
12 changes: 12 additions & 0 deletions src/main/webapp/app/shared/util/print.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from "rxjs";

@Injectable({ providedIn: 'root' })
export class PrintService {

isPrintLocked$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

setPrintLockTo(setTo: boolean) {
this.isPrintLocked$.next(setTo)
}
}
14 changes: 14 additions & 0 deletions src/main/webapp/content/scss/_print.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@media print {

* {
-webkit-print-color-adjust: exact;
}

.not-print {
display: none !important;
}

.modal-backdrop {
display: none !important;
}
}
1 change: 1 addition & 0 deletions src/main/webapp/content/scss/global.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

@import '~bootstrap/scss/bootstrap';
@import '~font-awesome/css/font-awesome';
@import "print";

/* ==============================================================
Bootstrap tweaks
Expand Down