<div class="main-content dataset-profile-listing">
	<div class="container-fluid">

		<div class="row">
			<div class="col-auto">
				<h3>{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}</h3>
			</div>
			<div class="col-12 col-lg d-flex justify-content-lg-end">
				<div class="align-self-center">
					<button mat-raised-button class="import-btn" (click)="openDialog()">{{ 'DATASET-WIZARD.UPLOAD.UPLOAD-XML' | translate }}</button>
					<button mat-raised-button class="create-btn ml-md-3" [routerLink]="['./new']">{{'DATASET-PROFILE-LISTING.ACTIONS.CREATE-DATASET-TEMPLATE' | translate}}</button>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-12 mt-5">
				<app-dataset-profile-criteria-component></app-dataset-profile-criteria-component>
			</div>
		</div>

		<div class="mat-elevation-z6">

		<!-- <mat-card class="row mat-card"> -->
			<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()" matSortActive="created" matSortDirection="desc">

				<!-- Column Definition: Name -->
				<ng-container cdkColumnDef="label">
					<mat-header-cell *matHeaderCellDef mat-sort-header="label">
						{{'DATASET-PROFILE-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
					<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
				</ng-container>

				<!-- Column Definition: Description -->
				<ng-container cdkColumnDef="description">
					<mat-header-cell *matHeaderCellDef>{{'DATASET-PROFILE-LISTING.COLUMNS.DESCRIPTION' | translate}}
					</mat-header-cell>
					<mat-cell *matCellDef="let row"><span [innerHTML]="row.description"></span></mat-cell>
				</ng-container>

				<!-- Column Definition: Created -->
				<ng-container cdkColumnDef="created">
					<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-PROFILE-LISTING.COLUMNS.CREATED' |
						translate}}</mat-header-cell>
					<mat-cell *matCellDef="let row">{{row.created | date:'short'}}</mat-cell>
				</ng-container>

				<!-- Column Definition: Status -->
				<ng-container cdkColumnDef="status">
					<mat-header-cell *matHeaderCellDef mat-sort-header="status">{{'DATASET-PROFILE-LISTING.COLUMNS.STATUS' |
						translate}}</mat-header-cell>
					<mat-cell *matCellDef="let row"> <div [ngClass]="['status-chip',getStatusClass(row.status)]">{{ (row.status | parseStatus) | translate}}</div></mat-cell>
				</ng-container>

				<!-- Column Definition: Submission Time -->
				<ng-container cdkColumnDef="actions">
					<mat-header-cell *matHeaderCellDef><!-- {{'DATASET-PROFILE-LISTING.COLUMNS.ACTIONS' | translate}} -->
					</mat-header-cell>
					<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
						<mat-menu #actionsMenu="matMenu">
							<button mat-menu-item (click)="newVersion(row.id, row.label)">
								<mat-icon>queue</mat-icon>{{'DATASET-PROFILE-LISTING.ACTIONS.NEW-VERSION' | translate}}
							</button>
							<button mat-menu-item (click)="clone(row.id)">
								<mat-icon>filter_none</mat-icon>{{'DATASET-PROFILE-LISTING.ACTIONS.CLONE' | translate}}
							</button>
							<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
								<mat-icon>library_books</mat-icon>
								{{'DATASET-PROFILE-LISTING.ACTIONS.VIEW-VERSIONS' | translate}}
							</button>
							<button mat-menu-item (click)="downloadXML(row.id)" *ngIf="row.status === datasetStatusEnum.Finalized">
								<mat-icon>download</mat-icon>
								{{'DMP-PROFILE-EDITOR.ACTIONS.DOWNLOAD-XML' | translate}}
							</button>
							<button mat-menu-item (click)="deleteTemplate(row.id)">
								<mat-icon>delete</mat-icon>
								{{'DATASET-PROFILE-LISTING.ACTIONS.DELETE' | translate}}
							</button>
							<!--<button *ngIf="row.status==1" mat-menu-item (click)="makeItPublic(row.id)"><mat-icon>people_outline</mat-icon>{{'DATASET-LISTING.ACTIONS.MAKE-IT-PUBLIC' | translate}}</button> -->
						</mat-menu>
						<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
							<mat-icon>more_horiz</mat-icon>
						</button>
					</mat-cell>
				</ng-container>

				<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
				<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id);"></mat-row>
				<!-- (click)="rowClick(row.id)" -->

			</mat-table>

			<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
			</mat-paginator>
		<!-- </mat-card> -->
		</div>
	</div>
</div>
