Skip to content

Commit

Permalink
Added Share/Edit Icons to Devices. Removed Delete Icon because of alr…
Browse files Browse the repository at this point in the history
…eady existing wipeOut action in Sidebar. #19 #74
  • Loading branch information
alexstocker committed Feb 11, 2019
1 parent 8d5b5c0 commit 889816c
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 54 deletions.
4 changes: 3 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ span.center {
.bodyDetails > .unique-id,
.bodyDetails > .group,
.bodyDetails > .parent-group,
.bodyDetails > .type {
.bodyDetails > .type,
.bodyDetails > .widget-type,
.bodyDetails > .device {
display: block;
}

Expand Down
50 changes: 42 additions & 8 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
var deviceGroupList = $('#deviceGroupList');
var dataTypeList = $('#dataTypeList');
var appContentWrapper = $('#app-content-wrapper');
var chartBtns = $('.deviceChart');

var _onClickAction = function(event) {
var $target = $(event.target);
Expand Down Expand Up @@ -55,9 +56,16 @@
_onClickAction(e);
var url = OC.generateUrl('/apps/sensorlogger/deviceList');
$.post(url).success(function (response) {
appContentWrapper.empty().append(response);
var $response = $(response).clone();
$.each($response
.find('.deviceChart > span, ' +
'.deviceListData > span, ' +
'.deviceactions > a.action-share, ' +
'.deviceactions > a.action-menu'),function(idx,element){
$(element).tooltip({placement:'right'})
});
appContentWrapper.empty().append($response);
});

});

deviceTypeList.click(function (e) {
Expand Down Expand Up @@ -278,6 +286,13 @@
}
});

var widgetTypeLabel = $('<label/>', {
'class':'widget-type'
}).text(t('sensorlogger', 'Select Widget Type'));
var widgetTypeContentSpan = $('<span/>', {
'class':'widget-type-content'
}).append(widgetTypeSelect);

var deviceSelect = $('<a/>',{
'id':'device_id',
'href': '#',
Expand All @@ -295,19 +310,30 @@
}
});

var deviceLabel = $('<label/>', {
'class':'device'
}).text(t('sensorlogger', 'Select Device'));
var deviceContentSpan = $('<span/>', {
'class':'device-content'
}).append(deviceSelect);

var bodyDetailsContainer = sidebar.find('.tpl_bodyDetails').clone();
bodyDetailsContainer.removeClass('tpl_bodyDetails').addClass('bodyDetails');

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

var widgetType = bodyDetailsContainer.clone().append(widgetTypeSelect);
var device = bodyDetailsContainer.clone().append(deviceSelect);
var widgetType = bodyDetailsContainer.clone()
.append(widgetTypeLabel)
.append(widgetTypeContentSpan);
var device = bodyDetailsContainer.clone()
.append(deviceLabel)
.append(deviceContentSpan);

sidebarBody.append(widgetType);
sidebarBody.append(device);
wipeOutBtn.hide();

sidebarTitle.empty().append('Dashboard widget');
sidebarTitle.empty().append('Dashboard Widget');

})
};
Expand Down Expand Up @@ -362,13 +388,21 @@
});
};

appContentWrapper.on('click','.deviceEdit',function(e) {
appContentWrapper.on('click','.deviceEdit, ' +
'.deviceactions > a.action-share, ' +
'.deviceactions > a.action-menu', function(e) {
var target = $(e.target);
/*
if(e.target.nodeName != 'TD') {
return;
}
*/

console.log(target);

$(target).parent().tooltip('hide');

var id = $(this).data('id');
var id = $(this).closest('tr').data('id');

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

Expand Down Expand Up @@ -398,7 +432,7 @@
var wipeOutUrl = OC.generateUrl('/apps/sensorlogger/wipeOutDevice');

var wipeOutDevice = $('#wipeout-btn').show();
wipeOutDevice.attr('title','Wipe out device!');
wipeOutDevice.find('span').attr('data-original-title','Wipe out device!').tooltip({placement:'right'});

var wipeOutDeviceConfirm = $('<button/>',{
"text": t('sensorlogger', 'Yes')
Expand Down
14 changes: 8 additions & 6 deletions l10n/de.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
OC.L10N.register(
"sensorlogger",
{
"Device NOT deleted" : "Gerät kann nicht gelöscht werden",
"Wiped out your device completely!": "Sensor und Daten wurden ausgelöscht!",
"Could not wipe out your device!": "Sensor und Daten konnten nicht ausgelöscht werden!",
"Are you sure?" : "Sind sie sicher?",
"Yes" : "Ja",
"No" : "Nein"
"Device NOT deleted" : "Gerät kann nicht gelöscht werden",
"Wiped out your device completely!": "Sensor und Daten wurden ausgelöscht!",
"Could not wipe out your device!": "Sensor und Daten konnten nicht ausgelöscht werden!",
"Are you sure?" : "Sind sie sicher?",
"Yes" : "Ja",
"No" : "Nein",
"Select Widget Type": "Wähle Widget",
"Select Device": "Wähle Sensor"
},
"nplurals=2; plural=(n != 1);");
16 changes: 8 additions & 8 deletions l10n/de.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"translations": {
"Reset Chart": "zurücksetzen",
"Delete Widget": "löschen",
"Dashboard": "Startseite",
"List": "Logs",
"Devices": "Sensoren",
"Device Types": "Typen",
"Device Groups": "Gruppen",
"Data Types": "Datentypen",
"Reset Chart": "zurücksetzen",
"Delete Widget": "löschen",
"Dashboard": "Startseite",
"List": "Logs",
"Devices": "Sensoren",
"Device Types": "Typen",
"Device Groups": "Gruppen",
"Data Types": "Datentypen",
"Widget Live - Current Data": "Aktuelle Werte",
"Widget 24h max Values": "24h Maximum"
},
Expand Down
4 changes: 1 addition & 3 deletions templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
//\OC_Util::addScript('sensorlogger','deviceactions');
vendor_style('select2/select2');
vendor_script('select2/select2');


?>
<div id="app">
<div id="app-navigation">
Expand Down Expand Up @@ -74,7 +72,7 @@
<span class="icon icon-save" ></span>
</a>
<a id="wipeout-btn" class="icon-wipeout" style="display:none;">
<span class="icon icon-wipeout"></span>
<span class="has-tooltip icon icon-wipeout"></span>
</a>
<a class="icon-delete handler" style="display:none;">
<span class="icon icon-delete"></span>
Expand Down
7 changes: 0 additions & 7 deletions templates/part.listDataTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@
<th id="descprition"><span class="th-header">Description</span></th>
<th id="type"><span class="th-header">Data Type</span></th>
<th id="short"><span class="th-header">Unit</span></th>
<th><span class="th-header">Assigned Devices</span></th>
<th><span class="th-header"></th>
</thead>
<tbody>
<?php foreach($_['dataTypes'] as $dataType){ ?>
<tr data-id="<?php p($dataType['id']); ?>" data-type="dir" class="dataTypeEdit">
<td class="td-data">
<a href="#" class="datatype-delete" title="<?php p($l->t('Delete Data Type')); ?>">
<span class="icon icon-delete"
data-id="<?php p($dataType['id']); ?>">
</span>
</a>
</td>
<td class="td-data"><?php p($dataType['id']); ?></td>
<td class="td-data"><?php p($dataType['description']); ?></td>
<td class="td-data"><?php p($dataType['type']); ?></td>
<td class="td-data"><?php p($dataType['short']); ?></td>
<td class="td-data"></td>
<td class="td-data">Show devices</td>
</tr>
<?php } ?>
Expand Down
4 changes: 1 addition & 3 deletions templates/part.listDeviceTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<th></th>
<th id="id"><span class="th-header">#</span></th>
<th id="deviceTypeName"><span class="th-header">Type Name</span></th>
<th id="name"><span class="th-header">Assigned devices</span></th>
<th><span class="th-header"></span></th>
</thead>
<tbody>
Expand All @@ -19,8 +18,7 @@
</td>
<td class="td-data"><?php p($deviceType['id']); ?></td>
<td class="td-data"><?php p($deviceType['device_type_name']); ?></td>
<td class="td-data"><?php p($deviceType['uuid']); ?></td>
<td class="td-data">Show devices</td>
<td class="td-data"></td>
</tr>
<?php } ?>
</tbody>
Expand Down
40 changes: 29 additions & 11 deletions templates/part.listDevices.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,50 @@
<thead>
<th></th>
<th id="headerId"><span class="th-header">#</span></th>
<th id="headerUuid"><span class="th-header">UUID</span></th>
<th id="headerName"><span class="th-header">Name</span></th>
<th id="headerType"><span class="th-header">Type</span></th>
<th id="headerGroup"><span class="th-header">Group</span></th>
<th></th>
</thead>
<tbody id="deviceList">
<?php foreach($_['devices'] as $device){ ?>
<tr data-id="<?php p($device->getId()); ?>" data-type="dir" class="deviceEdit">
<td class="td-data">
<a href="#" class="deviceChart device-datalist" data-id="<?php p($device->getId()); ?>" title="<?php p($l->t('Device Chart Data')); ?>">
<span class="icon icon-datachart"></span>
</a>
<a href="#" class="deviceListData device-datalist" data-id="<?php p($device->getId()); ?>" title="<?php p($l->t('Device List Data')); ?>">
<span class="icon icon-datalist"></span>
<a href="#"
class="deviceChart device-datalist"
data-id="<?php p($device->getId()); ?>" title="">
<span class="has-tooltip icon icon-datachart"
data-original-title="<?php p($l->t('Show Device Chart for %s',[$device->getUuid()])); ?>"></span>
</a>
<a href="#" class="device-delete" title="<?php p($l->t('Delete Device')); ?>">
<span class="icon icon-delete"
data-id="<?php p($device->getId()); ?>">
</span>
<a href="#"
class="deviceListData device-datalist"
data-id="<?php p($device->getId()); ?>" title="">
<span class="has-tooltip icon icon-datalist"
data-original-title="<?php p($l->t('Show Device Logs for %s',[$device->getUuid()])); ?>"></span>
</a>
<span class="deviceactions">
<a class="has-tooltip action action-share permanent"
href="#"
data-action="Share"
data-original-title="<?php p($l->t('Share Device %s',[$device->getUuid()])); ?>"
title="">
<span class="icon icon-share" ></span>
<span class="hidden-visually">Share</span></a>
<a class="has-tooltip action action-menu permanent"
href="#"
data-action="menu"
data-original-title="<?php p($l->t('Edit Device %s',[$device->getUuid()])); ?>"
title="">
<span class="icon icon-more"></span>
<span class="hidden-visually">Actions</span></a>
</span>
</td>
<td class="td-data"><?php p($device->getId()); ?></td>
<td class="td-data"><?php p($device->getUuid()); ?></td>
<td class="td-data"><?php p($device->getName()); ?></td>
<td class="td-data"><?php p($device->getDeviceTypeName()); ?></td>
<td class="td-data"><?php p($device->getDeviceGroupName()); ?></td>
<td>
</td>
</tr>
<?php } ?>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions templates/widget_dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class="widget dashboard-widget dragbox"
<div id="emptycontent" class="">
<div class="icon-info"></div>
<h2>No dashboard widget configured</h2>
<p>Read <a href="https://github.com/alexstocker/sensorlogger/wiki/Configuration#dashboard"
title="SensorLogger Wiki" target="_blank">SensorLogger Wiki</a></p>
<p>Read <a href="https://github.com/alexstocker/sensorlogger/wiki/Users#widgets"
title="SensorLogger Wiki Dashboard Widgets" target="_blank">SensorLogger Wiki Dashboard Widgets</a></p>
</div>
</div>
<?php } ?>
10 changes: 5 additions & 5 deletions tests/curl/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$registerArray = [
//'_route' => 'sensorlogger.apisensorlogger.registerDevice',
'deviceId' => '7e643ee8-0f9f-11e7-93ae-92361f002675',
'deviceId' => '0e643ee8-0f9f-11e7-93ae-92361f002675',
'deviceName' => 'Multi data sensor V2',
'deviceType' => 'Indoor',
'deviceGroup' => 'Wohnzimmer',
Expand All @@ -29,10 +29,10 @@

$data_json = json_encode($registerArray);

$username = 'admin';
$token = 'AZDMW-FWBYN-JLQAJ-YXHMD';
//$username = 'test';
//$token = 'GLOKN-ZRYIN-POCRJ-NFLYK';
//$username = 'admin';
//$token = 'AZDMW-FWBYN-JLQAJ-YXHMD';
$username = 'test';
$token = 'GLOKN-ZRYIN-POCRJ-NFLYK';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
Expand Down

0 comments on commit 889816c

Please sign in to comment.