Activities of "RobWiebkin"

Hi

Currently PageAlertContainerComponent unforunatly doesn't support html content rendering for both basic and lepton theme. I created an issue for this request.

Thanks for that. I assume this limitation is also present in LeptonX?

Question
  • ABP Framework version: v7.0.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: NA
  • Steps to reproduce the issue:" NA

I am attempting to use the Page Alerts Service (https://docs.abp.io/en/abp/latest/UI/Angular/Page-Alerts) to provide system notifications to users of our application. However, a requirement for this is to allow hyperlinks in the notifications. By default HTML does not appear to work within these notifications, is there a way to allow for hyperlinks?

Please use IRemoteStreamContent

See https://github.com/abpframework/abp/blob/c86d8406c82ac0281df19374ceb336edfaa661ba/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs#L15-L20

Hi liangshiwei, I've updated my code using the IRemoteStreamContent (see below), however generated method is still execting to parse the response as JSON unless I manually update the responseType.

Updated Code:

[HttpGet]
[Route("entry/export/csv")]
public async Task<IRemoteStreamContent> GetTimeEntryExportCSV(Guid[] ids)
{
    var bytes = await _fileExportAppService.GetTimeEntryExportCSV(ids);
    var memoryStream = new MemoryStream();
    await memoryStream.WriteAsync(bytes);
    memoryStream.Position = 0;
    return new RemoteStreamContent(memoryStream, "exported-time.csv");
}

Generated proxy:

getTimeEntryExportCSVByIds = (ids: string[]) =>
    this.restService.request<any, IRemoteStreamContent>({
      method: 'GET',
      url: '/api/timetracker-service/entry/export/csv',
      params: { ids },
    },
    { apiName: this.apiName });

Calling code:

this.timeTrackerService.getTimeEntryExportCSVByIds(stringOfIds)
      .subscribe(fileResponse => {
        console.group({fileResponse})
        const a = document.createElement('a');
        a.href = URL.createObjectURL(fileResponse);
        a.download = "exported-time" + moment().format("yyyyMMDDHHmmss") + ".csv";
        a.click();
      }, error => { console.log({error}) });

The error is: SyntaxError: Unexpected token P in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.o (http://localhost:4200/main.js:1:239492) at e.invokeTask (http://localhost:4200/polyfills.js:1:160868) at Object.onInvokeTask (http://localhost:4200/main.js:1:360127) at e.invokeTask (http://localhost:4200/polyfills.js:1:160789) at t.runTask (http://localhost:4200/polyfills.js:1:155947) at t.invokeTask [as invoke] (http://localhost:4200/polyfills.js:1:162000) at v (http://localhost:4200/polyfills.js:1:174611) at XMLHttpRequest.m (http://localhost:4200/polyfills.js:1:174917)

With the message: "Http failure during parsing for https://localhost:44325/api/timetracker-service/entry/export/csv?ids=39fff254-296b-4ce2-1498-c4b52e02c0db"

  • ABP Framework version: 4.4.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: NA
  • Steps to reproduce the issue:" NA

I am using the microservice template.

I need to create an endpoint which generates a csv download of data this is stored in our DB. I am using ABP generate proxy, however after the proxy is generated I cannot access the passed data in the front end (it errors in the subscribe). Experimenting with the proxy has shown me that if I edit the proxy to set the responseType to blob, the download works. Unfortunately this change is wiped out every time we regenerate the proxy, and so manually editing it does not seem like a long term viable solution. Is there a way to specify the proxies response type for an endpoint? Or is there a better way of accessing the FileStreamResult in the front end?

Here is the code for the Controller:

[HttpGet]
[Route("entry/export/csv")]
public async Task<IActionResult> GetTimeEntryExportCSV(Guid[] ids)
{
    var bytes = await _fileExportAppService.GetTimeEntryExportCSV(ids);
    MemoryStream stream = new MemoryStream();
    stream.Write(bytes, 0, bytes.Length);
    stream.Position = 0;
    var file = File(stream, "application/octet-stream", "exported-time"+DateTime.Now.ToString("yyyyMMddHHmmss")+".csv");
    return file;    
}

Here is the generated proxy:

getTimeEntryExportCSVByIds = (ids: string[]) =>
    this.restService.request<any, IActionResult>({
      method: 'GET',
      url: '/api/timetracker-service/entry/export/csv',
      params: { ids }
    },
    { apiName: this.apiName });
Showing 1 to 4 of 4 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11