Skip to content

Commit

Permalink
Fix missing last modified
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Jun 14, 2022
1 parent de2a6bf commit 1563da5
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 63 deletions.
4 changes: 2 additions & 2 deletions applications_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function __construct($serial='')
$this->rs['serial_number'] = $serial;
$this->rs['name'] = '';
$this->rs['path'] = '';
$this->rs['last_modified'] = 0;
$this->rs['last_modified'] = null;
$this->rs['obtained_from'] = '';
$this->rs['runtime_environment'] = '';
$this->rs['version'] = '';
Expand Down Expand Up @@ -47,7 +47,7 @@ function process($plist)

$typeList = array(
'name' => '',
'last_modified' => '',
'last_modified' => null,
'obtained_from' => 'unknown',
'path' => '',
'runtime_environment' => '',
Expand Down
25 changes: 25 additions & 0 deletions migrations/2022_06_14_000000_applications_null_last_modified.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;

class ApplicationsNullLastModified extends Migration
{
private $tableName = 'applications';

public function up()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->bigInteger('last_modified')->nullable()->change();
});
}

public function down()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->bigInteger('last_modified')->change();
});
}
}
118 changes: 60 additions & 58 deletions views/applications_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@

<div class="container">
<div class="row">
<div class="col-lg-12">

<h3><span data-i18n="applications.reporttitle"></span> <span id="total-count" class='label label-primary'>…</span></h3>

<table class="table table-striped table-condensed table-bordered">

<thead>
<tr>
<th data-i18n="listing.computername" data-colname='machine.computer_name'></th>
<th data-i18n="serial" data-colname='reportdata.serial_number'></th>
<th data-i18n="name" data-colname='applications.name'></th>
<th data-i18n="version" data-colname='applications.version'></th>
<th data-i18n="applications.bundle_version" data-colname='applications.bundle_version'></th>
<th data-i18n="applications.signed_by" data-colname='applications.signed_by'></th>
<th data-i18n="applications.obtained_from" data-colname='applications.obtained_from'></th>
<th data-i18n="applications.last_modified" data-colname='applications.last_modified'></th>
<th data-i18n="applications.has64bit" data-colname='applications.has64bit'></th>
<th data-i18n="applications.runtime_environment" data-colname='applications.runtime_environment'></th>
<th data-i18n="path" data-colname='applications.path'></th>
<th data-i18n="info" data-colname='applications.info'></th>
</tr>
</thead>

<tbody>
<tr>
<td data-i18n="listing.loading" colspan="12" class="dataTables_empty"></td>
</tr>
</tbody>

</table>
</div> <!-- /span 12 -->
<div class="col-lg-12">

<h3><span data-i18n="applications.reporttitle"></span> <span id="total-count" class='label label-primary'>…</span></h3>

<table class="table table-striped table-condensed table-bordered">

<thead>
<tr>
<th data-i18n="listing.computername" data-colname='machine.computer_name'></th>
<th data-i18n="serial" data-colname='reportdata.serial_number'></th>
<th data-i18n="name" data-colname='applications.name'></th>
<th data-i18n="version" data-colname='applications.version'></th>
<th data-i18n="applications.bundle_version" data-colname='applications.bundle_version'></th>
<th data-i18n="applications.signed_by" data-colname='applications.signed_by'></th>
<th data-i18n="applications.obtained_from" data-colname='applications.obtained_from'></th>
<th data-i18n="applications.last_modified" data-colname='applications.last_modified'></th>
<th data-i18n="applications.has64bit" data-colname='applications.has64bit'></th>
<th data-i18n="applications.runtime_environment" data-colname='applications.runtime_environment'></th>
<th data-i18n="path" data-colname='applications.path'></th>
<th data-i18n="info" data-colname='applications.info'></th>
</tr>
</thead>

<tbody>
<tr>
<td data-i18n="listing.loading" colspan="12" class="dataTables_empty"></td>
</tr>
</tbody>

</table>
</div> <!-- /span 12 -->
</div> <!-- /row -->
</div> <!-- /container -->

<script type="text/javascript">

$(document).on('appUpdate', function(e){
$(document).on('appUpdate', function(e){

var oTable = $('.table').DataTable();
oTable.ajax.reload();
return;
var oTable = $('.table').DataTable();
oTable.ajax.reload();
return;

});
});

$(document).on('appReady', function(e, lang) {
$(document).on('appReady', function(e, lang) {

// Get modifiers from data attribute
var mySort = [], // Initial sort
Expand All @@ -70,7 +70,7 @@
col++
});

oTable = $('.table').dataTable( {
oTable = $('.table').dataTable( {
ajax: {
url: appUrl + '/datatables/data',
type: "POST",
Expand All @@ -86,7 +86,7 @@
});

}
// IDK what this does
// IDK what this does
if(d.search.value.match(/^\d+\.\d+(\.(\d+)?)?$/)){
var search = d.search.value.split('.').map(function(x){return ('0'+x).slice(-2)}).join('');
d.search.value = search;
Expand All @@ -97,26 +97,28 @@
buttons: mr.dt.buttons,
order: mySort,
columnDefs: columnDefs,
createdRow: function( nRow, aData, iDataIndex ) {
// Update name in first column to link
var name=$('td:eq(0)', nRow).html();
if(name == ''){name = "No Name"};
var sn=$('td:eq(1)', nRow).html();
var link = mr.getClientDetailLink(name, sn, '#tab_applications-tab');
$('td:eq(0)', nRow).html(link);
createdRow: function( nRow, aData, iDataIndex ) {
// Update name in first column to link
var name=$('td:eq(0)', nRow).html();
if(name == ''){name = "No Name"};
var sn=$('td:eq(1)', nRow).html();
var link = mr.getClientDetailLink(name, sn, '#tab_applications-tab');
$('td:eq(0)', nRow).html(link);

// Localize Obtained From
var obtained_from=$('td:eq(6)', nRow).html();
obtained_from = obtained_from == 'unknown' ? i18n.t('unknown') :
obtained_from = obtained_from == 'mac_app_store' ? i18n.t('applications.mac_app_store') :
obtained_from = obtained_from == 'apple' ? "Apple":
(obtained_from === 'identified_developer' ? i18n.t('applications.identified_developer') : obtained_from)
$('td:eq(6)', nRow).html(obtained_from)
var obtained_from=$('td:eq(6)', nRow).html();
obtained_from = obtained_from == 'unknown' ? i18n.t('unknown') :
obtained_from = obtained_from == 'mac_app_store' ? i18n.t('applications.mac_app_store') :
obtained_from = obtained_from == 'apple' ? "Apple":
(obtained_from === 'identified_developer' ? i18n.t('applications.identified_developer') : obtained_from)
$('td:eq(6)', nRow).html(obtained_from)

// Format date
var event = parseInt($('td:eq(7)', nRow).html());
var date = new Date(event * 1000);
$('td:eq(7)', nRow).html('<span title="' + moment(date).fromNow() + '">'+ moment(date).format('llll')+'</span>');
var event = parseInt($('td:eq(7)', nRow).html());
if (event > 0){
var date = new Date(event * 1000);
$('td:eq(7)', nRow).html('<span title="' + moment(date).fromNow() + '">'+ moment(date).format('llll')+'</span>');
}

// runtime_environment
var colbit=$('td:eq(8)', nRow).html();
Expand All @@ -137,10 +139,10 @@
colvar = colvar == '1' ? i18n.t('yes') :
(colvar == '0' ? i18n.t('no') : '')
$('td:eq(8)', nRow).html(colvar)
}
});
}
});

});
});
</script>

<?php $this->view('partials/foot'); ?>
8 changes: 5 additions & 3 deletions views/applications_tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<th data-i18n="name" data-colname='applications.name'></th>
<th data-i18n="version" data-colname='applications.version'></th>
<th data-i18n="applications.bundle_version" data-colname='applications.bundle_version'></th>
<th data-i18n="applications.signed_by" data-colname='applications.signed_by'></th>
<th data-i18n="applications.signed_by" data-colname='applications.signed_by'></th>
<th data-i18n="applications.obtained_from" data-colname='applications.obtained_from'></th>
<th data-i18n="applications.last_modified" data-colname='applications.last_modified'></th>
<th data-i18n="applications.has64bit" data-colname='applications.has64bit'></th>
Expand Down Expand Up @@ -76,8 +76,10 @@
// Format date
var event = parseInt($('td:eq(5)', nRow).html());
var date = new Date(event * 1000);
$('td:eq(5)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
if (event > 0){
var date = new Date(event * 1000);
$('td:eq(5)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
}
// runtime_environment
var colbit=$('td:eq(6)', nRow).html();
Expand Down

0 comments on commit 1563da5

Please sign in to comment.