Base solution for your next web application

Activities of "daws"

My solution is to change the AppService method signature to return a JSON string. I then transform and parse that string when received in the frontend.

In order to make it work, I had to do the following :

  • In the backend :
    • Use a DefaultContractServiceResolver with a camelcaseNamingStrategy
    • Write a custom JSON converter which replaces all nulls by an empty string
    • In the object class, assign the JSON converter to the array property with a data annotation
  • In the frontend :
    • Parse the received string to JSON using a reviver function
    • In the reviver function, filter the property which has the null array, and replace the blanks with nulls using a Regex
    • I then get an object, but its array property has been parsed as a string because it was not yet a valid JSON array
    • Parse that property to JSON (it will now correctly parse it)

This is tedious and it breaks the webAPI contract but I haven't found a better solution to optimize the size of the transferred JSON. If someone comes up with a better solution, please share.

Thanks

I think that since this JSON response is returned by the AppService, it should be handled first on the server side, shouldn't it ?

Where does the AppService format the returned object to JSON ?

I have an AppService method which returns a very large array of int? (nullable int).

Most values in this array are null.

Currently, when calling the method via Web api, the response array is formatted like this in JSON :

[null,null,null, ..., 3, 4, 8, 11, 12, null, null, null, ...]

In order to spare network bandwith, I want my array to be like this :

[,,, ..., 3, 4, 8, 11, 12,,,, ...]

Is it doable without bypassing the service-proxies JSON parsing functions ?

(Using Aspnetcore 7.2.3 with angular)

I see now. Thanks.

For further reference, two things are necessary to achieve what I need :

  1. In the localization files, html must be enclosed in CDATA tags : <text name="MyTextKey"><![CDATA[<span><b>MyText</b><br/>is formatted in the current language</span>]]></text>

  2. In order for the html to be rendered on the client, assign it to the innerHtml of a span element : <span [innerHtml]="l('MyTextKey')"></span>

And voilà :-)

Whether I call the l() function in my html template or in my javascript code will not make a difference, since the string values in my App-xx.xml can't have html tags.

So where do I store the html translations ? And how do I display them to the user ?

Said otherwise : I need to display very long formatted texts in several different languages. The texts are provided to me in a Word document, which I then convert to html (in order to keep the formatting). The conversion result is what I want to display (according to the current language). In different languages, the html tags will be set on different parts of the text, which makes it impossible to have an html template and a lot of strings to translate between the tags.

I'm sorry but I see nothing about including html in translated text strings ?

How can I format localized text in html ?

Example : {{l('MyTextKey')}}

Would return (in English for instance) : <span><b>MyText</b><br/>is formatted in the current language</span>

Which would render on screen :

MyText is formatted in the current language

We're using abp 7.2.3 with angular

Our application is pretty big (15MB) and we would like to reduce its size. One of the things we can do is to remove the biggest unused packages.

With webpack-bundle-analyzer, we determined that the following packages are quite big :

  • All separate momentjs locales
  • momentjs min with locales
  • moment timezone
  • quill

Q1. Is it necessary to keep both momentjs AND momentjs-min ? Q2. We'd like to include only locales we need. In order to do that, we tried moment-locales-webpack-plugin + ngx-build-plus but it doesn't work on our code (even on a freshly downloaded template). Any recommendation to make it work ? Our current workaround is to replace moment locale folder with a custom locale folder post build but it's not super clean. ~~Q3. Can we safely remove quill without breaking abp features ?~~ EDIT: I just found out that someone in the team needs the primeng editor, which is based on quill, so forget about this one. Q4. How can we adjust the Web.Host server log to know which request completed in how much time ? (example : "Request finished in xx ms (<REQUEST_NAME>)"). This would help us identify which backend requests need optimization.

Our project is on aspnetzero 7.2.3, with asp.net core & angular .net framework 4.6.1

Works fine. Thanks !

We have the same issue on our code. We just migrated from abpzero 6.4 (where null was translated to null) to 7.2.3 (where null is translated to an empty javascript object)

Your solution @abarref doesn't compile for us : Property 'pipe' doesn't exist on type 'U'
observable = observable.pipe(map((data) => {

Any suggestion ?

Showing 21 to 30 of 126 entries