Skip to content

Commit

Permalink
feat(content): entries bulk operations for delete, change owner, remo…
Browse files Browse the repository at this point in the history
…ve from category, download, access control
  • Loading branch information
amirch1 authored and eransakal committed Jul 12, 2017
1 parent 2944106 commit c386c3d
Show file tree
Hide file tree
Showing 25 changed files with 1,182 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
<router-outlet></router-outlet>
</k-area-blocker>
<!--router-outlet></router-outlet-->
<p-confirmDialog header="Confirmation" [closeOnEscape]="false" width="425"></p-confirmDialog>
<p-confirmDialog header="Confirmation" [key]="'confirm'" [closeOnEscape]="false" width="440"></p-confirmDialog>
<p-confirmDialog header="Alert" [key]="'alert'" [closeOnEscape]="true" width="440" #cd>
<p-footer>
<button type="button" pButton icon="fa-check" label="OK" (click)="cd.accept()"></button>
</p-footer>
</p-confirmDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EntriesComponentsList } from './entries/entries-components-list';
import { CategoriesStore } from './shared/categories-store.service';
import { EntriesRefineFiltersProvider } from './entries/entries-refine-filters/entries-refine-filters-provider.service';
import { CategoriesPrimeService } from './shared/categories-prime.service';
import { BulkSchedulingService, BulkAddTagsService, BulkRemoveTagsService, BulkAddCategoriesService, BulkChangeOwnerService } from './entries/bulk-actions/services';
import { BulkSchedulingService, BulkAccessControlService, BulkAddTagsService, BulkRemoveTagsService, BulkAddCategoriesService, BulkChangeOwnerService, BulkRemoveCategoriesService, BulkDeleteService, BulkDownloadService } from './entries/bulk-actions/services';
import { SharedComponentsList } from './shared/shared-components-list';

@NgModule({
Expand Down Expand Up @@ -83,10 +83,14 @@ import { SharedComponentsList } from './shared/shared-components-list';
MetadataProfileStore,
EntriesRefineFiltersProvider,
BulkSchedulingService,
BulkAccessControlService,
BulkAddTagsService,
BulkRemoveTagsService,
BulkAddCategoriesService,
BulkChangeOwnerService
BulkChangeOwnerService,
BulkRemoveCategoriesService,
BulkDeleteService,
BulkDownloadService
],
})
export class ContentEntriesAppModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
<ng-template>
<div [ngSwitch]="_bulkAction">
<kBulkScheduling *ngSwitchCase="'setScheduling'" [parentPopupWidget]="bulkActionsPopup" (schedulingChanged)="onSchedulingChanged($event)"></kBulkScheduling>
<kBulkAccessControl *ngSwitchCase="'setAccessControl'" [parentPopupWidget]="bulkActionsPopup" (accessControlChangedChanged)="onAccessControlChanged($event)"></kBulkAccessControl>
<kBulkAddTags *ngSwitchCase="'addTags'" [parentPopupWidget]="bulkActionsPopup" (addTagsChanged)="onAddTagsChanged($event)"></kBulkAddTags>
<kBulkRemoveTags *ngSwitchCase="'removeTags'" [selectedEntries]="selectedEntries" [parentPopupWidget]="bulkActionsPopup" (removeTagsChanged)="onRemoveTagsChanged($event)"></kBulkRemoveTags>
<kCategoriesSelector *ngSwitchCase="'addToCategories'" [parentPopupWidget]="bulkActionsPopup" (valueChange)="onAddToCategoriesChanged($event)" [buttonLabel]="'applications.content.bulkActions.apply' | translate"></kCategoriesSelector>
<kBulkRemoveCategories *ngSwitchCase="'removeFromCategories'" [selectedEntries]="selectedEntries" [parentPopupWidget]="bulkActionsPopup" (removeCategoriesChanged)="onRemoveCategoriesChanged($event)"></kBulkRemoveCategories>
<kBulkChangeOwner *ngSwitchCase="'changeOwner'" [parentPopupWidget]="bulkActionsPopup" (ownerChanged)="onOwnerChanged($event)"></kBulkChangeOwner>
<kBulkDownload *ngSwitchCase="'download'" [selectedEntries]="selectedEntries" [parentPopupWidget]="bulkActionsPopup" (downloadChanged)="onDownloadChanged($event)"></kBulkDownload>
</div>
</ng-template>
</kPopupWidget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { PopupWidgetComponent } from '@kaltura-ng/kaltura-ui/popup-widget/popup-
import { BrowserService } from "app-shared/kmc-shell/providers/browser.service";

import { SchedulingParams } from './services'
import { BulkSchedulingService, BulkAddTagsService, BulkRemoveTagsService, BulkAddCategoriesService, EntryCategoryItem, BulkChangeOwnerService } from './services';
import { BulkSchedulingService, BulkAccessControlService, BulkAddTagsService, BulkRemoveTagsService, BulkAddCategoriesService, EntryCategoryItem, BulkChangeOwnerService, BulkRemoveCategoriesService, BulkDeleteService, BulkDownloadService } from './services';
import { KalturaMediaEntry } from "kaltura-typescript-client/types/KalturaMediaEntry";
import { BulkActionBaseService } from "./services/bulk-action-base.service";
import { environment } from 'app-environment';
import { KalturaUser } from 'kaltura-typescript-client/types/KalturaUser';

import { KalturaMediaType } from 'kaltura-typescript-client/types/KalturaMediaType';
import { KalturaAccessControl } from 'kaltura-typescript-client/types/KalturaAccessControl';
@Component({
selector: 'kBulkActions',
templateUrl: './bulk-actions.component.html',
Expand All @@ -31,10 +32,14 @@ export class BulkActionsComponent implements OnInit, OnDestroy {

constructor(private _appLocalization: AppLocalization, private _browserService : BrowserService,
private _bulkSchedulingService: BulkSchedulingService,
private _bulkAccessControlService: BulkAccessControlService,
private _bulkAddTagsService: BulkAddTagsService,
private _bulkRemoveTagsService: BulkRemoveTagsService,
private _bulkAddCategoriesService: BulkAddCategoriesService,
private _bulkChangeOwnerService: BulkChangeOwnerService) {
private _bulkChangeOwnerService: BulkChangeOwnerService,
private _bulkRemoveCategoriesService: BulkRemoveCategoriesService,
private _bulkDownloadService: BulkDownloadService,
private _bulkDeleteService: BulkDeleteService) {

}

Expand All @@ -61,13 +66,18 @@ export class BulkActionsComponent implements OnInit, OnDestroy {
this.executeService(this._bulkSchedulingService, schedulingParams);
}

// set access control changes
onAccessControlChanged(profile: KalturaAccessControl): void{
this.executeService(this._bulkAccessControlService, profile);
}

// add tags changed
onAddTagsChanged(tags: string[]): void{
this.executeService(this._bulkAddTagsService, tags);
}

// remove tags changed
onRemoveTagsChanged(tags: string[]): void{
onRemoveTagsChanged(tags: string[]): void {
this.executeService(this._bulkRemoveTagsService, tags);
}

Expand All @@ -76,21 +86,78 @@ export class BulkActionsComponent implements OnInit, OnDestroy {
this.executeService(this._bulkAddCategoriesService, categories);
}

// remove categories changed
onRemoveCategoriesChanged(categories: number[]): void{
this.executeService(this._bulkRemoveCategoriesService, categories);
}

// owner changed
onOwnerChanged(owners: KalturaUser[]): void{
if (owners && owners.length){
this.executeService(this._bulkChangeOwnerService, owners[0]);
}
}

private executeService(service: BulkActionBaseService<any>, data: any, reloadEntries: boolean = true ): void{
// download changed
onDownloadChanged(flavorId: number): void{
const showSuccessMsg = (result) => {
this._browserService.alert(
{
header: this._appLocalization.get('applications.content.bulkActions.download'),
message: this._appLocalization.get('applications.content.bulkActions.downloadMsg',{0: result && result.email ? result.email : ''})
}
);
};
this.executeService(this._bulkDownloadService, flavorId, false, showSuccessMsg);
}

// bulk delete
private deleteEntries(): void{
let msg = '';
// display entries marked for deletion in the confirmation box if there are up to 10 selected entries. Otherwise, just confirm deletion
if (this.selectedEntries.length > 10){
msg = `${this._appLocalization.get('applications.content.bulkActions.deleteConfirm')}<br/><br/>${this._appLocalization.get('applications.content.bulkActions.deleteNote')}`;
}else{
msg = `${this._appLocalization.get('applications.content.bulkActions.deleteConfirm')}<br/><br/>`;
this.selectedEntries.forEach(entry => {
msg += `${this._appLocalization.get('applications.content.entries.entryId', { 0: entry.id })}<br/>`;
});
msg += `<br/>${this._appLocalization.get('applications.content.bulkActions.deleteNote')}`
}
this._browserService.confirm(
{
header: this._appLocalization.get('applications.content.bulkActions.deleteEntries'),
message: msg,
accept: () => {
setTimeout(()=>{
this.executeService(this._bulkDeleteService); // need to use a timeout between multiple confirm dialogues (if more than 50 entries are selected)
},0);
}
}
);
}

// bulk download initial check
private downloadEntries():void{
// check for single image selection - immediate download
if (this.selectedEntries.length === 1 && this.selectedEntries[0].mediaType === KalturaMediaType.image){
this._browserService.openLink(this.selectedEntries[0].downloadUrl + "/file_name/name");
}else{
this.openBulkActionWindow("download", 570, 500)
}
}

private executeService(service: BulkActionBaseService<any>, data: any = {}, reloadEntries: boolean = true, callback?: Function ): void{
this._bulkAction = "";

const execute = () => {
this._browserService.setAppStatus({isBusy: true, errorMessage: null});
service.execute(this.selectedEntries, data).subscribe(
result => {
this._browserService.setAppStatus({isBusy: false, errorMessage: null});
if (callback){
callback(result);
}
this.onBulkChange.emit({reload: reloadEntries});
},
error => {
Expand All @@ -117,7 +184,7 @@ export class BulkActionsComponent implements OnInit, OnDestroy {
getBulkActionItems(): MenuItem[]{
return [
{ label: this._appLocalization.get('applications.content.bulkActions.setScheduling'), command: (event) => { this.openBulkActionWindow("setScheduling", 500, 500) } },
{ label: this._appLocalization.get('applications.content.bulkActions.setAccessControl'), command: (event) => { this.openBulkActionWindow("setAccessControl", 500, 500) } },
{ label: this._appLocalization.get('applications.content.bulkActions.setAccessControl'), command: (event) => { this.openBulkActionWindow("setAccessControl", 500, 550) } },
{ label: this._appLocalization.get('applications.content.bulkActions.addRemoveTags'), items: [
{ label: this._appLocalization.get('applications.content.bulkActions.addTags'), command: (event) => { this.openBulkActionWindow("addTags", 500, 500) } },
{ label: this._appLocalization.get('applications.content.bulkActions.removeTags'), command: (event) => { this.openBulkActionWindow("removeTags", 500, 500) } }]
Expand All @@ -131,8 +198,8 @@ export class BulkActionsComponent implements OnInit, OnDestroy {
{ label: this._appLocalization.get('applications.content.bulkActions.addToNewPlaylist'), command: (event) => { this.openBulkActionWindow("addToNewPlaylist", 500, 500) } }]
},
{ label: this._appLocalization.get('applications.content.bulkActions.changeOwner'), command: (event) => { this.openBulkActionWindow("changeOwner", 500, 500) } },
{ label: this._appLocalization.get('applications.content.bulkActions.download'), command: (event) => { this.openBulkActionWindow("download", 500, 500) } },
{ label: this._appLocalization.get('applications.content.bulkActions.delete'), command: (event) => { this.openBulkActionWindow("delete", 500, 500) } }
{ label: this._appLocalization.get('applications.content.bulkActions.download'), command: (event) => { this.downloadEntries() } },
{ label: this._appLocalization.get('applications.content.bulkActions.delete'), command: (event) => { this.deleteEntries() } }
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<k-area-blocker [showLoader]="_loading" [message]="_sectionBlockerMessage">
<div class="kContent kOverrideFAIcons">
<span class="kTitle">{{'applications.content.bulkActions.setAccessControl' | translate}}</span>

<div class="kAccessControl" *ngIf="_selectedProfile">

<div class="kAccessControlDetails">
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.profile' | translate}}</span>
<p-dropdown [options]="(_accessControlProfiles$ | async)?.items" [(ngModel)]="selectedProfile" (onChange)="onChange()"></p-dropdown>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.name' | translate}}</span>
<span>{{selectedProfile.name}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.accessControl' | translate}}</span>
<span>{{selectedProfile.description}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.domains' | translate}}</span>
<span>{{_domainsRestriction}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.countries' | translate}}</span>
<span>{{_countriesRestriction}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.ips' | translate}}</span>
<span>{{_ipRestriction}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.flavours' | translate}}</span>
<span>{{_flavourRestriction}}</span>
</div>
<div class="kRow">
<span class="kLabels">{{'applications.content.entryDetails.accessControl.advanced' | translate}}</span>
<span>{{_advancedRestriction}}</span>
</div>
</div>
</div>

<div class="kFooter">
<button type="button" class="kButtonBranded" pButton label="{{'applications.content.bulkActions.apply' | translate}}" (click)="_apply()"></button>
</div>
</div>
</k-area-blocker>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@import "app-theme/_variables.scss";

.kTitle{
color: $kGrayscale1;
font-size: 24px;
font-weight: 700;
text-align: center;
border-bottom: 1px solid $kGrayscale4;
height: 78px;
line-height: 78px;
}
.kContent{
display: flex;
flex-direction: column;
height: 550px;
.kLabel{
display: block;
margin-bottom: 8px;
}
.kAccessControl{
padding: 12px;
height: 380px;
overflow-y: auto;
overflow-x: hidden;
.kAccessControlDetails{
padding-left: 12px;
padding-right: 12px;
width: 100%;
.kRow{
display: flex;
padding-top: 24px;
align-items: center;
}
.kLabels{
width: 180px;
flex: 0 0 auto;
}
}
}
}
.kFooter{
position: absolute;
bottom: 0px;
display: flex;
width: 100%;
height: 66px;
border-top: 1px solid $kGrayscale4;
align-items: center;
justify-content: center;
}
:host /deep/ kautocomplete ul.ui-autocomplete-multiple-container.ui-inputtext{
padding: 0px;
.ui-autocomplete-input-token{
padding: 0px;
input{
height: 34px;
padding-left: 4px;
width: 472px;
}
}
}
Loading

0 comments on commit c386c3d

Please sign in to comment.