Skip to content

Commit

Permalink
Add wipeout icon set #49
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstocker committed Jun 9, 2018
1 parent d818eb5 commit bc2694a
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SensorLogger
### (0.0.7) UNRELEASED

# SensorLogger
### (0.0.6) RELEASED
* Added SensorLogs::deleteLogById and deleteLog controller action #37'
Expand Down Expand Up @@ -51,3 +54,4 @@

-- Alexander Stocker
-- alexstocker
-- Ozzie Isaacs
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
array('name' => 'sensorlogger#createWidget', 'url' => 'saveWidget', 'verb' => 'POST'),
array('name' => 'sensorlogger#deleteWidget', 'url' => 'deleteWidget/{id}', 'verb' => 'POST'),
array('name' => 'sensorlogger#deleteDevice', 'url' => 'deleteDevice/{id}', 'verb' => 'POST'),
array('name' => 'sensorlogger#wipeOutDevice', 'url' => 'wipeOutDevice', 'verb' => 'POST'),
array('name' => 'sensorlogger#deleteLog', 'url' => 'deleteLog/{id}', 'verb' => 'POST'),
array('name' => 'sensorlogger#showList', 'url' => 'showList', 'verb' => 'POST'),
array('name' => 'sensorlogger#showDeviceData', 'url' => 'showDeviceData/{id}', 'verb' => 'POST'),
Expand Down
20 changes: 19 additions & 1 deletion controller/sensorloggercontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function index() {

protected function getNavigationItems() {

App::getNavigationManager()->add(
App::getNavigationManager()->add(
[
'id' => 'showDashboard',
'appName' => 'sensorlogger',
Expand Down Expand Up @@ -437,6 +437,24 @@ public function deleteDevice($id)
return $this->returnJSON(array('success' => false));
}

/**
* @NoAdminRequired
* @return DataResponse
*/
public function wipeOutDevice() {
if($this->request->getParam('device_id') && $this->userSession->getUser()->getUID()) {
if (SensorDevices::isDeletable($this->userSession->getUser()->getUID(), (int)$id, $this->connection)) {
try {
SensorDevices::deleteDevice((int)$id, $this->connection);
DataTypes::deleteDeviceDataTypesByDeviceId((int)$id, $this->connection);
return $this->returnJSON(array('success' => true));
} catch (Exception $e) {}
}
}

return $this->returnJSON(array('success' => false));
}

/**
* @NoAdminRequired
* @param $id
Expand Down
13 changes: 13 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ span.center {
left: 8px;
}

#app-sidebar div.content-wrapper div.footer .icon-loading {
position: initial;
}

#app-sidebar div.content-wrapper div.footer .icon-save .icon {
background-image: url('../img/save.svg');
background-size: 100% 100%;
Expand All @@ -90,6 +94,15 @@ span.center {
left: 30px;
}

.icon.icon-wipeout {
background-image: url('../img/icon-erase.svg');
}

.icon.icon-wipeout:hover,
.icon.icon-wipeout:focus {
background-image: url('../img/icon-erase-hover.svg');
}

.icon.icon-datalist {
background-image: url('/core/img/actions/toggle-filelist.svg');
background-size: 100% 100%;
Expand Down
64 changes: 64 additions & 0 deletions img/icon-erase-hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions img/icon-erase.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 90 additions & 6 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,95 @@
return;
}

if(sidebar.is(':visible')) {
sidebar.hide();
saveBtn.hide();
return;
}
var id = $(this).data('id');

var sidebarFooter = sidebar.find('.footer');

var wipeOutDevicetest = $('<a/>', {
'id':'wipeout',
'href': '#',
'data-type': 'text',
'data-field': 'wipeout',
'data-pk': id,
'data-url': wipeOutUrl,
'data-title': 'response.name',
'text': 'wipeOut'
});

//wipeOutDevice.text('wipeOut');

//console.log(sidebarFooter);

//sidebarFooter.append(wipeOutDevice);

if(sidebar.is(':visible')) {
sidebar.hide();
saveBtn.hide();
return;
}

var wipeOutUrl = OC.generateUrl('/apps/sensorlogger/wipeOutDevice');

var wipeOutDevice = $('#wipeout-btn').show();
wipeOutDevice.attr('title','Wipe out device!');

var wipeOutDeviceConfirm = $('<button/>',{
"text": t('sensorlogger', 'Yes')
});

var wipeOutDeviceCancel = $('<button/>',{
"text": t('sensorlogger', 'No')
});

$(wipeOutDevice).on('click',function(e){
$(".confirm-container").remove();
var confirmContainer = $('<div/>',{
"class": "confirm-container",
"text": t('sensorlogger', 'Are you sure?')
}).append(wipeOutDeviceConfirm).append(wipeOutDeviceCancel);
wipeOutDevice.hide().parent().append(confirmContainer);

var wipeOutCall = function(id){
var deviceTr = $('table#sensorDevicesTable tr[data-id='+id+']');
var spinner = $('<div class="icon icon-loading">');
confirmContainer.parent().append(spinner);
console.log(confirmContainer);
confirmContainer.remove();
$.post(wipeOutUrl, {'device_id':id} )
.success(function (response) {
if(response.success) {
deviceTr.remove();
sidebar.hide();
spinner.remove();
$(".confirm-container").remove();
OC.Notification.showTemporary(t('sensorlogger', 'Wiped out your device completely!'));
} else {
wipeOutDevice.show();
$(".confirm-container").remove();
spinner.remove();
OC.Notification.showTemporary(t('sensorlogger', 'Could not wipe out your device!'));
}

})
.error(function(response) {
wipeOutDevice.show();
$(".confirm-container").remove();
spinner.remove();
OC.Notification.showTemporary(t('sensorlogger', 'Could not wipe out your device!'));
});
};


wipeOutDeviceCancel.on('click', function(e) {
confirmContainer.remove();
wipeOutDevice.show();
});
wipeOutDeviceConfirm.on('click', function(e) {
wipeOutCall(id);
});

});

var id = $(this).data('id');
var url = OC.generateUrl('/apps/sensorlogger/showDeviceDetails/'+id);
$.post(url).success(function (response) {
$.fn.editable.defaults.mode = 'inline';
Expand Down Expand Up @@ -465,6 +547,8 @@

sidebar.find('.bodyDetails').remove();



var uuid = bodyDetailsContainer.clone().append('UUID: '+response.deviceDetails.uuid);
var group = bodyDetailsContainer.clone().append(groupSelect);
var groupParent = bodyDetailsContainer.clone().append(groupParentSelect);
Expand Down
5 changes: 4 additions & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
OC.L10N.register(
"sensorlogger",
{
"Device NOT deleted" : "Gerät kann nicht gelöscht werden"
"Device NOT deleted" : "Gerät kann nicht gelöscht werden",
"Are you sure?" : "Sind sie sicher?",
"Yes" : "Ja",
"No" : "Nein",
},
"nplurals=2; plural=(n != 1);");
8 changes: 7 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{ "translations": {
"Reset Chart": "zurücksetzen",
"Delete Widget": "löschen"
"Delete Widget": "löschen",
"Dashboard": "Startseite",
"List": "Logs",
"Devices": "Sensoren",
"Device Types": "Typen",
"Device Groups": "Gruppen",
"Data Types": "Datentypen"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
3 changes: 3 additions & 0 deletions templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<a id="save-btn" class="icon-save" style="display:none;">
<span class="icon icon-save" ></span>
</a>
<a id="wipeout-btn" class="icon-wipeout" style="display:none;">
<span class="icon icon-wipeout"></span>
</a>
<a class="icon-delete handler" style="display:none;">
<span class="icon icon-delete"></span>
</a>
Expand Down

0 comments on commit bc2694a

Please sign in to comment.