mercredi 31 août 2022

html scrollable area define scrolled position

I have the following scrollable area, the html (using ember, so written using hbs) receives the selected div in the scrollable area, and it colors the selected div in gray. (code below).

Here is how the div looks like: enter image description here

here is the html (hbs)

        <div role="listbox" style="overflow-y: auto">
            
                <div class="variable-row  ">
                    
                </div>
            
        </div>

my issue is when the selectedVar isn't seen (for example var under kkkk needs to be scrolled to be seen) is there anyway I can tell the html to scrolled down to the selectedVar? something like

            
                <div >
                    
                </div>
            



mardi 30 août 2022

idpiframe_initialization_failed while using google signin on ember

building an ember app which uses google sign in yet when i added the button it fuc=nctions but it pops the error in console

idpiframe_initialization_failed

with the details You have created a new client application that uses libraries for user authentication or authorization that will soon be deprecated. New clients must use the new libraries instead; existing clients must also migrate before these libraries are deprecated. See the Migration Guide for more information."

my.hbs code


<div class="g-signin2"></div>


my index.html code

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Embu</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="google-signin-client_id" content="938293174818-eu6i0913ria6b3v6mre2ad01t0q1cjh2.apps.googleusercontent.com">

    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css" integrity="sha384-xeJqLiuOvjUBq3iGOjvSQSIlwrpqjSHXpduPd6rQpuiM3f5/ijby8pCsnbu5S81n" crossorigin="anonymous">//->client id
    <link integrity="" rel="stylesheet" href="assets/vendor.css">
    <link integrity="" rel="stylesheet" href="assets/embu.css">

    
  </head>
  <body>
    
    <script src="https://apis.google.com/js/platform.js" async defer></script> //--> google api import
    <script src="assets/vendor.js"></script>
    <script src="assets/embu.js"></script>

    
  </body>
</html>




lundi 29 août 2022

"ember is not defined" while using torii authentication

I am building a web app using ember js which includes google oauthand torii for authentication.. without torii being installed everything looks fine yet when i just installed torii(i never used it) the app crashes and it says ember not defined also there are depraction messages which are


See https://deprecations.emberjs.com/v3.x/#toc_ember-global for details.

Usages of the Ember Global may be caused by an outdated ember-cli-babel dependency. The following steps may help:

* Upgrade the following addons to the latest version:
  * torii

### Important ###

In order to avoid repeatedly showing the same deprecation messages, no further deprecation messages will be shown for usages of the Ember Global until ember-cli-babel is upgraded to v7.26.6 or above.

To see all instances of this deprecation message, set the `EMBER_GLOBAL_DEPRECATIONS` environment variable to "all", e.g. `EMBER_GLOBAL_DEPRECATIONS=all ember test`.      

### Details ###

Prior to v7.26.6, ember-cli-babel sometimes transpiled imports into the equivalent Ember Global API, potentially triggering this deprecation message indirectly, even when you did not observe these deprecated usages in your code.

The following outdated versions are found in your project:

* ember-cli-babel@6.18.0, currently used by:
  * torii@0.10.1
    * Depends on ember-cli-babel@^6.11.0

ember version : 4.6.0 torii version : 0.10.1




jeudi 25 août 2022

@computed property with this.args in ember.js

Some of codes contains @computed("args.param") property behind of getters in ember.js. But I can use this.args.param in the getters without @computed("args.param"), and there is no problem in it. What's the differece between @computed("args.param") using and not using?

between

  @computed('args.date')
  get currentMonth() {
    return moment(this.args.date, 'YYYY-MM').startOf('month');
  }

and

  get currentMonth() {
    return moment(this.args.date, 'YYYY-MM').startOf('month');
  }



mardi 23 août 2022

@computed and @tracked in Ember.js

Currently, I am working on Octanify Components in Ember.js. I can't figure out the difference between using @computed and @tracked. It's similar, but sometimes I found a problem.

@computed
get departments() {
  return this.store.query('department', { per_page: 1 });
}

In this case, removing @computed puts you in an infinity cycle. What's the problem?




lundi 22 août 2022

retriving table content data in ember

am creating an ember application which gets data from servlet and print it in a table format.. the table look like this

Capacity Price  RoomType    RoomNo  Action
6        4150   suite         93    Select
2        1579   villa          5    Select
1        1526   villa          1    Select

when i clicked select i need to get the value in the room no. i tried creating a tracked variable and updating the value but got stuck so any idea how can i do it in ember.. i found an article which uses jquery to do the same but dont know how to add jquery in ember.

my handlebar file


  loading data...

<main class="conttainer mt-5 ">

<container class="cond">
<table border="1|0" class = "tab">
  <thead>
    <tr>
      <th><td>Capacity</td></th>
      <th><td>Price</td></th>
      <th><td>RoomType</td></th>
      <th><td>RoomNo</td></th>
      <th><td>Action</td></th>
    </tr>
  </thead>
  <tbody>
   
        
      <tr>
        
          <td></td>
          
        
        <td><button  class = "btn-test" >Select</button></td>//--> wrong decleration yet i dont know how to access the roomno column
        
      </tr>
    
  </tbody>
</table>
</container>
<form>
  <table>
    <tr>
      <td><h5>room number</h5></td>
    </tr>
    <tr><td></td></tr>//---> i have to show the value here
    <tr><td><b>Enter the Start Date</b></td></tr>
    <tr><td><input type = "date" placeholder="yyyy-mm-dd" id = "sdate" value = "2022-07-01" min = "2022-07-01" max = "2022-07-31"></td></tr>
    <tr><td><b>Enter the End Date</b></td></tr>
    <tr><td><input type = "date" placeholder="yyyy-mm-dd" id = "edate" value = "2022-07-01" min = "2022-07-01" max = "2022-07-31"></td></tr>
    <tr><td><button type = "button" >submit</button></td></tr>
  </table>
</form>

</main>

my controller file

class RequestState {
  @tracked value;
  @tracked error;

  get isPending() {
    return !this.error && !this.value;
  }
}

export default class RoomselectController extends Controller {
  @service router;
  @tracked room =0;
  getroomno(value){
    var that = this;
    console.log(value);
    that.room = value;
    console.log(that.room)
  }

  @use request = resource(({ on }) => {
    const state = new RequestState();
    var dis = this;
    $.ajax({
      url: 'http://localhost:8080/hotelres/My',
      method: 'GET',
      dataType: 'json',
      success: function(response){ 
        console.log(response)
        if(response == 0){
          dis.transitionToRoute("error");
        }else{
          state.value = response
        }
      },
      error: (xhr, status, error) =>
        (state.error = `${status}: ${xhr.statusText}`),
    });

    return state;
  });

  get result() {
    return this.request.value || [];
  }

i need to render the room number when the select button is pressed




dimanche 21 août 2022

could not find module 'ember-resources'

am trying to build an web app with ember and in the process of making a request to server and receiving a response and for that i used resources from ember-resource yet it always popping the error module not found ember-resources

the js code

import { use, resource } from 'ember-resources';
import { tracked } from '@glimmer/tracking';

class RequestState {
  @tracked value;
  @tracked error;

  get isPending() {
    return !this.error && !this.value;
  }
}

export default class RoomselectController extends Controller {
    @service router;

    @use request = resource(({ on }) => {
      const mobile = '123123123';
      const state = new RequestState();
    
      $.ajax({
        url: 'My',
        method: 'GET',
        dataType: 'json',
        data: { mobile },
        success: (response) => state.value = response;,
        error: (xhr, status, error) => state.error = `${status}: ${xhr.statusText}`,
      });

      return state;
    });

    get result() {
      return this.request.value || [];
    }

}

i installed ember-resource using ember install ember-resources also done npm install ember-resources

still showing the same module not found errro what to do?




samedi 20 août 2022

couldnt render a json array from servlet in ember js

am trying to render a json array which is sent from a java servlet in ember. the work flow goes like follows

1.sending an ajax request to the servlet which will return the jsonobject

2.i will get the json object and try to render in the handlebar file

the problem is when i consoled the response it came with an indexes

0: {CAPACITY: '4', PRICE: '918', RTYPE: 'basic', ID: '4'}
1: {CAPACITY: '2', PRICE: '885', RTYPE: 'villa', ID: '8'}
2: {CAPACITY: '2', PRICE: '1579', RTYPE: 'villa', ID: '5'}
3: {CAPACITY: '1', PRICE: '1526', RTYPE: 'villa', ID: '1'}

but what the server sent was

{"CAPACITY":"4","PRICE":"918","RTYPE":"basic","ID":"4"}
{"CAPACITY":"2","PRICE":"885","RTYPE":"villa","ID":"8"}
{"CAPACITY":"2","PRICE":"1579","RTYPE":"villa","ID":"5"}
{"CAPACITY":"1","PRICE":"1526","RTYPE":"villa","ID":"1"}

the controller code

export default class RoomselectController extends Controller {
    @service router;
    @tracked obj = null  ;
    @tracked price =0;
    get res(){
        var dis = this;
        const mobile = "123123123";
        $.ajax({
            url:'My',
            method : 'GET',
            dataType:'json',
            data : {mobile:mobile},
            success:function(response){
                console.log(response);
                dis.price = response[0].PRICE;//when rendered this works
                dis.obj = response;//when changed to dis.obj = response[0] it renders the first
                
                return response[0];
            },
            error: function(xhr,status,error){
                var errorMessage = xhr.status + ": " + xhr.statusText;
                alert("error " + errorMessage);
            }
        })
    }

the .hbs code

<table border ="1">
    <tr><td><b>Capacity</b></td><td><b>Price</b></td><td><b>Room Type</b></td><td><b>Room No</b></td></tr>

    
        
    <td></td>
    

    </table>

it is not working but when i use dis.obj = response[0] it works and renders only the first index how to make it render every data?




Ember Octane - How to loop through model records inside a component?

I have an array of strings passed as an argument to a component, inside the component I am using "each" helper to render each string in a text input. I tried the following approach.

I have a model passed as an argument to a component. I'm using #each helper to iterate through that model and this does not work.

Example:

  1. Template
<div>
<Location::LocationList @model=""/>
</div>
  1. LocationList component:
<ul class="location-list">
  
    <li>
      
    </li>
  
</ul>

And if I just do it in this way:

<ul class="location-list">
    
      <li>
        <Location::LocationItem @location=/>
      </li>
    
</ul>

It works as needed. Any suggestions?




dimanche 7 août 2022

How to specify template for Glimmer Component?

I have a typical Glimmer "base" component:

import Component from '@glimmer/component';
export default class BaseComponent extends Component { ... }

It has a template like normally, but the actual implementations of that component are child componenents, that override some of the template getters and parameters so that it works with various different data types.

export default class TypeAComponent extends BaseComponent { ... }
export default class TypeBComponent extends BaseComponent { ... }

etc.

My question is: How do I specify that all the child components should use the parent class template, so I don't have to duplicate the same fairly complex HTML for all child components? Visually the components are supposed to look identical so any changes would have to be replicated across all child component types. Therefore multiple duplicated templates isn't ideal.

In Ember Classic components there was layout and layoutName properties so I could just do:

layoutName: 'components/component-name'

in the base component and all child components did automatically use the defined template.

Now that I'm migrating to Glimmer components I can't seem to figure out how to do this. I have tried:

  • layout property
  • layoutName property
  • template property
  • Using the child components without a template in hope that they would automatically fall back to the parent class template.

Only thing that seems to work is creating Application Initializer like this:

app.register('template:components/child1-component', app.lookup('template:components/base-component'));
app.register('template:components/child2-component', app.lookup('template:components/base-component'));

But that feels so hacky that I decided to ask here first if there is a proper way to do this that I have missed?




samedi 6 août 2022

Bootstrap dropdown menu not scrollable inside ember-perfectscroll

I'm showing a few lists of items under different categories in kanban view. In each item-list, I use ember-perfectscroll to scroll through the items vertically. And in each item-card, I have bs-dropdown to select from a list of sub-categories. Everything works fine until the item-list grows bigger and needs to be scrolled.

When I want to open and scroll inside sub-categories dropdown menu, the item-list is getting scrolled instead. I'm able to scroll sub-categories menu only for the items which are at the end of the item-list.

How can I make the dropdown menu scrollable by suppressing perfect-scroll ?




vendredi 5 août 2022

How can I get my locally running app to see cookies from an app that is in production?

I have an Ember app in production & I have recently created a React application that will eventually replace the Ember app.

The plan is to begin migrating pages over into the React app.

For now, I'm just trying to login to the production app & then grab that cookie from the React app (locally - since it is early stages of dev) The issue that I'm currently struggling with is that I can't access the tokens/cookies from the production app because they are at my-domain.com where as the react app is running at localhost:3000

How do I go about sharing cookies & tokens between production & local?

Thanks in advance!




mardi 2 août 2022

Drop Down List in ember

Hi I am new to ember and trying to create a dropdown list using .

Is there a way where I can access the selected item in drop down list in ember via component? Give me a short example.

Thanks in advance.




Ember Js: Getting Uncaught RangeError when calling Component

I've created a simple route and component. I'm trying to call component from the template. But when i call, component is called recursively and getting the below error

vendor.js:58853 Uncaught RangeError: Maximum call stack size exceeded
    at Class.init (vendor.js:58853:20)
    at Class.superWrapper [as init] (vendor.js:33826:20)
    at Class.superFunction [as _super] (vendor.js:29300:20)
    at Class.init (vendor.js:56183:19)
    at Class.superWrapper (vendor.js:33826:20)
    at Class.superFunction [as _super] (vendor.js:29300:20)
    at Class.init (vendor.js:55450:19)
    at Class.superWrapper (vendor.js:33826:20)
    at Class.superFunction [as _super] (vendor.js:29300:20)
    at Class.init (vendor.js:54600:19)

Template.hbs contains the below


modified the router.js as

this.route('admin-settings', { path: 'admin-configuration/admin-settings'}); ;

I didn't added anything to route.js and component.js