fix certificate selection

This commit is contained in:
Thomas Nordquist
2022-02-27 13:33:22 +01:00
parent e4add31793
commit 13b8f8d5da
42 changed files with 23477 additions and 5471 deletions

View File

@@ -1,181 +1,197 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
<title>MQTT Explorer</title>
<script src="./bugtracking.bundle.js"></script>
<style>
body,
html {
margin: 0;
padding: 0;
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
<title>MQTT Explorer</title>
<script src="./bugtracking.bundle.js"></script>
<style>
body,
html {
margin: 0;
padding: 0;
}
[tabindex] {
outline: none;
}
@keyframes updateDark {
0% {
background-color: none;
}
[tabindex] {
outline: none;
25% {
background-color: #595585;
}
@keyframes updateDark {
0% {
background-color: none;
}
25% {
background-color: #595585;
}
50% {
background-color: #595585;
}
100% {
background-color: none;
}
50% {
background-color: #595585;
}
@keyframes updateLight {
0% {
background-color: none;
color: inherit;
}
25% {
background-color: #c0c8c0;
}
50% {
background-color: #c0c8c0;
}
100% {
background-color: none;
color: inherit;
}
100% {
background-color: none;
}
}
@keyframes updateLight {
0% {
background-color: none;
color: inherit;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
25% {
background-color: #c0c8c0;
}
::-webkit-scrollbar-corner {
background-color: rgba(0, 0, 0, 0);
50% {
background-color: #c0c8c0;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(60, 60, 60, 0.5);
background-color: rgba(140, 140, 140, 0.1);
100% {
background-color: none;
color: inherit;
}
}
::-webkit-scrollbar-thumb {
background-color: rgba(140, 140, 140, 0.8);
}
</style>
<style>
.Resizer {
background: rgba(200, 200, 200, 0);
z-index: 10;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.Resizer:hover {
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
::-webkit-scrollbar-corner {
background-color: rgba(0, 0, 0, 0);
}
.Resizer.horizontal {
height: 10px;
margin: -10px 0 0 0;
border-top: 5px solid rgba(255, 255, 255, 0);
border-bottom: 5px solid rgba(255, 255, 255, 0);
cursor: row-resize;
width: 100%;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(60, 60, 60, 0.5);
background-color: rgba(140, 140, 140, 0.1);
}
.Resizer.horizontal::before {
content: '•••';
display: inline-block;
vertical-align: middle;
text-align: center;
width: 100%;
margin-top: -22px;
color: #aaa;
opacity: 1;
}
::-webkit-scrollbar-thumb {
background-color: rgba(140, 140, 140, 0.8);
}
</style>
<style>
.Resizer {
background: rgba(200, 200, 200, 0);
z-index: 10;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
}
.Resizer.horizontal:hover {
border-top: 5px solid rgba(120, 120, 120, 0.3);
border-bottom: 5px solid rgba(120, 120, 120, 0.3);
}
.Resizer:hover {
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
.Resizer.vertical {
width: 2px;
margin: 0px -8px 0px 0px;
border-left: 0px solid rgba(128, 128, 128, 0);
border-right: 8px solid rgba(128, 128, 128, 0);
cursor: col-resize;
}
.Resizer.horizontal {
height: 10px;
margin: -10px 0 0 0;
border-top: 5px solid rgba(255, 255, 255, 0);
border-bottom: 5px solid rgba(255, 255, 255, 0);
cursor: row-resize;
width: 100%;
}
.Resizer.vertical::before {
content: '•••';
margin-left: -11px;
height: 3em;
margin-top: calc(50vh - 32px);
display: inline-block;
vertical-align: middle;
text-align: center;
color: #aaa;
opacity: 1;
writing-mode: vertical-lr;
text-orientation: sideways;
}
.Resizer.horizontal::before {
content: '•••';
display: inline-block;
vertical-align: middle;
text-align: center;
width: 100%;
margin-top: -22px;
color: #aaa;
opacity: 1;
}
.Resizer.vertical:hover {
border-left: 0px solid rgba(130, 130, 130, 0.3);
border-right: 8px solid rgba(140, 140, 140, 0.3);
}
.Resizer.horizontal:hover {
border-top: 5px solid rgba(120, 120, 120, 0.3);
border-bottom: 5px solid rgba(120, 120, 120, 0.3);
}
.Resizer.disabled {
cursor: not-allowed;
}
.Resizer.disabled:hover {
border-color: transparent;
}
.Resizer.vertical {
width: 2px;
margin: 0px -8px 0px 0px;
border-left: 0px solid rgba(128, 128, 128, 0);
border-right: 8px solid rgba(128, 128, 128, 0);
cursor: col-resize;
}
.example-enter {
opacity: 0;
}
.example-enter-active {
opacity: 1;
transition: opacity 300ms ease-in;
}
.example-exit {
opacity: 1;
}
.example-exit-active {
opacity: 0;
transition: opacity 300ms ease-in;
}
</style>
</head>
<body>
<div id="app" style="font: -webkit-control;"></div>
<script>
function loadScript(path) {
var script = document.createElement('script')
script.src = path
document.head.appendChild(script)
}
.Resizer.vertical::before {
content: '•••';
margin-left: -11px;
height: 3em;
margin-top: calc(50vh - 32px);
display: inline-block;
vertical-align: middle;
text-align: center;
color: #aaa;
opacity: 1;
writing-mode: vertical-lr;
text-orientation: sideways;
}
document.addEventListener('DOMContentLoaded', onLoad(), false)
function onLoad() {
// <% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>loadScript("<%- file %>");<% }); %>
// loadScript("<%= JSON.stringify(htmlWebpackPlugin) %>")
}
</script>
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>
.Resizer.vertical:hover {
border-left: 0px solid rgba(130, 130, 130, 0.3);
border-right: 8px solid rgba(140, 140, 140, 0.3);
}
.Resizer.disabled {
cursor: not-allowed;
}
.Resizer.disabled:hover {
border-color: transparent;
}
.example-enter {
opacity: 0;
}
.example-enter-active {
opacity: 1;
transition: opacity 300ms ease-in;
}
.example-exit {
opacity: 1;
}
.example-exit-active {
opacity: 0;
transition: opacity 300ms ease-in;
}
</style>
<script>
global = globalThis //<- this should be enough
</script>
</head>
<body>
<div id="app" style="font: -webkit-control;"></div>
<script>
function loadScript(path) {
var script = document.createElement('script')
script.src = path
document.head.appendChild(script)
}
document.addEventListener('DOMContentLoaded', onLoad(), false)
function onLoad() {
// <% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>loadScript("<%- file %>");<% }); %>
// loadScript("<%= JSON.stringify(htmlWebpackPlugin) %>")
}
</script>
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>
<script src="<%- file %>"></script>
<% }); %>
</body>
</html>
</body>
</html>

View File

@@ -13,20 +13,19 @@
"author": "",
"license": "CC-BY-ND-4.0",
"dependencies": {
"@material-ui/core": "^4",
"@material-ui/core": "4.12",
"@material-ui/icons": "^4",
"@material-ui/lab": "^4.0.0-alpha",
"@material-ui/styles": "^4",
"@material-ui/styles": "4.11",
"@types/react-transition-group": "^4",
"ace-builds": "^1.4.11",
"axios": "^0.19.0",
"axios": "^0.26.0",
"compare-versions": "^3.5.0",
"copy-text-to-clipboard": "^2.1.0",
"d3": "^5.9.7",
"d3-shape": "^1.3.5",
"diff": "^4.0.1",
"dot-prop": "^5.0.0",
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist",
"file-loader": "6",
"get-value": "^3.0.1",
"immutable": "^4.0.0-rc.12",
@@ -35,7 +34,6 @@
"json-to-ast": "^2.1.0",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"moment": "^2.24.0",
"moving-average": "^1.0.0",
"number-abbreviate": "^2.0.0",
"parse-duration": "^0.1.1",
@@ -56,6 +54,7 @@
"uuid": "7"
},
"devDependencies": {
"@babel/runtime": "^7.17.2",
"@types/d3": "^5.7.2",
"@types/diff": "^4.0.1",
"@types/get-value": "^3.0.1",
@@ -69,24 +68,25 @@
"@types/socket.io-client": "^1.4.32",
"@types/uuid": "^7.0.2",
"@types/vis": "^4.21.9",
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"css-loader": "^3.0.0",
"hard-source-webpack-plugin": "^0.13.1",
"heapdump": "^0.3.12",
"html-webpack-plugin": "^4.0.0-beta.5",
"mocha": "^7.1.1",
"html-webpack-plugin": "^5.5.0",
"lodash": "^4.17.21",
"mocha": "^9.2.1",
"moment": "^2.29.1",
"node-loader": "^0.6.0",
"source-map-loader": "^0.2.4",
"style-loader": "^1",
"typescript": "^3.6.3",
"webpack": "^4.28.2",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.1.14"
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
"webpack": "^5.69.1",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
},
"peerDependencies": {
"electron": "^5.0.5"
"electron": "^17"
}
}

View File

@@ -9,12 +9,14 @@ import {
import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage'
import { Dispatch } from 'redux'
import { showError } from './Global'
import { remote } from 'electron'
import * as electron from 'electron'
import { promises as fsPromise } from 'fs'
import * as path from 'path'
import { ActionTypes, Action } from '../reducers/ConnectionManager'
import { Subscription } from '../../../backend/src/DataSource/MqttSource'
import { connectionsMigrator } from './migrations/Connection'
import { EventDispatcher, openDialogResponse, OpenDialogResponse, rendererEvents, requestOpenDialog } from '../../../events'
import { v4 } from 'uuid'
export interface ConnectionDictionary {
[s: string]: ConnectionOptions
@@ -72,11 +74,29 @@ async function openCertificate(): Promise<CertificateParameters> {
certificateSizeDoesNotMatch: 'Certificate size larger/smaller then expected.',
}
const openDialogReturnValue = await remote.dialog.showOpenDialog(remote.getCurrentWindow(), {
properties: ['openFile'],
securityScopedBookmarks: true,
let requestId = v4();
const response = new Promise<OpenDialogResponse>((resolve, reject) => {
let callback = (result: OpenDialogResponse) => {
rendererEvents.unsubscribe(openDialogResponse(), callback)
if (result.identifier == requestId) {
resolve(result)
} else {
reject(new Error("Unexpected file select"))
}
}
rendererEvents.subscribe(openDialogResponse(), callback)
})
rendererEvents.emit(requestOpenDialog(), {
identifier: requestId,
options: {
properties: ['openFile'],
securityScopedBookmarks: true,
}
})
const openDialogReturnValue = (await response).result;
const selectedFile = openDialogReturnValue.filePaths && openDialogReturnValue.filePaths[0]
if (!selectedFile) {
throw rejectReasons.noCertificateSelected

View File

@@ -1,7 +1,7 @@
import { ActionTypes, ConfirmationRequest } from '../reducers/Global'
import { Dispatch } from 'redux'
export const showError = (error?: string) => ({
export const showError = (error?: string | unknown) => ({
error,
type: ActionTypes.showError,
})

View File

@@ -13,6 +13,8 @@ import { connect } from 'react-redux'
import { globalActions, settingsActions } from '../actions'
import { Theme, withStyles } from '@material-ui/core/styles'
(window as any).global = window
const Settings = React.lazy(() => import('./SettingsDrawer/Settings'))
const ContentView = React.lazy(() => import('./Layout/ContentView'))
@@ -66,6 +68,8 @@ class App extends React.PureComponent<Props, {}> {
return null
}
const anyProps: any = {};
return (
<div className={centerContent}>
<CssBaseline />
@@ -73,7 +77,7 @@ class App extends React.PureComponent<Props, {}> {
<ConfirmationDialog confirmationRequests={this.props.confirmationRequests} />
{this.renderNotification()}
<React.Suspense fallback={<div></div>}>
<Settings />
<Settings {...anyProps} />
</React.Suspense>
<div className={centerContent}>
<div className={`${settingsVisible ? contentShift : content}`}>

View File

@@ -1,6 +1,6 @@
import * as React from 'react'
import { Theme, withStyles } from '@material-ui/core'
import cursor from './cursor.png'
const cursor = require('./cursor.png')
interface State {
enabled: boolean
@@ -43,15 +43,15 @@ class Demo extends React.Component<{ classes: any }, State> {
}
public componentDidMount() {
;(window as any).demo.enableMouse = () => {
; (window as any).demo.enableMouse = () => {
this.setState({ enabled: true })
}
;(window as any).demo.moveMouse = (x: number, y: number, animationTime: number) => {
const stepSizeX = Math.abs(this.state.position.x - x) / (animationTime / this.frameInterval)
const stepSizeY = Math.abs(this.state.position.y - y) / (animationTime / this.frameInterval)
this.setState({ stepSizeX, stepSizeY, enabled: true, target: { x, y } })
this.moveCloser()
}
; (window as any).demo.moveMouse = (x: number, y: number, animationTime: number) => {
const stepSizeX = Math.abs(this.state.position.x - x) / (animationTime / this.frameInterval)
const stepSizeY = Math.abs(this.state.position.y - y) / (animationTime / this.frameInterval)
this.setState({ stepSizeX, stepSizeY, enabled: true, target: { x, y } })
this.moveCloser()
}
}
public render() {

View File

@@ -5,14 +5,14 @@ let heapdump: any
function writeHeapdump(path?: string) {
if (!heapdump) {
heapdump = require('heapdump')
//heapdump = require('heapdump')
}
heapdump.writeSnapshot(path || `${Date.now()}.heapsnapshot`)
return path
}
;(window as any).demo = {
; (window as any).demo = {
writeHeapdump,
}

View File

@@ -2,7 +2,6 @@ import * as React from 'react'
import PersistentStorage from '../utils/PersistentStorage'
import SentimentDissatisfied from '@material-ui/icons/SentimentDissatisfied'
import Warning from '@material-ui/icons/Warning'
import { electronRendererTelemetry } from 'electron-telemetry'
import { Theme, withStyles } from '@material-ui/core/styles'
import { Button, Modal, Paper, Toolbar, Typography } from '@material-ui/core'
@@ -33,7 +32,7 @@ class ErrorBoundary extends React.PureComponent<Props, State> {
}
public componentDidCatch(error: Error, errorInfo: any) {
electronRendererTelemetry.trackError(error)
// electronRendererTelemetry.trackError(error)
console.log('did catch', error)
}

View File

@@ -3,10 +3,10 @@ import DateFormatter from '../helper/DateFormatter'
import { AppState } from '../../reducers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Input, InputLabel, MenuItem, Select, StyleRulesCallback, Theme } from '@material-ui/core'
import { Input, InputLabel, MenuItem, Select, Theme } from '@material-ui/core'
import { settingsActions } from '../../actions'
import { withStyles } from '@material-ui/styles'
const moment = require('moment/min/moment-with-locales')
const moment = require('moment')
interface Props {
actions: {

View File

@@ -122,7 +122,7 @@ const EditorMode = memo(function EditorMode(props: {
const str = JSON.stringify(JSON.parse(props.payload), undefined, ' ')
updatePayload(str)
} catch (error) {
props.globalActions.showError(`Format error: ${error.message}`)
props.globalActions.showError(`Format error: ${(error as Error)?.message}`)
}
}
}, [props.payload])

View File

@@ -50,7 +50,7 @@ class UpdateNotifier extends React.PureComponent<Props, State> {
super(props)
this.state = { newerVersions: [] }
const ownVersion = electron.remote.app.getVersion()
const ownVersion = electron.app.getVersion()
this.fetchReleases().then(releases => {
const newerVersions = releases
.filter(release => this.allowPrereleaseIfOwnVersionIsBeta(release, ownVersion))

View File

@@ -1,4 +1,4 @@
import { electronRendererTelemetry } from 'electron-telemetry'
// import { electronRendererTelemetry } from 'electron-telemetry'
const telemetry = electronRendererTelemetry
electronRendererTelemetry.registerErrorHandler()
// const telemetry = electronRendererTelemetry
// electronRendererTelemetry.registerErrorHandler()

View File

@@ -1,4 +1,4 @@
import { electronRendererTelemetry } from 'electron-telemetry'
// import { electronRendererTelemetry } from 'electron-telemetry'
// Used to determine long-time-stability and memory leaks
function trackProcessStatistics() {
@@ -30,6 +30,6 @@ export function trackEvent(name: string) {
}
const blacklist = ['CONNECTION_SET_HEALTH']
if (blacklist.indexOf(name) === -1) {
electronRendererTelemetry.trackEvent(name)
// electronRendererTelemetry.trackEvent(name)
}
}

View File

@@ -4,21 +4,32 @@
"noImplicitAny": true,
"strictNullChecks": true,
"strict": true,
"lib": ["es2017", "dom"],
"lib": [
"es2017",
"dom"
],
"moduleResolution": "node",
"outDir": "./build/",
"sourceMap": true,
"module": "esnext",
"target": "es2017",
"jsx": "react",
"types": ["react"],
"allowSyntheticDefaultImports": true
"types": [
"react"
],
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["./src/**/*"],
"exclude": ["**/*.d.ts", ".src/**/*.png"],
"include": [
"./src/**/*"
],
"exclude": [
"**/*.d.ts",
".src/**/*.png"
],
"awesomeTypescriptLoaderOptions": {
"useCache": true,
"transpileModule": true,
"errorsAsWarnings": true
}
}
}