<commit_before>const {
    ipcRenderer
} = require('electron');
const {
    success,
    error,
    info
} = require('./custom_modules/utils.js');
const Binder = require('./classes/binder.js');
var services = [];
//Utility function that will help us
//create the 3 types of links we need for our service list(Start, Stop,Restart)
//@param type Type of link to create(start,stop,restart)
//@param name name of servie (.e.g apache2 ,mysql etc.)
//@return serviceLink the link we created
var createServiceLink = (type, name) => {
    let allowedTypes = ['start', 'stop', 'restart'];
    if (allowedTypes.indexOf(type) == -1) {
        throw new IllegalArgumentError('Service link type must be one of the following:start,stop,restart');
    }
    let serviceLink = document.createElement('a');
    serviceLink.href = `javascript:${type}Service('${name}')`; //e.g. type start -> javascript:startService()
    serviceLink.innerText = `${type[0].toUpperCase()+type.slice(1)} Service` //Return first char of string capitallized and then return  the
        //rest of the string without the first char
    serviceLink.classList.add('center-block');
    return serviceLink;
};
//Utility function that takes a list of services and creates a table with info from each service
//@param data an array of service objects
var createServiceListTable = (data) => {
    if (!data.length) {
        bootbox.alert({
            title: "Error",
            message: "Fuck something happened",
            className: "dialog-error"
        })
        return;
    }
    var fragment = document.createDocumentFragment();
    for (let i = 0, max = data.length; i < max; i++) {
        let row = document.createElement("tr");
        row.id = data[i].name;
        let service = document.createElement("td");
        service.innerText = data[i].name;
        let status = document.createElement("td");
        status.innerText = data[i].status;
        let actionCell = document.createElement("td");
        let actionLink = document.createElement("a");
        let startServiceLink = createServiceLink('start', data[i].name);
        let stopServiceLink = createServiceLink('stop', data[i].name);
        let restartServiceLink = createServiceLink('restart', data[i].name);
        actionCell.appendChild(startServiceLink);
        actionCell.appendChild(stopServiceLink);
        actionCell.appendChild(restartServiceLink);
        row.appendChild(service);
        row.appendChild(status);
        row.appendChild(actionCell);
        fragment.appendChild(row);
    }
    document.querySelector("tbody").innerHTML = "";
    document.querySelector("tbody").appendChild(fragment);
};
var ipcRendererBinder = new Binder(ipcRenderer, {
    'receive-services': (event, data) => {
        services = data;<commit_msg>provide a useful error if no data received from main process<commit_after>const {
    ipcRenderer
} = require('electron');
const {
    success,
    error,
    info
} = require('./custom_modules/utils.js');
const Binder = require('./classes/binder.js');
var services = [];
//Utility function that will help us
//create the 3 types of links we need for our service list(Start, Stop,Restart)
//@param type Type of link to create(start,stop,restart)
//@param name name of servie (.e.g apache2 ,mysql etc.)
//@return serviceLink the link we created
var createServiceLink = (type, name) => {
    let allowedTypes = ['start', 'stop', 'restart'];
    if (allowedTypes.indexOf(type) == -1) {
        throw new IllegalArgumentError('Service link type must be one of the following:start,stop,restart');
    }
    let serviceLink = document.createElement('a');
    serviceLink.href = `javascript:${type}Service('${name}')`; //e.g. type start -> javascript:startService()
    serviceLink.innerText = `${type[0].toUpperCase()+type.slice(1)} Service` //Return first char of string capitallized and then return  the
        //rest of the string without the first char
    serviceLink.classList.add('center-block');
    return serviceLink;
};
//Utility function that takes a list of services and creates a table with info from each service
//@param data an array of service objects
var createServiceListTable = (data) => {
    if (!data.length) {
        error('Something happened.No data received.Probably unsupported platform');
        return;
    }
    var fragment = document.createDocumentFragment();
    for (let i = 0, max = data.length; i < max; i++) {
        let row = document.createElement("tr");
        row.id = data[i].name;
        let service = document.createElement("td");
        service.innerText = data[i].name;
        let status = document.createElement("td");
        status.innerText = data[i].status;
        let actionCell = document.createElement("td");
        let actionLink = document.createElement("a");
        let startServiceLink = createServiceLink('start', data[i].name);
        let stopServiceLink = createServiceLink('stop', data[i].name);
        let restartServiceLink = createServiceLink('restart', data[i].name);
        actionCell.appendChild(startServiceLink);
        actionCell.appendChild(stopServiceLink);
        actionCell.appendChild(restartServiceLink);
        row.appendChild(service);
        row.appendChild(status);
        row.appendChild(actionCell);
        fragment.appendChild(row);
    }
    document.querySelector("tbody").innerHTML = "";
    document.querySelector("tbody").appendChild(fragment);
};
var ipcRendererBinder = new Binder(ipcRenderer, {
    'receive-services': (event, data) => {
        services = data;
{'fraction_non_alphanumeric': 0.1303095752339813, 'fraction_numerical': 0.0021598272138228943, 'mean_word_length': 3.420843277645187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5231951', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1493, 'n_words': 430}