Skip to content

Commit 9615918

Browse files
author
Ibrahim Ethem Gursoy
authored
Merge pull request #14 from Sparse-Technology/eren/card-size-works
C#: DSCS: Fixed Card Height Arrangement Issue #13
2 parents 82c411d + a6dc22c commit 9615918

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Pages/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279

280280
@* Camera Cards Body *@
281281
<div id="cameraCardsBody" class="container-fluid" style="font-size: small; padding-top: 2rem">
282-
<div class="d-flex flex-wrap">
282+
<div id="sortedCameraCards" class="d-flex flex-wrap">
283283
@* Getting Model.Devices *@
284284
@foreach (var dev in @Model.Devices.OrderBy(d => d.DeviceActiveStatus))
285285
{

wwwroot/js/src/main.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { jsonrepair } from "jsonrepair";
99
// GLOBAL VARIABLES
1010
var jsonDeviceArray = [];
1111
var jsonStringCopy = "";
12-
var errorNotifColor = "#d72a6f";
12+
var errorNotifColor = "#d72a6f";
1313
var successNotifColor = "#20ad6b";
1414
var neutralNotifColor = "#8f6ac4";
1515

@@ -32,6 +32,8 @@ $(document).ready(function () {
3232
}
3333
);
3434

35+
sortAndAppendContainers();
36+
3537
// Closing modals
3638
$('[data-dismiss="modalLabel"]').on("click", function () {
3739
$("#exportDeviceModal").modal("hide");
@@ -65,6 +67,22 @@ window.toggleExportMenuVisibility = function () {
6567
}
6668
};
6769

70+
// Sorting camera cards by height
71+
window.sortAndAppendContainers = function(){
72+
var containers = $('[data-card="container"]');
73+
74+
containers.sort(function (a, b) {
75+
// Compare the heights of the camera containers in descending order
76+
var heightA = $(a).find('[data-card="cameraContainer"]').height();
77+
var heightB = $(b).find('[data-card="cameraContainer"]').height();
78+
79+
return heightA - heightB;
80+
});
81+
82+
// Append the sorted camera containers back to the parent containers with data-card="container"
83+
$('#sortedCameraCards').empty().append(containers);
84+
}
85+
6886
window.resetLabels = function () {
6987
$('#dynamicKeys input[type="checkbox"]').prop("checked", false).change();
7088
$("[id^=btnRenameInput_]").val(null);

0 commit comments

Comments
 (0)