Skip to content

Commit

Permalink
Set default widget height
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstocker committed Jun 4, 2019
1 parent de58402 commit 3558e37
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 30 deletions.
11 changes: 11 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ table th, table td {
margin-bottom: 10px;
background-color: #eee;
*/
/*background-color: lightgrey;*/
}

.widget-type-realTimeChart {
/*min-height: 350px;*/
}

.widget.icon-loading {
height: -webkit-fill-available;
height: inherit;
}

.dashboard-widget .section.list,
Expand Down Expand Up @@ -240,6 +250,7 @@ h2.widget-header a span.icon {
margin: 2px;
position: relative;
height: -webkit-fill-available;
height: inherit;
background-color: lightgrey;
}
.column .dragbox h2{
Expand Down
61 changes: 33 additions & 28 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

OCA.SensorLogger = {

widgets: [],
widgets: {
gridstack: null,
},

sidebar: {
infoContainer: {
Expand Down Expand Up @@ -327,10 +329,12 @@

//console.log(widgetContainer.find('div[data-widget-type]').data('widget-type'));
//$('.grid-stack').gridstack({});
widgetContainer.gridstack({
OCA.SensorLogger.widgets.gridstack = widgetContainer.gridstack({
itemClass: 'column',
// disableResize: true
}).on('change', function(event, items) {
});

OCA.SensorLogger.widgets.gridstack.on('change', function(event, items) {
var updateUrl = OC.generateUrl('/apps/sensorlogger/updateWidgetSettings');

var data = {};
Expand Down Expand Up @@ -788,35 +792,36 @@

SidebarWidgets: function () {
OCA.SensorLogger.sidebar.footerContainer.actions.saveBtn = $('a#save-btn');

//OCA.SensorLogger.Sidebar = sidebar.show();
var saveWidget = OC.generateUrl('/apps/sensorlogger/saveWidget');

OCA.SensorLogger.sidebar.footerContainer.actions.saveBtn.on('click',function() {
var loadingWidget = $('<div/>',{
'class':'column'
}).append('<div class="widget dashboard-widget dragbox"><div class="widget icon-loading"></div></div>');
OCA.SensorLogger.widgets.gridstack.data('gridstack').addWidget(loadingWidget,0,0,4,4,true);
$('.editable').editable('submit', {
url: saveWidget,
ajaxOptions: {
dataType: 'json' //assuming json response
},
success: function(data, config) {
if(data && data.id) {
$(this).editable('option', 'pk', data.id);
OCA.SensorLogger.Sidebar.hide();
OC.Notification.showTemporary(t('sensorlogger', 'Dashboard widget saved'));
//showDashboard[0].click();
location.reload(true);
} else if(data && data.errors){
OC.Notification.showTemporary(t('sensorlogger', data.errors));
}
},
error: function(errors) {
if(errors && errors.responseText) {
} else {
$.each(errors, function(k, v) { msg += k+": "+v+"<br>"; });
url: saveWidget,
ajaxOptions: {
dataType: 'json' //assuming json response
},
data: {x: loadingWidget.data('gsX'),y:loadingWidget.data('gsY')},
success: function(data, config) {
if(data && data.id) {
$(this).editable('option', 'pk', data.id);
OCA.SensorLogger.Sidebar.hide();
OC.Notification.showTemporary(t('sensorlogger', 'Dashboard widget saved'));
location.reload(true);
} else if(data && data.errors){
OC.Notification.showTemporary(t('sensorlogger', data.errors));
}
},
error: function(errors) {
if(errors && errors.responseText) {
} else {
$.each(errors, function(k, v) { msg += k+": "+v+"<br>"; });
}
OC.Notification.showTemporary(t('sensorlogger', 'Some Error occured'));
}
OC.Notification.showTemporary(t('sensorlogger', 'Some Error occured'));
}
});
});
});

var widgetDataUrl = OC.generateUrl('/apps/sensorlogger/widgetTypeList');
Expand Down
2 changes: 1 addition & 1 deletion lib/Widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function build($userId, $device, $config, $connection, $systemConf
$widget->setOptions('position',$position);
$size = [
'w' => $config->w ?: 4,
'h' => $config->h ?: 4
'h' => $config->h ?: 6
];
$widget->setOptions('size',$size);

Expand Down
2 changes: 1 addition & 1 deletion templates/widget_dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class="column"
data-gs-y="<?php p($widget->getOptions('position')['y']) ?>"
data-gs-auto-position>
<div id="dashboard-widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>"
class="widget dashboard-widget dragbox"
class="widget dashboard-widget widget-type-<?php p($widget->getType()); ?> dragbox"
data-id="<?php p($widget->getDeviceId()); ?>"
data-widget-type="<?php p($widget->getType()); ?>">
<h2 class="widget-header ui-widget-header">
Expand Down

0 comments on commit 3558e37

Please sign in to comment.