Skip to content

Commit

Permalink
feat(shell): support chunked upload file and resume upload action
Browse files Browse the repository at this point in the history
  • Loading branch information
diamond-darrell authored and eransakal committed Oct 16, 2017
1 parent cca1d4e commit 0c1e904
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 19 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"core-js": "^2.4.1",
"intl": "^1.2.5",
"jquery": "^3.1.0",
"kaltura-typescript-client": "^4.0.0",
"kaltura-typescript-client": "~5.1.0",
"moment": "^2.14.1",
"ng2-page-scroll": "^4.0.0-beta.7",
"ng2-translate": "^5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class EntryCaptionsHandler extends EntryFormWidget {
.subscribe(
({ relevantCaption, uploadedFile }) => {
switch (uploadedFile.status) {
case TrackedFileStatuses.waitingUpload:
case TrackedFileStatuses.prepared:
relevantCaption.serverUploadToken = (<NewEntryCaptionFile>uploadedFile.data).serverUploadToken;
break;
case TrackedFileStatuses.uploadCompleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ export class EntryFlavoursHandler extends EntryFormWidget
.subscribe(
({ relevantFlavor, uploadedFile }) => {
switch (uploadedFile.status) {
case TrackedFileStatuses.waitingUpload:
case TrackedFileStatuses.prepared:
const token = (<NewEntryFlavourFile>uploadedFile.data).serverUploadToken;
const resource = new KalturaUploadedFileTokenResource({ token });
if (!!relevantFlavor.id) {
this.updateFlavor(relevantFlavor, relevantFlavor.id, resource);
this.updateFlavor(relevantFlavor, resource);
} else {
this.addNewFlavor(relevantFlavor, resource);
}
Expand Down Expand Up @@ -370,9 +370,9 @@ export class EntryFlavoursHandler extends EntryFormWidget
});
}

private updateFlavor(flavor: Flavor, id: string, resource: KalturaContentResource): void {
private updateFlavor(flavor: Flavor,resource: KalturaContentResource): void {
this._kalturaServerClient.request(new FlavorAssetSetContentAction({
id: id,
id: flavor.id,
contentResource: resource
}))
.cancelOnDestroy(this, this.widgetReset$)
Expand Down Expand Up @@ -410,7 +410,8 @@ export class EntryFlavoursHandler extends EntryFormWidget
})
.subscribe(
response => {
this.updateFlavor(flavor, response.id, resource);
flavor.id = response.id;
this.updateFlavor(flavor, resource);
},
error => {
this._browserService.showGrowlMessage({
Expand All @@ -428,7 +429,7 @@ export class EntryFlavoursHandler extends EntryFormWidget
url : url
});
if (flavor.id.length){
this.updateFlavor(flavor, flavor.id, resource);
this.updateFlavor(flavor, resource);
}else {
this.addNewFlavor(flavor, resource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class EntryRelatedHandler extends EntryFormWidget
case TrackedFileStatuses.purged:
this._removeFile(relevantRelatedFile);
break;
case TrackedFileStatuses.waitingUpload:
case TrackedFileStatuses.prepared:
relevantRelatedFile.serverUploadToken = (<NewEntryRelatedFile>uploadedFile.data).serverUploadToken;
break;
case TrackedFileStatuses.uploadCompleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class UploadStatusPipe implements PipeTransform {

case TrackedFileStatuses.added:
case TrackedFileStatuses.preparing:
case TrackedFileStatuses.prepared:
case TrackedFileStatuses.waitingUpload:
translateToken = 'queued';
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@

<p-column field="progress"
[header]="'applications.content.uploadControl.table.progress' | translate"
[style]="{ 'width': '140px' }"
[style]="{ 'width': '120px' }"
[sortable]="false">
<ng-template let-col let-file="rowData" pTemplate="body">
<kUploadProgress [progress]="file[col.field]" [status]="file.status"></kUploadProgress>
</ng-template>
</p-column>

<p-column [style]="{ 'width': '65px', 'text-align': 'center' }" [sortable]="false">
<p-column [style]="{ 'width': '70px', 'text-align': 'center' }" [sortable]="false">
<ng-template let-col let-file="rowData" pTemplate="body">
<i class="kIconplay kIconRemoveFile"
*ngIf="_hasError(file.status)"
[kTooltip]="'applications.content.uploadControl.table.retry' | translate"
placement="top"
(click)="onRetryUpload.emit(file)"></i>
<i class="kIcontrash kIconRemoveFile"
*ngIf="!file.removing"
[kTooltip]="'applications.content.uploadControl.table.remove' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@
background-color: $kGrayscale6;
opacity: 0.3;
}

:host /deep/ .kUploadsTable td:last-child .ui-cell-data {
display: flex;
justify-content: center;

i:first-child {
margin-right: 15px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ export class UploadListTableComponent {

@Output() onSelectedEntriesChange = new EventEmitter<any>();
@Output() onCancelUpload = new EventEmitter<UploadFileData>();
@Output() onRetryUpload = new EventEmitter<UploadFileData>();

public _emptyMessage = this._appTranslation.get('applications.content.table.noResults');

constructor(private _appTranslation: AppLocalization) {
}

public _hasError(status: TrackedFileStatuses): boolean {
return status === TrackedFileStatuses.uploadFailed;
}

public _relatedTableRowStyle(rowData: UploadFileData): string {
return rowData.status === TrackedFileStatuses.uploadFailed ? 'has-error' : '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[uploads]="_uploads"
(onSelectedEntriesChange)="_selectedEntriesChange($event)"
(onCancelUpload)="_cancelUpload($event)"
(onRetryUpload)="_retryUpload($event)"
[selectedUploads]="_selectedUploads"
></kUploadListTable>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class UploadListComponent implements OnInit, OnDestroy {

case TrackedFileStatuses.added:
case TrackedFileStatuses.preparing:
case TrackedFileStatuses.prepared:
case TrackedFileStatuses.waitingUpload:
return 2;

Expand All @@ -162,6 +163,10 @@ export class UploadListComponent implements OnInit, OnDestroy {
this._uploadManagement.cancelUpload(file.id, true);
}

public _retryUpload(file: UploadFileData): void {
this._uploadManagement.resumeUpload(file.id);
}

public _bulkCancel(): void {
if (this._selectedUploads.length) {
this._browserService.confirm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class UploadProgressComponent {
set status(value: TrackedFileStatuses) {
switch (value) {
case TrackedFileStatuses.preparing:
case TrackedFileStatuses.prepared:
case TrackedFileStatuses.waitingUpload:
this._statusClass = 'pending';
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class UploadSettingsComponent implements OnInit, AfterViewInit {
const uploadFileDataList = this._files.map(fileData => ({
file: fileData.file,
mediaType: fileData.mediaType,
name: fileData.name
entryName: fileData.name
}));

this._newEntryUploadService.upload(uploadFileDataList, Number(trancodingProfileId));
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"uploadedOn": "Uploaded On",
"progress": "Progress",
"remove": "Remove",
"retry": "Retry",
"status": {
"header": "Status",
"uploaded": "Complete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export class NewEntryUploadFile extends KalturaUploadFile {
public createMediaEntrySubscription: ISubscription;
constructor(file: File,
public mediaType: KalturaMediaType,
public transcodingProfileId: number) {
public transcodingProfileId: number,
public entryName: string = file.name) {
super(file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { UploadTokenDeleteAction } from 'kaltura-typescript-client/types/UploadT
export interface KmcNewEntryUpload {
file: File;
mediaType: KalturaMediaType;
entryName: string;
}

@Injectable()
Expand Down Expand Up @@ -44,7 +45,7 @@ export class NewEntryUploadService implements OnDestroy {
case TrackedFileStatuses.purged:
this._cleanupUpload(trackedFile);
break;
case TrackedFileStatuses.waitingUpload:
case TrackedFileStatuses.prepared:
this._linkEntryWithFile(trackedFile);
break;
default:
Expand Down Expand Up @@ -110,7 +111,7 @@ export class NewEntryUploadService implements OnDestroy {
return this._kalturaServerClient.request(new MediaAddAction({
entry: new KalturaMediaEntry({
mediaType: file.mediaType,
name: file.getFileName(),
name: file.entryName,
conversionProfileId: file.transcodingProfileId
})
}));
Expand All @@ -127,7 +128,7 @@ export class NewEntryUploadService implements OnDestroy {

public upload(files: KmcNewEntryUpload[], trancodingProfileId: number): void {
this._uploadManagement.addFiles(
files.map(file => new NewEntryUploadFile(file.file, file.mediaType, trancodingProfileId))
files.map(file => new NewEntryUploadFile(file.file, file.mediaType, trancodingProfileId, file.entryName))
);
}
}

0 comments on commit 0c1e904

Please sign in to comment.