Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set API port manually during installation #2363

Open
janmarius opened this issue Apr 19, 2024 · 1 comment
Open

Set API port manually during installation #2363

janmarius opened this issue Apr 19, 2024 · 1 comment
Labels
Desktop Requires specific updates to the Desktop app Enhancement Improvement of existing functionality Low Priority

Comments

@janmarius
Copy link
Contributor

janmarius commented Apr 19, 2024

Currently, the API port is set with a hard-coded value during the installation process. If you need to change the port, you will have to configure it in the config file located in AppData.

To improve the user experience, we want to enable users to set a port for the API during installation. This will allow users to manually set a different port if needed.

Good starting point:

@janmarius janmarius added the Enhancement Improvement of existing functionality label Apr 19, 2024
@eliasbruvik eliasbruvik self-assigned this May 3, 2024
@eliasbruvik
Copy link
Contributor

To add custom pages to the nsis installation, we need to provide a custom nsis script. I tried creating a script, but could not get it to work. I successfully added a page to the existing installer, but it failed when trying to use nsJSON to create the json file.

These are the main steps of my attempts:

Add this to the nsis part of electron-builder.json:
"include": "installerAppConfig.nsi",

Create file installerAppConfig.nsi:

!include "nsDialogs.nsh"
!include "MUI2.nsh"

Var Dialog
Var DbPathInput
Var ApiPortInput
Var LogsPathInput
Var JsonHandle

Page custom ConfigPageCreate ConfigPageLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

Function ConfigPageCreate
    nsDialogs::Create 1018
    Pop $Dialog

    ${NSD_CreateLabel} 0 10u 100% 12u "Database Path:"
    ${NSD_CreateText} 0 25u 100% 12u "" $DbPathInput

    ${NSD_CreateLabel} 0 50u 100% 12u "API Port:"
    ${NSD_CreateText} 0 65u 100% 12u "" $ApiPortInput

    ${NSD_CreateLabel} 0 90u 100% 12u "Logs Path:"
    ${NSD_CreateText} 0 105u 100% 12u "" $LogsPathInput

    nsDialogs::Show
FunctionEnd

Function ConfigPageLeave
    ${NSD_GetText} $DbPathInput $0
    ${NSD_GetText} $ApiPortInput $1
    ${NSD_GetText} $LogsPathInput $2

    ${nsJSON::Create} $JsonHandle
    ${nsJSON::Set} $JsonHandle "$.\"dbPath\"" $0
    ${nsJSON::Set} $JsonHandle "$.\"apiPort\"" $1
    ${nsJSON::Set} $JsonHandle "$.\"logsPath\"" $2

    ${nsJSON::Serialize} $JsonHandle $0
    ${If} $0 == error
        MessageBox MB_OK "Failed to serialize JSON!"
        Abort
    ${EndIf}

    FileOpen $1 "$INSTDIR\config.json" w
    FileWrite $1 $0
    FileClose $1

    ${nsJSON::Delete} $JsonHandle
FunctionEnd

Section
SectionEnd

Download the nsJSON plugin from https://nsis.sourceforge.io/NsJSON_plug-in, and copy the arch folders with .dll files to WitsmlExplorer.Desktop/resources

I also tried to place the .dll files along with the default plugins in electron-builder's nsis cache in appData. I also placed them in a different folder and referenced them with !addplugindir /x86-unicode ${PROJECT_DIR}\plugins\x86-unicode or !addplugindir ${PROJECT_DIR}\plugins in installerAppConfig.nsi.

No matter what I tried, I always got a "plugin not found" error.
image

The error occurs even though I can see that the correct folder is logged as a plugin directory.
image

@eliasbruvik eliasbruvik removed their assignment May 7, 2024
@eliasbruvik eliasbruvik added Desktop Requires specific updates to the Desktop app and removed High Priority labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Desktop Requires specific updates to the Desktop app Enhancement Improvement of existing functionality Low Priority
Projects
None yet
Development

No branches or pull requests

2 participants