File size: 2,905 Bytes
27e40c0
1bc149f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27e40c0
1bc149f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27e40c0
 
 
1bc149f
 
 
 
27e40c0
1bc149f
 
27e40c0
1bc149f
 
 
 
 
 
 
 
 
27e40c0
 
 
 
 
 
1bc149f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27e40c0
 
 
 
1bc149f
 
27e40c0
1bc149f
 
 
 
 
 
 
27e40c0
1bc149f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
import {MatCard, MatCardActions, MatCardContent} from "@angular/material/card";
import {MatFormField, MatLabel} from "@angular/material/form-field";
import {MatInput} from "@angular/material/input";
import {MatButton} from "@angular/material/button";
import {NgIf} from "@angular/common";
import {MatOption} from "@angular/material/autocomplete";
import {MatSelect} from "@angular/material/select";
import {FormsModule} from "@angular/forms";
import {AppStateService} from "../../../state_management/services/app-state.service";
import {map} from "rxjs";
import {
  MatCell,
  MatCellDef,
  MatColumnDef,
  MatHeaderCell, MatHeaderCellDef,
  MatHeaderRow,
  MatHeaderRowDef,
  MatRow, MatRowDef, MatTable, MatTableDataSource
} from "@angular/material/table";
import {LeaderboardEntry} from "../../../state_management/models/leaderboard-entry.model";
import {SubmissionEntry} from "../../../state_management/models/submission-entry.model";
import {MatTab, MatTabGroup} from "@angular/material/tabs";
import {MatSort, MatSortModule} from "@angular/material/sort";

@Component({
  selector: 'app-submissions',
  standalone: true,
  imports: [
    MatCard,
    MatCardContent,
    MatFormField,
    MatInput,
    MatButton,
    MatCardActions,
    MatLabel,
    NgIf,
    MatOption,
    MatSelect,
    FormsModule,
    MatCell,
    MatCellDef,
    MatColumnDef,
    MatHeaderCell,
    MatHeaderRow,
    MatHeaderRowDef,
    MatRow,
    MatRowDef,
    MatTable,
    MatHeaderCellDef,
    MatTabGroup,
    MatTab,
    MatSort,
    MatSortModule
  ],
  templateUrl: './submissions.component.html',
  styleUrl: './submissions.component.css'
})
export class SubmissionsComponent implements OnInit, AfterViewInit {

  displayedColumns: string[] = [
    'index',
    'team',
    'model',
    'task',
    'dataset',
    'status',
    'predictions',
    'time',
  ];

  @ViewChild(MatSort) sort: MatSort | undefined;

  ngAfterViewInit() {
    if (this.sort)
      this.dataSource.sort = this.sort;
  }
  @Input()
  task: string = '';

  constructor(private state: AppStateService) {
  }

  submissions = this.state.state$.pipe(
    map(
      state =>
        state.submissions.filter(
          submission =>
            (submission.task == this.task || this.task == undefined)))
  );

  dataSource = new MatTableDataSource<SubmissionEntry>();

  ngOnInit() {
    this.submissions.subscribe(
      data => {
        this.dataSource.data = data.map(entry => {
          entry.blob_url = this.getTextDownloadURL(entry.predictions); // Precompute Blob URL
          return entry;
        })
      }
    )
    this.state.refreshSubmissions();
  }

  getTextDownloadURL(prediction: string) {
    return window.URL.createObjectURL(new Blob([prediction], {type: 'text/plain'}));
  }

  refresh() {
    this.state.refreshSubmissions();
  }
}