|
@@ -199,16 +199,25 @@ if(ao_module_virtualDesktop){
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$.get( "opr.php?opr=scan", function( data ) {
|
|
$.get( "opr.php?opr=scan", function( data ) {
|
|
|
|
|
+ //arr = scan result
|
|
|
|
|
+ //scan first
|
|
|
var arr = JSON.parse(data);
|
|
var arr = JSON.parse(data);
|
|
|
|
|
+ //check if something is selected, if no then redirect to first drive.
|
|
|
if(active == ""){
|
|
if(active == ""){
|
|
|
window.location = "index.php?drive=" + arr["devices"][0]["info_name"];
|
|
window.location = "index.php?drive=" + arr["devices"][0]["info_name"];
|
|
|
}
|
|
}
|
|
|
|
|
+ //for loop all devices out and check SMART
|
|
|
$(arr["devices"]).each(function(index, element) {
|
|
$(arr["devices"]).each(function(index, element) {
|
|
|
|
|
+ //call infomation for further deeper result
|
|
|
$.get( "opr.php?opr=info&drive=" + element["info_name"], function( data ) {
|
|
$.get( "opr.php?opr=info&drive=" + element["info_name"], function( data ) {
|
|
|
|
|
+ //check if something exists on return
|
|
|
if(data.length > 0){
|
|
if(data.length > 0){
|
|
|
smartstat[element["info_name"]] = "Unknown";
|
|
smartstat[element["info_name"]] = "Unknown";
|
|
|
- var table = JSON.parse(data);
|
|
|
|
|
|
|
+ //find for SMART bad, here do the for loop
|
|
|
|
|
+ var table = JSON.parse(data);
|
|
|
|
|
+ //check for SMART table exists
|
|
|
if(table["ata_smart_attributes"]["table"].length > 0){
|
|
if(table["ata_smart_attributes"]["table"].length > 0){
|
|
|
|
|
+ //for loop to find if something failed, then show warning
|
|
|
$(table["ata_smart_attributes"]["table"]).each(function(tindex, telement) {
|
|
$(table["ata_smart_attributes"]["table"]).each(function(tindex, telement) {
|
|
|
if(!typeof telement["when_failed"] === "undefined"){
|
|
if(!typeof telement["when_failed"] === "undefined"){
|
|
|
if(telement["when_failed"] !== ""){
|
|
if(telement["when_failed"] !== ""){
|
|
@@ -216,13 +225,17 @@ $.get( "opr.php?opr=scan", function( data ) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ // if nothing happen, then changed to GOOD
|
|
|
if(smartstat[active] == "Unknown"){
|
|
if(smartstat[active] == "Unknown"){
|
|
|
smartstat[active] = "Good";
|
|
smartstat[active] = "Good";
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
|
|
+ // if nothing exists, then show Unknown
|
|
|
smartstat[element["info_name"]] = "Unknown";
|
|
smartstat[element["info_name"]] = "Unknown";
|
|
|
}
|
|
}
|
|
|
|
|
+ //append it to nav bar
|
|
|
if(active == element["info_name"]){
|
|
if(active == element["info_name"]){
|
|
|
|
|
+ //append if active selected
|
|
|
$( "#menu" ).append('<a class="active item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
|
|
$( "#menu" ).append('<a class="active item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
|
|
|
}else{
|
|
}else{
|
|
|
$( "#menu" ).append('<a class="item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
|
|
$( "#menu" ).append('<a class="item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
|
|
@@ -231,8 +244,12 @@ $.get( "opr.php?opr=scan", function( data ) {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+//get the selected drive infomation
|
|
|
$.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
$.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
|
|
+ //parse data;
|
|
|
var arr = JSON.parse(data);
|
|
var arr = JSON.parse(data);
|
|
|
|
|
+
|
|
|
|
|
+ //append all shit here
|
|
|
$("#drivename").html(arr["model_name"] + " " + formatSizeUnits(arr["user_capacity"]["bytes"]));
|
|
$("#drivename").html(arr["model_name"] + " " + formatSizeUnits(arr["user_capacity"]["bytes"]));
|
|
|
$("#drivename").attr("data-tooltip",arr["model_family"]);
|
|
$("#drivename").attr("data-tooltip",arr["model_family"]);
|
|
|
$("#firmware").attr("value",arr["firmware_version"]);
|
|
$("#firmware").attr("value",arr["firmware_version"]);
|
|
@@ -242,6 +259,7 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
$("#driveleter").attr("value",arr["device"]["name"]);
|
|
$("#driveleter").attr("value",arr["device"]["name"]);
|
|
|
$("#standard").attr("value",arr["ata_version"]["string"]);
|
|
$("#standard").attr("value",arr["ata_version"]["string"]);
|
|
|
$("#features").attr("value","S.M.A.R.T.");
|
|
$("#features").attr("value","S.M.A.R.T.");
|
|
|
|
|
+ //check if it is SSD
|
|
|
if(arr["rotation_rate"] > 0){
|
|
if(arr["rotation_rate"] > 0){
|
|
|
$("#col1").html("----");
|
|
$("#col1").html("----");
|
|
|
$("#col1_v").attr("value","----");
|
|
$("#col1_v").attr("value","----");
|
|
@@ -261,6 +279,8 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
}
|
|
}
|
|
|
$("#powercount").attr("value",arr["power_cycle_count"] + " count");
|
|
$("#powercount").attr("value",arr["power_cycle_count"] + " count");
|
|
|
$("#powerhour").attr("value",arr["power_on_time"]["hours"] + " hours");
|
|
$("#powerhour").attr("value",arr["power_on_time"]["hours"] + " hours");
|
|
|
|
|
+
|
|
|
|
|
+ //check if SMART bad
|
|
|
smartstat[active] = "Unknown";
|
|
smartstat[active] = "Unknown";
|
|
|
$(arr["ata_smart_attributes"]["table"]).each(function(index, element) {
|
|
$(arr["ata_smart_attributes"]["table"]).each(function(index, element) {
|
|
|
if(!typeof element["when_failed"] === "undefined"){
|
|
if(!typeof element["when_failed"] === "undefined"){
|
|
@@ -274,6 +294,7 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
var stat = "OK";
|
|
var stat = "OK";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //prevent element undefined, check first
|
|
|
if(typeof element["id"] === "undefined"){
|
|
if(typeof element["id"] === "undefined"){
|
|
|
var id = 0;
|
|
var id = 0;
|
|
|
}else{
|
|
}else{
|
|
@@ -304,18 +325,21 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
}else{
|
|
}else{
|
|
|
var rvalue = element["raw"]["value"];
|
|
var rvalue = element["raw"]["value"];
|
|
|
}
|
|
}
|
|
|
|
|
+ //apend
|
|
|
$("#tbody").append('<tr><td>' + stat + '</td><td>' + id + '</td><td>' + name + '</td><td>' + value + '</td><td>' + worst + '</td><td>' + thresh + '</td><td>' + rvalue + '</td></tr>');
|
|
$("#tbody").append('<tr><td>' + stat + '</td><td>' + id + '</td><td>' + name + '</td><td>' + value + '</td><td>' + worst + '</td><td>' + thresh + '</td><td>' + rvalue + '</td></tr>');
|
|
|
|
|
|
|
|
if(element["name"] == "SSD_Life_Left"){
|
|
if(element["name"] == "SSD_Life_Left"){
|
|
|
$("#health_prec").html(element["value"] + "%");
|
|
$("#health_prec").html(element["value"] + "%");
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ //check if SMART exists and Not in warning, then shows GOOD
|
|
|
if(arr["ata_smart_attributes"]["table"].length > 0){
|
|
if(arr["ata_smart_attributes"]["table"].length > 0){
|
|
|
if(smartstat[active] == "Unknown"){
|
|
if(smartstat[active] == "Unknown"){
|
|
|
smartstat[active] = "Good";
|
|
smartstat[active] = "Good";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //change color
|
|
|
if(smartstat[active] == "Warning"){
|
|
if(smartstat[active] == "Warning"){
|
|
|
$("#health_c").attr("class","ts inverted warning card");
|
|
$("#health_c").attr("class","ts inverted warning card");
|
|
|
}else if(smartstat[active] == "Good"){
|
|
}else if(smartstat[active] == "Good"){
|
|
@@ -323,6 +347,8 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
|
|
|
}else if(smartstat[active] == "Unknown"){
|
|
}else if(smartstat[active] == "Unknown"){
|
|
|
$("#health_c").attr("class","ts card");
|
|
$("#health_c").attr("class","ts card");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //if temp more than 40C, then warning
|
|
|
if(arr["temperature"]["current"] > 40){
|
|
if(arr["temperature"]["current"] > 40){
|
|
|
$("#temperature_c").attr("class","ts inverted warning card");
|
|
$("#temperature_c").attr("class","ts inverted warning card");
|
|
|
}else if(arr["temperature"]["current"] > 0 && arr["temperature"]["current"] < 40){
|
|
}else if(arr["temperature"]["current"] > 0 && arr["temperature"]["current"] < 40){
|