Add default connection profiles
This commit is contained in:
@@ -13,6 +13,12 @@ const storedConnectionsIdentifier: StorageIdentifier<{[s: string]: ConnectionOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const loadConnectionSettings = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
export const loadConnectionSettings = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||||
|
const requiresMigration = true
|
||||||
|
if (requiresMigration) {
|
||||||
|
const connections = defaultConnections()
|
||||||
|
persistantStorage.store(storedConnectionsIdentifier, connections)
|
||||||
|
}
|
||||||
|
|
||||||
const connections = persistantStorage.load(storedConnectionsIdentifier)
|
const connections = persistantStorage.load(storedConnectionsIdentifier)
|
||||||
if (!connections) {
|
if (!connections) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -55,28 +55,28 @@ export function createEmptyConnection(): ConnectionOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function defaultConnections() {
|
export function defaultConnections() {
|
||||||
return [
|
return {
|
||||||
{
|
'iot.eclipse.org': {
|
||||||
...createEmptyConnection(),
|
...createEmptyConnection(),
|
||||||
id: 'iot.eclipse.org',
|
id: 'iot.eclipse.org',
|
||||||
name: 'iot.eclipse.org',
|
name: 'iot.eclipse.org',
|
||||||
host: 'iot.eclipse.org',
|
host: 'iot.eclipse.org',
|
||||||
},
|
},
|
||||||
{
|
'test.mosquitto.org': {
|
||||||
...createEmptyConnection(),
|
...createEmptyConnection(),
|
||||||
id: 'test.mosquitto.org',
|
id: 'test.mosquitto.org',
|
||||||
name: 'test.mosquitto.org',
|
name: 'test.mosquitto.org',
|
||||||
host: 'test.mosquitto.org',
|
host: 'test.mosquitto.org',
|
||||||
},
|
},
|
||||||
{
|
'broker.hivemq.com:8000': {
|
||||||
...createEmptyConnection(),
|
...createEmptyConnection(),
|
||||||
id: 'wss://broker.hivemq.com:8000/mqtt',
|
id: 'broker.hivemq.com:8000',
|
||||||
name: 'broker.hivemq.com',
|
name: 'broker.hivemq.com',
|
||||||
host: 'broker.hivemq.com',
|
host: 'broker.hivemq.com',
|
||||||
basePath: 'mqtt',
|
basePath: 'ws',
|
||||||
encryption: true,
|
encryption: true,
|
||||||
protocol: 'ws',
|
protocol: 'ws',
|
||||||
port: 8000,
|
port: 8000,
|
||||||
},
|
},
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user