<commit_before>var mainModule = angular.module('mainModule', ['ui.slider', 'angularResizable']);

mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', function ($scope, $http, $q, remote, config) {

    $scope.opent2t = require('opent2t').OpenT2T;
    $scope.config = config;
    $scope.remoteApp = remote.app;
    $scope.onboardingMap = {};
    $scope.configuredHubs = [];
    $scope.selectedHub = undefined;
    $scope.selectedPlatform = undefined;
    $scope.hubData = {};
    $scope.state = { currentOutput: '', showOutput: true, ready: false, busy: false };
    $scope.loadingMessage = '';

    // by default ensure loading screen shows on app launch
    $scope.loading = true;
    $scope.onboarding = false;

    $scope.loadData = function () {
        $q.all([$scope.loadOnboardingInfo()]);

        $scope.remoteApp.loadConfigs().then((files) => {
            $scope.configuredHubs = files;
            $scope.loading = false;
            $scope.state.ready = true;
        });
    }

    $scope.loadOnboardingInfo = function () {
        var LocalPackageSourceClass = require('opent2t/package/LocalPackageSource').LocalPackageSource;
        var localPackageSource = new LocalPackageSourceClass("./node_modules");

        return localPackageSource.getAllPackageInfoAsync().then((packages) => {

            // default use the first package
            var p = packages[0];
            if (p.translators.length > 0) {

                var tinfo = p.translators[0];
                return tinfo.onboardingFlow;
            }
        });
    }

    $scope.selectHub = function (hub) {
        $scope.selectedPlatform = undefined;
        $scope.loadingMessage = 'Loading Hub';

        if (hub !== undefined && $scope.hubData[hub.translatorPackageName] === undefined) {
            $scope.loading = true;
            getHubData(hub).then(platforms => {
                $scope.selectedHub = hub;
                $scope.selectPlatform(platforms[0]);
            }).catch(error => {
                $scope.loading = false;
                logError(error);
            });
        }
        else {
            $scope.selectPlatform($scope.hubData[$scope.selectedHub.translatorPackageName][0]);
        }
    }

    $scope.refreshHub = function () {
        let currentPlatformId = $scope.selectedPlatform === undefined ? undefined : $scope.selectedPlatform.info.opent2t.controlId;
        $scope.loadingMessage = 'Refreshing Hub Data';
        $scope.loading = true;<commit_msg>Fixed a small bug when reselecting a hub.<commit_after>var mainModule = angular.module('mainModule', ['ui.slider', 'angularResizable']);

mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', function ($scope, $http, $q, remote, config) {

    $scope.opent2t = require('opent2t').OpenT2T;
    $scope.config = config;
    $scope.remoteApp = remote.app;
    $scope.onboardingMap = {};
    $scope.configuredHubs = [];
    $scope.selectedHub = undefined;
    $scope.selectedPlatform = undefined;
    $scope.hubData = {};
    $scope.state = { currentOutput: '', showOutput: true, ready: false, busy: false };
    $scope.loadingMessage = '';

    // by default ensure loading screen shows on app launch
    $scope.loading = true;
    $scope.onboarding = false;

    $scope.loadData = function () {
        $q.all([$scope.loadOnboardingInfo()]);

        $scope.remoteApp.loadConfigs().then((files) => {
            $scope.configuredHubs = files;
            $scope.loading = false;
            $scope.state.ready = true;
        });
    }

    $scope.loadOnboardingInfo = function () {
        var LocalPackageSourceClass = require('opent2t/package/LocalPackageSource').LocalPackageSource;
        var localPackageSource = new LocalPackageSourceClass("./node_modules");

        return localPackageSource.getAllPackageInfoAsync().then((packages) => {

            // default use the first package
            var p = packages[0];
            if (p.translators.length > 0) {

                var tinfo = p.translators[0];
                return tinfo.onboardingFlow;
            }
        });
    }

    $scope.selectHub = function (hub) {
        $scope.selectedPlatform = undefined;
        $scope.loadingMessage = 'Loading Hub';

        if (hub !== undefined) {
            $scope.loading = true;
            getHubData(hub).then(platforms => {
                $scope.selectedHub = hub;
                $scope.selectPlatform(platforms[0]);
            }).catch(error => {
                $scope.loading = false;
                logError(error);
            });
        }
    }

    $scope.refreshHub = function () {
        let currentPlatformId = $scope.selectedPlatform === undefined ? undefined : $scope.selectedPlatform.info.opent2t.controlId;
        $scope.loadingMessage = 'Refreshing Hub Data';
        $scope.loading = true;
{'fraction_non_alphanumeric': 0.13877467105263158, 'fraction_numerical': 0.00390625, 'mean_word_length': 2.414035087719298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6571884', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1336, 'n_words': 258}