Add retrieve device files

This commit is contained in:
steve-lad 2021-07-14 13:10:15 +02:00
parent 2ffe4028e6
commit ef77bce159
4 changed files with 84 additions and 8 deletions

View file

@ -513,7 +513,16 @@ $(document).ready(function () {
}
// ----------------------- Server.model form ----------------
if ($(this).data('id') === 'get_ext_files') {
var dev_cmd = 'get_ext_files';
var dev_fld = ["device"];
datas = 'enabled=0' + 'type=firmware' + 'name=' + '&';
for (var i = 0; i < dev_fld.length; i++) {
datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&';
}
;
}
if ($(this).data('id') === 'model_add') {
var dev_cmd = 'model_add';
// var dev_fld = ["model","vendor","dns","buttons","loadimage","loadinformationid","validate","enabled"];

View file

@ -21,6 +21,7 @@ trait ajaxHelper {
case 'getUserGrid':
case 'getSoftKey':
case 'getDialTemplate':
case 'get_ext_files':
case 'create_hw_tftp':
case 'reset_dev':
case 'reset_token':
@ -382,6 +383,11 @@ trait ajaxHelper {
break;
case 'validateMac':
break;
case 'get_ext_files':
dbug('request is ', $_REQUEST);
return true;
break;
}
}
@ -554,7 +560,7 @@ trait ajaxHelper {
$save_settings[] = array('status' => true);
$this->createDefaultSccpXml();
$this->getFilesFromProvisioner();
//$this->getFileListFromProvisioner();
return $save_settings;
}

View file

@ -250,7 +250,7 @@ trait helperfunctions {
}
return false;
}
// temporary helper function to save xml with proper indentation
// helper function to save xml with proper indentation
public function saveXml($xml, $filename) {
$dom = new \DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
@ -259,13 +259,28 @@ trait helperfunctions {
$dom->save($filename);
}
public function getFilesFromProvisioner() {
public function getFileListFromProvisioner() {
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/tftpboot/";
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/";
// Get master tftpboot directory structure
file_put_contents("{$this->sccppath['tftp_path']}/masterFilesStructure.xml",file_get_contents("{$provisionerUrl}tools/tftpbootFiles.xml"));
//$xmlData = simplexml_load_file("{$provisionerUrl}tools/tftpbootFiles.xml");
return true;
}
public function getFilesFromProvisioner($type = "",$name = "",$device = "") {
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/";
// Get master tftpboot directory structure
$xmlData = simplexml_load_file("{$provisionerUrl}tools/tftpbootFiles.xml");
// Ringtones
$ringDir = 'ringtones/';
$ringDir = 'tftpboot/ringtones/';
$ringList = 'ringlist.xml';
$xmlData = simplexml_load_file("{$provisionerUrl}{$ringDir}{$ringList}");
//$xmlData = simplexml_load_file("{$provisionerUrl}{$ringDir}{$ringList}");
//preg_match_all("|>([0-9a-z]+.xml)</a></span>|U", $availableFiles, $out);
foreach ($xmlData as $child) {
$fileToSave = str_replace("\\","/",(string)$child->FileName);

View file

@ -32,6 +32,8 @@
<li><a class="dropitem" data-id="all" tabindex="-1" href="#"><span><?php echo _('Show All') ?></span></a></li>
</ul>
</div>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".get_ext_file"><i class="fa fa-bolt"></i> <?php echo _("Update Files from Provisioner"); ?>
</button>
</div>
<table data-cookie="true" data-row-style="SetRowColor" data-cookie-id-table="sccp_model-all" data-url="ajax.php?module=sccp_manager&command=getDeviceModel&type=enabled" data-cache="false" data-show-refresh="true" data-toolbar="#toolbar-model" data-maintain-selected="true" data-show-columns="true" data-show-toggle="true" data-toggle="table" data-pagination="true" data-search="true" class="table table-condensed" id="table-models" data-id="model" data-unique-id="model">
<thead>
@ -61,7 +63,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="gridSystemModalLabel"><?php echo _('Modal title');?></h4>
<h4 class="modal-title" id="gridSystemModalLabel"><?php echo _('Add new model');?></h4>
</div>
<div class="modal-body">
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
@ -141,7 +143,51 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _('Close');?></button>
<button type="button" class="btn btn-primary sccp_update" data-id="model_add" id="add_new_model" data-dismiss="modal"><?php echo _('Add New model without Enabled');?></button>
<button type="button" class="btn btn-primary sccp_update" data-id="model_add" id="add_new_model" data-dismiss="modal"><?php echo _('Add New model - Disabled');?></button>
</div>
</div>
</div>
</div>
<div class="modal fade get_ext_file" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="gridSystemModalLabel"><?php echo _('Get Files From Provisioner');?></h4>
</div>
<div class="modal-body">
<div class="element-container">
<div class="row">
<div class="col-md-12">
<?php echo "Sccp_Manager will try to download the firmware and template files from Provision_Sccp on GitHub.<br>
This site, dkgroot/provision_sccp, is unrelated to Sccp_Manager, and the files found cannot be warrantied<br>
If you accept this, please select the device type that you want to try to get files for and then Get Files From Provisioner<br><br>" ?>
</div>
</div>
</div>
<div class="element-container">
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="get_model_files"><?php echo _('Fetch Files for');?></label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="get_model_files"></i>
</div>
<div class="col-md-9">
<input type="text" class="form-control" id="ext_device" name="new_model" value="79XX">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span id="new_model-help" class="help-block fpbx-help-block">Help.</span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _('Cancel');?></button>
<button type="button" class="btn btn-primary sccp_update" data-id="get_ext_files" id="get_model_files" data-dismiss="modal"><?php echo _('Get Files from Provisioner');?></button>
</div>
</div>
</div>