function UrlEditBottomBarCtrl($scope,Debug,Url) {
    //点击以后，启动当前的
    //请求服务器获取一个ID，
        //服务器随机生成一个port ,创建一个docker服务。返回前端一个URL
    // 
    $scope.element_options = {
		is_debug: false
    }
    $scope.term_url = "";
    $scope.mock_url = "";
    $scope.openTerm = function(event){
        window.open($scope.term_url);
    }

    function getDebugStatus(){
		Debug.getDebugStatus({},function(res){
			if(res.is_debug){
				$scope.element_options.is_debug = true;
                $scope.term_url = res.term_url;
                $scope.mock_url = res.mock_url;
			}else{
				$scope.element_options.is_debug = false;
			}
		})
    }
    getDebugStatus();
	$scope.startDebug = function(){
        
        Debug.initTerm({},function(res){
            toastr.success("调试环境创建完毕")
            $scope.element_options.is_debug = true;
            $scope.term_url = res.term_url;
            $scope.mock_url = res.mock_url;
        })
	}

	$scope.stopDebug = function(){
        Debug.stop({},function(res){
            if(res.code == "0000"){
                toastr.success("调试环境已经关闭")
                $scope.element_options.is_debug = false; 
            }else{
                toastr.warning("环境关闭失败");
            }
            
        });
    }
    
    $scope.subDebugEnv = function(){
        // Debug.
    }

    $scope.subRelEnv = function(){
        console.log($scope.current_url)
        Url.subRelaceEnv({_id:$scope.current_url._id},function(res){
            if(res.code == "0000"){
                $scope.current_url.relace_flg = res.data.relace_flg;
                $scope.current_url.relace_version = res.data.relace_version;
                $scope.current_url.last_version = res.data.last_version;
                console.log($scope.current_url)
                toastr.success(`发布成功:${res.data.relace_version}`)
            }else{
                toastr.danger("发布失败")
            }
        })
    }
}   
UrlEditBottomBarCtrl.$inject = ["$scope","Debug","Url"];
BP.controller("UrlEditBottomBarCtrl", UrlEditBottomBarCtrl);    