Skip to content

Commit

Permalink
moved print lock to ngOnInit and nGOnDestroy, added comment
Browse files Browse the repository at this point in the history
removed commented out code
removed unused references to _print.scss
removed unused print tag
  • Loading branch information
Bdegraaf1234 committed Sep 18, 2023
1 parent e156b65 commit 179040e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface TabOptions {
selector: 'jhi-project-detail',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './project-detail.component.html',
styleUrls: ['project-detail.component.scss', '../../../content/scss/_print.scss'],
styleUrls: ['project-detail.component.scss'],
})
export class ProjectDetailComponent implements OnInit, OnDestroy {
private subscription = new Subscription();
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/app/layouts/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ export class JhiMainComponent implements OnInit {
}
});
this.isPrintLocked$ = this.printService.isPrintLocked$;
//this.isPrintLocked$.subscribe(setTo => console.log("now we updated main.html"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(click)="clear()">×
</button>
</div>
<div class="modal-body print">
<div class="modal-body">
<div class="form-group">
<div>
<label for="login" class="form-control-label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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 { JhiMainComponent } from '../../layouts/main/main.component';
import { PrintService } from '../util/print.service';

@Component({
Expand All @@ -41,18 +40,9 @@ export class SubjectPairDialogComponent implements OnInit, OnDestroy {
@Inject(DOCUMENT) private doc) {
this.authorities = ['ROLE_USER', 'ROLE_SYS_ADMIN'];
}
async exportHtmlToPDF() {
// let pp: PrintService = this.printService;
// window.onafterprint = function(){
// console.log("Printing completed...");
// //pp.togglePrintLock().then(_ => {})
// }

this.printService.setPrintLockTo(true);
await new Promise(r => setTimeout(r, 0.000000000000000000000000000000000000000000000000000001));
window.print()
this.printService.setPrintLockTo(false);

exportHtmlToPDF() {
window.print();
}

ngOnInit() {
Expand All @@ -61,10 +51,14 @@ export class SubjectPairDialogComponent implements OnInit, OnDestroy {
}
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
2 changes: 1 addition & 1 deletion src/main/webapp/app/shared/subject/subject.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { regularSortOrder, SortOrder, SortOrderImpl } from '../util/sort-util';
selector: 'jhi-subjects',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './subject.component.html',
styleUrls: ['./subject.component.scss', '../../../content/scss/_print.scss'],
styleUrls: ['./subject.component.scss'],
})
export class SubjectComponent implements OnInit, OnDestroy, OnChanges {
private subscriptions: Subscription = new Subscription();
Expand Down
4 changes: 1 addition & 3 deletions src/main/webapp/app/shared/util/print.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export class PrintService {

constructor(
) {
this.isPrintLocked$.subscribe(isPrintLocked => {
//console.log(`isPrintlocked: ${isPrintLocked}`)
})
this.isPrintLocked$.subscribe();
}

setPrintLockTo(setTo: boolean) {
Expand Down

0 comments on commit 179040e

Please sign in to comment.