resourcesSearch in typescript

0

i have the below method to validate user and then retrieve the resources from jasper server. the user credentials are validated correctly. However,  the "v" varialble is always null. please advise. kindly refer me to any typscript documentation for visualizejs.

public validateUser(userName: string, password: string, organization: string): Promise<any> {
    return new Promise(function(resolve, reject) {
        visualize({
            auth: {
                name: userName,
                password: password,
                organization: organization
            }
        },
        function() { resolve(); }, // successful validation
        function() { reject(); },
        function (v) {
            console.log(v);
            v.resourcesSearch({
                folderUri: "/public",
                recursive: true,
                types: ["reportUnit","dashboard"],
            }),
            //utility function
            function renderResults(results) {
                this.resourceDetails = results;
                console.log( this.resourceDetails);
            }
        }); 
    });

mounir.youssef's picture
Joined: Feb 16 2018 - 3:59am
Last seen: 1 month 1 week ago

1 Answer:

0

fixed as below. i guess i had to read more the typescript and angularjs framework:

public getressources(): Promise<any> {
    return new Promise(function(renderResults) {
        visualize({
            // already authenticated, so proceed with resource rendering
        }, function(v) {
            v.resourcesSearch({
                folderUri: "/public",
                recursive: true,
                types: ["reportUnit","dashboard"],
                success: renderResults,
                error: handleError
            });
 
            function renderResults(results) {
                this.resourceDetails = results;
                //console.log( this.resourceDetails);
            };
 
            function handleError(err){
                console.log(err.message);
                this.messageService.log(err.message);
            }
        });
    }
)}
mounir.youssef's picture
Joined: Feb 16 2018 - 3:59am
Last seen: 1 month 1 week ago
Feedback