diff --git a/php/clonos.php b/php/clonos.php index 7dfdd3db..c2f5e266 100644 --- a/php/clonos.php +++ b/php/clonos.php @@ -20,7 +20,7 @@ class ClonOS private $_db=null; private $_client_ip=''; private $_dialogs=array(); - private $_cmd_array=array('jcreate','jstart','jstop','jrestart','jedit','jremove','jexport','jimport','jclone','jrename','madd','sstart','sstop','projremove','bcreate','bstart','bstop','brestart','bremove','bclone','brename','vm_obtain','removesrc','srcup','removebase','world','repo'); + private $_cmd_array=array('jcreate','jstart','jstop','jrestart','jedit','jremove','jexport','jimport','jclone','jrename','madd','sstart','sstop','projremove','bcreate','bstart','bstop','brestart','bremove','bclone','brename','vm_obtain','removesrc','srcup','removebase','world','repo','forms'); /* public $projectId=0; @@ -90,7 +90,7 @@ class ClonOS $this->realpath_public=$_REALPATH.'/public/'; # /usr/home/web/cp/clonos/public/ - if(isset($_SERVER['SERVER_NAME'])) + if(isset($_SERVER['SERVER_NAME']) && !empty(trim($_SERVER['SERVER_NAME']))) $this->server_name=$_SERVER['SERVER_NAME']; else $this->server_name=$_SERVER['SERVER_ADDR']; @@ -266,6 +266,9 @@ class ClonOS echo json_encode($this->vpnetRemove()); return;break; + case 'updateBhyveISO': + echo json_encode($this->updateBhyveISO()); + return;break; case 'mediaAdd': //echo json_encode($this->mediaAdd()); return;break; @@ -284,6 +287,15 @@ class ClonOS case 'repoCompile': echo json_encode($this->repoCompile()); return;break; + case 'srcUpdate': + echo json_encode($this->srcUpdate()); + return;break; + case 'srcRemove': + echo json_encode($this->srcRemove()); + return;break; + case 'baseRemove': + echo json_encode($this->baseRemove()); + return;break; /* case 'saveHelperValues': echo json_encode($this->saveHelperValues()); @@ -456,7 +468,7 @@ class ClonOS */ function _getTasksStatus($jsonObj) { - return $jsonObj; + //return $jsonObj; $tasks=array(); $obj=json_decode($jsonObj,true); @@ -767,6 +779,7 @@ class ClonOS $form=$this->form; $helper=preg_replace('/^#/','',$this->_vars['hash']); + $db_path=''; $with_img_helpers=''; if($this->mode=='saveHelperValues') { @@ -774,6 +787,22 @@ class ClonOS { return $this->saveSettingsCBSD(); } + + if(!isset($this->_vars['db_path'])) + { + $res=$this->cbsd_cmd('make_tmp_helper module='.$helper); + if($res['retval']==0) + { + $db_path=$res['message']; + }else{ + echo json_encode(array('error'=>true,'errorMessage'=>'Error on open temporary form database!')); + return; + } + }else{ + $db_path=$this->_vars['db_path']; + } + + /* $file_name=$this->workdir.'/formfile/'.$helper.'.sqlite'; if(file_exists($file_name)) { @@ -797,6 +826,24 @@ class ClonOS //echo $with_img_helpers; } } + */ + + $db=new Db('file',$db_path); + if($db!==false) + { + foreach($form as $key=>$val) + { + if($key!='jname' && $key!='ip4_addr') + { + $query="update forms set new='{$val}' where param='{$key}'"; + $db->update($query); + unset($form[$key]); + } + } + + $with_img_helpers=$db_path; + } + $form['interface']='auto'; $form['user_pw_root']=''; $form['astart']=1; @@ -861,6 +908,7 @@ class ClonOS $err='Jail was created!'; $taskId=$res['message']; } + // local - поменять на реальный сервер, на котором создаётся клетка! $jid=$arr['jname']; @@ -901,7 +949,7 @@ class ClonOS ))); */ - return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'mode'=>$this->mode,'redirect'=>$redirect); //,'html'=>$html + return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'mode'=>$this->mode,'redirect'=>$redirect,'db_path'=>$db_path); //,'html'=>$html } function jailRenameVars() { @@ -1192,6 +1240,7 @@ class ClonOS $res['error']=false; $res['dialog']=$form['dialog']; $res['jail_id']=$form['jail_id']; + $res['iso_list']=$this->updateBhyveISO($form['jail_id']); return $res; } function bhyveRename() @@ -1251,7 +1300,7 @@ class ClonOS } function bhyveEdit() { - $form=$this->_vars['form_data']; + $form=$this->form; $str=array(); $jname=$form['jname']; @@ -1278,6 +1327,26 @@ class ClonOS $form['vm_ram']=$ram_tmp; + /* check mounted ISO */ + $db=new Db('base','storage_media'); + $res=$db->selectAssoc('select * from media where jname="'.$jname.'" and type="iso"'); + if($res!==false && !empty($res)) + { + $cmd1="cbsd media mode=unregister name=\"${res['name']}\" path=\"${res['path']}\" jname=${jname} type=${res['type']}"; + //echo $cmd1,PHP_EOL,PHP_EOL; + $this->cbsd_cmd($cmd1); + $res=$db->selectAssoc('select * from media where idx='.$form['vm_iso_image']); + if($res!==false && !empty($res) && $form['vm_iso_image']!=-2) + { + $cmd2="cbsd media mode=register name=\"${res['name']}\" path=\"${res['path']}\" jname=${jname} type=${res['type']}"; + $this->cbsd_cmd($cmd2); + //echo $cmd2; + } + } + //exit; + + /* end check */ + $cmd='bset jname='.$jname.' '.join(' ',$str); $res=$this->cbsd_cmd($cmd); $res['mode']='bhyveEdit'; @@ -1286,7 +1355,8 @@ class ClonOS } function bhyveAdd() { - $form=$this->_vars['form_data']; + $form=$this->form; + $os_types=$this->config->os_types; $sel_os=$form['vm_os_profile']; @@ -1316,6 +1386,33 @@ class ClonOS 'vm_vnc_port'=>$form['vm_vnc_port'], ); + $iso=true; + $res=array('name'=>'','path'=>'','iso_var_block'=>''); + $crlf="\r\n"; + $iso_var_block='iso_extract=""'.$crlf.'iso_img_dist=""'.$crlf.'iso_img=""'.$crlf.'iso_site=""'; + $iso_id=$form['vm_iso_image']; + if(!empty($iso_id)) + { + if($iso_id>0) + { + $db=new Db('base','storage_media'); + $res=$db->selectAssoc('select name,path from media where idx='.$iso_id); + if($res===false || empty($res)) $iso=false; + } + + if($iso_id==-1) + { + $iso=false; + } + + if($iso) + { + $arr['register_iso_as']='register_iso_as="'.$res['name'].'"'; + $arr['register_iso_name']='register_iso_name="'.$res['path'].'"'; + if($iso_id!=-2) $arr['iso_var_block']=$iso_var_block; + } + } + /* create vm */ $file_name='/tmp/'.$arr['jname'].'.conf'; @@ -1327,6 +1424,7 @@ class ClonOS $file=str_replace('#'.$var.'#',$val,$file); } } + //echo $file;exit; file_put_contents($file_name,$file); $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd bcreate inter=0 jconf='.$file_name); @@ -1438,28 +1536,28 @@ class ClonOS } function bhyveStart() { - $form=$this->_vars['form_data']; + $form=$this->form; $name=$form['jname']; $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd bstart inter=0 jname='.$name); // autoflush=2 return $res; } function bhyveStop() { - $form=$this->_vars['form_data']; + $form=$this->form; $name=$form['jname']; $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd bstop inter=0 jname='.$name); // autoflush=2 return $res; } function bhyveRestart() { - $form=$this->_vars['form_data']; + $form=$this->form; $name=$form['jname']; $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd brestart inter=0 jname='.$name); // autoflush=2 return $res; } function bhyveRemove() //$name { - $form=$this->_vars['form_data']; + $form=$this->form; $name=$form['jname']; $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd bremove inter=0 jname='.$name); // autoflush=2 return $res; @@ -1467,7 +1565,7 @@ class ClonOS function authkeyAdd() { - $form=$this->_vars['form_data']; + $form=$this->form; $query="insert into authkey (name,authkey) values ('{$form['keyname']}','{$form['keysrc']}')"; @@ -1558,24 +1656,49 @@ class ClonOS function mediaRemove() { - $form=$this->_vars['form_data']; - /* + $form=$this->form; $db=new Db('base','storage_media'); - $res=$db->update('delete from media where idx='.$form['media_id']); - if($res===false) return array('error'=>true,'res'=>print_r($res,true)); - */ - return array('error'=>false,'media_id'=>$form['media_id']); + //$res=$db->update('delete from media where idx='.$form['media_id']); + $res=$db->selectAssoc('select * from media where idx='.$form['media_id']); + if($res===false || empty($res)) return array('error'=>true,'res'=>print_r($res,true)); + + //if($res['jname']=='-') // если медиа отвязана, то просто удаляем + //print_r($res);exit; + $cmd='media mode=remove name="'.$res['name'].'" path="'.$res['path'].'" jname="'.$res['jname'].'" type="'.$res['type'].'"'; //.$res['name'] + //echo $cmd;exit; + + $res=$this->cbsd_cmd($cmd); + + if($res['error']) + { + $arr['error']=true; + $arr['error_message']='File image was not deleted! '.$res['error_message']; + }else{ + $arr['error']=false; + } + $arr['media_id']=$form['media_id']; + $arr['cmd']=$res; + //echo json_encode($arr); + + + //return array('error'=>false,'media_id'=>$form['media_id']); + return $arr; } - function srcRemove($ver) + function srcRemove() { + $form=$this->form; + $ver=$form['jname']; $ver=str_replace('src','',$ver); if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); $res=$this->cbsd_cmd('task owner=cbsdwebsys mode=new /usr/local/bin/cbsd removesrc inter=0 ver='.$ver.' jname=#src'.$ver); return $res; } - function srcUpdate($ver) + function srcUpdate() { + $form=$this->form; + $ver=$form['jname']; + //$ver=str_replace('src','',$ver); $ver=str_replace('src','',$ver); $stable=(preg_match('#\.\d#',$ver))?0:1; if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); @@ -1620,9 +1743,12 @@ class ClonOS return array('html'=>$html,'arr'=>$res); } - function baseRemove($id) + function baseRemove() //$id { //$id=str_replace('base','',$id); + //base10.3-amd64-0 + $form=$this->form; + $id=$form['jname']; $orig_id=$id; preg_match('#base([0-9\.]+)-([^-]+)-(\d+)#',$id,$res); $ver=$res[1]; @@ -1636,7 +1762,7 @@ class ClonOS function basesCompile() { - $form=$this->_vars['form_data']; + $form=$this->form; if(!isset($form['sources']) || !is_numeric($form['sources'])) return array('error'=>true,'errorMessage'=>'Wrong OS type selected!'); $id=$form['sources']; @@ -1647,7 +1773,6 @@ class ClonOS }else{ return array('error'=>true,'errorMessage'=>'Database connect error!'); } - $ver=$base['ver']; $stable_arr=array('release','stable'); $stable_num=strlen(intval($ver))_vars['form_data']; + $form=$this->form; if(!isset($form['version']) || !is_numeric($form['version'])) return array('error'=>true,'errorMessage'=>'Wrong OS type input!'); $stable_arr=array('release','stable'); @@ -1881,7 +2006,7 @@ class ClonOS function addHelperGroup($mode) { $module=$this->url_hash; - $form=$this->form; + if(isset($this->form)) $form=$this->form; else $form=array(); if(isset($form['db_path']) && !empty($form['db_path'])) { $db_path=$form['db_path']; @@ -1904,12 +2029,14 @@ class ClonOS function deleteHelperGroup($mode) { $module=$this->url_hash; - $form=$this->form; - $index=$form['index']; - $index=str_replace('ind-','',$index); + if(isset($this->form)) $form=$this->form; else $form=array(); if(!isset($form['db_path']) || empty($form['db_path'])) return; + if(!file_exists($form['db_path'])) return array('error'=>true,'errorMessage'=>'Error on open temporary form file!'); + + $index=$form['index']; + $index=str_replace('ind-','',$index); $db_path=$form['db_path']; $res=$this->cbsd_cmd('forms inter=0 module='.$module.' formfile='.$db_path.' group=del index='.$index); @@ -1973,10 +2100,13 @@ class ClonOS function runVNC($jname) { $res=$this->cbsd_cmd("vm_vncwss jname={$jname} permit={$this->_client_ip}"); - $res=$this->_db_local->selectAssoc('select nodeip from local'); - $nodeip=$res['nodeip']; + //$res=$this->_db_local->selectAssoc('select nodeip from local'); + //$nodeip=$res['nodeip']; // need for IPv4/IPv6 regex here, instead of strlen - if(strlen($nodeip)<7) $nodeip='127.0.0.1'; + //if(strlen($nodeip)<7) $nodeip='127.0.0.1'; + //if(strlen($nodeip)<7) $nodeip=$this->server_name; + $nodeip=$this->server_name; + header('Location: http://'.$nodeip.':6080/vnc_auto.html?host='.$nodeip.'&port=6080'); exit; } @@ -2059,4 +2189,60 @@ class ClonOS return ''.$cmd_string.''; } + + + function register_media($path,$file,$ext) + { + $cmd='cbsd media mode=register name='.$file.' path='.$path.$file.' type='.$ext; + $res=$this->cbsd_cmd($cmd); + if($res['error']) + { + $arr['error']=true; + $arr['error_message']='File image not registered!'; + }else{ + $arr['error']=false; + } + echo json_encode($arr); + } + function media_iso_list_html() + { +// $form=$this->form; + $db=new Db('base','storage_media'); + $res=$db->select('select * from media where type="iso"'); + if($res===false || empty($res)) return; + + $html=''; + foreach($res as $r) + { + $html.=''; + } + return $html; + } + function updateBhyveISO($iso='') + { + $db=new Db('base','storage_media'); + $res=$db->select('select * from media where type="iso"'); + if($res===false || empty($res)) return; + + $sel=''; + //if(empty($iso)) $sel='#sel#'; + $html=''; + foreach($res as $r) + { + $sel1=''; + if(empty($sel) && $iso==$r['jname']) $sel1='#sel1#'; + $html.=''; + } + + if(strpos($html,'#sel1#')!==false) + { + $html=str_replace('#sel1#',' selected="selected"',$html); + $html=str_replace('#sel#','',$html); + }else{ + $html=str_replace('#sel1#','',$html); + $html=str_replace('#sel#',' selected="selected"',$html); + } + + return $html; + } } \ No newline at end of file diff --git a/php/config.php b/php/config.php index 8c1c255a..1bd5bd72 100644 --- a/php/config.php +++ b/php/config.php @@ -36,13 +36,13 @@ class Config 'title'=>'Virtual machine control panel', 'icon'=>'icon-th-list', ), - +/* 'nodes'=>array( 'name'=>'Nodes', 'title'=>'Nodes control panel', 'icon'=>'icon-buffer', ), - +*/ 'vpnet'=>array( 'name'=>'Virtual Private Network', 'title'=>'Manage for virtual private networks', @@ -78,19 +78,19 @@ class Config 'title'=>'FreeBSD sources manager', 'icon'=>'icon-edit', ), - +/* 'jail_marketplace'=>array( 'name'=>'Jail Marketplace', 'title'=>'Public remote containers marketplace', 'icon'=>'icon-flag', ), - +*//* 'bhyve_marketplace'=>array( 'name'=>'Bhyve Marketplace', 'title'=>'Public remote virtual machine marketplace', 'icon'=>'icon-flag-checkered', ), - +*/ 'tasklog'=>array( 'name'=>'TaskLog', 'title'=>'System task log', @@ -109,8 +109,8 @@ class Config array( 'os'=>'DragonflyBSD', 'items'=>array( - array('name'=>'DragonflyBSD Daily SNAPSHOT','type'=>'dflybsd', - 'profile'=>'x86-LATEST','obtain'=>false), + array('name'=>'DragonflyBSD 4','type'=>'dflybsd', + 'profile'=>'x86-4','obtain'=>false), ), ), array( @@ -131,8 +131,6 @@ class Config 'profile'=>'ArchLinux-x86-2016','obtain'=>false), array('name'=>'Linux CentOS 7','type'=>'linux', 'profile'=>'CentOS-7-x86_64','obtain'=>false), - array('name'=>'Linux Debian 7','type'=>'linux', - 'profile'=>'Debian-x86-7','obtain'=>false), array('name'=>'Linux Debian 8','type'=>'linux', 'profile'=>'Debian-x86-8','obtain'=>false), array('name'=>'Linux Open Suse 42','type'=>'linux', diff --git a/public/css/styles.css b/public/css/styles.css index e5274c7a..149a0643 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -411,7 +411,7 @@ thead td:first-child, td:first-child { .tsimple thead th, .tsimple thead td { border-bottom:3px solid #337ab7; - padding:10px; + padding:8px 8px 8px 0; text-align:left; } .tsimple tbody td { @@ -423,12 +423,15 @@ thead td:first-child, td:first-child { .tsimple tbody tr:nth-child(2n){ background-color: #fafafa; } -.tsimple td.txtleft { +.tsimple .txtleft { text-align:left; } -.tsimple td.txtright { +.tsimple .txtright { text-align:right; } +.tsimple .txtcenter { + text-align:center; +} .tsimple td input[type="button"] { font-size:86%; padding:2px 4px; @@ -959,6 +962,7 @@ http://dimox.name/custom-checkboxes-and-radio-buttons-using-css-only/ #config-menu li { padding:6px !important; line-height:110%; + white-space:nowrap; } #config-menu li:hover { background:#f0f0f0; @@ -1207,4 +1211,87 @@ input[type=range]::-moz-range-track { border-radius:50%; } .online:before {content: '\e82c';color:green;} -.offline:before {content: '\e82d';color:red;} \ No newline at end of file +.offline:before {content: '\e82d';color:red;} + + +#drag-and-drop-zone { + width:400px; + border:1px dotted gray; +} +.uploader div { + padding:10px; + text-align:center; +} +.uploader .browser label { + background-color: #337ab7; + padding: 5px 15px; + color: white; + padding: 6px 0px; + font-weight: bold; + cursor: pointer; + position: relative; + overflow: hidden; + display: block; + width: 300px; + margin: 10px auto 0px auto; + box-shadow: 2px 2px 2px #888888; +} +.uploader div.browser input { + position: absolute; + top: 0; + right: 0; + margin: 0; + border: solid transparent; + border-width: 0 0 100px 200px; + opacity: .0; + filter: alpha(opacity= 0); + -o-transform: translate(250px,-50px) scale(1); + -moz-transform: translate(-300px,0) scale(4); + direction: ltr; + cursor: pointer; +} +.uploader-progress { + width:100%; + background-color:white; +} +.uploader-progress .file { + padding:4px; + border:1px solid silver; + margin-top:4px; +} +.uploader-progress .file-name { + overflow:hidden; + text-overflow:ellipsis; + white-space:nowrap; + width:390px; +} +.uploader-progress .line { + background-color:#337ab7; + height:10px; + opacity:.7; + margin-top:4px; + width:0; +} + + + + +#debug { + position:fixed; + top:20%; + bottom:20%; + left:30%; + right:30%; + overflow:auto; + z-index:15; + border:3px double red; + background-color:antiquewhite; +} +#debug h1 { + background:darkred; + padding:10px; + color:white; +} +#debug div { + padding:20px; +} \ No newline at end of file diff --git a/public/dialogs/bhyve-new.php b/public/dialogs/bhyve-new.php index 719fca0c..b66a3aa7 100644 --- a/public/dialogs/bhyve-new.php +++ b/public/dialogs/bhyve-new.php @@ -39,6 +39,14 @@ err_messages.add({ translate('VM RAM');?>:

+

+ translate('Attached boot ISO image');?>: + +

translate('VNC IP address');?>: diff --git a/public/dialogs/media-upload.php b/public/dialogs/media-upload.php new file mode 100644 index 00000000..a6a0c5e3 --- /dev/null +++ b/public/dialogs/media-upload.php @@ -0,0 +1,30 @@ + +

+

translate('Add Storage Media');?>

+

translate('Upload ISO');?>

+
+
+

+ +

+
Drag & Drop Files Here
+
-or-
+
+ +
+
+
+ +

+
+
+
+ +
+
+ diff --git a/public/images/logo-orig/rtorrent2_orig.png b/public/images/logo-orig/rtorrent2_orig.png new file mode 100644 index 00000000..283cb26b Binary files /dev/null and b/public/images/logo-orig/rtorrent2_orig.png differ diff --git a/public/images/logo/rtorrent.png b/public/images/logo/rtorrent.png index 0f05362e..48ab1de2 100644 Binary files a/public/images/logo/rtorrent.png and b/public/images/logo/rtorrent.png differ diff --git a/public/index.php b/public/index.php index 5e302cb8..27325f34 100644 --- a/public/index.php +++ b/public/index.php @@ -10,6 +10,13 @@ $uri=trim($_SERVER['REQUEST_URI'],'/'); include($_REALPATH.'/php/clonos.php'); $clonos=new ClonOS($_REALPATH,$uri); +if(isset($_GET['upload'])) +{ + include('upload.php'); + $clonos->register_media($path,$file,$ext); + exit; +} + $lang=$clonos->getLang(); $root=trim($_SERVER['DOCUMENT_ROOT'],DIRECTORY_SEPARATOR); $_ds=DIRECTORY_SEPARATOR; @@ -39,6 +46,7 @@ error_reporting(E_ALL); + @@ -97,6 +105,6 @@ if(isset($_languages))foreach($_languages as $lng=>$lngname)
-
+
\ No newline at end of file diff --git a/public/js/clonos.js b/public/js/clonos.js index 7ecec956..ee7f42d5 100644 --- a/public/js/clonos.js +++ b/public/js/clonos.js @@ -22,6 +22,11 @@ var clonos={ 'bclone':{stat:['Clone','Cloning','Cloned'],cmd:'bhyveClone'}, 'brename':{stat:['Rename','Renaming','Renamed'],cmd:'bhyveRename'}, 'vm_obtain':{stat:['Create','Creating','Created'],cmd:'bhyveObtain'}, + 'srcup':{stat:['Update','Updating','Updated'],cmd:'srcUpdate'}, + 'world':{stat:['Compile','Compiling','Compiled'],cmd:'basesCompile'}, + 'repo':{stat:['Fetch','Fetching','Fetched'],cmd:'repoCompile'}, + 'removesrc':{stat:['Remove','Removing','Removed'],cmd:'srcRemove'}, + 'removebase':{stat:['Remove','Removing','Removed'],cmd:'baseRemove'}, }, start:function() @@ -66,7 +71,7 @@ var clonos={ addEvents:function() { $(window).on('hashchange',$.proxy(this.onHashChange,this)); - $('#lng-sel').on('change',function(){document.cookie="lang="+$(this).val()+";path=/;";location.reload();}); + $('#lng-sel').on('change',$.proxy(this.setLang,this)); //function(){document.cookie="lang="+$(this).val()+";path=/;";location.reload();}); $('#content').on('click',$.proxy(this.bodyClick,this)); $('.closer').on('click',$.proxy(this.closerClick,this)); $(window).on('keypress',$.proxy(this.dialogCloseByKey,this)) @@ -180,6 +185,8 @@ var clonos={ if(id=='bhyve-new') { this.trids=this.getTrIdsForCheck('bhyveslist'); + this.updateBhyveISO(); + this.updateBhyveOSProfile(); } this.dialogShow1(id); } @@ -375,6 +382,7 @@ var clonos={ } if(id=='bhyve-new' && $('form#bhyveSettings').length>0) { + this.storageBhyveOSProfile(); var jid=$('form#bhyveSettings input[name="vm_name"]').val(); if(typeof this.trids!='undefined' && this.trids.length>0) { @@ -441,7 +449,11 @@ var clonos={ } if(id=='srcget') { - this.srcVerAdd(); + //this.srcVerAdd(); + var inp=$('form#srcSettings input[name="version"]'); + var id=$(inp).val(); + this.dialogClose(); + this.srcUpdate(id); } if(id=='basescompile') { @@ -486,7 +498,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data!='undefined' && !data.error) { @@ -521,11 +533,11 @@ var clonos={ var table='bhyveslist'; var operation='vm_obtain'; break; - case 'basesCompile': + case 'basesCompile': this.dialogClose();return; var table='baseslist'; var operation='world'; break; - case 'repoCompile': + case 'repoCompile': this.dialogClose();return; var table='baseslist'; var operation='repo'; break; @@ -578,7 +590,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} this.dialogClose(); @@ -588,7 +600,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data!='undefined' && !data.error) { @@ -621,7 +633,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data!='undefined' && !data.error) { @@ -651,7 +663,7 @@ var clonos={ } }, srcVerAdd:function() - { + {return; var n,nl; var posts=$('form#srcSettings').serializeArray(); var version=$('form#srcSettings input[name="version"]').val(); @@ -689,13 +701,51 @@ var clonos={ } if(!injected) { - $(html).insertAfter(tr); + //$(html).insertAfter(tr); + if(trs.length==0) + { + $('table#srcslist tbody').append(html); + }else{ + $(html).insertAfter(tr); + } this.srcUpdate('src'+version); } } }, - + updateBhyveOSProfile:function() + { + if(localStorage) + { + var pos=localStorage['vm_os_profile_pos']; + if(typeof pos!='undefined') + $('#bhyveSettings select[name="vm_os_profile"]').val(pos); + } + + //if(localStorage) db_path=localStorage[var_name]; + }, + storageBhyveOSProfile:function() + { + if(localStorage) + { + var pos=$('#bhyveSettings select[name="vm_os_profile"]').val(); + localStorage['vm_os_profile_pos']=pos; + } + }, + updateBhyveISO:function() + { + this.loadData('updateBhyveISO',$.proxy(this.onUpdateBhyveISO,this)); + }, + onUpdateBhyveISO:function(data) + { + try{ + var data=JSON.parse(data); + }catch(e){this.debug(e.message,data);return;} + if(typeof data.iso_list!='undefined') + { + $('dialog #bhyveSettings select[name="vm_iso_image"]').html(data.iso_list); + } + }, getFreeJname:function() { this.loadData('freejname',$.proxy(this.onGetFreeJname,this)); @@ -704,7 +754,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} $('dialog#jail-settings input[name="jname"]').val(data.freejname); $('dialog#jail-settings input[name="host_hostname"]').val(data.freejname+'.my.domain'); }, @@ -751,7 +801,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(data.error) { @@ -789,7 +839,7 @@ var clonos={ { var txt_status=task.txt_status; //this.tasks.add({'operation':task.task_cmd,'jail_id':t,'status':status,'task_id':task.task_id,'txt_status':txt_status}); - $('tr#'+t+' .jstatus').html(this.translate(txt_status)); + $('tr#'+this.dotEscape(t)+' .jstatus').html(this.translate(txt_status)); this.enableWait(t); } } @@ -1072,7 +1122,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} /* if(typeof data['mod_ops']!='undefined') { @@ -1297,7 +1347,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1322,7 +1372,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1347,7 +1397,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1367,18 +1417,23 @@ var clonos={ if(!c) return; var ver=$('#srcslist tr#'+this.dotEscape(id)+' .version').html(); var op='removesrc'; - this.enableWait(id); - this.tasks.add({'operation':op,'jail_id':id}); - this.tasks.start(); + //this.enableWait(id); + //this.tasks.add({'operation':op,'jail_id':id}); + //this.tasks.start(); + var posts=[{'name':'operation','value':op},{'name':'jname','value':id}]; + if(typeof this.commands[op]!='undefined') + this.loadData(this.commands[op]['cmd'],$.proxy(this.onJailStart,this),posts,false); }, srcUpdate:function(id,vers) { if(typeof vers=='undefined') vers='stable'; var ver=$('#srcslist tr#'+this.dotEscape(id)+' .version').html(); var op='srcup'; - this.enableWait(id); - this.tasks.add({'operation':op,'jail_id':id}); - this.tasks.start(); + //this.tasks.add({'operation':op,'jail_id':id}); + //this.tasks.start(); + var posts=[{'name':'operation','value':op},{'name':'jname','value':id}]; + if(typeof this.commands[op]!='undefined') + this.loadData(this.commands[op]['cmd'],$.proxy(this.onJailStart,this),posts,false); }, baseRemove:function(id) { @@ -1386,9 +1441,15 @@ var clonos={ if(!c) return; var ver=$('#baseslist tr#'+this.dotEscape(id)+' .version').html(); var op='removebase'; - this.enableWait(id); - this.tasks.add({'operation':op,'jail_id':id}); - this.tasks.start(); + //this.enableWait(id); + //this.tasks.add({'operation':op,'jail_id':id}); + //this.tasks.start(); + var posts=[{'name':'operation','value':op},{'name':'jname','value':id}]; + if(typeof this.commands[op]!='undefined') + { + this.loadData(this.commands[op]['cmd'],$.proxy(this.onJailStart,this),posts,false); + $('tr#'+id+' .jstatus').html(this.translate(this.commands[op]['stat'][1])); + } }, @@ -1403,7 +1464,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1425,7 +1486,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1780,6 +1841,9 @@ var clonos={ var id=dt.id; var table_id=dt.table_id; var preloadVars=false; + + this.DDMenuClose(); + switch(table_id) { case 'jailslist': @@ -1864,7 +1928,6 @@ var clonos={ break; } - this.DDMenuClose(); if(preloadVars) { var posts=[{'name':'jail_id','value':id},{'name':'dialog','value':dialog},{'name':'elid','value':elid}]; @@ -1877,7 +1940,7 @@ var clonos={ { try{ var data=JSON.parse(data); - }catch(e){alert(e.message);return;} + }catch(e){this.debug(e.message,data);return;} if(typeof data.error!='undefined') { @@ -1886,8 +1949,8 @@ var clonos={ this.notify(data.error_message,'error'); if(typeof data.reload!='undefined') { - if(data.reload) - this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); + if(data.reload) this.dataReload(); + //this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); } return; } @@ -1895,6 +1958,8 @@ var clonos={ var dialog=data.dialog; this.fillDialogVars(dialog,data.vars); + if(data.dialog=='bhyve-new' && typeof data.iso_list!='undefined') + $('dialog#bhyve-new select[name="vm_iso_image"]').html(data.iso_list); this.dialogShow1(dialog,this.cnt_mode); /* @@ -1907,6 +1972,36 @@ var clonos={ }, + dataReload:function() + { + this.loadData('getJsonPage',$.proxy(this.onLoadData,this)); + }, + + fillFormVars:function(form,data) + { + var n=0, + f=$(form); + if(f.length<1) return; + + for(n=0,nl=data.length;n0) return; + var trs=$('table#'+table+' tbody tr'); for(n=0,nl=trs.length;n
'+file.name+'
'); + }, + delete_file:function(id) + { + $('.uploader-progress #f-'+id).remove(); + }, + + debug:function(message,data) + { + this.dialogClose(); + $('body').append('

'+message+'

'+data+'
'); + }, + closeDebug:function() + { + $('#debug').remove(); + }, + + setLang:function(event) + { + var target=event.target; + var lang=$(target).val(); + if(localStorage) + { + //localStorage['lang']=lang; + } + document.cookie="lang="+lang+";path=/;"; + location.reload(); + }, } function isset(varr){for(a in arguments){if(typeof arguments[a]=='undefined')return false;}return true;} +function ws_debug(){ + var res=prompt('Введите JSON строку',''); + if(res=='' || res==null) return; + var data=JSON.parse(res); + clonos.onChangeStatus(data); +} $(window).on('load',function(){clonos.start();}); diff --git a/public/js/dmuploader.js b/public/js/dmuploader.js new file mode 100644 index 00000000..7ba7d469 --- /dev/null +++ b/public/js/dmuploader.js @@ -0,0 +1,9 @@ +/* + * dmuploader.min.js - Jquery File Uploader - 0.1 + * http://www.daniel.com.uy/projects/jquery-file-uploader/ + * + * Copyright (c) 2013 Daniel Morales + * Dual licensed under the MIT and GPL licenses. + * http://www.daniel.com.uy/doc/license/ + */ +(function(t){var n="dmUploader";var r={url:document.URL,method:"POST",extraData:{},maxFileSize:0,allowedTypes:"*",extFilter:null,dataType:null,fileName:"file",onInit:function(){},onFallbackMode:function(){message},onNewFile:function(e,t){},onBeforeUpload:function(e){},onComplete:function(){},onUploadProgress:function(e,t){},onUploadSuccess:function(e,t){},onUploadError:function(e,t){},onFileTypeError:function(e){},onFileSizeError:function(e){},onFileExtError:function(e){}};var i=function(e,n){this.element=t(e);this.settings=t.extend({},r,n);if(!this.checkBrowser()){return false}this.init();return true};i.prototype.checkBrowser=function(){if(window.FormData===undefined){this.settings.onFallbackMode.call(this.element,"Browser doesn't support Form API");return false}if(this.element.find("input[type=file]").length>0){return true}if(!this.checkEvent("drop",this.element)||!this.checkEvent("dragstart",this.element)){this.settings.onFallbackMode.call(this.element,"Browser doesn't support Ajax Drag and Drop");return false}return true};i.prototype.checkEvent=function(e,t){var t=t||document.createElement("div");var e="on"+e;var n=e in t;if(!n){if(!t.setAttribute){t=document.createElement("div")}if(t.setAttribute&&t.removeAttribute){t.setAttribute(e,"");n=typeof t[e]=="function";if(typeof t[e]!="undefined"){t[e]=undefined}t.removeAttribute(e)}}t=null;return n};i.prototype.init=function(){var e=this;e.queue=new Array;e.queuePos=-1;e.queueRunning=false;e.element.on("drop",function(t){t.preventDefault();var n=t.originalEvent.dataTransfer.files;e.queueFiles(n)});e.element.find("input[type=file]").on("change",function(n){var r=n.target.files;e.queueFiles(r);t(this).val("")});this.settings.onInit.call(this.element)};i.prototype.queueFiles=function(e){var n=this.queue.length;for(var r=0;r0&&i.size>this.settings.maxFileSize){this.settings.onFileSizeError.call(this.element,i);continue}if(this.settings.allowedTypes!="*"&&!i.type.match(this.settings.allowedTypes)){this.settings.onFileTypeError.call(this.element,i);continue}if(this.settings.extFilter!=null){var s=this.settings.extFilter.toLowerCase().split(";");var o=i.name.toLowerCase().split(".").pop();if(t.inArray(o,s)<0){this.settings.onFileExtError.call(this.element,i);continue}}this.queue.push(i);var u=this.queue.length-1;this.settings.onNewFile.call(this.element,u,i)}if(this.queueRunning){return false}if(this.queue.length==n){return false}this.processQueue();return true};i.prototype.processQueue=function(){var n=this;n.queuePos++;if(n.queuePos>=n.queue.length){n.settings.onComplete.call(n.element);n.queuePos=n.queue.length-1;n.queueRunning=false;return}var r=n.queue[n.queuePos];var i=new FormData;i.append(n.settings.fileName,r);n.settings.onBeforeUpload.call(n.element,n.queuePos);t.each(n.settings.extraData,function(e,t){i.append(e,t)});n.queueRunning=true;t.ajax({url:n.settings.url,type:n.settings.method,dataType:n.settings.dataType,data:i,cache:false,contentType:false,processData:false,forceSync:false,xhr:function(){var r=t.ajaxSettings.xhr();if(r.upload){r.upload.addEventListener("progress",function(t){var r=0;var i=t.loaded||t.position;var s=t.total||e.totalSize;if(t.lengthComputable){r=Math.ceil(i/s*100)}n.settings.onUploadProgress.call(n.element,n.queuePos,r)},false)}return r},success:function(e,t,r){n.settings.onUploadSuccess.call(n.element,n.queuePos,e)},error:function(e,t,r){n.settings.onUploadError.call(n.element,n.queuePos,r)},complete:function(e,t){n.processQueue()}})};t.fn.dmUploader=function(e){return this.each(function(){if(!t.data(this,n)){t.data(this,n,new i(this,e))}})};t(document).on("dragenter",function(e){e.stopPropagation();e.preventDefault()});t(document).on("dragover",function(e){e.stopPropagation();e.preventDefault()});t(document).on("drop",function(e){e.stopPropagation();e.preventDefault()})})(jQuery) \ No newline at end of file diff --git a/public/lang/ru.js b/public/lang/ru.js index dceeedb3..a45d2eec 100644 --- a/public/lang/ru.js +++ b/public/lang/ru.js @@ -42,6 +42,12 @@ clonos.lang={ "Rename":"Переименовать", "Renaming":"Переименовываем", "Renamed":"Переименовано", + "Fetch":"Получить", + "Fetching":"Получаем", + "Fetched":"Получено", + "Compile":"Собрать", + "Compiling":"Собираем", + "Compiled":"Собрано", //"Create jail":"Создание контейнера", //"Edit jail":"Редактирование параметров контейнера", diff --git a/public/pages/bases/a.json.php b/public/pages/bases/a.json.php index fc056c94..2a015281 100644 --- a/public/pages/bases/a.json.php +++ b/public/pages/bases/a.json.php @@ -8,6 +8,7 @@ $nodes=array_reverse($nodes); $ids=array(); $nth=0; +$hres=$this->getTableChunk('baseslist','tbody'); if(!empty($nodes))foreach($nodes as $node) { $db1=new Db('base',$node['nodename']); @@ -26,24 +27,24 @@ if(!empty($nodes))foreach($nodes as $node) } $ids[]=$base['idx']; - $bid=$base['ver'].'-'.$base['arch'].'-'.$base['stable']; + $id='base'.$base['ver'].'-'.$base['arch'].'-'.$base['stable']; - $hres=$this->getTableChunk('baseslist','tbody'); if($hres!==false) { $html_tpl=$hres[1]; $vars=array( - 'bid'=>$bid, + 'id'=>$id, 'nth-num'=>'nth'.$num, 'node'=>$node['nodename'], 'name'=>$base['name'], 'platform'=>$base['platform'], 'arch'=>$base['arch'], 'targetarch'=>$base['targetarch'], - 'ver'=>$base['ver'], - 'stable'=>($base['stable']==1)?'stable':'release', + 'version'=>$base['ver'], + 'version1'=>($base['stable']==1)?'stable':'release', 'elf'=>$base['elf'], 'date'=>$base['date'], + 'jstatus'=>'', 'maintenance'=>($idle==0)?' maintenance':'', 'deltitle'=>$this->translate('Delete'), ); @@ -54,23 +55,45 @@ if(!empty($nodes))foreach($nodes as $node) $html.=$html_tpl; } - $ids[]='#base'.$bid; + //$ids[]='#base'.$bid; + $ids[]='#'.$id; } $nth++; } } +$html=str_replace(array("\n","\r","\t"),'',$html); + $tasks=''; if(!empty($ids)) { $tasks=$this->getRunningTasks($ids); } +$html_tpl=str_replace(array("\n","\r","\t"),'',$hres[1]); +if($hres!==false) +{ + $vars=array( + 'nth-num'=>'nth0', + 'status'=>'', + //'jstatus'=>$this->translate('Updating'), + //'icon'=>'spin6 animate-spin', + 'desktop'=>' s-off', + 'maintenance'=>' maintenance busy', + 'updtitle'=>$this->translate('Update'), + 'deltitle'=>$this->translate('Delete'), + ); + + foreach($vars as $var=>$val) + $html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); +} + echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'baseslist', 'tasks'=>$tasks, + 'template'=>$html_tpl, )); \ No newline at end of file diff --git a/public/pages/bases/baseslist.table b/public/pages/bases/baseslist.table index c06e44ee..4cc3cc9f 100644 --- a/public/pages/bases/baseslist.table +++ b/public/pages/bases/baseslist.table @@ -1,16 +1,16 @@ - - #node# - #name# - #platform# - #arch# - #targetarch# - #ver# - #stable# - #elf# - #date# + + #node# + #name# + #platform# + #arch# + #targetarch# + #version# + #version1# + #elf# + #date# - + #jstatus# diff --git a/public/pages/bhyvevms/a.json.php b/public/pages/bhyvevms/a.json.php index db60bb72..754fa421 100644 --- a/public/pages/bhyvevms/a.json.php +++ b/public/pages/bhyvevms/a.json.php @@ -13,6 +13,7 @@ $allnodes=array(); $jail_ids=array(); $nth=0; +$hres=$this->getTableChunk('bhyveslist','tbody'); if(!empty($nodes))foreach($nodes as $node) { $db1=new Db('base',$node); @@ -25,7 +26,6 @@ if(!empty($nodes))foreach($nodes as $node) if(!empty($bhyves)) foreach($bhyves as $bhyve) { - $hres=$this->getTableChunk('bhyveslist','tbody'); if($hres!==false) { $html_tpl=$hres[1]; diff --git a/public/pages/bhyvevms/bhyveslist.table b/public/pages/bhyvevms/bhyveslist.table index ab198fc9..2b45ef63 100644 --- a/public/pages/bhyvevms/bhyveslist.table +++ b/public/pages/bhyvevms/bhyveslist.table @@ -2,7 +2,7 @@ #node# #jname# - #vm_ram# + #vm_ram# #vm_cpus# #vm_os_type# #vm_status# diff --git a/public/pages/bhyvevms/ru.index.php b/public/pages/bhyvevms/ru.index.php index 7310d810..90e4847b 100644 --- a/public/pages/bhyvevms/ru.index.php +++ b/public/pages/bhyvevms/ru.index.php @@ -19,10 +19,10 @@ $clonos->useDialogs(array( Имя сервера Виртуальная машина - RAM + RAM CPU - Тип ОС - Статус + Тип ОС + Статус Действия VNC diff --git a/public/pages/instance_jail/helpers.php b/public/pages/instance_jail/helpers.php index c995d7fb..da515ebd 100644 --- a/public/pages/instance_jail/helpers.php +++ b/public/pages/instance_jail/helpers.php @@ -1,19 +1,21 @@ url_hash; //=preg_replace('/^#/','',$this->_vars['hash']); - + $db_path=false; -if(isset($this->_vars['db_path']) && !empty($this->_vars['db_path'])) +if(!isset($this->_vars['db_path'])) { - $db_path=$this->_vars['db_path']; + //$db_path=$this->_vars['db_path']; $res=$this->cbsd_cmd('make_tmp_helper module='.$hash); if($res['retval']==0) { $db_path=$res['message']; }else{ - echo json_encode(array('error'=>true,'errorMessage'=>'Error on open temporary form file!')); + echo json_encode(array('error'=>true,'errorMessage'=>'Error on open temporary form database!')); return; } +}else{ + $db_path=$this->_vars['db_path']; } $form=new Forms('',$hash,$db_path); diff --git a/public/pages/jailscontainers/a.json.php b/public/pages/jailscontainers/a.json.php index 588ef2f6..075cfe41 100644 --- a/public/pages/jailscontainers/a.json.php +++ b/public/pages/jailscontainers/a.json.php @@ -22,6 +22,7 @@ $allnodes=array(); $jail_ids=array(); $nth=0; +$hres=$this->getTableChunk('jailslist','tbody'); if(!empty($nodes))foreach($nodes as $node) { $db1=new Db('base',$node); @@ -33,8 +34,6 @@ if(!empty($nodes))foreach($nodes as $node) $num=$nth & 1; if(!empty($jails)) foreach($jails as $jail) { - - $hres=$this->getTableChunk('jailslist','tbody'); if($hres!==false) { $html_tpl=$hres[1]; diff --git a/public/pages/jailscontainers/helpers.json.php b/public/pages/jailscontainers/helpers.json.php index f2f34415..fa1fa3b1 100644 --- a/public/pages/jailscontainers/helpers.json.php +++ b/public/pages/jailscontainers/helpers.json.php @@ -91,7 +91,7 @@ if(empty($hash)) $db_path=$db->getFileName(); $form=new Forms($jail_name,$hash,$db_path); $res=$form->generate(); - $res['html']='

'.$this->translate('Helper settings').'

'.$res['html']; + $res['html']='

'.$this->translate('Helper settings: '.$hash).'

'.$res['html']; } diff --git a/public/pages/jailscontainers/ru.index.php b/public/pages/jailscontainers/ru.index.php index 0369e63f..a8e3f62c 100644 --- a/public/pages/jailscontainers/ru.index.php +++ b/public/pages/jailscontainers/ru.index.php @@ -25,7 +25,7 @@ $clonos->useDialogs(array( Имя сервера Контейнер IP-адрес - Статус + Статус Действия VNC diff --git a/public/pages/media/a.json.php b/public/pages/media/a.json.php index 731a8b14..01805096 100644 --- a/public/pages/media/a.json.php +++ b/public/pages/media/a.json.php @@ -1,7 +1,7 @@ select('SELECT idx,name,path FROM media'); +$res=$db->select('SELECT idx,name,path,jname FROM media where type="iso"'); $html=''; if($res!==false) @@ -20,6 +20,7 @@ if($res!==false) 'mediaid'=>$item['idx'], 'medianame'=>$item['name'], 'mediapath'=>$item['path'], + 'jname'=>$item['jname'], 'deltitle'=>' title="'.$this->translate('Delete').'"', ); diff --git a/public/pages/media/en.index.php b/public/pages/media/en.index.php index 614ea29f..3fcfc7ea 100644 --- a/public/pages/media/en.index.php +++ b/public/pages/media/en.index.php @@ -2,19 +2,22 @@ $section_name='media'; $clonos->useDialogs(array( - $section_name, + //$section_name, + 'media-upload', )); ?> -

Subnet list

+

Virtual media list

- Add ISO + + Upload ISO

- + + diff --git a/public/pages/media/mediaslist.table b/public/pages/media/mediaslist.table index 24ee9c34..991266b5 100644 --- a/public/pages/media/mediaslist.table +++ b/public/pages/media/mediaslist.table @@ -2,6 +2,7 @@ + diff --git a/public/pages/media/ru.index.php b/public/pages/media/ru.index.php index 11d937df..e227fdd4 100644 --- a/public/pages/media/ru.index.php +++ b/public/pages/media/ru.index.php @@ -2,19 +2,22 @@ $section_name='media'; $clonos->useDialogs(array( - $section_name, + //$section_name, + 'media-upload', )); ?> -

Список подсетей

+

Список виртуальных дисков

- Добавить ISO + + Добавить ISO

Storage nameName of the disk PathVM Action
#medianame# #mediapath##jname#
+ diff --git a/public/pages/overview/en.index.php b/public/pages/overview/en.index.php index de49d229..cbfbec5b 100644 --- a/public/pages/overview/en.index.php +++ b/public/pages/overview/en.index.php @@ -3,7 +3,7 @@
Имя носителя ПутьКлетка/VM Действия
- + @@ -14,7 +14,7 @@ - + @@ -23,216 +23,13 @@

It is an open source and free product which powered by other project (major importance list):

-'; -print_r($wd->getHello()); - -return; - -function fetch_node_inv($dbfilepath) -{ - global $allncpu, $allcpufreq, $allphysmem, $allnodes, $nodetable, $alljails, $knownfreq, $workdir; - - $stat = file_exists($dbfilepath); - - if (!$stat) { - $nodetable .= ""; - return 0; - } - - $db = new SQLite3($dbfilepath); $db->busyTimeout(5000); - $results = $db->query('SELECT COUNT(*) FROM jails;'); - - if (!($results instanceof Sqlite3Result)) { - $numjails=0; - } else { - while ($row = $results->fetchArray()) { - $numjails=$row[0]; - } - } - - $gwinfo=""; - - $netres = $db->query('SELECT ip4,ip6,mask4,mask6 FROM net;'); - - if (!($netres instanceof Sqlite3Result)) { - echo "Error: $dbfilepath"; - $gwinfo="unable to fetch net info"; - } else { - while ($row = $netres->fetchArray()) { - for ($i=0;$i<4;$i++) - if (isset($row[$i])) $gwinfo.= $row[$i]." "; - } - } - - $netres = $db->query('select * from gw;'); - - if (!($netres instanceof Sqlite3Result)) { - } else { - while ($row = $netres->fetchArray()) { - for ($i=0;$i<4;$i++) - if (isset($row[$i])) $gwinfo.= $row[$i]." "; - } - } - - $results = $db->query('SELECT nodename,nodeip,fs,ncpu,physmem,cpufreq,osrelease FROM local;'); - if (!($results instanceof Sqlite3Result)) { - $nodetable .=<< - - -EOF; - } else { - while ($row = $results->fetchArray()) { - list($nodename, $nodeip, $fs, $ncpu, $physmem, $cpufreq, $osrelease) = $row; - $descrfile=$workdir."/var/db/nodedescr/".$nodename.".descr"; - $desc=""; - if (file_exists($descrfile)) { - $fp = fopen($descrfile, "r"); - $size = filesize($descrfile); - if ($size>0) - $desc = fread($fp, filesize($descrfile)); - fclose($fp); - } - - $locfile=$workdir."/var/db/nodedescr/".$nodename.".location"; - $loc=""; - - if (file_exists($locfile)) { - $fp = fopen($locfile, "r"); - $size = filesize($locfile); - if ($size>0) - $loc = fread($fp, filesize($locfile)); - fclose($fp); - } - - $notesfile=$workdir."/var/db/nodedescr/".$nodename.".notes"; - $notes=""; - - if (file_exists($notesfile)) { - $fp = fopen($notesfile, "r"); - $size = filesize($notesfile); - if ($size>0) - $notes = fread($fp, filesize($notesfile)); - fclose($fp); - } - - $nodetable .=<< - - - - - - - - - - - - -EOF; - $allncpu+=$ncpu; - $allphysmem+=$physmem; - $allcpufreq+=$cpufreq; - $alljails+=$numjails; - if ($cpufreq>1) $knownfreq++; - } - } -$db->close(); -} - - -function show_overview($workdir) -{ - global $allncpu, $allcpufreq, $allphysmem, $allnodes, $nodetable, $alljails, $knownfreq, $workdir; - echo "Summary statistics for cloud:"; - -$allncpu=0; -$allcpufreq=0; -$allphysmem=0; -$allnodes=0; -$nodetable=""; -$alljails=0; -$knownfreq=0; -$offlinenodes=0; - -$db = new SQLite3("$workdir/var/db/nodes.sqlite"); $db->busyTimeout(5000); -$sql = "SELECT nodename,ip FROM nodelist"; -$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC); -$row = array(); -$i = 0; - -while($res = $result->fetchArray(SQLITE3_ASSOC)){ - if(!isset($res['nodename'])) continue; - $nodename = $res['nodename']; - $nodeip = $res['ip']; - ++$allnodes; - $path=$workdir."/var/db/"; - $postfix=".sqlite"; - $dbpath=$path.chop($nodename).$postfix; - - $idle=check_locktime($nodeip); - - if ( $idle == 0 ) { - $offlinenodes++; - } - - fetch_node_inv($dbpath); -} - -fetch_node_inv($workdir."/var/db/local.sqlite"); - -if ( $offlinenodes == 0 ) { - $offlinecolor="#FFFF99"; -} else { - $offlinecolor="#FF9B77"; -} - - -if ( $knownfreq > 0 ) { - $avgfreq=round($allcpufreq / $knownfreq); -} else { - $avgfreq=0; -} - -$outstr=<< - - - - - - - - - - - - - - - - - - - - - - - - -
ItemValueParamValues
Num of cores:
Average freq. Mhz:
Summary RAM:
Summary Storage:
Summary storage size:
-EOF; - -echo $outstr; -} - -show_overview($wd->workdir); + \ No newline at end of file diff --git a/public/pages/settings/en.index.php b/public/pages/settings/en.index.php new file mode 100644 index 00000000..5cf7bdd6 --- /dev/null +++ b/public/pages/settings/en.index.php @@ -0,0 +1,7 @@ +

ClonOS Settings

+generate(); + +echo $res['html']; \ No newline at end of file diff --git a/public/pages/settings/ru.index.php b/public/pages/settings/ru.index.php index 7f72981c..84cb2087 100644 --- a/public/pages/settings/ru.index.php +++ b/public/pages/settings/ru.index.php @@ -1,4 +1,4 @@ -

Настройки CBSD

+

Настройки ClonOS

getTableChunk('srcslist','tbody'); if(!empty($nodes))foreach($nodes as $node) { $db1=new Db('base',$node['nodename']); @@ -25,7 +26,6 @@ if(!empty($nodes))foreach($nodes as $node) $idle=$this->check_locktime($node['ip']); } - $hres=$this->getTableChunk('srcslist','tbody'); if($hres!==false) { $html_tpl=$hres[1]; @@ -35,10 +35,12 @@ if(!empty($nodes))foreach($nodes as $node) 'node'=>$node['nodename'], 'name'=>$base['name'], 'platform'=>$base['platform'], - 'ver'=>$base['ver'], - 'ver1'=>$vers, + 'version'=>$base['ver'], + 'version1'=>$vers, 'rev'=>$base['rev'], 'date'=>$base['date'], + 'jstatus'=>'', + 'icon'=>'', 'maintenance'=>($idle==0)?' maintenance':'', 'deltitle'=>$this->translate('Delete'), 'updtitle'=>$this->translate('Update'), @@ -57,16 +59,37 @@ if(!empty($nodes))foreach($nodes as $node) } } +$html=str_replace(array("\n","\r","\t"),'',$html); + $tasks=''; if(!empty($ids)) { $tasks=$this->getRunningTasks($ids); } +$html_tpl=str_replace(array("\n","\r","\t"),'',$hres[1]); +if($hres!==false) +{ + $vars=array( + 'nth-num'=>'nth0', + 'status'=>'', + 'jstatus'=>$this->translate('Updating'), + //'icon'=>'spin6 animate-spin', + 'desktop'=>' s-off', + 'maintenance'=>' maintenance busy', + 'updtitle'=>$this->translate('Update'), + 'deltitle'=>$this->translate('Delete'), + ); + + foreach($vars as $var=>$val) + $html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); +} + echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'srcslist', 'tasks'=>$tasks, + 'template'=>$html_tpl, )); \ No newline at end of file diff --git a/public/pages/sources/srcslist.table b/public/pages/sources/srcslist.table index 7e96a6c6..b1b66078 100644 --- a/public/pages/sources/srcslist.table +++ b/public/pages/sources/srcslist.table @@ -1,14 +1,14 @@ - - #node# + + #node# - #ver# - #ver1# - #rev# - #date# - - + #version# + #version1# + #rev# + #date# + + - + #jstatus# diff --git a/public/templates/vm.tpl b/public/templates/vm.tpl index 4e9932cc..666ee67e 100644 --- a/public/templates/vm.tpl +++ b/public/templates/vm.tpl @@ -56,7 +56,10 @@ vm_efi="uefi"; #iso_site=""; # must be merged from CBSD profiles #iso_img=""; # must be merged from CBSD profiles #register_iso_name="" # must be merged from CBSD profiles -#register_iso_as="" # must be merged from CBSD profiles +#register_iso_as="" # must be merged from CBSD profiles +#register_iso_name# # template for iso name variable +#register_iso_as# # template for iso path variable +#iso_var_block# # template for block of vars: iso_extract, iso_img_dist, iso_img, iso_site #vm_hostbridge="hostbridge"; # must be merged from CBSD profiles #bhyve_flags=""; # must be merged from CBSD profiles diff --git a/public/upload.php b/public/upload.php new file mode 100644 index 00000000..4c318475 --- /dev/null +++ b/public/upload.php @@ -0,0 +1,77 @@ +$path); + + //$filename=$path.$filename.'-'.$uid.".".$ext; + $file=$file.'.'.$ext; + $filename=$path.$file; //.'.'.$ext; + if (move_uploaded_file($_FILES['file']['tmp_name'], $filename)) + { + $status = 'ok'; //'Successfully uploaded!'; + }else{ + $status = 'Upload Fail: Unknown error occurred!'; + } + } +} +if($status!='ok') {echo json_encode(array('status' => $status));exit;} +return; + +$valid_exts = array('image/jpeg', 'image/jpg', 'image/png', 'image/gif'); // valid extensions +$max_size = 30000 * 1024; // max file size in bytes + +$json = array(); + if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) + { + for($i=0;$i$path); + + $filename = "image_" . $date . "_" .$uid . "." . $ext; + //$this->createthumb($i,$filename); + + // move uploaded file from temp to uploads directory + if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $path)) + { + $status = 'ok'; //'Successfully uploaded!'; + //perform sql updates here + }else{ + $status = 'Upload Fail: Unknown error occurred!'; + } + }else{ + $status = 'Upload Fail: Unsupported file format or It is too large to upload!'; + } + }else{ + $status = 'Upload Fail: File not uploaded!'; + } + } + }else{ + $status = 'Bad request!'; + } + + echo json_encode(array('status' => $status)); + //echo json_encode($json); \ No newline at end of file