jeudi 28 juillet 2022

Emberjs inside of get computed making request to backend multiple times cause infinite loop

I have a table basically in every row i have get function that makes a backend request with store service. But somehow when there is one row it works expect, but when there is multiple rows it always try to recalculate get function which makes sending infinite request to backend. I am using glimmer component

I cannot use model relation on ember side at this point, there is deep chain on backend side. Thats why i am making backend request.

get <function_name>() {
  return this.store.query('<desired_model_name>', { <dependent1_id>: <dependent1_id_from_args>, <dependent2_id>: <dependent2_id_from_args> });
}

I fixed this problem with using constructor. But do you have any idea why this get function re-calculate all the time? Dependent_ids are constant.

Weird thing is when results are [] empty array it does not re calculate every time. Even the query results are same it still try to recalculate every time and making infinite request to backend.




samedi 23 juillet 2022

How to referer to a page of ember js in web.xml document (for applying jaas authentication)

I'm new to ember js I need to apply Jaas authentication to my app whose front end is built on Ember JS and backend is done using servlets. I build the ember js part and run it on my tomcat server so, technically my application is on tomcat. So i tried to apply security constraints on those ember pages or routes. When I hit the protected URL, the protected page gets loaded instead of the page getting redirected to the login route.

Here is the web.xml file

<security-constraint>
        <web-resource-collection>
             <web-resource-name>admin</web-resource-name>
             <url-pattern>/admin</url-pattern>
        </web-resource-collection>
        <auth-constraint>
             <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    
    <security-role>
        <role-name>admin</role-name>
    </security-role>
    
    <login-config>
         <auth-method>FORM</auth-method>
         <realm-name>studentDB_ember</realm-name>
         <form-login-config>
              <form-login-page>/login</form-login-page>
             <form-error-page>/error-login</form-error-page>
         </form-login-config>
    </login-config>

I know something is wrong with my xml page. The other parts of my authentication works fine. I can't find the correct way to represent the url of my ember page. Should I mention a path on router.js? I tried, it still doesn't work. Please let me know what am I doing wrong and how I should configure my xml so that the security contraints are applied appropriately and that my authentication works properly.

FYI: I have mentioned the location type as hash'#' in my environment.js file. and my link looks like this http://localhost:8085/test_auth/#/admin. It would direct me to the login page if its not authenticated and to the error page if the user name or password is wrong. If everything goes well we can see the admin page.

Thanks in advance. Let me know If you need more info. Any help is appreciated.




vendredi 22 juillet 2022

How to have multiple routes for retrieving same html content

I have 2 routes /main and /home. Both should show the same HTML content. Is it possible to point both the routes to the same hbs file?




jeudi 21 juillet 2022

Visual Studio Code marks each line of all files red

I am having the latest version of Visual Studio code.

Version: 1.69.2 (user setup)
Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a
Date: 2022-07-18T16:12:52.460Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Windows_NT x64 10.0.19042

I am using Ember.js projects. Whenever I am opening any file, it is marking each and every line as red.

Native JS classes should be used instead of classic classes eslintember/no-classic-classes

I tried uninstall/ install VS Code (also I completely uninstalled and then installed again) but nothing helpled

Asap I try install my usual extensions it starts giving trouble.




mercredi 20 juillet 2022

Chrome launcher not installed on Jenkins

I have a problem with running ember test on Jenkins, i am currently trying to generate a code coverage report for my app using ember-cli-code-coverage and locally everything works fine with running COVERAGE=true ember test but when i run the same command in Jenkins, i got Launcher Chrome not found. Not installed? i also try to run ember test in ci mode and i got the same error

This is testem.js

module.exports = {
    test_page: 'tests/index.html?hidepassed',
    disable_watching: true,
    launch_in_ci: ['Chrome'],
    launch_in_dev: ['Chrome'],
    browser_start_timeout: 120,
    browser_args: {
        Chrome: {
            ci: [
                // --no-sandbox is needed when running Chrome inside a container
                process.env.CI ? '--no-sandbox' : null,
                '--headless',
                '--disable-gpu',
                '--disable-dev-shm-usage',
                '--mute-audio',
                '--window-size=1440,900',
                '--remote-debugging-port=9222',
                '--remote-debugging-address=0.0.0.0',
                '--no-sandbox',
                '--user-data-dir=/tmp',
            ].filter(Boolean),
        },
    },
};

any idea how i can fix this ?

Screenshot of Jenkins errors

[1]: https://i.stack.imgur.com/HlYKQ.png




using watchman only on specific project

I am running 2 ember applications on my computer.

On one of them I want watchman to run (to solve EMFILE: too many open files, watch),
on the other project I do not want it to run - since it causes an error (TypeError: Invalid Version: 2022.06.27.00)

Is there a way to configure watchman to run/ not run on specific projects?




mardi 19 juillet 2022

Ember Ajax request doesn't wait for the response

Here I'm calling an AJAX request with this "Security.createAuthenticatedAjaxRequest(session, URL)" method and I want to return the response of that request. But, it seems like the response doesn't wait until the request completes. It returns undefined as the response. I think it's because it returns the response before ajax request completes.

function minAndMaxGradeAllowedRequest(session) {   if (Common.isEmpty(minAndMaxGradeAllowed)) {
        Security.createAuthenticatedAjaxRequest(session, URL).then(function(minAndMaxGradeAllowedResponse) {
          minAndMaxGradeAllowed = minAndMaxGradeAllowedResponse;
        }).fail(function(error) {
          LOGGER('Failed to find Shaywitz Min and Max grades information', error.toString());
        });   }   return minAndMaxGradeAllowed; }





createAuthenticatedAjaxRequest: function(session, url, config){
        if(Common.isEmpty(config)) {
          config = {};
        }
      return this.createAuthenticatedAjaxRequestWithAcceptHeaderParam(session, url, config, true);
    },
    createAuthenticatedAjaxRequestWithAcceptHeaderParam: function(session, url, config, isAcceptRequired){
        if(Common.isEmpty(config)) {
            config = {};
        }

        if(Common.isEmpty(config.headers)) {
            config.headers = {};
        }

        config.headers['Authorization'] = 'Bearer ' + session.get('data.authenticated.access_token');
        if(!Common.isEmpty(isAcceptRequired) &&  isAcceptRequired  === true) {
          config.headers['Accept'] = 'application/json';
        }

        if(Common.isNotEmpty(session.get('data.authenticated.supportuser'))){
          config.headers['supportuser'] = session.get('data.authenticated.supportuser');
        }

        return Ember.$.ajax(url, config);
    },

Below is the code where it uses the response of the function minAndMaxGradeAllowedRequest(session).

let minAndMaxGradeAllowed = ShaywitzGradesAllowed.getMinAndMaxGradeAllowed(this.get('session'));

I don't have much experience with Ember js. Can someone please help me to solve this problem?




mercredi 6 juillet 2022

Ember js, in heroku production, live reload fails to load and time out and loading spinner keeps spinning

I just deployed a simple side project using ember and rails. Evenything is good but when first enter the webpage, the browser loading spinner keeps spinning.

I checked on the console and it has an error saying fetching ember cli live reload has timed out.

This does not happen on local and live reload works fine on local. How can I fix this?

Thanks!

spinner

error message




vendredi 1 juillet 2022

Ember-table shows index on the header

I am using ember-table but have a weird behavior. It automatically adds index next to my header title.

image

But after I click one of the header to sort the table, the index will disappear as I want. How do I get rid of the index in the first place. Plus, without the sorting function, the table was normal.

After I click anyone of the header to sort the column, the index will go away.

image

Here is my sort object

sorts = [
  { valuePath: 'username' },
  { valuePath: 'total_assignment_count' },
  { valuePath: 'accepted_assignment_count' },
  { valuePath: 'accepted_rate' },
  { valuePath: 'acl_name' },
  { valuePath: 'repo_name'}
];

template

<EmberTable as |t|>
  <t.head
    @columns=
    @sorts=
    @onUpdateSorts=
  />
  <t.body @rows= />
</EmberTable>