-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(export): New export logic to prevent KS usage in email (#461)
* AWS export fix * updated design + support report name and export date * url cleanup + additional error handling * use valueSeparator for name split * do not use valueSeparator for name split * updated clientlib and export baseUrl parameter * typo fix * enable getting export route from config + error handling
- Loading branch information
Showing
13 changed files
with
211 additions
and
7 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+8.12 MB
...ra-ngx-client-12.0.0-v20210421-080207.tgz → ...ra-ngx-client-12.0.0-v20210924-085014.tgz
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div data-aid="report-group-entry" class="kMain"> | ||
<k-area-blocker [showLoader]="_downloadingReport" [message]="_blockerMessage"> | ||
<div class="kReportView kContent"> | ||
<div *ngIf="!_invalidLink" class="kExportContent"> | ||
<span class="kTitle" [innerHTML]="'app.exportReports.reportReady' | translate: { reportName: _reportName } "></span> | ||
<span class="kTitle">{{'app.exportReports.exportDate' | translate: {exportDate: _exportDate} }}</span> | ||
<button type="button" class="kButtonBranded" pButton [label]="'app.exportReports.download' | translate" [disabled]="_downloadingReport" (click)="_downloadReport()"></button> | ||
</div> | ||
<div *ngIf="_invalidLink" class="kExportContent"> | ||
<span class="kTitle">{{'app.exportReports.errorMessage' | translate }}</span> | ||
</div> | ||
</div> | ||
</k-area-blocker> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.kExportContent { | ||
display: flex; | ||
width: 100%; | ||
background: white; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: calc(100vh - 52px); | ||
position: relative; | ||
margin-top: 24px; | ||
.kTitle { | ||
margin-top: 8px; | ||
margin-bottom: 8px; | ||
color: black; | ||
font-size: 16px; | ||
} | ||
button { | ||
margin-top: 12px; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import {Component, OnDestroy, OnInit} from '@angular/core'; | ||
import {ActivatedRoute, Router} from '@angular/router'; | ||
import {cancelOnDestroy} from '@kaltura-ng/kaltura-common'; | ||
import {AreaBlockerMessage} from '@kaltura-ng/kaltura-ui'; | ||
import {AuthService, BrowserService, ErrorsManagerService, NavigationDrillDownService} from 'shared/services'; | ||
import {TranslateService} from '@ngx-translate/core'; | ||
import {HttpClient, HttpHeaders} from "@angular/common/http"; | ||
import {analyticsConfig, buildCDNUrl} from "configuration/analytics-config"; | ||
import {DateFilterUtils} from "shared/components/date-filter/date-filter-utils"; | ||
|
||
@Component({ | ||
selector: 'app-export', | ||
templateUrl: './export.component.html', | ||
styleUrls: ['./export.component.scss'], | ||
}) | ||
export class ExportComponent implements OnInit, OnDestroy { | ||
public _downloadingReport = false; | ||
public _blockerMessage: AreaBlockerMessage = null; | ||
public _reportId = ''; | ||
public _reportName = ''; | ||
public _exportDate = ''; | ||
public _invalidLink = false; | ||
|
||
constructor(private _route: ActivatedRoute, | ||
private _http: HttpClient, | ||
private _translate: TranslateService, | ||
private _errorsManager: ErrorsManagerService, | ||
private _browserService: BrowserService, | ||
private _authService: AuthService) { | ||
} | ||
|
||
ngOnInit() { | ||
this._route.params | ||
.pipe(cancelOnDestroy(this)) | ||
.subscribe(params => { | ||
const queryParams = params && params.id ? params.id.split('|') : []; | ||
if (queryParams.length > 0) { | ||
this._reportId = queryParams[0]; | ||
this._reportName = queryParams.length > 1 ? queryParams[1] : ''; | ||
const dateFormat = analyticsConfig.dateFormat === 'month-day-year' ? 'MMMM DD, YYYY' : 'DD MMMM, YYYY'; | ||
const date = queryParams.length > 2 ? queryParams[2] : ''; | ||
this._exportDate = DateFilterUtils.getMomentDate(parseInt(date)).format(dateFormat); | ||
if (window.parent && window.parent.history) { | ||
window.parent.history.replaceState(null, null, window.parent.location.pathname); | ||
} | ||
} else { | ||
this._invalidLink = true; | ||
} | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
} | ||
|
||
public _downloadReport(): void { | ||
this._downloadingReport = true; | ||
this._blockerMessage = null; | ||
|
||
const url = buildCDNUrl(`/api_v3/index.php/service/report/action/serve/id/${this._reportId}/ks/${this._authService.ks}`); | ||
const httpOptions = { | ||
headers: new HttpHeaders({ | ||
'Accept': 'text/html, application/xhtml+xml, */*', | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
}), | ||
responseType: 'text' | ||
}; | ||
|
||
this._http.post(url, {}, httpOptions as any).subscribe( | ||
result => { | ||
this._downloadingReport = false; | ||
if (result.toString() === "") { | ||
const actions = { | ||
'close': () => { | ||
this._blockerMessage = null; | ||
} | ||
}; | ||
this._blockerMessage = new AreaBlockerMessage({ | ||
message: this._translate.instant('app.exportReports.reportNotFound'), | ||
buttons: [{ | ||
label: this._translate.instant('app.common.close'), | ||
action: () => this._blockerMessage = null | ||
}] | ||
}); | ||
} else { | ||
this._browserService.download(result, `${this._reportId}.csv`, 'text/csv'); | ||
} | ||
}, | ||
error => { | ||
this._downloadingReport = false; | ||
const actions = { | ||
'close': () => { | ||
this._blockerMessage = null; | ||
}, | ||
'retry': () => { | ||
this._downloadReport(); | ||
} | ||
}; | ||
this._blockerMessage = this._errorsManager.getErrorMessage(error, actions); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { RouterModule } from '@angular/router'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { routing } from './export.routes'; | ||
import { ExportComponent } from './export.component'; | ||
import { AreaBlockerModule } from '@kaltura-ng/kaltura-ui'; | ||
import { ButtonModule } from 'primeng/button'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
TranslateModule, | ||
AreaBlockerModule, | ||
ButtonModule, | ||
RouterModule.forChild(routing) | ||
], | ||
declarations: [ | ||
ExportComponent | ||
], | ||
exports: [], | ||
providers: [] | ||
}) | ||
export class ExportModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Route } from '@angular/router'; | ||
import { ExportComponent } from './export.component'; | ||
|
||
export const routing: Route[] = [ | ||
{ | ||
path: '', component: ExportComponent, | ||
children: [ | ||
{ path: 'export', redirectTo: 'export/:id', pathMatch: 'full' }, | ||
{ path: 'export/:id', component: ExportComponent } | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters