Skip to content

Commit

Permalink
Update client_detail when archived change
Browse files Browse the repository at this point in the history
  • Loading branch information
bochoven committed Apr 11, 2020
1 parent b074bb7 commit 4fe9b12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions js/machine_detail.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).on('appReady', function(e, lang) {
$(document).on('appReady ', function(e, lang) {

$.getJSON( appUrl + '/module/machine/report/' + serialNumber, function( data ) {

Expand Down Expand Up @@ -33,7 +33,9 @@ $(document).on('appReady', function(e, lang) {
$('.machine-uptime').text(i18n.t('unavailable'));
}
});
});

$(document).on('appReady appUpdate', function(e, lang) {
// Get reportdata
$.getJSON( appUrl + '/module/reportdata/report/' + serialNumber, function( data ) {

Expand All @@ -45,19 +47,26 @@ $(document).on('appReady', function(e, lang) {
// Registration date
var msecs = moment(data.reg_timestamp * 1000);
$('.reportdata-reg_date').html('<time title="'+msecs.format('LLLL')+'" >'+msecs.fromNow()+'</time>');

// Check-in date
var msecs = moment(data.timestamp * 1000);
$('.reportdata-check-in_date').html('<time title="'+msecs.format('LLLL')+'" >'+msecs.fromNow()+'</time>');

// Remote IP
$('.reportdata-remote_ip').text(data.remote_ip);
});

// Get machinegroup name
$.getJSON(appUrl + '/unit/get_machine_groups', function( data ){
var machine_group = parseInt($('.machine-machine_group').text())
var name = data.find(x => parseInt(x.groupid) === machine_group).name;
$('.machine-machine_group').text(name)
})
// Get machinegroup name
$.getJSON(appUrl + '/unit/get_machine_groups', function( data ){
var machine_group = parseInt($('.machine-machine_group').text())
var name = data.find(x => parseInt(x.groupid) === machine_group).name;
$('.machine-machine_group').text(name)
})

// Status
var machineStatus = { '0': 'in_use', '1': 'archived'};
$('.reportdata-status').text(
i18n.t('machine.status.' + machineStatus[$('.reportdata-status').text()])
);

});
});
2 changes: 1 addition & 1 deletion machine_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function report($serial_number = '')
{
jsonView(
Machine_model::where('machine.serial_number', $serial_number)
->filter()
->filter('groupOnly')
->first()
);
}
Expand Down

0 comments on commit 4fe9b12

Please sign in to comment.