jeudi 5 décembre 2019

Ember Inspector doesn't detect ember-cli app

I'm running an ember-cli app. The Inspector (Chrome) says This webpage is not running Ember.js.

Looking at the source view on the browser, it includes

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">    
...
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>

How can I get the Inspector to recognize it?




How to display nested JSON object in the next row of mdc-layout-grid in Ember?

I want to display a nested JSON object in the next row of the grid. I am using Ember and mdc-layout-grid.

My JSON data is as follows:

data = [{
"amzOrderId": "403-8957866-2673902",
"financialEventType": "SHIPMENT",
"timestamp": 1570025882722,
"numOfItems": 1,
"nested": [{
"amzOrderId": "405-3430902-0842748",
"financialEventType": "SHIPMENT",
"timestamp": 1570025882722,
"numOfItems": 1}]},
{
"amzOrderId": "171-9021455-7043516",
"financialEventType": "SHIPMENT",
"timestamp": 15700258888722,
"numOfItems": 1,
"nested":null,
}]

My hbs file to render:

<li class="sales-list-row">
  
    
      
        <h3 class="bought__value"></h3>
      
      
        <span class="purchased__text">Purchased</span>
        <h3 class="purchased__value"></h3>
      
      
        <h4 class="id__value"></h4>
              
    
  
</li>

Now I want to render "nested" object values just in the next row if it is present (move to next data[element] in case nested is null). How do I approach this problem? I have tried a few methods but they are not working.




mercredi 4 décembre 2019

Using parentView inside an Ember component

Inside an Ember component, what does using "parentView" as shown below represent ?

targetObject: alias('parentView')



Same resource for multiple routes - EmberJS

I would like use routes like:

/seller
/seller/
/seller/123
/seller/456

I define my route-setup like this:

this.route('seller', { path: '/seller' });
this.route('seller', { path: '/seller/:sellerId' });

In other words, I would like to use the same controller for these two routes, this works fine when I call route directly in browser but when I call

get(this,'router').transitionTo('seller', id);

Ocurrs a warning(I will update the question with the error that occurs), probaly because is the same name of controller.... What I can do?




lundi 2 décembre 2019

PDFJS: error on Text rendering for the PDF

Recently the PDF rendering get a messed up text layer where text gets duplicated with the grey colored overlay. No idea about how to fix it as when i remove textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory() it works fine. but need this as if not is render as images which takes a lot of time for large documents

Im using pdfjsViewer.PDFPageView

my code as follows

 getPdf() {

    var pdfDocument;

    if ( this._state !== 'inDOM' ) return false;

    pdfjsLib.disableRange = true;
    pdfjsLib.disableStream = true;

    let self = this;
    pdfDocument = pdfjsLib.getDocument(this.src);
    pdfDocument.promise.then(function(pdf) {
      self.set( 'pdfDocument', pdf );
      self.set( 'maxNumPages',  pdf.numPages );
      self.set( 'prevBtnDisabled', true );
      self.set( 'documentRendered', true );

      self.setViewportWidth();
      self.renderPdf();
    });

    return pdfDocument;
  },

  renderPdf() {

    var pdf = this.pdfDocument,
        maxNumPages,
        pagePromise;

    if ( !pdf ) return false;

    maxNumPages  = this.maxNumPages;

    pagePromise = this.getAndRenderPage( pdf, 1 );

    Array.apply( null, new Array( maxNumPages - 1 ) ).forEach( ( value, index ) => {

      pagePromise = pagePromise.then( () => this.getAndRenderPage( pdf, index + 2 ) );
    } );
  },

  getAndRenderPage( pdf, index ) {

    return pdf.getPage( index ).then( page => this.renderPage( page, index ) );
  },


  renderPage( pdfPage, pageNum ) {

    var parentWidth       = this.$().parent().width(),
        pageViewportScale = ( parentWidth >= this.get( 'breakpoints.mobile' ) ) ? 1.5 : 1.3,
        viewport          = pdfPage.getViewport( { scale: parentWidth / pdfPage.getViewport( { scale: pageViewportScale } ).width } ),
        container         = this.$().find( '.pdf_viewer--container' )[ 0 ],
        pdfPageView;

    pdfPageView = new pdfjsViewer.PDFPageView( {
      container: container,
      id: pageNum,
      scale: viewport.scale,
      defaultViewport: viewport,
     textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory()

    } );
    var pages = this.get('pages');
    // Associates the actual page with the view, and drawing it
     pages.push( pdfPageView );
    this.set( 'pages', pages );
    this.set( 'scale', viewport.scale );z

    pdfPageView.setPdfPage( pdfPage );

    return pdfPageView.draw();
  },

i have seen same kind of questioned asked and its for angular Im importing his image as for the reference in here to give a more explanation about the issue

enter image description here

Reported Issue PDFJS: Text layer rendering twice




dimanche 1 décembre 2019

Possible problem between heroku and parse server

I'm working on a application which uses parse server as api, i deployed both on heroku. When i try to save a user on my database i get this error: ParseError { code: 107, message: 'Received an error with invalid JSON from Parse: Cannot POST /classes/_User\n' }




How can i found the application id of my heroku application?

I have an ember project deployed on heroku and also an api to make graphs calculation. I have to set an appid to my api application, and i can't figure out where to find it. The api is a parse-server api, which is deployed on heroku.

if (environment === 'production') {
    ENV.APP.HOST = 'xxxxxx(my url).herokuapp.com'
    ENV.rootURL = null;
    ENV.locationType = 'hash';
    ENV.APP.applicationId = '(I don't know what to set here)'
  }

That's my code on environment.js