servermgrv2/public/hpilo/js/hostPwr.js
2023-07-17 21:09:49 +09:00

42 lines
2.1 KiB
JavaScript

function HostPower(parent) {
this.verifyPowerChange = function(change, callback) {
var icon = myIcons.circleQuestion, msgText = iLO.translateString("summary.verPwrChg1", "Are you sure you want to ") + change + iLO.translateString("summary.verPwrChg2", " this device?") + "<br/><br/>", msgbox = {
message: icon + msgText
};
iLO.confirm(msgbox, function(resp) {
callback(resp);
});
}, this.momentaryPress = function(callback) {
this.verifyPowerChange(iLO.translateString("summary._monentaryPress", "momentary press"), function(resp) {
1 == resp && iLO.sendJsonRequest("host_power/press_power_button", "POST", "json/host_power", {
method: "press_power_button"
}, this.getHostPower);
});
}, this.pressAndHold = function(callback) {
this.verifyPowerChange(iLO.translateString("summary._pressHold", "press and hold"), function(resp) {
1 == resp && iLO.sendJsonRequest("host_power/hold_power_button", "POST", "json/host_power", {
method: "hold_power_button"
}, this.getHostPower);
});
}, this.systemReset = function(callback) {
this.verifyPowerChange(iLO.translateString("pwr_srv._reset", "reset"), function(resp) {
1 == resp && iLO.sendJsonRequest("host_power/system_reset", "POST", "json/host_power", {
method: "system_reset"
}, this.getHostPower);
});
}, this.ColdBoot = function(callback) {
this.verifyPowerChange(iLO.translateString("pwr_srv._coldBoot", "cold boot"), function(resp) {
1 == resp && iLO.sendJsonRequest("host_power/system_coldboot", "POST", "json/host_power", {
method: "system_coldboot"
}, this.coldBootCallback);
});
}, this.getHostPower = function() {
iLO.sendJsonRequest("host_power", "GET", "json/host_power", null, this.hostPowerCallback);
}, this.coldBootCallback = function(o, fname, error) {
error != iLOGlobal.constants.HttpErrors.None && (iLO.showMainScreen(), $("#errorDisplay").displayError("Error making cold boot call: " + o.message + " " + o.details));
};
}
var hostPwr = null;
hostPwr = new HostPower(this), hostPwr.getHostPower();