jeudi 4 juillet 2019

Use constant for Ember computed property dependent key

For an Ember app, is it possible to use a constant as part of a computed property key ?

So, essentially, I have a constant as below;

MY_SECTION {
MY_FIELD: "my-field-id"
}

What I want is a computed property on "my-field-id" i.e.

myCP: function() {
console.log('Inside CP...');
}.property('section.field.my-field-id.value')

However, I want to be able to use constant for my-field-id instead of using it directly. Is that possible ?




In Ember.js IOS Cordova Building App Not Working?

when I add the ios platform in ember.js by using cordova comand.

  • ember cdv:platform add ios

Adding platform in my project is ok.

Then I tried to build by using this command.

  • ember cdv:build --platform=ios

Now showing error. I tried a lot of things and by using this command too.

  • ember cdv:build --platform=ios --buildFlag='-UseModernBuildSystem=0'

Not working.

Error showing this only.

enter image description here




mercredi 3 juillet 2019

Find nested property from ember lodash and pick the value

I am new to javascript.

I would like to check whether the specific nested property is present or not in an array of items, ex)

[{
    "_id" : ObjectId("5c4ec057e21b840001968d31"),
    "status" : "ACTIVE",
    "customerId" : "sample-book",
    "bookInfo" : {
        "bookChunks" : [ 
            {
                "key" : "Name",
                "value" : "test"
            }, 
            {
                "key" : "Surname1",
                "value" : "testtt"
            }, 
            {
                "key" : "user-contact",
                "value" : "sample-value",
                "ContactList" : {
                    "id" : "sample-id",
                    "timeStamp" : "Tue, 20 Sep 2016 07:49:25 +0000",
                    "contacts" : [ 
                        {
                            "id" : "contact-id1",
                            "name" : "Max Muller",
                            "phone_number" : "+XXXXXXX"
                        }, 
                        {
                            "id" : "contact-id2",
                            "name" : "Max Muller",
                            "phone_number" : "+XXXXXXX"
                        }
                    ]
                }
            }
        ]
    }
},
{
    "_id" : ObjectId("5c4ec057e21b840001968d32"),
    "status" : "ACTIVE",
    "customerId" : "sample-book1",
    "bookInfo" : {
        "bookChunks" : [ 
            {
                "key" : "Name",
                "value" : "test"
            }, 
            {
                "key" : "Surname1",
                "value" : "testtt"
            }
        ]
    }
}]

Here, I would like to find whether any item has ContactList or contacts present. If it is present take the item and put it in a separate list.

I am using ember-lodash. Using normal javascript or lodash would be fine for me. Any help will be really appreciated.




mardi 2 juillet 2019

Editor Error - No such editor found: dateEditor in tabulator code

I am using tabulator code in ember js, to build editable table. Here I need a formatter for date(http://tabulator.info/examples/4.2 -- Editable data), as per the example given in tabulator api I have tried, here I am getting Editor Error - No such editor found: dateEditor.

I am assigning the dateEditor for the column as below at run time. I have tried like below this also editor: "dateEditor(cell, onRendered, success, cancel)" getting same error.

columnMap = 
{ 
align: "center", editor: "dateEditor"
}

var dateEditor = function(cell, onRendered, success, cancel){
    //cell - the cell component for the editable cell
    //onRendered - function to call when the editor has been rendered
    //success - function to call to pass the successfuly updated value to Tabulator
    //cancel - function to call to abort the edit and return to a normal cell

    //create and style input
    var cellValue = moment(cell.getValue(), "DD/MM/YYYY").format("YYYY-MM-DD"),
    input = document.createElement("input");

    input.setAttribute("type", "date");

    input.style.padding = "4px";
    input.style.width = "100%";
    input.style.boxSizing = "border-box";

    input.value = cellValue;

    onRendered(function(){
        input.focus();
        input.style.height = "100%";
    });

    function onChange(){
        if(input.value != cellValue){
            success(moment(input.value, "YYYY-MM-DD").format("DD/MM/YYYY"));
        }else{
            cancel();
        }
    }

    //submit new value on blur or change
    input.addEventListener("blur", onChange);

    //submit new value on enter
    input.addEventListener("keydown", function(e){
        if(e.keyCode == 13){
            onChange();
        }

        if(e.keyCode == 27){
            cancel();
        }
    });

    return input;
};

Could some please help me how to call customEditor in tabulator code.




How to refresh token with different endpoint?

I have an Ember app in which I use ember-simple-auth for authentication. My backend is structure in a way that the endpoint for authorization is different from the endpoint for refreshing.

How can I specify a different endpoint for refreshing? So far, I only found serverTokenEndpoint which specifies both auth and refreshing endpoints at once.




I am getting the following error while creating the ember application through cmd

I am trying to create an ember application through command prompt

i installed Nodejs version v10.16.0 and then i use the command 'install npm install -g ember -cli' to install ember

ember successfully insatalled with version ember-cli 3.10.1 then i create a new application by using command 'ember new ember-quickstart' then i got the below error

Error creating new application. Removing generated directory ./kushi Command failed: npm install --loglevel error npm WARN deprecated @babel/polyfill@7.4.4: 🚨 As of Babel 7.4.0, this npm WARN deprecated package has been deprecated in favor of directly npm WARN deprecated including core-js/stable (to polyfill ECMAScript npm WARN deprecated features) and regenerator-runtime/runtime npm WARN deprecated (needed to use transpiled generator functions): npm WARN deprecated npm WARN deprecated > import "core-js/stable"; npm WARN deprecated > import "regenerator-runtime/runtime"; npm WARN deprecated exists-sync@0.0.4: Please replace with usage of fs.existsSync npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\broccoli-rollup-93db1951\dist\index.d.ts' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\broccoli-rollup-93db1951\dist\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\blueprints\ember-cli-typescript\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\lib\commands\clean.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\lib\commands\precompile.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\lib\utilities\copy-declarations.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\lib\utilities\ember-cli-entities.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\js\lib\utilities\fork.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\blueprint-files\ember-cli-typescript__config_root__\config\environment.d.ts' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-typescript-b54d1b7c\blueprint-files\ember-cli-typescript\types__app_name__\index.d.ts' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-5cfc18ea\blueprints\module-unification-app\files\src\ui\routes\application\template.hbs' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-5cfc18ea\lib\tasks\server\middleware\broccoli-watcher\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-5cfc18ea\lib\tasks\server\middleware\broccoli-watcher\package.json' npm WARN tar ENOENT: no such file or directory, lstat 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-5cfc18ea\lib\tasks\server\middleware' npm WARN tar ENOENT: no such file or directory, lstat 'C:\Users\kagrawal.EMEAAD\Desktop\kushi\node_modules.staging\ember-cli-5cfc18ea\lib' npm ERR! code ERR_INVALID_OPT_VALUE npm ERR! The value "false" is invalid for option "readableHighWaterMark" npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\kagrawal.EMEAAD\AppData\Roaming\npm-cache_logs\2019-07-02T09_36_58_880Z-debug.log Stack Trace and Error Report: C:\Users\KAGRAW~1.EME\AppData\Local\Temp/error.dump.4edeef2bba53a9733909115d695aa4ba.log

can someone help me to resolve the error.




How to include an ember app inside a jsp file and serve it using tomcat

I am new to ember. I am having an ember app which I could run using ember serve and see the output. I want to include this app in a jsp file and run the whole app from tomcat server (i.e., port 8080). I saw in some posts that including handlebars and routes in jsp is possible but I'm unable to get a proper tutorial for it. please help me with these!!