(function() {
    'use strict';

    // generic UI For listing files
    angular.module('ti_common').directive('ticComponentVersionInfo', ticComponentVersionInfo);

    function ticComponentVersionInfo() {
        return {
            restrict: 'E',
            templateUrl: 'ti_common/nav/component_version_info.html',
            scope: {},
            controller: ticComponentVersionInfoCtrl,
            controllerAs: 'vm',
            bindToController: true
        };
    }

    ticComponentVersionInfoCtrl.$inject = ['ticAgentAPI','navSrv'];
    function ticComponentVersionInfoCtrl(ticAgentAPI,navSrv) {
        let vm = this;
        vm.navSrv = navSrv;
        vm.componentsList = [];
        vm.showHideText = 'Show Components';
        vm.showingComponents = false;
        
       ticAgentAPI.getComponentInfo(TICloudAgent.getOS())
            .then((response) => {
				vm.componentsList = JSON.parse(response.data);
			});
        
        vm.showHide = function() {
            if ( vm.showingComponents ) {
                vm.showingComponents = false;
                vm.showHideText = 'Show Components';
            } else {
                vm.showingComponents = true;
                vm.showHideText = 'Hide Components';
            }
        };
    }
})();