1
| define(function(require,exports,module){function e(){}var t,a,n,o,i;t=require("jquery"),require("ui.slider"),require("ui.table"),require("ui.jquery"),require("config/ui.config"),a=require("translator"),n=require("common"),o=require("utils"),i=require("isapi/response"),e.prototype={init:function(){this.initController()},initController:function(){angular.module("hddTestApp",["ui.jquery","ui.config"]).service("service",function(){var e=this;this.m_oScope=null,this.m_oLan=a.oLastLanguage,this.m_oCapbilities={aStepNames:[e.m_oLan.smartTest,e.m_oLan.badBlockTest],aHddOptions:[],oTestStatusOption:{ok:e.m_oLan.hddTestOk,aborted:e.m_oLan.hddTestAborted,interrupted:e.m_oLan.hddTestInterrupted,failed:e.m_oLan.hddTestFailed,unkown:e.m_oLan.hddTestUnkown,electronic_element_error:e.m_oLan.hddTestElectronicError,servo_error:e.m_oLan.hddTestServoError,read_failed:e.m_oLan.hddTestReadFailed,progress:e.m_oLan.hddTestProgress,not_tested:e.m_oLan.hddTestNotTested,not_recognized:e.m_oLan.hddTestNotRecognized},oTestSelfEvaluaingOpt:{ok:e.m_oLan.selfEvaluaingPass,error:e.m_oLan.selfEvaluaingError},oTestAllEvaluaingOpt:{functional:e.m_oLan.allEvaluaingFunctional,badsectors:e.m_oLan.allEvaluaingBadsectors,fault:e.m_oLan.allEvaluaingFault},oHddTestStatus:{none:e.m_oLan.hddTestNotTested,running:e.m_oLan.hddTestings,pause:e.m_oLan.hddTestPaused,complete:e.m_oLan.hddTestComplete,exceed:e.m_oLan.hddTestExceed,abort:e.m_oLan.hddTestAbort},oAttributeName:{0:"Unknown attribute",1:"Raw Read Error Rate",2:"Throughput Performance",3:"Spin Up Time",4:"Start/Stop Count",5:"Reallocated Sector Count",6:"Read Channel Margin",7:"Seek Error Rate",8:"Seek Time Performance",9:"Power-on Hours Count",10:"Spin Up Retry Count",11:"Calibration Retry Count",12:"Power Cycle Count",13:"Soft Read Error Rate",183:"SATA Downshift Error Count",184:"End-to-End error",185:"Head Stability",186:"Induced Op-Vibration Detection",187:"Reported Uncorrectable Errors",188:"Command Timeout",189:"High Fly Writes",190:"Temperature Difference from 100",191:"G-Sense Error Rate",192:"Power Off Retract Count",193:"Load/Unload Cycle Count",194:"Power temperature",195:"ECC on the Fly count",196:"Reallocation Event Count",197:"Current Pending Sector Count",198:"Off-line Scan Uncorrect. Sector Count",199:"Ultra ATA CRC Error Rate",200:"Write Error Count",201:"Soft Read Error Rate",202:"TA Increase Count",203:"Run Out Cancel",204:"Shock Count Write Opern",205:"Shock Rate Write Opern",206:"Flying Height Measurement",207:"Spin High Current",208:"Spin Buzz",209:"Offline Seek Performance",211:"Vibration During Write",212:"Shock During Write",220:"Disk Shift",221:"G-Sense Error Rate",222:"Loaded Hours",223:"Load Retry Count",224:"Load Friction",225:"Load Cycle Count",226:"Load-in Time",227:"Torq-amp Count",228:"Power Off Retract Count",230:"Head Amplitude",231:"Temperature Celsius",240:"Head Flying Hours",250:"Read Error Retry Rate"}}[B],this.m_oParams={szHddSmartChoose:"",szHddTestChoose:""[/B],szSmartTestType:"short",szTestStatus:"ok",szTemperature:"39",szUseDays:"485",szSelfEvaluaingStatus:"ok",szAllEvaluaingStatus:"functional",szHddTestType:"metadata",aBlockStatus:[],iSmartTestPersent:0,szBlockTestStatus:"none",szHddCapability:"",iBlockNums:1,szBlockSize:"",szErrorNums:"0",szHddTestPersent:"",iLastTestBlock:0,bEnableUseHdd:!1,szPauseResumetxt:e.m_oLan.pause};var r=null;this.getHddList=function(){WebSDK.WSDK_GetDeviceConfig(n.m_szHostName,"storage",null,{async:!1,success:function(a,n){e.m_oCapbilities.aHddOptions.length=0;for(var i=t(n).find("hdd").length,r=0;i>r;r++)"notexist"!==t(n).find("hdd").eq(r).find("status").eq(0).text()&&"eSATA"!==t(n).find("hdd").eq(r).find("hddType").eq(0).text()&&e.m_oCapbilities.aHddOptions.push({id:o.nodeValue(t(n).find("hdd").eq(r),"id")});e.m_oCapbilities.aHddOptions.length>0&&(e.m_oParams.szHddSmartChoose=e.m_oCapbilities.aHddOptions[0].id,e.m_oParams.szHddTestChoose=e.m_oParams.szHddSmartChoose)}})},this.initTable=function(){r=t("#tableSmartStatus").table({header:[{display:"ID",width:"50",type:""},{display:"Attribute Name",width:"248",type:e.m_oCapbilities.oAttributeName,disabled:!0},{display:"Status",width:"50",type:""},{display:"Flags",width:"50",type:""},{display:"Threshold",width:"80",type:""},{display:"Value",width:"50",type:""},{display:"Worst",width:"100",type:""},{display:"Raw Value",width:"100",type:""}]})},this.initParams=function(){for(var t=0;30>t;t++){e.m_oParams.aBlockStatus[t]=[];for(var a=0;30>a;a++)e.m_oParams.aBlockStatus[t][a]=0}},this.startSmartTest=function(){var t="<?xml version='1.0' encoding='UTF-8'?><HDDSMARTTest><testType>"+e.m_oParams.szSmartTestType+"</testType></HDDSMARTTest>",a=o.parseXmlFromStr(t);WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"startSmartTest",{disk:e.m_oParams.szHddSmartChoose},{processData:!1,data:a,success:function(){e.getSmartStatus()},error:function(e,t,a){i.saveState(a)}})},this.getSmartStatus=function(){WebSDK.WSDK_GetDeviceConfig(n.m_szHostName,"smartStatus",{disk:e.m_oParams.szHddSmartChoose},{success:function(a,n){r.deleteRows();var i=[];e.m_oParams.szTestStatus=o.nodeValue(t(n),"selfTestStatus"),e.m_oParams.szTemperature=o.nodeValue(t(n),"temprature"),e.m_oParams.szUseDays=o.nodeValue(t(n),"powerOnDay"),e.m_oParams.iSmartTestPersent=o.nodeValue(t(n),"selfTestPercent","i"),e.m_oParams.szSelfEvaluaingStatus=o.nodeValue(t(n),"selfEvaluaingStatus"),e.m_oParams.szAllEvaluaingStatus=o.nodeValue(t(n),"allEvaluaingStatus"),e.m_oParams.szSmartTestType=o.nodeValue(t(n),"testType");for(var s=t(n).find("TestResult").length,l=0;s>l;l++)"0"!==o.nodeValue(t(n).find("TestResult").eq(l),"attributeID")&&(i[l]=[],i[l][0]=o.nodeValue(t(n).find("TestResult").eq(l),"attributeID"),i[l][1]=i[l][0],i[l][2]=o.nodeValue(t(n).find("TestResult").eq(l),"status"),i[l][3]=o.nodeValue(t(n).find("TestResult").eq(l),"flags"),i[l][4]=o.nodeValue(t(n).find("TestResult").eq(l),"thresholds"),i[l][5]=o.nodeValue(t(n).find("TestResult").eq(l),"value"),i[l][6]=o.nodeValue(t(n).find("TestResult").eq(l),"worst"),i[l][7]=o.nodeValue(t(n).find("TestResult").eq(l),"rawValue"));r.addRows(i),e.m_oParams.iSmartTestPersent>0&&100>e.m_oParams.iSmartTestPersent&&setTimeout(function(){e.getSmartStatus()},2e3),e.m_oScope.$digest()},error:function(){e.m_oParams.szTestStatus="not_tested",e.m_oParams.szTemperature="",e.m_oParams.szUseDays="",e.m_oParams.iSmartTestPersent=0,e.m_oParams.szSelfEvaluaingStatus="",e.m_oParams.szAllEvaluaingStatus="",e.m_oParams.szSmartTestType="short",e.m_oScope.$digest()}})},this.getSmartTestInfo=function(){WebSDK.WSDK_GetDeviceConfig(n.m_szHostName,"smartTestInfo",null,{async:!1,success:function(a,n){e.m_oParams.bEnableUseHdd=o.nodeValue(t(n),"enabled","b")}})},this.initBlockParams=function(){e.m_oParams.iLastTestBlock=0,t("#hddTestTable").find("tr").each(function(){t(this).find("td").each(function(){t(this).removeClass("ok-type").removeClass("bad-type").removeClass("shield-type")})})},this.startBlockTest=function(){"pause"===e.m_oParams.szBlockTestStatus&&e.stopBlockTest(),e.initBlockParams();var t="<?xml version='1.0' encoding='UTF-8'?><BadSectorsTest><testType>"+e.m_oParams.szHddTestType+"</testType></BadSectorsTest>",a=o.parseXmlFromStr(t);WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"startHddTest",{disk:e.m_oParams.szHddTestChoose},{processData:!1,data:a,success:function(){e.getBlockTestStatus()},error:function(e,t,a){i.saveState(a)}})},this.stopBlockTest=function(){WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"stopHddTest",{disk:e.m_oParams.szHddTestChoose},{processData:!1,async:!1,data:null,success:function(){},error:function(e,t,a){i.saveState(a)}})},this.getBlockTestStatus=function(){WebSDK.WSDK_GetDeviceConfig(n.m_szHostName,"hddTestStatus",{disk:e.m_oParams.szHddTestChoose},{success:function(a,n){var i=o.nodeValue(t(n).find("BlockAreaTestStatus"),"currentBlock","i");e.m_oParams.szBlockTestStatus=o.nodeValue(t(n).find("BlockAreaTestStatus"),"testStatus"),e.m_oParams.szHddTestType=o.nodeValue(t(n).find("BlockAreaTestStatus"),"testType"),e.m_oParams.szPauseResumetxt="pause"===e.m_oParams.szBlockTestStatus?e.m_oLan.restoreLib:e.m_oLan.pause,e.m_oParams.iBlockNums=parseInt(o.nodeValue(t(n).find("BlockAreaTestStatus"),"lastBlock"),10)-parseInt(o.nodeValue(t(n).find("BlockAreaTestStatus"),"fistBlock"),10),e.m_oParams.szErrorNums=""+t(n).find("BadSectorsList").eq(0).find("BadSectors").length,e.m_oParams.szHddTestPersent=(100*i/e.m_oParams.iBlockNums).toFixed(2)+"%";var r=Math.round(1600*e.m_oParams.iLastTestBlock/e.m_oParams.iBlockNums),s=Math.round(1600*i/e.m_oParams.iBlockNums);t(n).find("MaskAreaList").eq(0).find("MaskArea").each(function(){var a=parseInt(o.nodeValue(t(this),"startLBA","i"),10),n=parseInt(o.nodeValue(t(this),"endLBA","i"),10),i=Math.round(1600*a/e.m_oParams.iBlockNums),s=Math.round(1600*n/e.m_oParams.iBlockNums);if(i>=r)for(var l=i;s>l;l++){var d=Math.floor(l/40),m=l%40;t("#hddTestTable").find("tr").eq(d).find("td").eq(m).addClass("shield-type")}}),t(n).find("BadSectorsList").eq(0).find("BadSectors").each(function(){var a=parseInt(o.nodeValue(t(this),"id","i"),10),n=Math.round(1600*a/e.m_oParams.iBlockNums),i=Math.floor(n/40),s=n%40;n>=r&&t("#hddTestTable").find("tr").eq(i).find("td").eq(s).addClass("bad-type")});for(var l=r;s>l;l++){var d=Math.floor(l/40),m=l%40;t("#hddTestTable").find("tr").eq(d).find("td").eq(m).hasClass("shield-type")||t("#hddTestTable").find("tr").eq(d).find("td").eq(m).hasClass("bad-type")||t("#hddTestTable").find("tr").eq(d).find("td").eq(m).addClass("ok-type")}"running"===e.m_oParams.szBlockTestStatus&&setTimeout(function(){e.getBlockTestStatus()},5e3),e.m_oParams.iLastTestBlock=i,e.m_oScope.$digest()},error:function(){e.m_oParams.szBlockTestStatus="none",e.m_oParams.szHddTestType="metadata",e.m_oParams.szPauseResumetxt=e.m_oLan.pause,e.m_oParams.szHddTestPersent="",e.m_oParams.szErrorNums="0",e.m_oScope.$digest()}})},this.getHddProperty=function(){WebSDK.WSDK_GetDeviceConfig(n.m_szHostName,"hddProperty",{disk:e.m_oParams.szHddTestChoose},{async:!1,success:function(a,n){e.m_oParams.szHddCapability=(parseInt(o.nodeValue(t(n),"capacity","i"),10)/1024).toFixed(2)+"GB",e.m_oParams.szBlockSize=(parseInt(o.nodeValue(t(n),"capacity","i"),10)/1600).toFixed(2)+"MB"}})},this.initSmartTest=function(){e.initParams(),e.getHddList()},this.pauseTest=function(){"running"===e.m_oParams.szBlockTestStatus?WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"hddTestPause",{disk:e.m_oParams.szHddTestChoose},{processData:!1,data:null,success:function(){e.m_oParams.szPauseResumetxt=e.m_oLan.restoreLib,e.getBlockTestStatus()},error:function(e,t,a){i.saveState(a)}}):"pause"===e.m_oParams.szBlockTestStatus&&WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"hddTestResume",{disk:e.m_oParams.szHddTestChoose},{processData:!1,data:null,success:function(){e.m_oParams.szPauseResumetxt=e.m_oLan.pause,e.getBlockTestStatus()},error:function(e,t,a){i.saveState(a)}})},this.save=function(){var t=o.parseXmlFromStr("<?xml version='1.0' encoding='UTF-8'?><SMARTTestConfig><enabled>"+(""+e.m_oParams.bEnableUseHdd)+"</enabled></SMARTTestConfig>");WebSDK.WSDK_SetDeviceConfig(n.m_szHostName,"smartTestInfo",null,{processData:!1,data:t,complete:function(e,t,a){i.saveState(a)}})}}).controller("hddTestController",function($scope,service){service.initSmartTest(),$scope.oLan=service.m_oLan,service.m_oScope=$scope,$scope.oCapbilities=service.m_oCapbilities,$scope.oParams=service.m_oParams,$scope.iTabIndex=0,$scope.startSmartTest=service.startSmartTest,$scope.startBlockTest=service.startBlockTest,$scope.stopBlockTest=service.stopBlockTest,$scope.pauseTest=service.pauseTest,$scope.save=service.save,$scope.changeTab=function(e){$scope.iTabIndex=e},$scope.$watch("oParams.szHddSmartChoose",function(e){e&&(service.initTable(),setTimeout(function(){service.getSmartStatus()},200),service.getSmartTestInfo())}),$scope.$watch("oParams.szHddTestChoose",function(e){e&&(service.initBlockParams(),setTimeout(function(){service.getBlockTestStatus()},200),service.getHddProperty())})}).directive("hddtest",function(){return{restrict:"A",replace:!0,template:"<div class='grid-test'><div class='table-container'></div><div class='info'><div class='block-style'><span class='block-ok'></span><span class='block-text' ng-bind='oLan.okBlock'></span></div><div class='block-style'><span class='block-bad'></span><span class='block-text' ng-bind='oLan.badBlock'></span></div><div class='block-style'><span class='block-shield'></span><span class='block-text' ng-bind='oLan.shieldBlock'></span></div><div class='blank-part'></div><div class='test-status'><div class='status-line'><span><label ng-bind='oLan.hddCapacity'></label>: <label ng-bind='oParams.szHddCapability'></label></span></div><div class='status-line'><span><label ng-bind='oLan.blockCapacity'></label>: <label ng-bind='oParams.szBlockSize'></label></span></div><div class='status-line'><span><label ng-bind='oLan.state'></label>: <label ng-bind='oCapbilities.oHddTestStatus[oParams.szBlockTestStatus]'></label> <label ng-show='oParams.szBlockTestStatus === \"running\"' ng-bind='oParams.szHddTestPersent'></label></span></div><div class='status-line'><span><label ng-bind='oLan.errorNums'></label>: <label ng-bind='oParams.szErrorNums'></label></span></div></div></div><div class='tool-bar'><input type='button' ng-show='false' ng-disabled='oParams.szBlockTestStatus === \"running\"' ng-click='getErrorInfo()' class='btn' ng-value='oLan.errorInfo' /><input type='button' ng-disabled='oParams.szBlockTestStatus !== \"running\" && oParams.szBlockTestStatus !== \"pause\"' ng-click='pauseTest()' class='btn' ng-value='oParams.szPauseResumetxt' /><input type='button' ng-disabled='oParams.szBlockTestStatus !== \"running\" && oParams.szBlockTestStatus !== \"pause\"' ng-click='stopBlockTest()' class='btn' ng-value='oLan.cancel' /></div></div>",controller:function(){},link:function(e,a){if(0===t(a).find("div").eq(0).find("table").length){for(var n="<table id='hddTestTable' cellpadding='0' cellspacing='0' style='border-collapse: collapse;'>",o=0;40>o;o++){n+="<tr>";for(var i=0;40>i;i++)n+="<td class='cell'></td>";n+="</tr>"}n+="</table>",t(a).find("div").eq(0).append(n)}}}}),angular.bootstrap(angular.element("#hddTest"),["hddTestApp"])}},module.exports=new e}); |