<commit_before>/*globals define, angular, WebGMEGlobal*/
/*jshint browser: true*/
/**
 * @author nabana / https://github.com/nabana
 * @author lattmann / https://github.com/lattmann
 */

define([
    'js/logger',
    'js/Constants',
    'angular',
    'js/Dialogs/Projects/ProjectsDialog',
    'js/Dialogs/Commit/CommitDialog',
    'js/Dialogs/Merge/MergeDialog',
    'js/Dialogs/ProjectRepository/ProjectRepositoryDialog',
    'js/Dialogs/Branches/BranchesDialog',
    'common/storage/util',
    'isis-ui-components/simpleDialog/simpleDialog',
    'text!js/Dialogs/Projects/templates/DeleteDialogTemplate.html',
    'text!js/Dialogs/Projects/templates/TransferDialogTemplate.html',
    'js/Utils/SaveToDisk'
], function (Logger,
             CONSTANTS,
             ng,
             ProjectsDialog,
             CommitDialog,
             MergeDialog,
             ProjectRepositoryDialog,
             BranchesDialog,
             StorageUtil,
             ConfirmDialog,
             DeleteDialogTemplate,
             TransferDialogTemplate,
             saveToDisk) {
    'use strict';


    angular.module('gme.ui.ProjectNavigator', []).run(function ($templateCache) {
        $templateCache.put('DeleteDialogTemplate.html', DeleteDialogTemplate);
        $templateCache.put('TransferDialogTemplate.html', TransferDialogTemplate);
    });


    var ProjectNavigatorController;

    ProjectNavigatorController = function ($scope, gmeClient, $simpleDialog, $timeout, $window, $http) {
        var self = this;
        self.logger = Logger.create('gme:Panels:Header:ProjectNavigatorController', WebGMEGlobal.gmeConfig.client.log);
        self.$scope = $scope;
        self.$window = $window;
        self.gmeClient = gmeClient;
        self.$simpleDialog = $simpleDialog;
        self.$timeout = $timeout;
        self.$http = $http;

        // internal data representation for fast access to objects
        self.projects = {};
        self.root = {
            id: 'root',
            label: 'GME',
//            isSelected: true,
            itemClass: 'gme-root',
            menu: []
        };

        // navigation items in the navigator list
        self.navIdRoot = 0;
        self.navIdProject = 1;
        self.navIdBranch = 2;

        self.requestedSelection = null;

        self.userId = null;
        self.initialize();
    };

    ProjectNavigatorController.prototype.update = function () {
        this.logger.debug('update');
        // force ui update
        this.$timeout(function () {

        });
    };

    ProjectNavigatorController.prototype.initialize = function () {
        var self = this,
            newProject,
            manageProjects;

        // initialize model structure for view
        self.$scope.navigator = {
            items: [],
            separator: true
        };

        if (self.gmeClient) {
            manageProjects = function (/*data*/) {
                var pd = new ProjectsDialog(self.gmeClient);
                pd.show();
            };
            newProject = function (data) {
                var pd = new ProjectsDialog(self.gmeClient, true, data.newType);
                pd.show();
            };
            self.userId = self.gmeClient.getUserId();
        } else {
            newProject = function (/*data*/) {
                self.dummyProjectsGenerator('New Project ' + Math.floor(Math.random() * 10000), 4);
            };

            manageProjects = function (/*data*/) {
                self.dummyProjectsGenerator('Manage projects ' + Math.floor(Math.random() * 10000), 4);
            };
            self.userId = 'dummyUser';
        }

        // initialize root menu
        // projects id is mandatory
        self.root.menu = [
            {
                id: 'top',
                items: [
                    {
                        id: 'manageProject',
                        label: 'Manage projects ...',
                        iconClass: 'glyphicon glyphicon-folder-open',
                        action: manageProjects,
                        actionData: {}
                    },
                    {
                        id: 'newProject',
                        label: 'New project ...',
                        iconClass: 'glyphicon glyphicon-plus',
                        action: newProject,
                        actionData: {newType: 'seed'}
                    },
                    {
                        id: 'importProject',
                        label: 'Import project ...',
                        iconClass: 'glyphicon glyphicon-import',
                        action: newProject,
                        actionData: {newType: 'import'}
                    }
                ]
            },
            {
                id: 'projects',
                label: 'Recent projects',
                totalItems: 20,
                items: [],
                showAllItems: newProject
            }
        ];

        if (self.gmeClient) {
            self.initWithClient();
            self.$scope.ownerList = [self.userId];
        } else {
            self.initTestData();
            self.$scope.ownerList = [self.userId];<commit_msg>Fixes issue, that 'Show all...' on navigator bar causes exception<commit_after>/*globals define, angular, WebGMEGlobal*/
/*jshint browser: true*/
/**
 * @author nabana / https://github.com/nabana
 * @author lattmann / https://github.com/lattmann
 */

define([
    'js/logger',
    'js/Constants',
    'angular',
    'js/Dialogs/Projects/ProjectsDialog',
    'js/Dialogs/Commit/CommitDialog',
    'js/Dialogs/Merge/MergeDialog',
    'js/Dialogs/ProjectRepository/ProjectRepositoryDialog',
    'js/Dialogs/Branches/BranchesDialog',
    'common/storage/util',
    'isis-ui-components/simpleDialog/simpleDialog',
    'text!js/Dialogs/Projects/templates/DeleteDialogTemplate.html',
    'text!js/Dialogs/Projects/templates/TransferDialogTemplate.html',
    'js/Utils/SaveToDisk'
], function (Logger,
             CONSTANTS,
             ng,
             ProjectsDialog,
             CommitDialog,
             MergeDialog,
             ProjectRepositoryDialog,
             BranchesDialog,
             StorageUtil,
             ConfirmDialog,
             DeleteDialogTemplate,
             TransferDialogTemplate,
             saveToDisk) {
    'use strict';


    angular.module('gme.ui.ProjectNavigator', []).run(function ($templateCache) {
        $templateCache.put('DeleteDialogTemplate.html', DeleteDialogTemplate);
        $templateCache.put('TransferDialogTemplate.html', TransferDialogTemplate);
    });


    var ProjectNavigatorController;

    ProjectNavigatorController = function ($scope, gmeClient, $simpleDialog, $timeout, $window, $http) {
        var self = this;
        self.logger = Logger.create('gme:Panels:Header:ProjectNavigatorController', WebGMEGlobal.gmeConfig.client.log);
        self.$scope = $scope;
        self.$window = $window;
        self.gmeClient = gmeClient;
        self.$simpleDialog = $simpleDialog;
        self.$timeout = $timeout;
        self.$http = $http;

        // internal data representation for fast access to objects
        self.projects = {};
        self.root = {
            id: 'root',
            label: 'GME',
//            isSelected: true,
            itemClass: 'gme-root',
            menu: []
        };

        // navigation items in the navigator list
        self.navIdRoot = 0;
        self.navIdProject = 1;
        self.navIdBranch = 2;

        self.requestedSelection = null;

        self.userId = null;
        self.initialize();
    };

    ProjectNavigatorController.prototype.update = function () {
        this.logger.debug('update');
        // force ui update
        this.$timeout(function () {

        });
    };

    ProjectNavigatorController.prototype.initialize = function () {
        var self = this,
            newProject,
            manageProjects;

        // initialize model structure for view
        self.$scope.navigator = {
            items: [],
            separator: true
        };

        if (self.gmeClient) {
            manageProjects = function (/*data*/) {
                var pd = new ProjectsDialog(self.gmeClient);
                pd.show();
            };
            newProject = function (data) {
                var pd = new ProjectsDialog(self.gmeClient, true, data.newType);
                pd.show();
            };
            self.userId = self.gmeClient.getUserId();
        } else {
            newProject = function (/*data*/) {
                self.dummyProjectsGenerator('New Project ' + Math.floor(Math.random() * 10000), 4);
            };

            manageProjects = function (/*data*/) {
                self.dummyProjectsGenerator('Manage projects ' + Math.floor(Math.random() * 10000), 4);
            };
            self.userId = 'dummyUser';
        }

        // initialize root menu
        // projects id is mandatory
        self.root.menu = [
            {
                id: 'top',
                items: [
                    {
                        id: 'manageProject',
                        label: 'Manage projects ...',
                        iconClass: 'glyphicon glyphicon-folder-open',
                        action: manageProjects,
                        actionData: {}
                    },
                    {
                        id: 'newProject',
                        label: 'New project ...',
                        iconClass: 'glyphicon glyphicon-plus',
                        action: newProject,
                        actionData: {newType: 'seed'}
                    },
                    {
                        id: 'importProject',
                        label: 'Import project ...',
                        iconClass: 'glyphicon glyphicon-import',
                        action: newProject,
                        actionData: {newType: 'import'}
                    }
                ]
            },
            {
                id: 'projects',
                label: 'Recent projects',
                totalItems: 20,
                items: [],
                showAllItems: manageProjects
            }
        ];

        if (self.gmeClient) {
            self.initWithClient();
            self.$scope.ownerList = [self.userId];
        } else {
            self.initTestData();
            self.$scope.ownerList = [self.userId];
{'fraction_non_alphanumeric': 0.11309867282169649, 'fraction_numerical': 0.0032698595883823814, 'mean_word_length': 1.4765420338175756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '6886269', 'n_tokens_mistral': 2738, 'n_tokens_neox': 2593, 'n_words': 498}