mirror of
				https://github.com/optim-enterprises-bv/control-pane.git
				synced 2025-10-31 01:47:52 +00:00 
			
		
		
		
	sync
This commit is contained in:
		
							
								
								
									
										160
									
								
								php/clonos.php
									
									
									
									
									
								
							
							
						
						
									
										160
									
								
								php/clonos.php
									
									
									
									
									
								
							| @@ -340,6 +340,18 @@ class ClonOS | |||||||
| 				case 'userEditInfo': | 				case 'userEditInfo': | ||||||
| 					echo json_encode($this->userEditInfo()); | 					echo json_encode($this->userEditInfo()); | ||||||
| 					return;break; | 					return;break; | ||||||
|  | 				case 'vmTemplateAdd': | ||||||
|  | 					echo json_encode($this->vmTemplateAdd()); | ||||||
|  | 					return;break; | ||||||
|  | 				case 'vmTemplateEditInfo': | ||||||
|  | 					echo json_encode($this->vmTemplateEditInfo()); | ||||||
|  | 					return;break; | ||||||
|  | 				case 'vmTemplateEdit': | ||||||
|  | 					echo json_encode($this->vmTemplateEdit()); | ||||||
|  | 					return;break; | ||||||
|  | 				case 'vmTemplateRemove': | ||||||
|  | 					echo json_encode($this->vmTemplateRemove()); | ||||||
|  | 					return;break; | ||||||
| 					 | 					 | ||||||
| /*				case 'saveHelperValues': | /*				case 'saveHelperValues': | ||||||
| 					echo json_encode($this->saveHelperValues()); | 					echo json_encode($this->saveHelperValues()); | ||||||
| @@ -1302,6 +1314,7 @@ class ClonOS | |||||||
| 			return $res; | 			return $res; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
|  | 		$res['vars']['vm_vnc_password']='-nochange-'; | ||||||
| 		$res['error']=false; | 		$res['error']=false; | ||||||
| 		$res['dialog']=$form['dialog']; | 		$res['dialog']=$form['dialog']; | ||||||
| 		$res['jail_id']=$form['jail_id']; | 		$res['jail_id']=$form['jail_id']; | ||||||
| @@ -1379,6 +1392,7 @@ class ClonOS | |||||||
| 		$form['vm_ram']=$ram; | 		$form['vm_ram']=$ram; | ||||||
| 		 | 		 | ||||||
| 		$arr=array('vm_cpus','vm_ram','bhyve_vnc_tcp_bind','vm_vnc_port','interface'); | 		$arr=array('vm_cpus','vm_ram','bhyve_vnc_tcp_bind','vm_vnc_port','interface'); | ||||||
|  | 		if($form['vm_vnc_password']!='-nochange-') $arr[]='vm_vnc_password'; | ||||||
| 		foreach($arr as $a) | 		foreach($arr as $a) | ||||||
| 		{ | 		{ | ||||||
| 			if(isset($form[$a])) | 			if(isset($form[$a])) | ||||||
| @@ -1450,6 +1464,7 @@ class ClonOS | |||||||
| 			'vm_guestfs'=>'', | 			'vm_guestfs'=>'', | ||||||
| 			'bhyve_vnc_tcp_bind'=>$form['bhyve_vnc_tcp_bind'], | 			'bhyve_vnc_tcp_bind'=>$form['bhyve_vnc_tcp_bind'], | ||||||
| 			'vm_vnc_port'=>$form['vm_vnc_port'], | 			'vm_vnc_port'=>$form['vm_vnc_port'], | ||||||
|  | 			'vm_vnc_password'=>$form['vm_vnc_password'], | ||||||
| 		); | 		); | ||||||
| 		 | 		 | ||||||
| 		$iso=true; | 		$iso=true; | ||||||
| @@ -1559,7 +1574,7 @@ class ClonOS | |||||||
| 		{ | 		{ | ||||||
| 			$key_name=$nres['name']; | 			$key_name=$nres['name']; | ||||||
| 		} | 		} | ||||||
| 		$cmd="task owner=${username} mode=new /usr/local/bin/cbsd vm_obtain jname={$form['vm_name']} vm_size={$form['vm_size']} vm_cpus={$form['vm_cpus']} vm_ram={$form['vm_ram']} vm_os_type={$os_type} mask={$form['mask']} ip4_addr={$form['ip4_addr']} gw={$form['gateway']} authkey={$key_name} pw={$form['vm_password']}"; | 		$cmd="task owner=${username} mode=new /usr/local/bin/cbsd vm_obtain jname={$form['vm_name']} vm_size={$form['vm_size']} vm_cpus={$form['vm_cpus']} vm_ram={$form['vm_ram']} vm_os_type={$os_type} mask={$form['mask']} ip4_addr={$form['ip4_addr']} gw={$form['gateway']} authkey={$key_name} pw={$form['vm_password']} vnc_password={$form['vnc_password']}"; | ||||||
| 		 | 		 | ||||||
| 		$res=$this->cbsd_cmd($cmd); | 		$res=$this->cbsd_cmd($cmd); | ||||||
| 		$err='Virtual Machine is not created!'; | 		$err='Virtual Machine is not created!'; | ||||||
| @@ -2185,6 +2200,14 @@ class ClonOS | |||||||
| 	 | 	 | ||||||
| 	function runVNC($jname) | 	function runVNC($jname) | ||||||
| 	{ | 	{ | ||||||
|  | 		$query="SELECT vnc_password FROM bhyve WHERE jname='${jname}'"; | ||||||
|  | 		$res=$this->_db_local->selectAssoc($query); | ||||||
|  | 		$pass='cbsd'; | ||||||
|  | 		if($res!==false) | ||||||
|  | 		{ | ||||||
|  | 			$pass=$res['vnc_password']; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
| 		$res=$this->cbsd_cmd("vm_vncwss jname={$jname} permit={$this->_client_ip}"); | 		$res=$this->cbsd_cmd("vm_vncwss jname={$jname} permit={$this->_client_ip}"); | ||||||
| 		//$res=$this->_db_local->selectAssoc('select nodeip from local'); | 		//$res=$this->_db_local->selectAssoc('select nodeip from local'); | ||||||
| 		//$nodeip=$res['nodeip']; | 		//$nodeip=$res['nodeip']; | ||||||
| @@ -2193,7 +2216,7 @@ class ClonOS | |||||||
| 		//if(strlen($nodeip)<7) $nodeip=$this->server_name; | 		//if(strlen($nodeip)<7) $nodeip=$this->server_name; | ||||||
| 		$nodeip=$this->server_name; | 		$nodeip=$this->server_name; | ||||||
| 		 | 		 | ||||||
| 		header('Location: http://'.$nodeip.':6080/vnc_auto.html?host='.$nodeip.'&port=6080?password=cbsd'); | 		header('Location: http://'.$nodeip.':6080/vnc_auto.html?host='.$nodeip.'&port=6080?password='.$pass); | ||||||
| 		exit; | 		exit; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @@ -2228,28 +2251,28 @@ class ClonOS | |||||||
| 		$bytes = floatval($bytes); | 		$bytes = floatval($bytes); | ||||||
| 		$arBytes = array( | 		$arBytes = array( | ||||||
| 			0 => array( | 			0 => array( | ||||||
| 				"UNIT" => "TB", | 				"UNIT" => "tb", | ||||||
| 				"VALUE" => pow($bytes_in_mb, 4) | 				"VALUE" => pow($bytes_in_mb, 4) | ||||||
| 			), | 			), | ||||||
| 			1 => array( | 			1 => array( | ||||||
| 				"UNIT" => "GB", | 				"UNIT" => "gb", | ||||||
| 				"VALUE" => pow($bytes_in_mb, 3) | 				"VALUE" => pow($bytes_in_mb, 3) | ||||||
| 			), | 			), | ||||||
| 			2 => array( | 			2 => array( | ||||||
| 				"UNIT" => "MB", | 				"UNIT" => "mb", | ||||||
| 				"VALUE" => pow($bytes_in_mb, 2) | 				"VALUE" => pow($bytes_in_mb, 2) | ||||||
| 			), | 			), | ||||||
| 			3 => array( | 			3 => array( | ||||||
| 				"UNIT" => "KB", | 				"UNIT" => "kb", | ||||||
| 				"VALUE" => $bytes_in_mb | 				"VALUE" => $bytes_in_mb | ||||||
| 			), | 			), | ||||||
| 			4 => array( | 			4 => array( | ||||||
| 				"UNIT" => "B", | 				"UNIT" => "b", | ||||||
| 				"VALUE" => 1 | 				"VALUE" => 1 | ||||||
| 			), | 			), | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
| 		$result='0 MB'; | 		$result='0 mb'; | ||||||
| 		foreach($arBytes as $arItem) | 		foreach($arBytes as $arItem) | ||||||
| 		{ | 		{ | ||||||
| 			if($bytes >= $arItem["VALUE"]) | 			if($bytes >= $arItem["VALUE"]) | ||||||
| @@ -2308,7 +2331,7 @@ class ClonOS | |||||||
| 	{ | 	{ | ||||||
| 		$db=new Db('base','storage_media'); | 		$db=new Db('base','storage_media'); | ||||||
| 		$res=$db->select('select * from media where type="iso"'); | 		$res=$db->select('select * from media where type="iso"'); | ||||||
| 		if($res===false || empty($res)) return; | 		if($res===false || empty($res)) return array(); //array('error'=>true,'error_message'=>'Profile ISO is not find!'); | ||||||
| 		 | 		 | ||||||
| 		$sel=''; | 		$sel=''; | ||||||
| 		//if(empty($iso)) $sel='#sel#'; | 		//if(empty($iso)) $sel='#sel#'; | ||||||
| @@ -2577,4 +2600,123 @@ class ClonOS | |||||||
| 			return array('DB connection error!'); | 			return array('DB connection error!'); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	function vmTemplateAdd() | ||||||
|  | 	{ | ||||||
|  | 		$form=$this->form; | ||||||
|  | 		 | ||||||
|  | 		$name=$form['name']; | ||||||
|  | 		$description=$form['description']; | ||||||
|  | 		$pkg_vm_ram=$form['pkg_vm_ram']; | ||||||
|  | 		$pkg_vm_disk=$form['pkg_vm_disk']; | ||||||
|  | 		$pkg_vm_cpus=$form['pkg_vm_cpus']; | ||||||
|  | 		$owner=$this->_user_info['username']; | ||||||
|  | 		$query="insert into vmpackages (name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus,owner,timestamp) | ||||||
|  | 			values | ||||||
|  | 			('${name}','${description}','${pkg_vm_ram}','${pkg_vm_disk}','${pkg_vm_cpus}','${owner}',datetime('now','localtime'))"; | ||||||
|  | 		 | ||||||
|  | 		$db=new Db('base','local'); | ||||||
|  | 		if($db!==false) | ||||||
|  | 		{ | ||||||
|  | 			$res=$db->insert($query); | ||||||
|  | 			if($res!==false) | ||||||
|  | 			{ | ||||||
|  | 				if(!$res['error']) | ||||||
|  | 					return $this->messageSuccess($res); | ||||||
|  | 				else | ||||||
|  | 					return $this->messageError('sql error!',$res); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 				return $this->messageError('sql error!'); | ||||||
|  | 		}else{ | ||||||
|  | 			return $this->messageError('data incorrect!'); //array('error'=>true,'error_message'=>'data incorrect!'); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	function vmTemplateEditInfo() | ||||||
|  | 	{ | ||||||
|  | 		$form=$this->form; | ||||||
|  | 		 | ||||||
|  | 		if(!isset($form['template_id'])) | ||||||
|  | 		{ | ||||||
|  | 			return $this->messageError('incorrect data!'); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		$tpl_id=$form['template_id']; | ||||||
|  | 		$db=new Db('base','local'); | ||||||
|  | 		if($db!==false) | ||||||
|  | 		{ | ||||||
|  | 			$res=$db->selectAssoc("select name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus from vmpackages where id=${tpl_id}"); | ||||||
|  | 			return $this->messageSuccess(array('vars'=>$res,'template_id'=>$tpl_id)); | ||||||
|  | 		}else{ | ||||||
|  | 			return $this->messageError('DB connection error!'); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	function vmTemplateEdit() | ||||||
|  | 	{ | ||||||
|  | 		$form=$this->form; | ||||||
|  | 		 | ||||||
|  | 		$id=$form['template_id']; | ||||||
|  | 		if(!isset($id) || $id<1) $this->messageError('wrong data!'); | ||||||
|  | 		$name=$form['name']; | ||||||
|  | 		$description=$form['description']; | ||||||
|  | 		$pkg_vm_ram=$form['pkg_vm_ram']; | ||||||
|  | 		$pkg_vm_disk=$form['pkg_vm_disk']; | ||||||
|  | 		$pkg_vm_cpus=$form['pkg_vm_cpus']; | ||||||
|  | 		$owner=$this->_user_info['username']; | ||||||
|  | 		$query="update vmpackages set | ||||||
|  | 			name='${name}',description='${description}', | ||||||
|  | 			pkg_vm_ram='${pkg_vm_ram}',pkg_vm_disk='${pkg_vm_disk}', | ||||||
|  | 			pkg_vm_cpus='${pkg_vm_cpus}',owner='${owner}',timestamp=datetime('now','localtime') where id=${id}"; | ||||||
|  | 		 | ||||||
|  | 		$db=new Db('base','local'); | ||||||
|  | 		if($db!==false) | ||||||
|  | 		{ | ||||||
|  | 			$res=$db->update($query); | ||||||
|  | 			if($res!==false) | ||||||
|  | 			{ | ||||||
|  | 				return $this->messageSuccess($res); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 				return $this->messageError('sql error!'); | ||||||
|  | 		}else{ | ||||||
|  | 			return $this->messageError('db connection error!'); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	function vmTemplateRemove() | ||||||
|  | 	{ | ||||||
|  | 		$form=$this->form; | ||||||
|  | 		 | ||||||
|  | 		$id=$form['template_id']; | ||||||
|  | 		if(is_numeric($id) && $id>0) | ||||||
|  | 		{ | ||||||
|  | 			$query="delete from vmpackages where id=${id}"; | ||||||
|  | 			$db=new Db('base','local'); | ||||||
|  | 			if($db!==false) | ||||||
|  | 			{ | ||||||
|  | 				$res=$db->select($query); | ||||||
|  | 				return $this->messageSuccess($res); | ||||||
|  | 			}else{ | ||||||
|  | 				return $this->messageError('DB connection error!'); | ||||||
|  | 			} | ||||||
|  | 		}else{ | ||||||
|  | 			return $this->messageError('wrong data!'); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	function messageError($message,$vars=array()) | ||||||
|  | 	{ | ||||||
|  | 		$rarr=array( | ||||||
|  | 			'error'=>true, | ||||||
|  | 			'error_message'=>$message, | ||||||
|  | 		); | ||||||
|  | 		return array_merge($rarr,$vars); | ||||||
|  | 	} | ||||||
|  | 	function messageSuccess($vars=array()) | ||||||
|  | 	{ | ||||||
|  | 		$rarr=array( | ||||||
|  | 			'error'=>false, | ||||||
|  | 		); | ||||||
|  | 		return array_merge($rarr,$vars); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| @@ -167,14 +167,28 @@ class Config | |||||||
| 		) | 		) | ||||||
| 	); | 	); | ||||||
| 	 | 	 | ||||||
|  | 	public $os_types_obtain=array(); | ||||||
|  | 	 | ||||||
| 	function __construct() | 	function __construct() | ||||||
| 	{ | 	{ | ||||||
| 		$array=array(); | 		$array=array(); | ||||||
| 		$array1=array(); | 		$array1=array(); | ||||||
| 		$res=ClonOS::cbsd_cmd('get_bhyve_profiles'); | 		// $res=ClonOS::cbsd_cmd('get_bhyve_profiles --template'); for obtain/library | ||||||
|  | 		$res=ClonOS::cbsd_cmd('get_bhyve_profiles --vm'); | ||||||
| 		if($res['retval']==0) | 		if($res['retval']==0) | ||||||
| 		{ | 		{ | ||||||
| 			$res=json_decode($res['message'],true); | 			$this->os_types=$this->create_bhyve_profiles($res); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		$res1=ClonOS::cbsd_cmd('get_bhyve_profiles --template'); | ||||||
|  | 		if($res1['retval']==0) | ||||||
|  | 		{ | ||||||
|  | 			$this->os_types_obtain=$this->create_bhyve_profiles($res1); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	function create_bhyve_profiles($info) | ||||||
|  | 	{ | ||||||
|  | 		$res=json_decode($info['message'],true); | ||||||
| 		if(!empty($res))foreach($res as $item) | 		if(!empty($res))foreach($res as $item) | ||||||
| 		{ | 		{ | ||||||
| 			$os_name=$this->os_types_names[$item['type']]; | 			$os_name=$this->os_types_names[$item['type']]; | ||||||
| @@ -187,30 +201,35 @@ class Config | |||||||
| 		} | 		} | ||||||
| 		if(!empty($array))foreach($array as $item) $array1[]=$item; | 		if(!empty($array))foreach($array as $item) $array1[]=$item; | ||||||
| 		unset($array); | 		unset($array); | ||||||
| 			$this->os_types=$array1; | 		return $array1; | ||||||
| 		} | 		//$this->os_types=$array1; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	function os_types_create($obtain='new') | 	function os_types_create($obtain='new') | ||||||
| 	{ | 	{ | ||||||
| 		$obtain=($obtain=='obtain'); | 		$obtain=($obtain=='obtain'); | ||||||
|  | 		if($obtain) | ||||||
|  | 			$info=$this->os_types_obtain; | ||||||
|  | 		else | ||||||
|  | 			$info=$this->os_types; | ||||||
| 		 | 		 | ||||||
| 		$html=''; | 		$html=''; | ||||||
| 		foreach($this->os_types as $num1=>$os) | 		foreach($info as $num1=>$os) | ||||||
| 		{ | 		{ | ||||||
| 			$obtain_count=0; | 			$obtain_count=0; | ||||||
| 			$html_tmp='					<optgroup label="'.$os['os'].'">'.PHP_EOL; | 			$html_tmp='					<optgroup label="'.$os['os'].'">'.PHP_EOL; | ||||||
| 			$items=$os['items']; | 			$items=$os['items']; | ||||||
| 			foreach($items as $num2=>$item) | 			foreach($items as $num2=>$item) | ||||||
| 			{ | 			{ | ||||||
| 				if(!isset($item['obtain'])) $item['obtain']=false; | 				//if(!isset($item['obtain'])) $item['obtain']=false; | ||||||
| 				if(!$obtain || $item['obtain']) | 				//if(!$obtain || $item['obtain']) | ||||||
| 					$html_tmp.='						<option value="'.$num1.'.'.$num2.'">'.$item['name'].'</option>'.PHP_EOL; | 					$html_tmp.='						<option value="'.$num1.'.'.$num2.'">'.$item['name'].'</option>'.PHP_EOL; | ||||||
| 				if($item['obtain']) $obtain_count++; | 				//if($item['obtain']) $obtain_count++; | ||||||
| 			} | 			} | ||||||
| 			$html_tmp.='					</optgroup>'.PHP_EOL; | 			$html_tmp.='					</optgroup>'.PHP_EOL; | ||||||
| 			 | 			 | ||||||
| 			if(!$obtain || $obtain_count>0) $html.=$html_tmp; | 			//if(!$obtain || $obtain_count>0) $html.=$html_tmp; | ||||||
|  | 			$html.=$html_tmp; | ||||||
| 		} | 		} | ||||||
| 		return $html; | 		return $html; | ||||||
| 	} | 	} | ||||||
| @@ -228,4 +247,42 @@ class Config | |||||||
| 		} | 		} | ||||||
| 		return $html; | 		return $html; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	function vm_packages_list() | ||||||
|  | 	{ | ||||||
|  | 		$db=new Db('base','local'); | ||||||
|  | 		$res=$db->select('select id,name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus,owner from vmpackages order by name asc;'); | ||||||
|  | 		 | ||||||
|  | 		$html='<option value="0"></option>'; | ||||||
|  | 		$min=0; | ||||||
|  | 		$min_id=0; | ||||||
|  | 		if(!empty($res))foreach($res as $item) | ||||||
|  | 		{ | ||||||
|  | 			$cpu=$item['pkg_vm_cpus']; | ||||||
|  | 			$ram=trim($item['pkg_vm_ram']); | ||||||
|  | 			$ed=substr($ram,-1); | ||||||
|  | 			if($ed=='b') | ||||||
|  | 			{ | ||||||
|  | 				$ed=substr($ram,-2,1).'b'; | ||||||
|  | 				$ram=substr($ram,0,-2); | ||||||
|  | 			} | ||||||
|  | 			if($ed=='m' || $ed=='g') $ed.='b'; | ||||||
|  | 			if($ed=='mb') | ||||||
|  | 			{ | ||||||
|  | 				$ram1=substr($ram,0,-1); | ||||||
|  | 				$ram1=$ram1/1000000; | ||||||
|  | 			} | ||||||
|  | 			if($ed=='gb') | ||||||
|  | 			{ | ||||||
|  | 				$ram1=substr($ram,0,-1); | ||||||
|  | 				$ram1=$ram1/1000; | ||||||
|  | 			} | ||||||
|  | 			$res1=$cpu+$ram1; | ||||||
|  | 			if($min>$res1 || $min==0) {$min=$res1;$min_id=$item['id'];} | ||||||
|  | 			 | ||||||
|  | 			$name='<strong>'.$item['name'].'</strong> (cpu: '.$cpu.'; ram: '.$ram.'; hdd: '.$item['pkg_vm_disk'].')'; | ||||||
|  | 			$html.='					<option value="'.$item['id'].'" title="'.$item['description'].'">'.$name.'</option>'.PHP_EOL; | ||||||
|  | 		} | ||||||
|  | 		return array('html'=>$html,'min_id'=>$min_id); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| @@ -393,11 +393,15 @@ thead td, thead th { | |||||||
| } | } | ||||||
| .tfill thead td, td { | .tfill thead td, td { | ||||||
| 	border-style: solid; | 	border-style: solid; | ||||||
| 	border-width: 0 1px 1px 0; | 	border-width: 0;	/* 0 1px 1px 0; */ | ||||||
| 	border-color: white; | 	border-color: white; | ||||||
| } | } | ||||||
|  | .tfill thead td { | ||||||
|  | 	border-bottom: 1px solid #f0f0f0; | ||||||
|  | } | ||||||
| .tfill td { | .tfill td { | ||||||
| 	background: #D8E6F3; | 	background: #D8E6F3; | ||||||
|  | 	border-bottom: 1px solid #f0f0f0; | ||||||
| } | } | ||||||
| thead td:first-child, td:first-child { | thead td:first-child, td:first-child { | ||||||
| 	text-align: left; | 	text-align: left; | ||||||
| @@ -423,6 +427,18 @@ thead td:first-child, td:first-child { | |||||||
| .tsimple tbody tr:nth-child(2n){ | .tsimple tbody tr:nth-child(2n){ | ||||||
| 	background-color: #fafafa; | 	background-color: #fafafa; | ||||||
| } | } | ||||||
|  | .tsimple tbody tr:nth-child(2n):hover { | ||||||
|  | 	background-color:#fbfbe3;	/*#fdfded;*/ | ||||||
|  | } | ||||||
|  | .tsimple tbody tr:hover { | ||||||
|  | 	background-color:#fcfccc	/*#ffffef;*/ | ||||||
|  | } | ||||||
|  | .tsimple tbody tr.del { | ||||||
|  | 	background-color: #ffe6e6;	/* #ffcccc; */ | ||||||
|  | } | ||||||
|  | .tsimple tbody tr.del:nth-child(2n) { | ||||||
|  | 	background-color:#fde3e3; | ||||||
|  | } | ||||||
| .tsimple .txtleft { | .tsimple .txtleft { | ||||||
| 	text-align:left; | 	text-align:left; | ||||||
| } | } | ||||||
| @@ -544,6 +560,9 @@ td.jstatus, | |||||||
| td.small { | td.small { | ||||||
| 	font-size:small; | 	font-size:small; | ||||||
| } | } | ||||||
|  | td.x-small { | ||||||
|  | 	font-size:x-small; | ||||||
|  | } | ||||||
| tr.busy .jstatus, | tr.busy .jstatus, | ||||||
| tr.busy.s-on .jstatus, | tr.busy.s-on .jstatus, | ||||||
| tr.busy.s-off .jstatus { | tr.busy.s-off .jstatus { | ||||||
| @@ -589,6 +608,10 @@ tr.busy.maintenance .ops span { | |||||||
| 	white-space:nowrap; | 	white-space:nowrap; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .vnc-grey { | ||||||
|  | 	color:gray; | ||||||
|  | } | ||||||
|  |  | ||||||
| /* td.ops span.icon-play:before { | /* td.ops span.icon-play:before { | ||||||
| 	margin-left:.2em; | 	margin-left:.2em; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -24,20 +24,27 @@ err_messages.add({ | |||||||
| 				<input type="text" name="vm_name" value="" pattern="[^0-9]{1}[a-zA-Z0-9]{1,}" required="required" class="edit-disable" /> | 				<input type="text" name="vm_name" value="" pattern="[^0-9]{1}[a-zA-Z0-9]{1,}" required="required" class="edit-disable" /> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p class="new"> | 			<p class="new"> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM Image size');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM template (cpu, ram, hdd)');?>:</span> | ||||||
| 				<input type="text" name="vm_size" value="" pattern="^[0-9]+g$" placeholder="10g" required="required" class="edit-disable" /> | 				<select name="vm_packages" onchange="clonos.onChangePkgTemplate(this,event);"> | ||||||
|  | <?php $vm_res=$this->config->vm_packages_list(); echo $vm_res['html']; ?> | ||||||
|  | 				</select> | ||||||
|  | 				<script type="text/javascript">clonos.vm_packages_new_min_id=<?php echo $vm_res['min_id']; ?>;</script> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM CPUs');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM CPUs');?>:</span> | ||||||
| 				<span class="range"> | 				<span class="range"> | ||||||
| 					<input type="range" name="vm_cpus" class="vHorizon" min="1" max="16" value="1" style="margin:6px 0;" id="rngCpus" oninput="rngCpusShow.value=rngCpus.value" /> | 					<input type="range" name="vm_cpus" class="vHorizon" min="1" max="16" value="1" style="margin:6px 0;" id="rngCpus" oninput="rngCpusShow.value=rngCpus.value" /> | ||||||
| 					<input type="text" disabled="disabled" id="rngCpusShow" value="1" /> | 					<input type="text" disabled="disabled" id="rngCpusShow" value="1" name="vm_cpus_show" /> | ||||||
| 					<!-- input type="text" name="vm_cpus" value="" pattern="[0-9]+" placeholder="1" required="required" / --> | 					<!-- input type="text" name="vm_cpus" value="" pattern="[0-9]+" placeholder="1" required="required" / --> | ||||||
| 				</span> | 				</span> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM RAM');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM RAM');?>:</span> | ||||||
| 				<input type="text" name="vm_ram" value="" pattern="^[0-9]+\s*(g|G|gb|GB|mb|MB|m|M)$" placeholder="1g" required="required" /> | 				<input type="text" name="vm_ram" value="" pattern="^[0-9]+\s*(g|gb|mb|m|t|tb)$" placeholder="1g" required="required" /> | ||||||
|  | 			</p> | ||||||
|  | 			<p class="new"> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('VM Image size');?>:</span> | ||||||
|  | 				<input type="text" name="vm_size" value="" pattern="^[0-9]+(g|gb|t|tb)$" placeholder="10g" required="required" class="edit-disable" /> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('Attached boot ISO image');?>:</span> | 				<span class="field-name"><?php echo $this->translate('Attached boot ISO image');?>:</span> | ||||||
| @@ -56,6 +63,10 @@ err_messages.add({ | |||||||
| 				<span class="field-name"><?php echo $this->translate('VNC PORT');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VNC PORT');?>:</span> | ||||||
| 				<input type="text" name="vm_vnc_port" value="" placeholder="0" maxlength="5" /> | 				<input type="text" name="vm_vnc_port" value="" placeholder="0" maxlength="5" /> | ||||||
| 			</p> | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('VNC Password');?>:</span> | ||||||
|  | 				<input type="password" name="vm_vnc_password" value="" placeholder="3-20 symbols" pattern=".{3,20}" maxlength="20"></input> <small>— <?php echo $this->translate('use to log in VNC console');?></small> | ||||||
|  | 			</p> | ||||||
| <!--			<p> | <!--			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('CD-ROM ISO');?>:</span> | 				<span class="field-name"><?php echo $this->translate('CD-ROM ISO');?>:</span> | ||||||
| 				<select name="cd-rom"> | 				<select name="cd-rom"> | ||||||
|   | |||||||
| @@ -14,25 +14,26 @@ | |||||||
| 				<input type="text" name="vm_name" value="" pattern="[^0-9]{1}[a-zA-Z0-9]{1,}" required="required" /> | 				<input type="text" name="vm_name" value="" pattern="[^0-9]{1}[a-zA-Z0-9]{1,}" required="required" /> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM Image size');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM template (cpu, ram, hdd)');?>:</span> | ||||||
| 				<input type="text" name="vm_size" value="" pattern="^[0-9]+g$" placeholder="10g" required="required" /> | 				<select name="vm_packages" onchange="clonos.onChangePkgTemplate(this,event);"> | ||||||
|  | <?php $vm_res=$this->config->vm_packages_list(); echo $vm_res['html']; ?> | ||||||
|  | 				</select> | ||||||
|  | 				<script type="text/javascript">clonos.vm_packages_obtain_min_id=<?php echo $vm_res['min_id']; ?>;</script> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM CPUs');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM CPUs');?>:</span> | ||||||
| 				<span class="range"> | 				<span class="range"> | ||||||
| 					<input type="range" name="vm_cpus" class="vHorizon" min="1" max="16" value="1" style="margin:6px 0;" id="rngCpus" oninput="rngCpusShow.value=rngCpus.value" /> | 					<input type="range" name="vm_cpus" class="vHorizon" min="1" max="16" value="1" style="margin:6px 0;" id="rngCpus1" oninput="rngCpusShow1.value=rngCpus1.value" /> | ||||||
| 					<input type="text" disabled="disabled" id="rngCpusShow" value="1" /> | 					<input type="text" disabled="disabled" id="rngCpusShow1" value="1" name="vm_cpus_show" /> | ||||||
| 				</span> | 				</span> | ||||||
| 			</p> | 			</p> | ||||||
| <!-- |  | ||||||
| 			<p> |  | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM CPUs');?>:</span> |  | ||||||
| 				<input type="text" name="vm_cpus" value="" pattern="[0-9]+" placeholder="1" required="required" /> |  | ||||||
| 			</p> |  | ||||||
| --> |  | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('VM RAM');?>:</span> | 				<span class="field-name"><?php echo $this->translate('VM RAM');?>:</span> | ||||||
| 				<input type="text" name="vm_ram" value="" pattern="^[0-9]+g$" placeholder="1g" required="required" /> | 				<input type="text" name="vm_ram" value="" pattern="^[0-9]+(g|gb|mb|m)$" placeholder="1g" required="required" /> | ||||||
|  | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('VM Image size');?>:</span> | ||||||
|  | 				<input type="text" name="vm_size" value="" pattern="^[0-9]+(g|gb|mb|m|t|tb)$" placeholder="10g" required="required" /> | ||||||
| 			</p> | 			</p> | ||||||
| 			<p> | 			<p> | ||||||
| 				<span class="field-name"><?php echo $this->translate('IP address');?>:</span> | 				<span class="field-name"><?php echo $this->translate('IP address');?>:</span> | ||||||
| @@ -56,6 +57,10 @@ | |||||||
| <?php echo $this->config->authkeys_list(); ?> | <?php echo $this->config->authkeys_list(); ?> | ||||||
| 				</select> | 				</select> | ||||||
| 			</p> | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('VNC Password');?>:</span> | ||||||
|  | 				<input type="password" name="vnc_password" value="cbsd" placeholder="3-20 symbols" pattern=".{3,20}" maxlength="20"></input> <small>— <?php echo $this->translate('use to log in VNC. Default is');?>: cbsd</small> | ||||||
|  | 			</p> | ||||||
| 		</div> | 		</div> | ||||||
| 	</form> | 	</form> | ||||||
| 	<div class="buttons"> | 	<div class="buttons"> | ||||||
|   | |||||||
							
								
								
									
										46
									
								
								public/dialogs/vm_packages-new.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								public/dialogs/vm_packages-new.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | |||||||
|  | <script type="text/javascript"> | ||||||
|  | err_messages.add({ | ||||||
|  | 	'name':'<?php echo $this->translate("CHANGE THIS TEXT!!! Can not be empty. Name must begin with a letter / a-z / and not have any special symbols: -,.=%");?>', | ||||||
|  | 	'first_name':'<?php echo $this->translate("TYPE THIS TEXT!!!");?>', | ||||||
|  | 	'last_name':'<?php echo $this->translate("TYPE THIS TEXT!!!");?>', | ||||||
|  | }); | ||||||
|  | </script> | ||||||
|  | <dialog id="vm_packages-new" class="window-box new"> | ||||||
|  | 	<h1> | ||||||
|  | 		<span class="new"><?php echo $this->translate('Add new template');?></span> | ||||||
|  | 		<span class="edit"><?php echo $this->translate('Edit template');?></span> | ||||||
|  | 	</h1> | ||||||
|  | 	<h2><?php echo $this->translate('Template Settings');?></h2> | ||||||
|  | 	<form class="win" method="post" id="templateSettings" onsubmit="return false;"> | ||||||
|  | 		<div class="window-content"> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('Name');?>:</span> | ||||||
|  | 				<input type="text" name="name" value="" pattern=".{2,}" required="required" class="edit-enable" /> | ||||||
|  | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('Description');?>:</span> | ||||||
|  | 				<textarea name="description" rows="3"></textarea> | ||||||
|  | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('RAM Size');?>:</span> | ||||||
|  | 				<input type="text" name="pkg_vm_ram" value="" pattern="^[0-9]+\s*(g|G|gb|GB|mb|MB|m|M)$" placeholder="1g" required="required" /> | ||||||
|  | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('HDD Size');?>:</span> | ||||||
|  | 				<input type="text" name="pkg_vm_disk" value="" pattern="^[0-9]+\s*(g|G|gb|GB|mb|MB|m|M)$" placeholder="10g" required="required" /> | ||||||
|  | 			</p> | ||||||
|  | 			<p> | ||||||
|  | 				<span class="field-name"><?php echo $this->translate('CPUs Count');?>:</span> | ||||||
|  | 				<span class="range"> | ||||||
|  | 					<input type="range" name="pkg_vm_cpus" class="vHorizon" min="1" max="16" value="1" style="margin:6px 0;" id="rngCpus" oninput="rngCpusShow.value=rngCpus.value" /> | ||||||
|  | 					<input type="text" disabled="disabled" id="rngCpusShow" value="1" /> | ||||||
|  | 				</span> | ||||||
|  | 			</p> | ||||||
|  | 		</div> | ||||||
|  | 	</form> | ||||||
|  | 	<div class="buttons"> | ||||||
|  | 		<input type="button" value="<?php echo $this->translate('Add');?>" class="new button ok-but" /> | ||||||
|  | 		<input type="button" value="<?php echo $this->translate('Save');?>" class="edit button ok-but" /> | ||||||
|  | 		<input type="button" value="<?php echo $this->translate('Cancel');?>" class="button red cancel-but" /> | ||||||
|  | 	</div> | ||||||
|  | </dialog> | ||||||
| @@ -188,6 +188,13 @@ var clonos={ | |||||||
| 				this.trids=this.getTrIdsForCheck('bhyveslist'); | 				this.trids=this.getTrIdsForCheck('bhyveslist'); | ||||||
| 				this.updateBhyveISO(); | 				this.updateBhyveISO(); | ||||||
| 				this.updateBhyveOSProfile(); | 				this.updateBhyveOSProfile(); | ||||||
|  | 				if(typeof this.vm_packages_new_min_id!='undefined') | ||||||
|  | 					$('#bhyveSettings select[name="vm_packages"]').val(this.vm_packages_new_min_id).change(); | ||||||
|  | 			} | ||||||
|  | 			if(id=='bhyve-obtain') | ||||||
|  | 			{ | ||||||
|  | 				if(typeof this.vm_packages_obtain_min_id!='undefined') | ||||||
|  | 					$('#bhyveObtSettings select[name="vm_packages"]').val(this.vm_packages_obtain_min_id).change(); | ||||||
| 			} | 			} | ||||||
| 			this.dialogShow1(id); | 			this.dialogShow1(id); | ||||||
| 		} | 		} | ||||||
| @@ -505,6 +512,13 @@ var clonos={ | |||||||
| 				if(mode=='edit') posts.push({'name':'user_id','value':this.lastEditedUser}); | 				if(mode=='edit') posts.push({'name':'user_id','value':this.lastEditedUser}); | ||||||
| 				this.loadData(fmode,$.proxy(this.onUsersAdd,this),posts); | 				this.loadData(fmode,$.proxy(this.onUsersAdd,this),posts); | ||||||
| 			} | 			} | ||||||
|  | 			if(id=='vm_packages-new') | ||||||
|  | 			{ | ||||||
|  | 				var fmode=(mode=='edit')?'vmTemplateEdit':'vmTemplateAdd'; | ||||||
|  | 				var posts=$('form#templateSettings').serializeArray(); | ||||||
|  | 				if(mode=='edit') posts.push({'name':'template_id','value':this.lastEditedVmTemplate}); | ||||||
|  | 				this.loadData(fmode,$.proxy(this.onVmTemplateAdd,this),posts); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
| @@ -531,12 +545,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onJailAdd:function(data) | 	onJailAdd:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data!='undefined' && !data.error) | 		if(typeof data!='undefined' && !data.error) | ||||||
| 		{ | 		{ | ||||||
| 			if(typeof data.mode!='undefined') | 			if(typeof data.mode!='undefined') | ||||||
| @@ -625,24 +633,12 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onHelpersAdd:function(data) | 	onHelpersAdd:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		this.dialogClose(); | 		this.dialogClose(); | ||||||
| 		 | 		 | ||||||
| 		this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); | 		this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); | ||||||
| 	}, | 	}, | ||||||
| 	onAuthkeyAdd:function(data) | 	onAuthkeyAdd:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data!='undefined' && !data.error) | 		if(typeof data!='undefined' && !data.error) | ||||||
| 		{ | 		{ | ||||||
| 			var injected=false; | 			var injected=false; | ||||||
| @@ -672,12 +668,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onVpnetAdd:function(data) | 	onVpnetAdd:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data!='undefined' && !data.error) | 		if(typeof data!='undefined' && !data.error) | ||||||
| 		{ | 		{ | ||||||
| 			var injected=false; | 			var injected=false; | ||||||
| @@ -781,12 +771,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onUpdateBhyveISO:function(data) | 	onUpdateBhyveISO:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.iso_list!='undefined') | 		if(typeof data.iso_list!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			$('dialog #bhyveSettings select[name="vm_iso_image"]').html(data.iso_list); | 			$('dialog #bhyveSettings select[name="vm_iso_image"]').html(data.iso_list); | ||||||
| @@ -798,24 +782,12 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onGetFreeJname:function(data) | 	onGetFreeJname:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		$('dialog#jail-settings input[name="jname"]').val(data.freejname); | 		$('dialog#jail-settings input[name="jname"]').val(data.freejname); | ||||||
| 		$('dialog#jail-settings input[name="host_hostname"]').val(data.freejname+'.my.domain'); | 		$('dialog#jail-settings input[name="host_hostname"]').val(data.freejname+'.my.domain'); | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
| 	onUsersAdd:function(data) | 	onUsersAdd:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') | 		if(typeof data.error!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			if(data.error) | 			if(data.error) | ||||||
| @@ -844,6 +816,12 @@ var clonos={ | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|  | 	onVmTemplateAdd:function(data) | ||||||
|  | 	{ | ||||||
|  | 		this.dialogClose(); | ||||||
|  | 		this.wssReload(); | ||||||
|  | 		this.dataReload(); | ||||||
|  | 	}, | ||||||
| 	 | 	 | ||||||
| 	loadData:function(mode,return_func,arr,spinner) | 	loadData:function(mode,return_func,arr,spinner) | ||||||
| 	{ | 	{ | ||||||
| @@ -908,15 +886,6 @@ var clonos={ | |||||||
| 	}, */ | 	}, */ | ||||||
| 	onLoadData:function(data) | 	onLoadData:function(data) | ||||||
| 	{ | 	{ | ||||||
| /* |  | ||||||
| 		if(typeof data!='object') |  | ||||||
| 		{ |  | ||||||
| 			try{ |  | ||||||
| 				var data=JSON.parse(data); |  | ||||||
| 			}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		} |  | ||||||
| */ |  | ||||||
| 		 |  | ||||||
| 		if(data.error) | 		if(data.error) | ||||||
| 		{ | 		{ | ||||||
| 			var t=$('tbody.error td.error_message'); | 			var t=$('tbody.error td.error_message'); | ||||||
| @@ -1093,8 +1062,10 @@ var clonos={ | |||||||
| 		var op='jremove'; | 		var op='jremove'; | ||||||
| 		var txt='jail'; | 		var txt='jail'; | ||||||
| 		if(opt=='bhyve'){op='bremove';txt='virtual machine';} | 		if(opt=='bhyve'){op='bremove';txt='virtual machine';} | ||||||
| 		var c=confirm(this.translate('You want to delete selected '+txt+'! Are you sure?')); | 		var name=$('#'+id+' td.jname').html(); | ||||||
| 		if(!c) return; | 		if(this.removeConfirm(id,'You want to delete selected '+txt+': «'+name+'»! Are you sure?')===false) return; | ||||||
|  | 		//var c=confirm(this.translate('You want to delete selected '+txt+'! Are you sure?')); | ||||||
|  | 		//if(!c) return; | ||||||
| 		this.enableWait(id); | 		this.enableWait(id); | ||||||
| 		// --- | 		// --- | ||||||
| 		var posts=[{'name':'operation','value':op},{'name':'jname','value':id}]; | 		var posts=[{'name':'operation','value':op},{'name':'jname','value':id}]; | ||||||
| @@ -1234,12 +1205,6 @@ var clonos={ | |||||||
| 		 | 		 | ||||||
| 		update:function(data) | 		update:function(data) | ||||||
| 		{ | 		{ | ||||||
| 			/* |  | ||||||
| 			try{ |  | ||||||
| 				var data=JSON.parse(data); |  | ||||||
| 			}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 			*/ |  | ||||||
| 			 |  | ||||||
| /* 			if(typeof data['mod_ops']!='undefined') | /* 			if(typeof data['mod_ops']!='undefined') | ||||||
| 			{ | 			{ | ||||||
| 				var key='mod_ops'; | 				var key='mod_ops'; | ||||||
| @@ -1452,91 +1417,67 @@ var clonos={ | |||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
|  | 	sleepFor:function(sleepDuration) | ||||||
|  | 	{ | ||||||
|  | 		var now=new Date().getTime(); | ||||||
|  | 		while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }  | ||||||
|  | 	}, | ||||||
|  | 	removeConfirm:function(id,answer) | ||||||
|  | 	{ | ||||||
|  | 		if(typeof id!='undefined') | ||||||
|  | 		{ | ||||||
|  | 			var obj=$('#'+id); | ||||||
|  | 			if(typeof obj!='undefined') | ||||||
|  | 			{ | ||||||
|  | 				$(obj).addClass('del'); | ||||||
|  | 				var c=confirm(this.translate(answer)); | ||||||
|  | 				if(!c) | ||||||
|  | 				{ | ||||||
|  | 					$(obj).removeClass('del'); | ||||||
|  | 					return false; | ||||||
|  | 				} | ||||||
|  | 				return true; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	}, | ||||||
|  | 	 | ||||||
| 	authkeyRemove:function(id) | 	authkeyRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected authkey! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected authkey! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var posts=[{'name':'auth_id','value':id}]; | 		var posts=[{'name':'auth_id','value':id}]; | ||||||
| 		this.loadData('authkeyRemove',$.proxy(this.onAuthkeyRemove,this),posts); | 		this.loadData('authkeyRemove',$.proxy(this.onAuthkeyRemove,this),posts); | ||||||
| 	}, | 	}, | ||||||
| 	onAuthkeyRemove:function(data) | 	onAuthkeyRemove:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 			 |  | ||||||
| 		$('#authkeyslist tr#'+data.auth_id).remove(); | 		$('#authkeyslist tr#'+data.auth_id).remove(); | ||||||
| 		} |  | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
| 	vpnetRemove:function(id) | 	vpnetRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected network! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected network! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var posts=[{'name':'vpnet_id','value':id}]; | 		var posts=[{'name':'vpnet_id','value':id}]; | ||||||
| 		this.loadData('vpnetRemove',$.proxy(this.onVpnetRemove,this),posts); | 		this.loadData('vpnetRemove',$.proxy(this.onVpnetRemove,this),posts); | ||||||
| 	}, | 	}, | ||||||
| 	onVpnetRemove:function(data) | 	onVpnetRemove:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 			 |  | ||||||
| 		$('#vpnetslist tr#'+data.vpnet_id).remove(); | 		$('#vpnetslist tr#'+data.vpnet_id).remove(); | ||||||
| 		} |  | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
| 	mediaRemove:function(id) | 	mediaRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected storage media! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected storage media! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var posts=[{'name':'media_id','value':id}]; | 		var posts=[{'name':'media_id','value':id}]; | ||||||
| 		this.loadData('mediaRemove',$.proxy(this.onMediaRemove,this),posts); | 		this.loadData('mediaRemove',$.proxy(this.onMediaRemove,this),posts); | ||||||
| 	}, | 	}, | ||||||
| 	onMediaRemove:function(data) | 	onMediaRemove:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 			 |  | ||||||
| 		$('#mediaslist tr#'+data.media_id).remove(); | 		$('#mediaslist tr#'+data.media_id).remove(); | ||||||
| 		} |  | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
| 	srcRemove:function(id) | 	srcRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected FreeBSD sources! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected FreeBSD sources! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var ver=$('#srcslist tr#'+this.dotEscape(id)+' .version').html(); | 		var ver=$('#srcslist tr#'+this.dotEscape(id)+' .version').html(); | ||||||
| 		var op='removesrc'; | 		var op='removesrc'; | ||||||
| 		//this.enableWait(id); | 		//this.enableWait(id); | ||||||
| @@ -1559,8 +1500,7 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	baseRemove:function(id) | 	baseRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected FreeBSD bases! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected FreeBSD bases! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var ver=$('#baseslist tr#'+this.dotEscape(id)+' .version').html(); | 		var ver=$('#baseslist tr#'+this.dotEscape(id)+' .version').html(); | ||||||
| 		var op='removebase'; | 		var op='removebase'; | ||||||
| 		//this.enableWait(id); | 		//this.enableWait(id); | ||||||
| @@ -1576,28 +1516,24 @@ var clonos={ | |||||||
| 	 | 	 | ||||||
| 	userRemove:function(id) | 	userRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 		var c=confirm(this.translate('You want to delete selected CBSD user! Are you sure?')); | 		if(this.removeConfirm(id,'You want to delete selected CBSD user! Are you sure?')===false) return; | ||||||
| 		if(!c) return; |  | ||||||
| 		var posts=[{'name':'user_id','value':id}]; | 		var posts=[{'name':'user_id','value':id}]; | ||||||
| 		this.loadData('userRemove',$.proxy(this.onUserRemove,this),posts,false); | 		this.loadData('userRemove',$.proxy(this.onUserRemove,this),posts,false); | ||||||
| 	}, | 	}, | ||||||
| 	onUserRemove:function(data) | 	onUserRemove:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* | 		this.wssReload(); | ||||||
| 		try{ | 		this.dataReload(); | ||||||
| 			var data=JSON.parse(data); | 	}, | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 	 | 	 | ||||||
| 		if(typeof data.error!='undefined') | 	vmTemplateRemove:function(id) | ||||||
| 	{ | 	{ | ||||||
| 			if(data.error) | 		if(this.removeConfirm(id,'You want to delete selected template! Are you sure?')===false) return; | ||||||
|  | 		var posts=[{'name':'template_id','value':id}]; | ||||||
|  | 		this.loadData('vmTemplateRemove',$.proxy(this.onVmTemplateRemove,this),posts,false); | ||||||
|  | 	}, | ||||||
|  | 	onVmTemplateRemove:function(data) | ||||||
| 	{ | 	{ | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		this.wssReload(); | 		this.wssReload(); | ||||||
| 		this.dataReload(); | 		this.dataReload(); | ||||||
| 	}, | 	}, | ||||||
| @@ -1612,21 +1548,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onLogLoad:function(data) | 	onLogLoad:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		$('dialog#tasklog .window-content').html(data.html); | 		$('dialog#tasklog .window-content').html(data.html); | ||||||
| 		this.dialogShow1('tasklog'); | 		this.dialogShow1('tasklog'); | ||||||
| 	}, | 	}, | ||||||
| @@ -1636,21 +1557,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onLogFlush:function(data) | 	onLogFlush:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		$('#taskloglist tbody').html(''); | 		$('#taskloglist tbody').html(''); | ||||||
| 		this.wssend({'cmd':'reload','path':location.pathname},'system'); | 		this.wssend({'cmd':'reload','path':location.pathname},'system'); | ||||||
| 	}, | 	}, | ||||||
| @@ -1776,7 +1682,17 @@ var clonos={ | |||||||
| 					this.userRemove(trid); | 					this.userRemove(trid); | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
|  | 				if(tblid=='jailslist' || tblid=='bhyveslist') | ||||||
|  | 				{ | ||||||
| 					this.jailRemove(trid,opt); | 					this.jailRemove(trid,opt); | ||||||
|  | 					return; | ||||||
|  | 				} | ||||||
|  | 				if(tblid=='packageslist') | ||||||
|  | 				{ | ||||||
|  | 					this.vmTemplateRemove(trid); | ||||||
|  | 					return; | ||||||
|  | 				} | ||||||
|  | 				alert(tblid); | ||||||
| 				return;break; | 				return;break; | ||||||
| 			case 'icon-arrows-cw': | 			case 'icon-arrows-cw': | ||||||
| 				if(tblid=='srcslist') | 				if(tblid=='srcslist') | ||||||
| @@ -1805,6 +1721,9 @@ var clonos={ | |||||||
| 					case 'userslist': | 					case 'userslist': | ||||||
| 						this.userEdit(trid,tblid); | 						this.userEdit(trid,tblid); | ||||||
| 						return; | 						return; | ||||||
|  | 					case 'packageslist': | ||||||
|  | 						this.vmTemplateEdit(trid,tblid); | ||||||
|  | 						return; | ||||||
| 				} | 				} | ||||||
| 				 | 				 | ||||||
| 				return;break; | 				return;break; | ||||||
| @@ -1969,6 +1888,22 @@ var clonos={ | |||||||
| 		*/ | 		*/ | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
|  | 	onChangePkgTemplate:function(obj,event) | ||||||
|  | 	{ | ||||||
|  | 		var id=$(obj).val(); | ||||||
|  | 		var index=$(obj).prop('selectedIndex'); | ||||||
|  | 		var txt=$('option:selected',obj).text(); | ||||||
|  | 		var res=txt.match(new RegExp(/cpu:[ ]*(\d+).*ram:[ ]*([\dmg]+).*hdd:[ ]*([\dmg]+)/)); | ||||||
|  | 		if(res!=null) | ||||||
|  | 		{ | ||||||
|  | 			var par=$(obj).closest('form'); | ||||||
|  | 			$('input[name="vm_cpus"]',par).val(res[1]); | ||||||
|  | 			$('input[name="vm_cpus_show"]',par).val(res[1]); | ||||||
|  | 			$('input[name="vm_ram"]',par).val(res[2]); | ||||||
|  | 			$('input[name="vm_size"]',par).val(res[3]); | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	 | ||||||
| 	loginAction:function(event) | 	loginAction:function(event) | ||||||
| 	{ | 	{ | ||||||
| 		var target=event.target; | 		var target=event.target; | ||||||
| @@ -1991,12 +1926,6 @@ var clonos={ | |||||||
| 	onLogin:function(data) | 	onLogin:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		$('.login-wait').hide(); | 		$('.login-wait').hide(); | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.errorCode!=='undefined') | 		if(typeof data.errorCode!=='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			if(data.errorCode==1) | 			if(data.errorCode==1) | ||||||
| @@ -2189,17 +2118,10 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onDDMenuLoad:function(data) | 	onDDMenuLoad:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined') | 		if(typeof data.error!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			if(data.error) | 			if(data.error) | ||||||
| 			{ | 			{ | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				if(typeof data.reload!='undefined') | 				if(typeof data.reload!='undefined') | ||||||
| 				{ | 				{ | ||||||
| 					if(data.reload) this.dataReload(); | 					if(data.reload) this.dataReload(); | ||||||
| @@ -2233,12 +2155,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onUserEdit:function(data) | 	onUserEdit:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		var dialog=data.dialog; | 		var dialog=data.dialog; | ||||||
| 		$('dialog#'+dialog+' fieldset.edit input[type="password"]').prop('disabled',true); | 		$('dialog#'+dialog+' fieldset.edit input[type="password"]').prop('disabled',true); | ||||||
| 		this.fillDialogVars(dialog,data.vars); | 		this.fillDialogVars(dialog,data.vars); | ||||||
| @@ -2246,6 +2162,21 @@ var clonos={ | |||||||
| 		this.dialogShow1(dialog,'edit'); | 		this.dialogShow1(dialog,'edit'); | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
|  | 	vmTemplateEdit:function(template_id,tblid) | ||||||
|  | 	{ | ||||||
|  | 		var mode='vmTemplateEditInfo'; | ||||||
|  | 		var posts=[{'name':'template_id','value':template_id}]; | ||||||
|  | 		this.loadData(mode,$.proxy(this.onVmTemplateEdit,this),posts); | ||||||
|  | 		 | ||||||
|  | 	}, | ||||||
|  | 	onVmTemplateEdit:function(data) | ||||||
|  | 	{ | ||||||
|  | 		var dialog='vm_packages-new'; | ||||||
|  | 		this.lastEditedVmTemplate=data.template_id; | ||||||
|  | 		this.fillDialogVars(dialog,data.vars); | ||||||
|  | 		this.dialogShow1(dialog,'edit'); | ||||||
|  | 	}, | ||||||
|  | 	 | ||||||
| 	dataReload:function() | 	dataReload:function() | ||||||
| 	{ | 	{ | ||||||
| 		this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); | 		this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); | ||||||
| @@ -2294,6 +2225,8 @@ var clonos={ | |||||||
| 			switch(type) | 			switch(type) | ||||||
| 			{ | 			{ | ||||||
| 				case 'text': | 				case 'text': | ||||||
|  | 				case 'password': | ||||||
|  | 				case 'textarea': | ||||||
| 				case 'select': | 				case 'select': | ||||||
| 					if(typeof v!='undefined') $(inp).val(v); | 					if(typeof v!='undefined') $(inp).val(v); | ||||||
| 					break; | 					break; | ||||||
| @@ -2351,16 +2284,6 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onSaveHelperValues:function(data) | 	onSaveHelperValues:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(typeof data.error!='undefined' && data.error) |  | ||||||
| 		{ |  | ||||||
| 			this.notify(data.errorMessage,'error'); |  | ||||||
| 		} |  | ||||||
| 		if(typeof data.redirect!='undefined') | 		if(typeof data.redirect!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			if(data.redirect!='') | 			if(data.redirect!='') | ||||||
| @@ -2392,21 +2315,7 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onDeleteHelperGroup:function(data) | 	onDeleteHelperGroup:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(!data) return; | 		if(!data) return; | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		if(typeof data.db_path!='undefined') | 		if(typeof data.db_path!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			this.saveDbPath(data.db_path); | 			this.saveDbPath(data.db_path); | ||||||
| @@ -2458,21 +2367,7 @@ var clonos={ | |||||||
| 	}, | 	}, | ||||||
| 	onAddHelperGroup:function(data) | 	onAddHelperGroup:function(data) | ||||||
| 	{ | 	{ | ||||||
| 		/* |  | ||||||
| 		try{ |  | ||||||
| 			var data=JSON.parse(data); |  | ||||||
| 		}catch(e){this.debug(e.message,data);return;} |  | ||||||
| 		*/ |  | ||||||
| 		 |  | ||||||
| 		if(!data) return; | 		if(!data) return; | ||||||
| 		if(typeof data.error!='undefined') |  | ||||||
| 		{ |  | ||||||
| 			if(data.error) |  | ||||||
| 			{ |  | ||||||
| 				this.notify(data.error_message,'error'); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		if(typeof data.db_path!='undefined') | 		if(typeof data.db_path!='undefined') | ||||||
| 		{ | 		{ | ||||||
| 			this.saveDbPath(data.db_path); | 			this.saveDbPath(data.db_path); | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ if(!empty($nodes))foreach($nodes as $node) | |||||||
| 	$db1=new Db('base',$node); | 	$db1=new Db('base',$node); | ||||||
| 	if($db1!==false) | 	if($db1!==false) | ||||||
| 	{ | 	{ | ||||||
| 		$bhyves=$db1->select("SELECT jname,vm_ram,vm_cpus,vm_os_type,hidden,protected FROM bhyve where hidden!=1 order by jname asc;"); | 		$bhyves=$db1->select("SELECT jname,vm_ram,vm_cpus,vm_os_type,hidden,protected,bhyve_vnc_tcp_bind FROM bhyve where hidden!=1 order by jname asc;"); | ||||||
| 		//$allnodes[$node]=$bhyves; | 		//$allnodes[$node]=$bhyves; | ||||||
| 		 | 		 | ||||||
| 		$num=$nth & 1; | 		$num=$nth & 1; | ||||||
| @@ -30,6 +30,22 @@ if(!empty($nodes))foreach($nodes as $node) | |||||||
| 			{ | 			{ | ||||||
| 				$html_tpl=$hres[1]; | 				$html_tpl=$hres[1]; | ||||||
| 				$status=$this->check_vmonline($bhyve['jname']); | 				$status=$this->check_vmonline($bhyve['jname']); | ||||||
|  |  | ||||||
|  | 				$jname=$bhyve['jname']; | ||||||
|  | 				$vnc_port_status='grey'; | ||||||
|  | 				$vnc_ip=$bhyve['bhyve_vnc_tcp_bind']; | ||||||
|  | 				if($status==1) | ||||||
|  | 				{ | ||||||
|  | 					$vnc_port_file=$this->workdir.'/jails-system/'.$jname.'/vnc_port'; | ||||||
|  | 					if(file_exists($vnc_port_file)) | ||||||
|  | 					{ | ||||||
|  | 						$vnc_port=trim(file_get_contents($vnc_port_file)); | ||||||
|  | 					} | ||||||
|  | 				}else{ | ||||||
|  | 					$vnc_port=''; | ||||||
|  | 				} | ||||||
|  | 				if($vnc_ip!='127.0.0.1') $vnc_port_status='black'; | ||||||
|  | 				 | ||||||
| 				$vars=array( | 				$vars=array( | ||||||
| 					'jname'=>$bhyve['jname'], | 					'jname'=>$bhyve['jname'], | ||||||
| 					'nth-num'=>'nth'.$num, | 					'nth-num'=>'nth'.$num, | ||||||
| @@ -50,6 +66,8 @@ if(!empty($nodes))foreach($nodes as $node) | |||||||
| //					'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"', | //					'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"', | ||||||
| 					'vnc_title'=>$this->translate('Open VNC'), | 					'vnc_title'=>$this->translate('Open VNC'), | ||||||
| 					'reboot_title'=>$this->translate('Restart bhyve'), | 					'reboot_title'=>$this->translate('Restart bhyve'), | ||||||
|  | 					'vnc_port'=>$vnc_port, | ||||||
|  | 					'vnc_port_status'=>$vnc_port_status, | ||||||
| 				); | 				); | ||||||
| 				 | 				 | ||||||
| 				foreach($vars as $var=>$val) | 				foreach($vars as $var=>$val) | ||||||
|   | |||||||
| @@ -11,5 +11,6 @@ | |||||||
| 			<td width="5" class="op-reboot" title="#reboot_title#"><span class="icon-arrows-cw"></span></td> | 			<td width="5" class="op-reboot" title="#reboot_title#"><span class="icon-arrows-cw"></span></td> | ||||||
| 			<td width="5" class="op-del"#protitle#><span class="#protected#"></span></td> | 			<td width="5" class="op-del"#protitle#><span class="#protected#"></span></td> | ||||||
| 			<td width="5" class="op-vnc"><span class="icon-desktop" title="#vnc_title#"></span></td> | 			<td width="5" class="op-vnc"><span class="icon-desktop" title="#vnc_title#"></span></td> | ||||||
|  | 			<td class="small vnc-#vnc_port_status#">#vnc_port#</td> | ||||||
| 		</tr> | 		</tr> | ||||||
| 	</tbody> | 	</tbody> | ||||||
| @@ -24,6 +24,7 @@ $clonos->useDialogs(array( | |||||||
| 		<th class="wdt-120">Status</th> | 		<th class="wdt-120">Status</th> | ||||||
| 		<th colspan="4" class="wdt-100">Action</th> | 		<th colspan="4" class="wdt-100">Action</th> | ||||||
| 		<th class="wdt-30">VNC</th> | 		<th class="wdt-30">VNC</th> | ||||||
|  | 		<th class="txtcenter wdt-50">VNC port</th> | ||||||
| 	</thead> | 	</thead> | ||||||
| 	<tbody></tbody> | 	<tbody></tbody> | ||||||
| </table> | </table> | ||||||
| @@ -25,6 +25,7 @@ $clonos->useDialogs(array( | |||||||
| 		<th class="txtcenter wdt-120">Статус</th> | 		<th class="txtcenter wdt-120">Статус</th> | ||||||
| 		<th colspan="4" class="wdt-100">Действия</th> | 		<th colspan="4" class="wdt-100">Действия</th> | ||||||
| 		<th class="wdt-30">VNC</th> | 		<th class="wdt-30">VNC</th> | ||||||
|  | 		<th class="txtcenter wdt-50">VNC порт</th> | ||||||
| 	</thead> | 	</thead> | ||||||
| 	<tbody></tbody> | 	<tbody></tbody> | ||||||
| </table> | </table> | ||||||
| @@ -36,13 +36,24 @@ if(!empty($nodes))foreach($nodes as $node) | |||||||
| 		{ | 		{ | ||||||
| 			if($hres!==false) | 			if($hres!==false) | ||||||
| 			{ | 			{ | ||||||
|  | 				$jname=$jail['jname']; | ||||||
|  | 				$vnc_port_status='grey'; | ||||||
|  | 				$vnc_port=''; | ||||||
|  | 				$vnc_port_file=$this->workdir.'/jails-system/'.$jname.'/vnc_port'; | ||||||
|  | 				if(file_exists($vnc_port_file)) | ||||||
|  | 				{ | ||||||
|  | 					$vnc_port=trim(file_get_contents($vnc_port_file)); | ||||||
|  | 				} | ||||||
|  | 				 | ||||||
| 				$html_tpl=$hres[1]; | 				$html_tpl=$hres[1]; | ||||||
| 				$status=$jail['status']; | 				$status=$jail['status']; | ||||||
| 				$vars=array( | 				$vars=array( | ||||||
| 					'nth-num'=>'nth'.$num, | 					'nth-num'=>'nth'.$num, | ||||||
| 					'node'=>$node, | 					'node'=>$node, | ||||||
| 					'ip4_addr'=>str_replace(',',',<wbr />',$jail['ip4_addr']), | 					'ip4_addr'=>str_replace(',',',<wbr />',$jail['ip4_addr']), | ||||||
| 					'jname'=>$jail['jname'], | 					'jname'=>$jname, | ||||||
|  | 					'vnc_port'=>$vnc_port, | ||||||
|  | 					'vnc_port_status'=>$vnc_port_status, | ||||||
| 					'status'=>$status, | 					'status'=>$status, | ||||||
| 					'jstatus'=>$this->translate($statuses[$status]), | 					'jstatus'=>$this->translate($statuses[$status]), | ||||||
| 					'icon'=>($status==0)?'play':'stop', | 					'icon'=>($status==0)?'play':'stop', | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ $clonos->useDialogs(array( | |||||||
| 			<th class="wdt-120">Status</th> | 			<th class="wdt-120">Status</th> | ||||||
| 			<th colspan="4" class="wdt-100">Action</th> | 			<th colspan="4" class="wdt-100">Action</th> | ||||||
| 			<th class="wdt-30">VNC</th> | 			<th class="wdt-30">VNC</th> | ||||||
|  | 			<th class="txtcenter wdt-50">VNC port</th> | ||||||
| 		</tr> | 		</tr> | ||||||
| 	</thead> | 	</thead> | ||||||
| 	<tbody></tbody> | 	<tbody></tbody> | ||||||
|   | |||||||
| @@ -9,5 +9,6 @@ | |||||||
| 			<td width="5" class="op-reboot" title="#reboot_title#"><span class="icon-arrows-cw"></span></td> | 			<td width="5" class="op-reboot" title="#reboot_title#"><span class="icon-arrows-cw"></span></td> | ||||||
| 			<td width="5" class="op-del"#protitle#><span class="#protected#"></span></td> | 			<td width="5" class="op-del"#protitle#><span class="#protected#"></span></td> | ||||||
| 			<td width="5" class="op-vnc"><span class="icon-desktop" title="#vnc_title#"></span></td> | 			<td width="5" class="op-vnc"><span class="icon-desktop" title="#vnc_title#"></span></td> | ||||||
|  | 			<td class="small vnc-#vnc_port_status#">#vnc_port#</td> | ||||||
| 		</tr> | 		</tr> | ||||||
| 	</tbody> | 	</tbody> | ||||||
| @@ -28,6 +28,7 @@ $clonos->useDialogs(array( | |||||||
| 			<th class="txtcenter wdt-120">Статус</th> | 			<th class="txtcenter wdt-120">Статус</th> | ||||||
| 			<th colspan="4" class="wdt-100">Действия</th> | 			<th colspan="4" class="wdt-100">Действия</th> | ||||||
| 			<th class="wdt-30">VNC</th> | 			<th class="wdt-30">VNC</th> | ||||||
|  | 			<th class="txtcenter wdt-50">VNC порт</th> | ||||||
| 		</tr> | 		</tr> | ||||||
| 	</thead> | 	</thead> | ||||||
| 	<tbody></tbody> | 	<tbody></tbody> | ||||||
|   | |||||||
| @@ -0,0 +1,23 @@ | |||||||
|  | <?php | ||||||
|  | $clonos->useDialogs(array( | ||||||
|  | 	'users-new', | ||||||
|  | )); | ||||||
|  | ?> | ||||||
|  |  | ||||||
|  | <h1>User management</h1> | ||||||
|  | <p><span class="top-button icon-plus id:users-new">Add users</span></p> | ||||||
|  |  | ||||||
|  | <table class="tsimple" id="userslist" width="100%"> | ||||||
|  | 	<thead> | ||||||
|  | 		<tr> | ||||||
|  | 			<th class="txtleft">Login</th> | ||||||
|  | 			<th class="txtleft">First Name</th> | ||||||
|  | 			<th class="txtleft">Last Name</th> | ||||||
|  | 			<th class="txtleft">Registration</th> | ||||||
|  | 			<th class="txtleft">Last login</th> | ||||||
|  | 			<th class="txtcenter">Active</th> | ||||||
|  | 			<th class="txtcenter wd-100">Action</th> | ||||||
|  | 		</tr> | ||||||
|  | 	</thead> | ||||||
|  | 	<tbody></tbody> | ||||||
|  | </table> | ||||||
							
								
								
									
										41
									
								
								public/pages/vm_packages/a.json.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								public/pages/vm_packages/a.json.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | $html=''; | ||||||
|  | $db=new Db('base','local'); | ||||||
|  | if($db!==false) | ||||||
|  | { | ||||||
|  | 	$res=$db->select("select id,name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus,owner from vmpackages order by name asc"); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $nth=0; | ||||||
|  | $hres=$this->getTableChunk('packages','tbody'); | ||||||
|  |  | ||||||
|  | $html_tpl=$hres[1]; | ||||||
|  | if(!empty($res))foreach($res as $r) | ||||||
|  | { | ||||||
|  | 	$html_tpl1=$html_tpl; | ||||||
|  | 	$vars=array( | ||||||
|  | 		'id'=>$r['id'], | ||||||
|  | 		'name'=>$r['name'], | ||||||
|  | 		'description'=>$r['description'], | ||||||
|  | 		'pkg_vm_ram'=>$r['pkg_vm_ram'], | ||||||
|  | 		'pkg_vm_disk'=>$r['pkg_vm_disk'], | ||||||
|  | 		'pkg_vm_cpus'=>$r['pkg_vm_cpus'], | ||||||
|  | 		'owner'=>$r['owner'], | ||||||
|  | 		'edit_title'=>$this->translate('edit_title'), | ||||||
|  | 		'delete_title'=>$this->translate('delete_title'), | ||||||
|  | 	); | ||||||
|  | 	foreach($vars as $var=>$val) | ||||||
|  | 		$html_tpl1=str_replace('#'.$var.'#',$val,$html_tpl1); | ||||||
|  | 	$html.=$html_tpl1; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | $html=str_replace(array("\n","\r","\t"),'',$html); | ||||||
|  |  | ||||||
|  | echo json_encode(array( | ||||||
|  | 	'tbody'=>$html, | ||||||
|  | 	'error'=>false, | ||||||
|  | 	'func'=>'fillTable', | ||||||
|  | 	'id'=>'packageslist', | ||||||
|  | )); | ||||||
							
								
								
									
										23
									
								
								public/pages/vm_packages/en.index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								public/pages/vm_packages/en.index.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | <?php | ||||||
|  | $clonos->useDialogs(array( | ||||||
|  | 	'vm_packages-new', | ||||||
|  | )); | ||||||
|  | ?> | ||||||
|  |  | ||||||
|  | <h1>VM Packages</h1> | ||||||
|  | <p><span class="top-button icon-plus id:vm_packages-new">Add package</span></p> | ||||||
|  |  | ||||||
|  | <table class="tsimple" id="packageslist" width="100%"> | ||||||
|  | 	<thead> | ||||||
|  | 		<tr> | ||||||
|  | 			<th class="txtleft">Package name</th> | ||||||
|  | 			<th class="txtleft">Description</th> | ||||||
|  | 			<th class="txtcenter">RAM</th> | ||||||
|  | 			<th class="txtcenter">Disk size</th> | ||||||
|  | 			<th class="txtcenter">vCPU</th> | ||||||
|  | 			<th class="txtcenter">Modified by</th> | ||||||
|  | 			<th class="txtcenter wd-100">Action</th> | ||||||
|  | 		</tr> | ||||||
|  | 	</thead> | ||||||
|  | 	<tbody></tbody> | ||||||
|  | </table> | ||||||
							
								
								
									
										14
									
								
								public/pages/vm_packages/packages.table
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								public/pages/vm_packages/packages.table
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | |||||||
|  | 	<tbody> | ||||||
|  | 		<tr class="#nth-num# helper" id="#id#"> | ||||||
|  | 			<td class="txtleft vmiddle">#name#</td> | ||||||
|  | 			<td class="txtleft vmiddle">#description#</td> | ||||||
|  | 			<td class="txtcenter vmiddle">#pkg_vm_ram#</td> | ||||||
|  | 			<td class="txtcenter vmiddle">#pkg_vm_disk#</td> | ||||||
|  | 			<td class="txtcenter vmiddle">#pkg_vm_cpus#</td> | ||||||
|  | 			<td class="txtcenter vmiddle">#owner#</td> | ||||||
|  | 			<td class="ops vmiddle" width="5"> | ||||||
|  | 				<span class="icon-edit" title="#edit_title#"></span> | ||||||
|  | 				<span class="icon-cancel" title="#delete_title#"></span> | ||||||
|  | 			</td> | ||||||
|  | 		</tr> | ||||||
|  | 	</tbody> | ||||||
							
								
								
									
										23
									
								
								public/pages/vm_packages/ru.index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								public/pages/vm_packages/ru.index.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | <?php | ||||||
|  | $clonos->useDialogs(array( | ||||||
|  | 	'vm_packages-new', | ||||||
|  | )); | ||||||
|  | ?> | ||||||
|  |  | ||||||
|  | <h1>Шаблоны виртуальных машин</h1> | ||||||
|  | <p><span class="top-button icon-plus id:vm_packages-new">Добавить шаблон</span></p> | ||||||
|  |  | ||||||
|  | <table class="tsimple" id="packageslist" width="100%"> | ||||||
|  | 	<thead> | ||||||
|  | 		<tr> | ||||||
|  | 			<th class="txtleft">Название</th> | ||||||
|  | 			<th class="txtleft">Описание</th> | ||||||
|  | 			<th class="txtcenter">Объём RAM</th> | ||||||
|  | 			<th class="txtcenter">Размер диска</th> | ||||||
|  | 			<th class="txtcenter">Количество ядер</th> | ||||||
|  | 			<th class="txtcenter">Добавил</th> | ||||||
|  | 			<th class="txtcenter wd-100">Действия</th> | ||||||
|  | 		</tr> | ||||||
|  | 	</thead> | ||||||
|  | 	<tbody></tbody> | ||||||
|  | </table> | ||||||
| @@ -83,7 +83,6 @@ vm_vnc_port="#vm_vnc_port#"; | |||||||
| cd_vnc_wait="1"; | cd_vnc_wait="1"; | ||||||
| bhyve_vnc_resolution="1024x768"; | bhyve_vnc_resolution="1024x768"; | ||||||
| bhyve_vnc_tcp_bind="#bhyve_vnc_tcp_bind#"; | bhyve_vnc_tcp_bind="#bhyve_vnc_tcp_bind#"; | ||||||
|  | bhyve_vnc_vgaconf="io"; | ||||||
|  |  | ||||||
| vnc_password=""; | vnc_password="#vm_vnc_password#"; | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 olevole
					olevole