Skip to content

Commit

Permalink
fix(settings/automation-manager): bug fixes KMCNG-2618, KMCNG-2620, K…
Browse files Browse the repository at this point in the history
…MCNG-2625, KMCNG-2626, KMCNG-2627
  • Loading branch information
amirch1 committed Apr 15, 2024
1 parent a4da5a4 commit 4c52b67
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/applications/settings-mr-app/logs/logs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {AppLocalization} from '@kaltura-ng/mc-shared';
import {KalturaLogger} from '@kaltura-ng/kaltura-logger';
import {ColumnsResizeManagerService, ResizableColumnsTableName} from 'app-shared/kmc-shared/columns-resize-manager';
import {ReviewTagsComponent} from '../review/review-tags/review-tags.component';
import {BrowserService} from 'app-shared/kmc-shell';

@Component({
selector: 'kMrLogs',
Expand Down Expand Up @@ -43,6 +44,7 @@ export class LogsComponent implements OnInit {

constructor(private _mrMainViewService: SettingsMrMainViewService,
public _columnsResizeManager: ColumnsResizeManagerService,
private _browserService: BrowserService,
private _appLocalization: AppLocalization,
private _logger: KalturaLogger,
private _mrStore: MrStoreService) {
Expand Down Expand Up @@ -158,11 +160,15 @@ export class LogsComponent implements OnInit {
public download(id: string): void {
this._isBusy = true;
this._mrStore.downloadReport(id).subscribe(
success => {
data => {
this._isBusy = false;
this._browserService.download(data, id + '.csv', 'text/csv');
},
error => {
this.displayError(this._appLocalization.get('applications.settings.mr.reportDownloadError'), () => this.download(id));
// temp solution until BE supports text/csv content-type for the request
this._isBusy = false;
this._browserService.download(error?.error?.text || '', id + '.csv', 'text/csv');
// this.displayError(this._appLocalization.get('applications.settings.mr.reportDownloadError'), () => this.download(id));
}
);
}
Expand Down
14 changes: 12 additions & 2 deletions src/applications/settings-mr-app/mr-store/mr-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ export class MrStoreService implements OnDestroy {
}
}

public downloadReport(id: string): Observable<LoadReportsResponse> {
public downloadReport(id: string): Observable<string> {
try {
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/report/serve`, {id}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<LoadReportsResponse>;
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/report/serve`, {id}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<string>;
} catch (ex) {
return throwError(new Error('An error occurred while trying to serve report'));
}
Expand All @@ -293,6 +293,16 @@ export class MrStoreService implements OnDestroy {
};
}

private getHttpDownloadOptions() {
const ks = this._appAuthentication.appUser.ks;
return {
headers: new HttpHeaders({
'authorization': `KS ${ks}`,
'Content-Type': 'text/csv',
})
};
}

ngOnDestroy(): void {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ActionNotificationComponent implements OnDestroy{

public validate(): void {
if (this.selected) {
if (!this.action || (this.action.requires === 'delete' && !this.action.task.id)) {
if (!this.action || this.action.requires === 'delete') {
this.action = {
requires: 'create',
type: this.getNotificationType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CriteriaCreatedComponent implements OnInit{
if (value && value[key]) {
this.createdTimeInterval = key;
this.createdTime = Math.abs(value[key].numberOfUnits) || 0;
this.createdTimeUnit = value[key].createdTimeUnit || 'day';
this.createdTimeUnit = value[key].dateUnit || 'day';
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class CriteriaPlayedComponent implements OnInit{

public playedTimeUnit = 'day';
public playedTime = 0;
public playedTimeInterval = 'less';
public playedTimeInterval = 'lastPlayedAtLessThanOrEqual';

@Input() set filter(value: any) {
['lastPlayedAtLessThanOrEqual', 'lastPlayedAtGreaterThanOrEqual'].forEach(key => {
if (value && value[key]) {
this.playedTimeInterval = key;
this.playedTime = Math.abs(value[key].numberOfUnits) || 0;
this.playedTimeUnit = value[key].createdTimeUnit || 'day';
this.playedTimeUnit = value[key].dateUnit || 'day';
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3671,7 +3671,7 @@
"repeat": "Repeat",
"every": "Every",
"period": "Review period",
"period_tt": "Review period tooltip",
"period_tt": "Set a time period (in days) to review queued entries with one or more actions scheduled to be performed",
"startDate": "Start date",
"on": "On day",
"of": "of the month"
Expand Down

0 comments on commit 4c52b67

Please sign in to comment.