Software: Microsoft-IIS/10.0. PHP/7.4.33 uname -a: Windows NT LAKE 10.0 build 20348 (Windows Server 2016) AMD64 IWPD_801(traduongco) Safe-mode: OFF (not secure) C:\Windows\SystemApps\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\webapps\inclusiveOobe\js\ drwxrwxrwx | |
| Viewing file: Select action/file-type: //
// Copyright (C) Microsoft. All rights reserved.
//
define(['lib/knockout', 'legacy/bridge', 'legacy/events', 'legacy/core', 'autopilot-telemetry'], (ko, bridge, constants, core, autopilotTelemetryUtility) => {
class WhiteGloveResultViewModel {
constructor(resourceStrings) {
this.enterpriseManagementWorker = new EnterpriseDeviceManagement.Enrollment.ReflectedEnroller();
this.pluginManager = new CloudExperienceHostAPI.Provisioning.PluginManager();
this.autoPilotManager = new EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotServer();
// UI element initialization
this.resourceStrings = resourceStrings;
this.organizationName = ko.observable(resourceStrings.WhiteGloveOrganizationNotFound);
this.profileName = ko.observable(resourceStrings.WhiteGloveProfileNotFound);
this.assignedUserName = ko.observable(resourceStrings.WhiteGloveUserNotAssigned);
this.elapsedHoursText = resourceStrings.WhiteGloveHoursText;
this.elapsedMinutesText = resourceStrings.WhiteGloveMinutesText;
this.elapsedTimeNumber = ko.observable(resourceStrings.WhiteGloveTimeText);
this.title = resourceStrings.WhiteGloveTitle;
this.subHeaderText = ko.observable("");
this.subHeaderErrorText = ko.observable("");
this.organizationText = resourceStrings.WhiteGloveOrganizationTitle;
this.profileText = resourceStrings.WhiteGloveProfileTitle;
this.assignedUserText = resourceStrings.WhiteGloveAssignedUserTitle;
this.elapsedTimeText = resourceStrings.WhiteGloveElapsedTimeTitle;
this.whiteGloveQRCodeText = resourceStrings.WhiteGloveQRCode;
this.provisioningTextStyle = ko.observable("");
this.resultBackground = ko.observable("");
this.showResultFooter = ko.observable("");
this.isResetButtonDisabled = ko.observable(false);
this.isRetryButtonDisabled = ko.observable(true);
this.isDiagnosticsDisabled = ko.observable(false);
this.isLoading = ko.observable(false);
let flexStartHyperlinksSets = {};
let flexEndButtonsSets = {};
this.hyperlinkVisibility = ko.observable(0);
this.buttonVisibility = ko.observable(0);
// Log event values. Event names must remain in sync with ETWProcessingData.json
this.eventName_CommercialOOBE_WhiteGlove_TechnicianFlow_Succeeded = "CommercialOOBE_WhiteGlove_TechnicianFlow_Succeeded";
// Sharable Data Values - must be kept in sync with their values in:
// autopilotwhiteglovelanding-vm.js
// oobeprovisioningprogress-vm.js
this.whiteGloveStartTimeValueName = "AutopilotWhiteGloveStartTime";
this.whiteGloveEndTimeValueName = "AutopilotWhiteGloveEndTime";
this.whiteGloveSuccessValueName = "AutopilotWhiteGloveSuccess";
this.whiteGloveDomainJoinStateValueName = "AutopilotWhiteGloveDomainJoinInProgress";
// Time Constants
this.msPerHour = 3600000;
this.msPerMinute = 60000;
// Footer Button Visibility Enumerations
this.BUTTON_WHITE_GLOVE_SUCCESS = 0;
this.BUTTON_WHITE_GLOVE_FAILURE = 1;
// Footer Hyperlink Visibility Enumerations
this.HYPERLINK_WHITE_GLOVE_NONE = 0;
this.HYPERLINK_WHITE_GLOVE_DIAGNOSTICS_ENABLED = 1;
this.showDiagnosticsHyperlinkEnabled = false;
// Diagnostics Enumerations
const whiteGloveAreaName = "Autopilot;TPM";
const whiteGloveLogName = "\\AutopilotWhiteGloveLogs.zip";
this.diagnosticsPreviousCXID = "DiagnosticsPreviousCXID";
// This value has to be kept in sync with the CXID in Navigation.json
this.PAGE_TRANSITION_DIAGNOSTICS_PAGE = "OobeDiagnostics";
flexStartHyperlinksSets[this.HYPERLINK_WHITE_GLOVE_NONE] = [];
flexStartHyperlinksSets[this.HYPERLINK_WHITE_GLOVE_DIAGNOSTICS_ENABLED] = [
{
handler: () => {
this.onDiagnosticsClickAsync(whiteGloveAreaName, whiteGloveLogName);
},
disableControl: ko.pureComputed(() => {
return this.isDiagnosticsDisabled();
}),
hyperlinkText: resourceStrings.WhiteGloveDiagnosticsButtonText
}
];
this.flexStartHyperLinks = ko.pureComputed(() => {
return flexStartHyperlinksSets[this.hyperlinkVisibility()];
});
flexEndButtonsSets[this.BUTTON_WHITE_GLOVE_SUCCESS] = [
{
buttonText: resourceStrings.WhiteGloveResealButtonText,
buttonType: "button",
isPrimaryButton: true,
buttonClickHandler: () => {
this.onResealAsync();
}
}
];
flexEndButtonsSets[this.BUTTON_WHITE_GLOVE_FAILURE] = [
{
buttonText: resourceStrings.WhiteGloveRetryButtonText,
buttonType: "button",
isPrimaryButton: true,
disableControl: ko.pureComputed(() => {
return this.isRetryButtonDisabled();
}),
buttonClickHandler: () => {
bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveSuccessValueName);
bridge.fireEvent(constants.Events.done, constants.AppResult.action1);
}
},
{
buttonText: resourceStrings.WhiteGloveResetButtonText,
buttonType: "button",
isPrimaryButton: true,
disableControl: ko.pureComputed(() => {
return this.isResetButtonDisabled();
}),
buttonClickHandler: () => {
this.onResetAsync();
}
}
];
this.flexEndButtons = ko.pureComputed(() => {
return flexEndButtonsSets[this.buttonVisibility()];
});
this.runAsync(this.displayResultsAsyncGen);
}
*isShowDiagnosticsEnabledAsyncGen() {
try {
this.showDiagnosticsHyperlinkEnabled = yield this.enterpriseManagementWorker.shouldShowCollectLogsAsync(true);
yield bridge.invoke(
"CloudExperienceHost.AutoPilot.logInfoEvent",
"CommercialOOBE_WhiteGlove_ShowDiagnosticsHyperlinkPolicy_Succeeded",
`Show diagnostics policy enabled = ${this.showDiagnosticsHyperlinkEnabled}`);
} catch (error) {
yield bridge.invoke("CloudExperienceHost.AutoPilot.logHresultEvent",
"CommercialOOBE_WhiteGlove_ShowDiagnosticsHyperlinkPolicy_Failed",
"Show diagnostics policy retrieval failed.",
error.number);
}
}
onResetAsync() {
return this.runAsync(this.resetAsyncGen);
}
*resetAsyncGen() {
this.isResetButtonDisabled(true);
this.isDiagnosticsDisabled(true);
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove failure page system reset chosen");
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveStartTimeValueName);
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveDomainJoinStateValueName);
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveSuccessValueName);
try {
yield this.pluginManager.initiateSystemResetAsync();
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove failure page system reset successful");
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Reset, "system reset error", error);
this.displayError();
}
}
onDiagnosticsClickAsync(area, file) {
if (CloudExperienceHostAPI.FeatureStaging.isOobeFeatureEnabled("WindowsAutopilotDiagnostics")) {
return this.runAsync(this.viewDiagnosticsClickHandlerAsyncGen);
}
return this.runAsync(this.collectLogsClickHandlerAsyncGen, area, file);
}
*viewDiagnosticsClickHandlerAsyncGen() {
// TODO: [ADO 28009402] Add logging
try {
// Save current CXID and navigate to troubleshooting page
let currentNode = yield bridge.invoke("CloudExperienceHost.AutoPilot.AutopilotWrapper.GetCurrentNode");
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.addValue", this.diagnosticsPreviousCXID, currentNode.cxid);
bridge.fireEvent(CloudExperienceHost.Events.done, this.PAGE_TRANSITION_DIAGNOSTICS_PAGE);
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, "view diagnostics error", error);
this.displayError();
}
}
*collectLogsClickHandlerAsyncGen(area, file) {
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove failure page collect logs chosen");
let formerSubheaderText = this.subHeaderText._latestValue;
let formerIsRetryButtonDisabledState = this.isRetryButtonDisabled._latestValue;
try {
let folderPath = yield bridge.invoke("CloudExperienceHost.showFolderPicker");
this.isResetButtonDisabled(true);
this.isDiagnosticsDisabled(true);
this.isRetryButtonDisabled(true);
this.isLoading(true);
this.subHeaderText(this.resourceStrings.CollectingLogsSpinnerText);
yield this.enterpriseManagementWorker.collectLogsEx(area, folderPath + file);
this.isResetButtonDisabled(false);
this.isDiagnosticsDisabled(false);
this.isLoading(false);
this.isRetryButtonDisabled(formerIsRetryButtonDisabledState);
this.subHeaderText(formerSubheaderText);
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove failure page collect logs failure");
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, "log collection error", error);
this.isResetButtonDisabled(false);
this.isDiagnosticsDisabled(false);
this.isLoading(false);
this.isRetryButtonDisabled(formerIsRetryButtonDisabledState);
this.subHeaderText(formerSubheaderText);
this.displayError();
}
}
onResealAsync() {
return this.runAsync(this.resealAsyncGen);
}
*resealAsyncGen() {
try {
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove reseal started");
// Clears new sharable data
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveStartTimeValueName);
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveSuccessValueName);
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", this.whiteGloveDomainJoinStateValueName);
// Update the white glove mode indicating that technician flow has completed and the device has been resealed.
yield this.autoPilotManager.setDeviceAutopilotModeAsync(EnterpriseDeviceManagement.Service.AutoPilot.AutopilotMode.whiteGloveResealed);
// Clears value so first page of OOBE will show on start up
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", "resumeCXHId");
// Disables resuming OOBE at a certain node
yield bridge.invoke("CloudExperienceHost.Storage.SharableData.removeValue", "OOBEResumeEnabled");
// Powers down the device
yield CloudExperienceHostAPI.UtilStaticsCore.shutdownAsync();
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "White glove shut down initiated");
yield bridge.invoke("CloudExperienceHost.Telemetry.oobeHealthEvent", CloudExperienceHostAPI.HealthEvent.machineReseal, 0 /* Unused Result Parameter */);
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Shutdown, "shutdown error", error);
this.displayError();
}
}
*displayResultsAsyncGen()
{
try {
yield this.runAsync(this.isShowDiagnosticsEnabledAsyncGen);
// Check for success value written by ESP when it successfully completes.
let success = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveSuccessValueName);
this.displayResult(success);
yield this.runAsync(this.displayCategoriesAsyncGen);
yield this.runAsync(this.displayProvisioningTimeAsyncGen);
yield this.runAsync(this.displayQRCodeAsyncGen);
} catch (error) {
// Swallow exception and show error on page.
this.displayError();
}
}
*displayCategoriesAsyncGen() {
try {
let organizationName = yield this.autoPilotManager.getStringPolicyAsync("CloudAssignedTenantDomain");
if (organizationName !== "") {
this.organizationName(organizationName);
}
let profileName = yield this.autoPilotManager.getStringPolicyAsync("DeploymentProfileName");
if (profileName !== "") {
this.profileName(profileName);
}
let userName = yield this.autoPilotManager.getStringPolicyAsync("CloudAssignedTenantUpn");
if (userName !== "") {
this.assignedUserName(userName);
}
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Error, "error retrieving Autopilot policies.", error);
throw error;
}
}
*displayQRCodeAsyncGen() {
try {
let result = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveSuccessValueName);
let startTime = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveStartTimeValueName);
let endTime = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveEndTimeValueName);
let elapsedTimeMilliseconds = endTime - startTime;
let qrData = yield this.autoPilotManager.getDeviceBlobForQRCodeAsync();
let qrDataJson = JSON.parse(qrData);
// Add result and elapsed time to QR code
if (result === "Success") {
qrDataJson.Result = "Success";
}
else {
qrDataJson.Result = "Failure";
}
qrDataJson.ElapsedTimeMilliseconds = elapsedTimeMilliseconds;
let qrDataString = JSON.stringify(qrDataJson);
yield bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "AutopilotWhiteGlove: QR code result", qrDataString);
// If ZtdId was retrieved, display the QR code
if (qrDataJson.ZtdId != "") {
let walletBarcode = new Windows.ApplicationModel.Wallet.WalletBarcode(Windows.ApplicationModel.Wallet.WalletBarcodeSymbology.qr, qrDataString);
let image = yield walletBarcode.getImageAsync();
if (image != null) {
let qrCode = document.getElementById("qrAssignmentCode");
qrCode.setAttribute("aria-label", this.whiteGloveQRCodeText);
let blob = yield image.openReadAsync();
let qrImageStream = MSApp.createStreamFromInputStream("image/bmp", blob);
qrCode.src = URL.createObjectURL(qrImageStream);
}
} else {
// Else the device is not registered, so display error message and block next button
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Error, "Unable to get device ZtdId");
}
} catch (error) {
// If device blob retrieval failed, display error message and block next button
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Error, "QR blob generation error", error);
throw error;
}
}
*displayProvisioningTimeAsyncGen() {
try {
let startTime = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveStartTimeValueName);
let endTime = yield bridge.invoke("CloudExperienceHost.Storage.SharableData.getValue", this.whiteGloveEndTimeValueName);
let milliseconds = endTime - startTime;
let hours = Math.floor(milliseconds / this.msPerHour);
let minutes = Math.floor((milliseconds - (hours * this.msPerHour)) / this.msPerMinute);
this.elapsedTimeNumber(resourceStrings.WhiteGloveTimeText
.replace("{0}", hours)
.replace("{1}", minutes));
} catch (error) {
yield this.runAsync(this.logFailureEventAsyncGen, autopilotTelemetryUtility.whiteGloveError.Error, "error retrieving start time", error);
throw error;
}
}
displayError() {
this.provisioningTextStyle("error");
this.subHeaderText(resourceStrings.WhiteGloveQRCodeError);
}
displayResult(result) {
if (result === "Success") {
this.resultBackground("success-background");
this.showResultFooter("success-footer");
this.subHeaderText(this.resourceStrings.WhiteGloveCompletedText);
this.hyperlinkVisibility(this.HYPERLINK_WHITE_GLOVE_NONE);
this.buttonVisibility(this.BUTTON_WHITE_GLOVE_SUCCESS);
autopilotTelemetryUtility.logger.logError(autopilotTelemetryUtility.whiteGloveInformational.Success, "AutopilotWhiteGlove: showing success page because AutopilotWhiteGloveSuccess was marked as success.");
bridge.invoke(
"CloudExperienceHost.AutoPilot.logInfoEvent",
this.eventName_CommercialOOBE_WhiteGlove_TechnicianFlow_Succeeded,
"White glove technician flow succeeded.");
} else {
this.resultBackground("failure-background");
this.showResultFooter("failure-footer");
if (this.showDiagnosticsHyperlinkEnabled) {
this.hyperlinkVisibility(this.HYPERLINK_WHITE_GLOVE_DIAGNOSTICS_ENABLED);
this.subHeaderText(this.resourceStrings.WhiteGloveFailureText);
} else {
this.hyperlinkVisibility(this.HYPERLINK_WHITE_GLOVE_NONE);
this.subHeaderText(this.resourceStrings.WhiteGloveFailureDiagnosticsDisabledText);
}
this.buttonVisibility(this.BUTTON_WHITE_GLOVE_FAILURE);
this.isRetryButtonDisabled(!this.isRetriableError(result));
if (result !== null) {
this.subHeaderErrorText(result);
autopilotTelemetryUtility.logger.logError(autopilotTelemetryUtility.whiteGloveError.Error, "AutopilotWhiteGLove: showing failure page because AutopilotWhiteGloveSuccess was marked as an error.");
}
}
}
// By default assume all errors are re-triable
isRetriableError(result) {
return true;
}
*logFailureEventAsyncGen(area, failureName, e) {
yield autopilotTelemetryUtility.logger.logError(area, failureName + " " + JSON.stringify({ number: e && e.number.toString(16), stack: e && e.asyncOpSource && e.asyncOpSource.stack }));
if (typeof e !== "undefined") {
yield autopilotTelemetryUtility.logger.logErrorCode(area, e.number);
}
}
runAsync(makeGenerator) {
let generatorArgs = [].slice.call(arguments, 1);
return function () {
let generator = makeGenerator.apply(this, arguments);
function iterateGenerator(result) {
// every yield returns: result => { done: [Boolean], value: [Object] }
if (result.done) {
return Promise.resolve(result.value);
}
return Promise.resolve(result.value).then(function (result) {
return iterateGenerator(generator.next(result));
}, function (error) {
return iterateGenerator(generator.throw(error));
});
}
try {
return iterateGenerator(generator.next());
} catch (error) {
return Promise.reject(error);
}
}.apply(this, generatorArgs);
}
}
return WhiteGloveResultViewModel;
});
|
:: Command execute :: | |
--[ c99shell v. 2.1 [PHP 8 Update] [02.02.2022] maintained byC99Shell Github | Generation time: 0.5797 ]-- |