Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
1
Indexable
Never
importNodesArray() {
    let dataArray = JSON.parse(this.cSVJSONUtilityLib.convertRowCSVToJS(this.fileContentString, true));
    console.log(dataArray);
    this.appService.masterWrapperAdmin({
        params: {
            'allparameters': dataArray,
            'allconfig': this.commonUtilitiesLib.copy({
                'verbtype': 'post',
                'apiname': ['ADMINUSERNODENAMES;'],
                'responseformat': {
                    'format': 'rest'
                }
            })
        }
    }).subscribe(
        (response: any) => {
            if (response.status === 'Success') {
                const data = response.data[0].ADMINUSERNODENAMES[0];
                if (data.messageCode === 200) {
                    this.toastr.success('Import Successful');
                    this.router.navigate(['/admin', 'list', 'all']);
                } else {
                    // Handle specific error message
                    const skippedNodes = data.message.match(/(?<=skipped nodes : \[)(.*?)(?=\])/);
                    if (skippedNodes) {
                        const nodes = skippedNodes[0].split(', ');
                        console.log('Skipped Nodes:', nodes);
                        // Handle skipped nodes
                    } else {
                        // Handle other error messages
                        console.log('Error Message:', data.message);
                    }
                }
            } else {
                // Handle general error case
                console.error('Error:', response.errorCode);
            }
        },
        (error: any) => {
            // Handle general error case
            console.error(error);
        }
    );
}