{"size": 2729, "ext": "js", "max_stars_repo_path": "app/frontend/components/layers/layer-editor.js", "max_stars_repo_name": "SummaLabs/DLS", "max_stars_repo_stars_event_min_datetime": "2017-09-04T17:40:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-16T23:08:34.000Z", "max_issues_repo_path": "app/frontend/components/layers/layer-editor.js", "max_issues_repo_name": "AymanNabih/DLS", "max_issues_repo_issues_event_min_datetime": "2017-10-09T12:52:54.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-29T02:48:38.000Z", "max_forks_repo_path": "app/frontend/components/layers/layer-editor.js", "max_forks_repo_name": "AymanNabih/DLS", "max_forks_repo_forks_event_min_datetime": "2017-10-07T17:29:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-23T22:01:54.000Z"}
{"max_stars_count": 32, "max_issues_count": 3, "max_forks_count": 20, "avg_line_length": 41.9846153846, "max_line_length": 106, "alphanum_fraction": 0.5441553683}
'use strict';

angular
    .module('layerEditor', ['ngMaterial',
        'convolution1dEditor',
        'convolution2dEditor',
        'convolution3dEditor',
        'pooling1dEditor',
        'pooling2dEditor',
        'pooling3dEditor',
        'activationEditor',
        'flattenEditor',
        'mergeEditor',
        'denseEditor',
        'upsampling2dEditor',
        'upsampling3dEditor',
        'datainputEditor',
        'dataoutputEditor'
    ])
    .directive('layerEditor', ['$compile', function($compile) {

        function buildTemplate(layer) {
            var layerDirectives =
            {
                'convolution1d':    '<convolution1d-editor layer-data=elem.layer></convolution1d-editor>',
                'convolution2d':    '<convolution2d-editor layer-data=elem.layer></convolution2d-editor>',
                'convolution3d':    '<convolution3d-editor layer-data=elem.layer></convolution3d-editor>',
                'pooling1d':        '<pooling1d-editor layer-data=elem.layer></pooling1d-editor>',
                'pooling2d':        '<pooling2d-editor layer-data=elem.layer></pooling2d-editor>',
                'pooling3d':        '<pooling3d-editor layer-data=elem.layer></pooling3d-editor>',
                'activation':       '<activation-editor layer-data=elem.layer></activation-editor>',
                'merge':            '<merge-editor layer-data=elem.layer></merge-editor>',
                'flatten':          '<flatten-editor layer-data=elem.layer></flatten-editor>',
                'dense':            '<dense-editor layer-data=elem.layer></dense-editor>',
                'upsampling2d':     '<upsampling2d-editor layer-data=elem.layer></upsampling2d-editor>',
                'upsampling3d':     '<upsampling3d-editor layer-data=elem.layer></upsampling3d-editor>',
                'datainput':        '<datainput-editor layer-data=elem.layer></datainput-editor>',
                'dataoutput':       '<dataoutput-editor layer-data=elem.layer></dataoutput-editor>'
            };
            return layerDirectives[layer.layerType];
        }
        
        function ElementController($scope, $element) {
            let self = this;
            $scope.$watch('layerData', function(newValue, oldValue) {
                self.layer = $scope.layerData;
                if (!self.layer)
                    return;
                let template = buildTemplate(self.layer);

                $element.html(template);
                $compile($element.contents())($scope);

            });
        }

        return {
            controller: ElementController,
            controllerAs: 'elem',
            scope: {
                layerData: '='
            }
        };
    }]);
