lundi 30 mai 2022

Using Auth0 with ember-simple-auth

I'm currently adding Auth0 to an Ember Application that previously used ember-simple-auth to authorize it's users. I was hoping to plug auth0 into ember-simple-auth to avoid having to refactor too much. I found the following library provided by Auth0, but it appears to be deprecated: https://www.npmjs.com/package/ember-simple-auth-auth0

Is there any simple way to still accomplish this? The new instructions seem to be for if you're just using Auth0 and no ember-simple-auth.




ember-native-class-codemods TypeError: Cannot read property 'process' of undefined

My test app is using ember-cli and ember is 3.28. When I tried to use ember-native-class-codemods to convert my test appli cation it throws below error,

TypeError: Cannot read property 'process' of undefined
    at bLZ (C:\Users\AS0002\AppData\Local\Volta\tools\image\packages\ember-native-class-codemod\node_modules\ember-native-class-codemod\node_modules\flow-parser\/flow_parser.js:565:79)
    at C:\Users\AS0002\AppData\Local\Volta\tools\image\packages\ember-native-class-codemod\node_modules\ember-native-class-codemod\node_modules\flow-parser\/flow_parser.js:566:4
    at Object.<anonymous> (C:\Users\AS0002\AppData\Local\Volta\tools\image\packages\ember-native-class-codemod\node_modules\ember-native-class-codemod\node_modules\flow-parser\/flow_parser.js:2:2)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Module._compile (C:\Users\AS0002\AppData\Local\Volta\tools\image\packages\ember-native-class-codemod\node_modules\ember-native-class-codemod\node_modules\pirates\lib\index.js:136:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.newLoader [as .js] (C:\Users\AS0002\AppData\Local\Volta\tools\image\packages\ember-native-class-codemod\node_modules\ember-native-class-codemod\node_modules\pirates\lib\index.js:141:7)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)

It was already reported in github issue but no solutions mentioned https://github.com/ember-codemods/ember-native-class-codemod/issues/392

I have installed ember install ember-classic-decorator and ember install ember-decorators and my project is running while running the npx command. Below is my versions, ember-cli: 3.28.5 node: 14.19.3 os: win32 x64




jeudi 26 mai 2022

Override computed property in Ember 4 adapter

In the "new" class style of Ember / JavaScript (at least new to me), I am having trouble adapting old tutorials to set a computed property in my JSONAPIAdapter.

export default class ApplicationAdapter extends JSONAPIAdapter {
  @service session;

  headers: computed('session.isAuthenticated', 'session.data.authenticated.token', function() {
    if (this.session.isAuthenticated) {
      return {
        Authorization: `Bearer ${ this.session.data.authenticated.token }`,

Results in

$TMPDIR/embroider/b3d2a6/adapters/application.js/application.js: Unexpected token (8:9)

   6 |   @service session;
   7 |
>  8 |   headers: computed('session.isAuthenticated', 'session.data.authenticated.token', function() {

The docs ( https://api.emberjs.com/ember-data/4.3/classes/JSONAPIAdapter/properties/headers?anchor=headers ) imply that this should work, but I think the @service session line is messing things up.

What is the correct way to set the headers property an Ember 4 class in 2022?




lundi 23 mai 2022

Ember js Ember-Highcharts data bar does'nt viewed in output

i have used this ember highchart code js in component and in hbs but it doest display any bars in my output it only displays a side parthbs

component js

output




vendredi 20 mai 2022

Ember.JS Tutorial "Super-Rentals" and API Paths

I've been following the SuperRentals Ember.JS tutorial and have also cloned the finished product from here.

I'm struggling to identify where we define that we retrieve data from rentals.json in <app_dir>/public/api:

XXX@XXXX-XX:~/super-rentals/public/api$ ls
rentals rentals.json

If I change rentals.json to another name, the site stops loading entirely implying some configuration or code requires changing to reflect this.

However, when I grep for "rentals" recursively in <app_dir>/app none of the references returned appear related.

Is this naming picked up by convention, or is it explicitly defined somewhere in the application?




jeudi 19 mai 2022

How to create a user authentication using rails as backend and ember as frontend

I'm working on eCommerce for my internship project. But I don't know how to create the user authentication using rails and ember




Fetch with Session ID in ember JS

i am a newbie in ember and servlet. Here is the code snippet of dashboard.js from the route directory.

import Route from '@ember/routing/route';

export default class DashboardRoute extends Route {

    async model()
    {
        let response = await fetch("http://localhost:8080/Servlet/getfilename");
        let data = await response.json();
        return data;
    }
}

I have maintained Session in my Servlet (i.e) When an user logged in via login Page LoginServlet will create a Session for the request and redirects the user to the Dashboard Page, where it fetches a json response from another servlet which does a session validation. Now that throws an error saying that the Session is null.Why does this happen? Is there is way to store the Session ID in ember and send it to the servlet via fetch?

Thanks in advance




mardi 10 mai 2022

How to get input value in TypeScript (ember)?

I am new to Ember, try to make simple todo app by my own after YT tutorial. However I have a problem when I try to access input value.

Property 'value' does not exist on type 'EventTarget'

My function:

updateNewItemValue(event: InputEvent) {
    this.newItem = event!.target.value;
 }

Using it in template:

<input
    type='text'
    
    value=
/>

Maybe am I using wrong type for event argument?




mardi 3 mai 2022

Babel:ember-ace > applyPatches]node:internal/validators:164 throw new ERR_INVALID_ARG_TYPE(name,'object',value);

I am not able to run my ember project getting this error and it says template compiler error(broccoli-persistent-filter:TemplateCompiler) in ember-popper/templates/components/ember-popper-targeting-parent.hbs Loc$$1.sliceStartChars is not a function Stack Trace and Error Report:/temp/error.dump.abcbf77920a1c………….log




lundi 2 mai 2022

monaco-editor - Uncaught ReferenceError: window is not defined

I am using monaco-editor on my ember.js app,
here is my code: https://gist.github.com/dinager/4090965700f54e9d74c8899e54820353
I get the following runtime error - it does not seem to influence my app, the code editor is working perfect, but I would still like to remove this error from my console:

Uncaught ReferenceError: window is not defined
    at eval (errors.js:53:1)
    at Object.../../../../../../../../Users/my-app/client/node_modules/monaco-editor/esm/vs/base/common/errors.js (editor.worker.js:79:1)
    at __webpack_require__ (editor.worker.js:483:41)
    at eval (simpleWorker.js:8:68)
    at Object.../../../../../../../../Users/my-app/client/node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js (editor.worker.js:259:1)
    at __webpack_require__ (editor.worker.js:483:41)
    at eval (editor.worker.js:5:93)
    at Object.../../../../../../../../Users/my-app/client/node_modules/monaco-editor/esm/vs/editor/editor.worker.js (editor.worker.js:459:1)
    at __webpack_require__ (editor.worker.js:483:41)
    at editor.worker.js:523:37

seems like it fails on this line: enter image description here
what am I missing? how can I solve it?