Admin page: delete feed / project
This commit is contained in:
11
inc/feed.php
11
inc/feed.php
@@ -194,4 +194,15 @@ class Feed extends PhpObject {
|
|||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
$sDesc = '';
|
||||||
|
if($this->getFeedId() > 0) {
|
||||||
|
$bSuccess = $this->oDb->deleteRow(self::FEED_TABLE, $this->getFeedId());
|
||||||
|
if(!$bSuccess) $sDesc = $this->oDb->getLastError();
|
||||||
|
}
|
||||||
|
else $sDesc = 'Error while setting project: no Feed ID';
|
||||||
|
|
||||||
|
return $sDesc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -176,4 +176,15 @@ class Project extends PhpObject {
|
|||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
$sDesc = '';
|
||||||
|
if($this->getProjectId() > 0) {
|
||||||
|
$bSuccess = $this->oDb->deleteRow(self::PROJ_TABLE, $this->getProjectId());
|
||||||
|
if(!$bSuccess) $sDesc = $this->oDb->getLastError();
|
||||||
|
}
|
||||||
|
else $sDesc = 'Error while setting project: no project ID';
|
||||||
|
|
||||||
|
return $sDesc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
24
inc/spot.php
24
inc/spot.php
@@ -442,11 +442,12 @@ class Spot extends Main
|
|||||||
|
|
||||||
public function getAdminSettings() {
|
public function getAdminSettings() {
|
||||||
$oFeed = new Feed($this->oDb);
|
$oFeed = new Feed($this->oDb);
|
||||||
return self::getJsonResult(true, '', array(
|
$asData = array(
|
||||||
'project' => $this->oProject->getProjects(),
|
'project' => $this->oProject->getProjects(),
|
||||||
'feed' => $oFeed->getFeeds(),
|
'feed' => $oFeed->getFeeds(),
|
||||||
'spot' => $oFeed->getSpots()
|
'spot' => $oFeed->getSpots()
|
||||||
));
|
);
|
||||||
|
return self::getJsonResult(true, '', $asData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAdminSettings($sType, $iId, $sField, $sValue) {
|
public function setAdminSettings($sType, $iId, $sField, $sValue) {
|
||||||
@@ -497,6 +498,25 @@ class Spot extends Main
|
|||||||
return self::getJsonResult($bSuccess, $sDesc, array($sType=>array($asResult)));
|
return self::getJsonResult($bSuccess, $sDesc, array($sType=>array($asResult)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delAdminSettings($sType, $iId) {
|
||||||
|
$bSuccess = false;
|
||||||
|
$sDesc = '';
|
||||||
|
|
||||||
|
switch($sType) {
|
||||||
|
case 'project':
|
||||||
|
$oProject = new Project($this->oDb, $iId);
|
||||||
|
$sDesc = $oProject->delete();
|
||||||
|
break;
|
||||||
|
case 'feed':
|
||||||
|
$oFeed = new Feed($this->oDb, $iId);
|
||||||
|
$sDesc = $oFeed->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$bSuccess = ($sDesc=='');
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sDesc, array($sType=>array(array('id'=>$iId, 'del'=>$bSuccess))));
|
||||||
|
}
|
||||||
|
|
||||||
public function createProject() {
|
public function createProject() {
|
||||||
$oProject = new Project($this->oDb);
|
$oProject = new Project($this->oDb);
|
||||||
$iNewProjectId = $oProject->createProjectId();
|
$iNewProjectId = $oProject->createProjectId();
|
||||||
|
|||||||
@@ -57,14 +57,17 @@ if($sAction!='')
|
|||||||
case 'sync_pics':
|
case 'sync_pics':
|
||||||
$sResult = $oSpot->syncPics();
|
$sResult = $oSpot->syncPics();
|
||||||
break;
|
break;
|
||||||
|
case 'admin_new':
|
||||||
|
$sResult = $oSpot->createProject();
|
||||||
|
break;
|
||||||
case 'admin_get':
|
case 'admin_get':
|
||||||
$sResult = $oSpot->getAdminSettings();
|
$sResult = $oSpot->getAdminSettings();
|
||||||
break;
|
break;
|
||||||
case 'admin_set':
|
case 'admin_set':
|
||||||
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
||||||
break;
|
break;
|
||||||
case 'admin_new':
|
case 'admin_del':
|
||||||
$sResult = $oSpot->createProject();
|
$sResult = $oSpot->delAdminSettings($sType, $iId);
|
||||||
break;
|
break;
|
||||||
case 'build_geojson':
|
case 'build_geojson':
|
||||||
$sResult = $oSpot->convertGpxToGeojson($sName);
|
$sResult = $oSpot->convertGpxToGeojson($sName);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ status = Status
|
|||||||
last_update = Last Update
|
last_update = Last Update
|
||||||
ref_spot_id = Ref. Spot ID
|
ref_spot_id = Ref. Spot ID
|
||||||
model = Model
|
model = Model
|
||||||
|
delete = Delete
|
||||||
|
|
||||||
date_time = $0 at $1
|
date_time = $0 at $1
|
||||||
time_zone = Time zone
|
time_zone = Time zone
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ status = Statut
|
|||||||
last_update = Dernière maj
|
last_update = Dernière maj
|
||||||
ref_spot_id = ID Spot ref.
|
ref_spot_id = ID Spot ref.
|
||||||
model = Modèle
|
model = Modèle
|
||||||
|
delete = Supprimer
|
||||||
|
|
||||||
date_time = $0 à $1
|
date_time = $0 à $1
|
||||||
time_zone = Fuseau horaire
|
time_zone = Fuseau horaire
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<th>[#]lang:start[#]</th>
|
<th>[#]lang:start[#]</th>
|
||||||
<th>[#]lang:end[#]</th>
|
<th>[#]lang:end[#]</th>
|
||||||
<th>[#]lang:time_zone[#]</th>
|
<th>[#]lang:time_zone[#]</th>
|
||||||
|
<th>[#]lang:delete[#]</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
<th>[#]lang:name[#]</th>
|
<th>[#]lang:name[#]</th>
|
||||||
<th>[#]lang:status[#]</th>
|
<th>[#]lang:status[#]</th>
|
||||||
<th>[#]lang:last_update[#]</th>
|
<th>[#]lang:last_update[#]</th>
|
||||||
|
<th>[#]lang:delete[#]</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
@@ -53,11 +55,12 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
oSpot.pageInit = function(asHash) {
|
oSpot.pageInit = function(asHash) {
|
||||||
self.get('admin_get', setProjects);
|
self.get('admin_get', setProjects);
|
||||||
$('#new').addInput('button', 'new', 'New Project', [{on:'click', callback:createProject}]);
|
$('#new').addButton('new', 'New Project', 'new', createProject, 'main-btn');
|
||||||
};
|
};
|
||||||
|
|
||||||
oSpot.onFeedback = function(sType, sMsg, asContext) {
|
oSpot.onFeedback = function(sType, sMsg, asContext) {
|
||||||
delete asContext.a;
|
delete asContext.a;
|
||||||
|
delete asContext.t;
|
||||||
sMsg += ' (';
|
sMsg += ' (';
|
||||||
$.each(asContext, function(sKey, sElem) {
|
$.each(asContext, function(sKey, sElem) {
|
||||||
sMsg += sKey+'='+sElem+' / ' ;
|
sMsg += sKey+'='+sElem+' / ' ;
|
||||||
@@ -79,6 +82,8 @@ function setProjects(asElemTypes) {
|
|||||||
.data('id', oElem.id)
|
.data('id', oElem.id)
|
||||||
.append($('<td>').text(oElem.id || ''));
|
.append($('<td>').text(oElem.id || ''));
|
||||||
|
|
||||||
|
if(oElem.del) $Elem.remove();
|
||||||
|
else {
|
||||||
switch(sElemType) {
|
switch(sElemType) {
|
||||||
case 'project':
|
case 'project':
|
||||||
$Elem
|
$Elem
|
||||||
@@ -87,7 +92,8 @@ function setProjects(asElemTypes) {
|
|||||||
.append($('<td>').addInput('text', 'codename', oElem.codename, aoEvents))
|
.append($('<td>').addInput('text', 'codename', oElem.codename, aoEvents))
|
||||||
.append($('<td>').addInput('date', 'active_from', oElem.active_from.substr(0, 10), aoEvents))
|
.append($('<td>').addInput('date', 'active_from', oElem.active_from.substr(0, 10), aoEvents))
|
||||||
.append($('<td>').addInput('date', 'active_to', oElem.active_to.substr(0, 10), aoEvents))
|
.append($('<td>').addInput('date', 'active_to', oElem.active_to.substr(0, 10), aoEvents))
|
||||||
.append($('<td>').addInput('text', 'timezone', oElem.timezone, aoEvents));
|
.append($('<td>').addInput('text', 'timezone', oElem.timezone, aoEvents))
|
||||||
|
.append($('<td>').addButton('close fa-lg', '', 'del_proj', del));
|
||||||
break;
|
break;
|
||||||
case 'feed':
|
case 'feed':
|
||||||
$Elem
|
$Elem
|
||||||
@@ -96,7 +102,8 @@ function setProjects(asElemTypes) {
|
|||||||
.append($('<td>').addInput('number', 'project_id', oElem.id_project, aoEvents))
|
.append($('<td>').addInput('number', 'project_id', oElem.id_project, aoEvents))
|
||||||
.append($('<td>').text(oElem.name))
|
.append($('<td>').text(oElem.name))
|
||||||
.append($('<td>').text(oElem.status))
|
.append($('<td>').text(oElem.status))
|
||||||
.append($('<td>').text(oElem.last_update));
|
.append($('<td>').text(oElem.last_update))
|
||||||
|
.append($('<td>').addButton('close fa-lg', '', 'del_feed', del));
|
||||||
break;
|
break;
|
||||||
case 'spot':
|
case 'spot':
|
||||||
$Elem
|
$Elem
|
||||||
@@ -107,6 +114,7 @@ function setProjects(asElemTypes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(bNew) $Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
if(bNew) $Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -145,4 +153,20 @@ function waitAndCommit(event) {
|
|||||||
if(typeof self.tmp('wait') != 'undefined') clearTimeout(self.tmp('wait'));
|
if(typeof self.tmp('wait') != 'undefined') clearTimeout(self.tmp('wait'));
|
||||||
self.tmp('wait', setTimeout(()=>{commit(event,$(this));}, 2000));
|
self.tmp('wait', setTimeout(()=>{commit(event,$(this));}, 2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function del() {
|
||||||
|
var $Record = $(this).closest('tr');
|
||||||
|
var asInputs = {type: $Record.data('type'), id: $Record.data('id')};
|
||||||
|
self.get(
|
||||||
|
'admin_del',
|
||||||
|
function(asData){
|
||||||
|
oSpot.onFeedback('success', self.lang('admin_save_success'), asInputs);
|
||||||
|
setProjects(asData);
|
||||||
|
},
|
||||||
|
asInputs,
|
||||||
|
function(sError){
|
||||||
|
oSpot.onFeedback('error', sError, asInputs);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -266,6 +266,18 @@ $.prototype.addInput = function(sType, sName, sValue, aoEvents)
|
|||||||
return $(this).append($Input);
|
return $(this).append($Input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.prototype.addButton = function(sIcon, sText, sName, fOnClick, sClass)
|
||||||
|
{
|
||||||
|
sText = sText || '';
|
||||||
|
sClass = sClass || '';
|
||||||
|
var $Btn = $('<button>', {name: sName, 'class':sClass})
|
||||||
|
.addIcon('fa-'+sIcon, (sText != ''))
|
||||||
|
.append(sText)
|
||||||
|
.click(fOnClick);
|
||||||
|
|
||||||
|
return $(this).append($Btn);
|
||||||
|
};
|
||||||
|
|
||||||
$.prototype.addIcon = function(sIcon, bMargin, sStyle)
|
$.prototype.addIcon = function(sIcon, bMargin, sStyle)
|
||||||
{
|
{
|
||||||
bMargin = bMargin || false;
|
bMargin = bMargin || false;
|
||||||
|
|||||||
@@ -81,3 +81,6 @@ $fa-css-prefix: fa;
|
|||||||
.#{$fa-css-prefix}-prev:before { content: fa-content($fa-var-chevron-left); }
|
.#{$fa-css-prefix}-prev:before { content: fa-content($fa-var-chevron-left); }
|
||||||
.#{$fa-css-prefix}-next:before { content: fa-content($fa-var-chevron-right); }
|
.#{$fa-css-prefix}-next:before { content: fa-content($fa-var-chevron-right); }
|
||||||
.#{$fa-css-prefix}-close:before { content: fa-content($fa-var-times-circle); }
|
.#{$fa-css-prefix}-close:before { content: fa-content($fa-var-times-circle); }
|
||||||
|
|
||||||
|
/* Admin */
|
||||||
|
.#{$fa-css-prefix}-new:before { content: fa-content($fa-var-plus); }
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
#admin {
|
#admin {
|
||||||
margin: 1em;
|
margin: 1em;
|
||||||
|
|
||||||
|
button.main-btn {
|
||||||
|
color: #000;
|
||||||
|
background: #eee;
|
||||||
|
&:hover {
|
||||||
|
color: #eee;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@@ -23,6 +32,13 @@
|
|||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: #AAA;
|
||||||
|
&:hover {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user