зеркало из
1
0
Форкнуть 0

String update per request; get rid of ruler of json editor; friendly error message for nodejs conflicting port (#337)

* friendly maessage for nodejs

* update tooltip

* text, style and error handling

* Update public/electron.ts

Co-authored-by: Ryan K <ryan.k@outlook.com>

* Update src/server/serverBase.ts

Co-authored-by: Ryan K <ryan.k@outlook.com>

Co-authored-by: Ryan K <ryan.k@outlook.com>
This commit is contained in:
YingXue 2020-07-23 11:37:43 -07:00 коммит произвёл GitHub
Родитель 33d59213d8
Коммит 310d0902f8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 46 добавлений и 38 удалений

2
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-iot-explorer",
"version": "0.11.1",
"version": "0.11.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-iot-explorer",
"version": "0.11.1",
"version": "0.11.2",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.",
"main": "public/electron.js",
"build": {

Просмотреть файл

@ -157,6 +157,14 @@ else {
app.on('ready', () => {
createWindow();
createMenu();
process.on('uncaughtException', err => {
const messageBoxOptions = {
message: err && err.message || 'Something went wrong. Please try restarting the app.',
title: 'Error in controller process',
type: 'error',
};
electron.dialog.showMessageBox(messageBoxOptions);
});
});
}

Просмотреть файл

@ -57,24 +57,19 @@ export const fetchModelDefinition = async (parameters: FetchModelParameters): Pr
};
export const validateModelDefinitions = async (modelDefinitions: string) => {
try {
const apiVersionQueryString = `?${API_VERSION}${MODEL_REPO_API_VERSION}`;
const controllerRequest: RequestInitWithUri = {
body: modelDefinitions,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-ms-client-request-id': 'azure iot explorer: validate model definition'
},
method: HTTP_OPERATION_TYPES.Post,
uri: `https://${PUBLIC_REPO_HOSTNAME}/models/validate${apiVersionQueryString}`
};
const apiVersionQueryString = `?${API_VERSION}${MODEL_REPO_API_VERSION}`;
const controllerRequest: RequestInitWithUri = {
body: modelDefinitions,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-ms-client-request-id': 'azure iot explorer: validate model definition'
},
method: HTTP_OPERATION_TYPES.Post,
uri: `https://${PUBLIC_REPO_HOSTNAME}/models/validate${apiVersionQueryString}`
};
return (await request(controllerRequest)).ok;
}
catch (error) {
throw new Error(error);
}
return (await request(controllerRequest)).ok;
};
export interface RequestInitWithUri extends RequestInit {

Просмотреть файл

@ -39,6 +39,7 @@ export const JSONEditor: React.FC<JSONEditorProps> = (props: JSONEditorProps) =>
editor.setValue(content);
editor.on('change', onUpdate);
editor.clearSelection();
editor.setShowPrintMargin(false);
}
}, [content, editorTheme]);

Просмотреть файл

@ -66,8 +66,8 @@
"redirectLink": "Please visit Home."
},
"modelDefinitions": {
"headerText": "Plug and Play configuration",
"redirect": "Looking for Plug and Play settings?",
"headerText": "IoT Plug and Play configuration",
"redirect": "Looking for IoT Plug and Play settings?",
"redirectLink": "Please visit Home."
},
"questions": {
@ -105,7 +105,7 @@
"cloudToDeviceMessage": "Cloud-to-device message",
"moduleIdentity": "Module identity",
"interfaces": "Interface",
"properties": "Properties (non-writable)",
"properties": "Properties (read-only)",
"settings": "Properties (writable)",
"commands": "Commands",
"ioTPlugAndPlay": "IoT Plug and Play components",
@ -117,7 +117,7 @@
"navBar": {
"identity": "Device identity",
"twin": "Device twin",
"properties": "Properties (non-writable)",
"properties": "Properties (read-only)",
"settings": "Properties (writable)",
"commands": "Commands",
"events": "Telemetry",
@ -448,14 +448,14 @@
"digitalTwin": {
"headerText": "IoT Plug and Play components",
"modelId": "Model ID",
"modelContainsNoComponents": "Model '{{modelId}}' contains no Plug and Play components",
"modelContainsNoComponents": "Model '{{modelId}}' contains no IoT Plug and Play components",
"componentName": "Component",
"steps": {
"zero": "Your device is not recognized as a Plug and Play device. To learn more, please check out ",
"first": "Step 1. Your device has been discovered as a Plug and Play device",
"secondSuccess": "Step 2. We've resolved your Plug and Play model",
"zero": "Your device is not recognized as a IoT Plug and Play device. To learn more, please check out ",
"first": "Step 1. Your device has been discovered as a IoT Plug and Play device",
"secondSuccess": "Step 2. We've resolved your IoT Plug and Play model",
"secondFailure": "Step 2. We are not able to retrieve model definition for {{modelId}}",
"third": "Step 3. Continue your Plug and Play journey by drilling down to each component",
"third": "Step 3. Continue your IoT Plug and Play journey by drilling down to each component",
"explanation": "If you have defined 'Property', 'Command' or 'Telemetry' in model {{modelId}}, you would be able to see 'Default component' in the table below. If you havea defined 'Component', you would be able to see a list of components down below."
},
"pivot": {
@ -473,8 +473,8 @@
"openReportedValuePanel": "Click to view value",
"close": "Back"
},
"headerText": "Non-writable properties",
"noProperties": "ComponentName {{componentName}} contains no non-writable property definitions",
"headerText": "Read-only properties",
"noProperties": "ComponentName {{componentName}} contains no read-only property definitions",
"columns": {
"name": "Name (Display Name / Description)",
"value": "Value",
@ -637,7 +637,7 @@
"responseTimeoutTooltip": "Number of seconds to wait until a result is received from the Direct method.",
"invokeMethodButtonText": "Invoke method",
"payload" : "Payload",
"payloadTooltip" : "The payload for the Direct method to invoke on this device which needs to be in JSON format",
"payloadTooltip" : "The payload for the Direct method to invoke on the device",
"result" : "Result"
},
"cloudToDeviceMessage": {
@ -814,7 +814,7 @@
"getModuleIdentityOnError": "Failed to get module identity {{moduleId}}: {{error}}",
"deleteModuleIdentityOnSuccess": "Successfully deleted module {{moduleId}}",
"deleteModuleIdentityOnError": "Failed to delete module identity {{moduleId}}: {{error}}",
"portIsInUseError": "The port {{portNumber}} is in use. To configure a custom port value, set system environment variable 'AZURE_IOT_EXPLORER_PORT' to an available port number. To learn more, visit https://github.com/Azure/azure-iot-explorer/wiki/FAQ ",
"portIsInUseError": "The port {{portNumber}} is in use. To get around with the issue, configure a custom port by setting the system environment variable 'AZURE_IOT_EXPLORER_PORT' to an available port number. To learn more, please visit https://github.com/Azure/azure-iot-explorer/wiki/FAQ",
"modelRepoistorySettingsUpdated": "Model repository locations successfully updated.",
"startEventMonitoringOnError": "Faile to start monitoring device telemetry: {{error}}",
"stopEventMonitoringOnError": "Faile to stop monitoring device telemetry: {{error}}"
@ -835,8 +835,8 @@
"modelRepository" : {
"empty": {
"header": "No model repository locations to display",
"description": "Model repository locations specify where the application looks to find Plug and Play model definitions. Locations are saved to application storage and can be edited or removed at any time by returning",
"help": "What is Plug and Play Preview"
"description": "Model repository locations specify where the application looks to find IoT Plug and Play model definitions. Locations are saved to application storage and can be edited or removed at any time by returning",
"help": "What is IoT Plug and Play Preview"
},
"instruction": "We'll look for your model definition in the following order. Please drag and drop to change it. Click 'Add' to enable more ways we can resolve your model definitions.",
"commands": {

Просмотреть файл

@ -105,7 +105,7 @@ describe('server', () => {
it('generates data plane response with no httpResponse', () => {
const response = processDataPlaneResponse(null, null);
expect(response.body).toEqual(undefined);
expect(response.body).toEqual(`Cannot read property 'headers' of null`);
});
it('generates data plane response using device status code', () => {

Просмотреть файл

@ -47,9 +47,9 @@ export const processDataPlaneResponse = (httpRes: request.Response, body: any):
};
}
}
catch {
catch (error) {
return {
body: undefined,
body: error.message,
statusCode: SERVER_ERROR
};
}

Просмотреть файл

@ -56,7 +56,11 @@ export class ServerBase {
app.get(readFileUri, handleReadFileRequest);
app.get(getDirectoriesUri, handleGetDirectoriesRequest);
app.listen(this.port);
app.listen(this.port).on('error', () => { throw new Error(
`Failed to start the app on port ${this.port} as it is in use.
You can still view static pages, but requests cannot be made to the services if the port is still occupied.
To get around with the issue, configure a custom port by setting the system environment variable 'AZURE_IOT_EXPLORER_PORT' to an available port number.
To learn more, please visit https://github.com/Azure/azure-iot-explorer/wiki/FAQ`); });
}
}