Skip to content

Commit

Permalink
refactor: use new alert service for scorm editor
Browse files Browse the repository at this point in the history
  • Loading branch information
satikaj committed Jun 2, 2024
1 parent 40a7366 commit f052f7f
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component, Inject, Input } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { alertService } from 'src/app/ajs-upgraded-providers';
import { TaskDefinition } from 'src/app/api/models/task-definition';
import { Unit } from 'src/app/api/models/unit';
import { TaskDefinitionService } from 'src/app/api/services/task-definition.service';
import { FileDownloaderService } from 'src/app/common/file-downloader/file-downloader.service';
import {Component, Input} from '@angular/core';
import {FormControl, Validators} from '@angular/forms';
import {AlertService} from 'src/app/common/services/alert.service';
import {TaskDefinition} from 'src/app/api/models/task-definition';
import {Unit} from 'src/app/api/models/unit';
import {TaskDefinitionService} from 'src/app/api/services/task-definition.service';
import {FileDownloaderService} from 'src/app/common/file-downloader/file-downloader.service';

@Component({
selector: 'f-task-definition-scorm',
Expand All @@ -16,8 +16,8 @@ export class TaskDefinitionScormComponent {

constructor(
private fileDownloaderService: FileDownloaderService,
@Inject(alertService) private alerts: any,
private taskDefinitionService: TaskDefinitionService
private alerts: AlertService,
private taskDefinitionService: TaskDefinitionService,
) {}

public attemptLimitControl = new FormControl('', [Validators.max(100), Validators.min(0)]);
Expand All @@ -41,9 +41,11 @@ export class TaskDefinitionScormComponent {
}

public uploadScormData(files: FileList) {
console.log(Array.from(files).map(f => f.type));
console.log(Array.from(files).map((f) => f.type));
const validMimeTypes = ['application/zip', 'application/x-zip-compressed', 'multipart/x-zip'];
const validFiles = Array.from(files as ArrayLike<File>).filter(f => validMimeTypes.includes(f.type));
const validFiles = Array.from(files as ArrayLike<File>).filter((f) =>
validMimeTypes.includes(f.type),
);
if (validFiles.length > 0) {
const file = validFiles[0];
this.taskDefinitionService.uploadScormData(this.taskDefinition, file).subscribe({
Expand Down

0 comments on commit f052f7f

Please sign in to comment.