-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to reset database readings
- Loading branch information
Showing
7 changed files
with
189 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script> | ||
/** | ||
* | ||
* | ||
* @author Knut Kohl <[email protected]> | ||
* @copyright 2012-2016 Knut Kohl | ||
* @license MIT License (MIT) http://opensource.org/licenses/MIT | ||
* @version 1.0.0 | ||
*/ | ||
|
||
var resetTimer; | ||
|
||
/** | ||
* | ||
*/ | ||
function resetDeleteButton() { | ||
var b = $('#empty-database'), s = $('span', b); | ||
b.removeClass('confirm'); | ||
s.text(s.data('text')); | ||
$.wait(false); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
$(function() { | ||
|
||
$('#empty-database').on('click', function(event) { | ||
|
||
var b = $(this), s = $('span', b); | ||
|
||
if (!b.hasClass('confirm')) { | ||
|
||
s.data('text', s.text()).text('Click again if you are ABSOLUTELY sure ...'); | ||
b.addClass('confirm'); | ||
resetTimer = setTimeout(resetDeleteButton, 8000); | ||
|
||
} else { | ||
|
||
clearTimeout(resetTimer); | ||
|
||
$.wait(); | ||
|
||
$.ajax({ | ||
type: 'DELETE', | ||
url: PVLngAPI + 'data', | ||
dataType: 'json', | ||
}).done(function(data, textStatus, jqXHR) { | ||
$('[name="d[core--EmptyDatabaseAllowed]"]').val(0).change(); | ||
b.replaceWith('<strong>'+data.message+'</strong>'); | ||
}).fail(function(jqXHR, textStatus, errorThrown) { | ||
$.pnotify({ | ||
type: textStatus, hide: false, text: jqXHR.responseJSON.message | ||
}); | ||
}).always(function() { | ||
resetDeleteButton(); | ||
}); | ||
|
||
} | ||
|
||
event.preventDefault(); | ||
}); | ||
|
||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,8 @@ | |
margin-left: 1em; | ||
display: block; | ||
} | ||
|
||
#empty-database.confirm .ui-button-text { | ||
color: red; | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
INSERT INTO `pvlng_settings` | ||
(`scope`, `name`, `key`, `value`, `order`, `description`, `type`, `data`) | ||
VALUES | ||
('core', '', 'EmptyDatabaseAllowed', '0', 100, 'Enable function for deletion of all measuring data from database.<br>Channels and channel hierarchy will <strong>not</strong> be deleted!<br><strong style=\"color:red\">Only if this is allowed, the deletion is possible!</strong>', 'bool', ''); | ||
|
||
UPDATE `pvlng_type` SET `unit` = '', `icon` = '/images/ico/calculator_scientific.png' WHERE `id` = 15; | ||
|
||
INSERT INTO `pvlng_type` | ||
(`id`, `name`, `description`, `model`, `unit`, `type`, `childs`, `read`, `write`, `graph`, `icon`) | ||
VALUES | ||
(33, 'Percentage calculator', 'model::Ratio', 'Ratio', '%', 'sensor', 2, 1, 0, 1, '/images/ico/edit_percent.png'); |