mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Maximum limit of alerts
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
<app-widget-frame title="Upload new documents" i18n-title [class.has-multiple-status]="getStatus().length > 1">
 | 
					<app-widget-frame title="Upload new documents" i18n-title [class.has-multiple-status]="(getStatus().length + getStatusesHidden().length)> 1">
 | 
				
			||||||
  <div header-buttons>
 | 
					  <div header-buttons>
 | 
				
			||||||
    <button type="button" class="btn btn-link dismiss-all" [disabled]="!getStatus().length" (click)="dismissAll()">
 | 
					    <button type="button" class="btn btn-link dismiss-all" [disabled]="!getStatus().length" (click)="dismissAll()">
 | 
				
			||||||
      <small class="mr-1">Hide all</small>
 | 
					      <small class="mr-1">Hide all</small>
 | 
				
			||||||
@@ -17,6 +17,20 @@
 | 
				
			|||||||
      </ngx-file-drop>
 | 
					      </ngx-file-drop>
 | 
				
			||||||
    </form>
 | 
					    </form>
 | 
				
			||||||
    <div *ngFor="let status of getStatus()">
 | 
					    <div *ngFor="let status of getStatus()">
 | 
				
			||||||
 | 
					      <ng-container [ngTemplateOutlet]="consumerAlert" [ngTemplateOutletContext]="{ $implicit: status }"></ng-container>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div *ngIf="getStatusesHidden().length" class="alerts-hidden">
 | 
				
			||||||
 | 
					      <p *ngIf="!alertsExpanded" class="mt-3 mb-0 text-center">{{getStatusesHidden().length}} more hidden <button class="btn btn-sm btn-link py-0" (click)="alertsExpanded = !alertsExpanded" aria-controls="hiddenAlerts" [attr.aria-expanded]="alertsExpanded">Show all</button></p>
 | 
				
			||||||
 | 
					      <div #hiddenAlerts="ngbCollapse" [(ngbCollapse)]="!alertsExpanded">
 | 
				
			||||||
 | 
					        <div *ngFor="let status of getStatusesHidden()">
 | 
				
			||||||
 | 
					          <ng-container [ngTemplateOutlet]="consumerAlert" [ngTemplateOutletContext]="{ $implicit: status }"></ng-container>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					</app-widget-frame>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<ng-template #consumerAlert let-status>
 | 
				
			||||||
  <ngb-alert type="secondary" class="mt-2 mb-0" [dismissible]="isFinished(status)" (closed)="dismiss(status)">
 | 
					  <ngb-alert type="secondary" class="mt-2 mb-0" [dismissible]="isFinished(status)" (closed)="dismiss(status)">
 | 
				
			||||||
    <h6 class="alert-heading">{{status.filename}}</h6>
 | 
					    <h6 class="alert-heading">{{status.filename}}</h6>
 | 
				
			||||||
    <p class="mb-0 pb-1" *ngIf="!isFinished(status) || (isFinished(status) && !status.documentId)">{{status.message}}</p>
 | 
					    <p class="mb-0 pb-1" *ngIf="!isFinished(status) || (isFinished(status) && !status.documentId)">{{status.message}}</p>
 | 
				
			||||||
@@ -30,6 +44,4 @@
 | 
				
			|||||||
      </button>
 | 
					      </button>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </ngb-alert>
 | 
					  </ngb-alert>
 | 
				
			||||||
    </div>
 | 
					</ng-template>
 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
</app-widget-frame>
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,12 @@ form {
 | 
				
			|||||||
  font-weight: bold;
 | 
					  font-weight: bold;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.alerts-hidden {
 | 
				
			||||||
 | 
					  .btn {
 | 
				
			||||||
 | 
					    line-height: 1;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.btn-open {
 | 
					.btn-open {
 | 
				
			||||||
  line-height: 1;
 | 
					  line-height: 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';
 | 
				
			|||||||
import { ConsumerStatusService, FileStatus, FileStatusPhase } from 'src/app/services/consumer-status.service';
 | 
					import { ConsumerStatusService, FileStatus, FileStatusPhase } from 'src/app/services/consumer-status.service';
 | 
				
			||||||
import { DocumentService } from 'src/app/services/rest/document.service';
 | 
					import { DocumentService } from 'src/app/services/rest/document.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const MAX_ALERTS = 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-upload-file-widget',
 | 
					  selector: 'app-upload-file-widget',
 | 
				
			||||||
@@ -11,6 +12,7 @@ import { DocumentService } from 'src/app/services/rest/document.service';
 | 
				
			|||||||
  styleUrls: ['./upload-file-widget.component.scss']
 | 
					  styleUrls: ['./upload-file-widget.component.scss']
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class UploadFileWidgetComponent implements OnInit {
 | 
					export class UploadFileWidgetComponent implements OnInit {
 | 
				
			||||||
 | 
					  alertsExpanded = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    private documentService: DocumentService,
 | 
					    private documentService: DocumentService,
 | 
				
			||||||
@@ -18,7 +20,12 @@ export class UploadFileWidgetComponent implements OnInit {
 | 
				
			|||||||
  ) { }
 | 
					  ) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getStatus() {
 | 
					  getStatus() {
 | 
				
			||||||
    return this.consumerStatusService.getConsumerStatus()
 | 
					    return this.consumerStatusService.getConsumerStatus().slice(0, MAX_ALERTS)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getStatusesHidden() {
 | 
				
			||||||
 | 
					    if (this.consumerStatusService.getConsumerStatus().length < MAX_ALERTS) return []
 | 
				
			||||||
 | 
					    else return this.consumerStatusService.getConsumerStatus().slice(MAX_ALERTS)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getStatusUploading() {
 | 
					  getStatusUploading() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user