Skip to content

Commit 0f7abb5

Browse files
committed
Version 2.2
1 parent 75e942b commit 0f7abb5

File tree

448 files changed

+44736
-13564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

448 files changed

+44736
-13564
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ frontend/.DS_Store
3434
frontend/**/.idea
3535
frontend/libs
3636
frontend/src/css/images
37-
frontend/package-lock.json
3837
frontend/oraclejetconfig.json
3938
.vscode/*
4039
client.log.*
@@ -48,7 +47,6 @@ frontend/seleniumTest.log
4847
electron/dist/**
4948
electron/extraFiles/**
5049
electron/node_modules/**
51-
electron/package-lock.json
5250

5351
hugo/*/docs/
5452
hugo/*/.vscode/

THIRD_PARTY_LICENSES.txt

Lines changed: 1435 additions & 3086 deletions
Large diffs are not rendered by default.

assembly/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<artifactId>console-backend</artifactId>
1111
<groupId>com.oracle.weblogic</groupId>
12-
<version>2.1.0</version>
12+
<version>2.2.0</version>
1313
</parent>
1414

1515
<packaging>pom</packaging>

build-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.oracle.weblogic.console-backend</groupId>
88
<artifactId>build-tools</artifactId>
9-
<version>2.1.0</version>
9+
<version>2.2.0</version>
1010
<name>Build Tools</name>
1111

1212
<properties>

electron/main.js

Lines changed: 142 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
let keytar;
1+
/**
2+
* @license
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
4+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
* @ignore
6+
*/
7+
let keytar;
28

39
const { BrowserWindow, app, Menu, shell, ipcMain, dialog } = require("electron")
10+
const net = require('net');
411
const { autoUpdater } = require('electron-updater');
512
autoUpdater.autoDownload = false;
613
const prompt = require('electron-prompt');
@@ -11,14 +18,20 @@ const canCheckForUpdates = !instDir.startsWith('/opt/');
1118
const { homepage, productName, version, copyright } = require(`${instDir}/package.json`);
1219

1320
const fs = require('fs');
21+
var checkPid = 0;
1422
var newVersion = version;
23+
var cbePort = 0;
1524
var window;
1625
var projects;
1726
var current_project;
1827
var width = 1600;
1928
var height = 1000;
2029
var started = false;
30+
var stdinOption = false;
31+
var showPort = false;
32+
var quiet = false;
2133
var lines = [ ];
34+
var origConsoleLog;
2235

2336
if (process.platform === 'darwin') {
2437
quitkey = 'Command+Q';
@@ -148,6 +161,13 @@ function getFilteredProviders(providers) {
148161
if (providers[i].file) {
149162
filteredProvider.file = providers[i].file;
150163
}
164+
165+
// Filter out properties associated with modelComposite
166+
// provider type.
167+
if (providers[i].models) {
168+
filteredProvider.models = providers[i].models;
169+
}
170+
151171
filteredProviders.push(filteredProvider);
152172
}
153173
return filteredProviders;
@@ -509,7 +529,7 @@ function makeMenu() {
509529
}
510530

511531

512-
if (canCheckForUpdates) {
532+
if (canCheckForUpdates && !app.commandLine.hasSwitch("headless")) {
513533
autoUpdater.checkForUpdates().then(result => {
514534
newVersion = result.versionInfo.version;
515535
if (app.isReady())
@@ -524,9 +544,10 @@ var readline = require('readline');
524544
function writeAutoPrefs() {
525545
const prefs = {
526546
version: `${version}`,
527-
width: window.getSize()[0],
528-
height: window.getSize()[1],
529-
projects: getMaskedProjects(["password"])
547+
width: width,
548+
height: height,
549+
projects: getMaskedProjects(["password"]),
550+
location: process.env.APPIMAGE ? process.env.APPIMAGE : app.getPath('exe')
530551
};
531552
fs.writeFileSync(`${app.getPath('userData')}/auto-prefs.json`, JSON.stringify(prefs, null, 4));
532553
}
@@ -551,16 +572,45 @@ function readAutoPrefs() {
551572
projects = [ ];
552573
}
553574

575+
function doCheckPid() {
576+
try {
577+
process.kill(checkPid, 0);
578+
} catch(err) {
579+
process.exit();
580+
}
581+
}
582+
554583
function doit() {
555-
var port = 8012;
584+
if (!app.commandLine.hasSwitch("headless"))
585+
window.loadURL(`http://localhost:${cbePort}/`);
586+
}
587+
588+
function processOptions() {
556589
let filename = `${app.getPath('userData')}/config.json`;
557590
if (fs.existsSync(filename)) {
558591
props = JSON.parse(fs.readFileSync(filename));
559592
if (props["server.port"])
560-
port = props["server.port"];
593+
cbePort = props["server.port"];
561594
}
562-
if (!app.commandLine.hasSwitch("headless"))
563-
window.loadURL(`http://localhost:${port}/`);
595+
checkPid = app.commandLine.getSwitchValue("check-pid");
596+
if (checkPid != 0) {
597+
setInterval(doCheckPid, 5000);
598+
}
599+
portOption = app.commandLine.getSwitchValue("port");
600+
if (portOption) {
601+
cbePort = portOption;
602+
}
603+
stdinOption = app.commandLine.hasSwitch("stdin");
604+
if (stdinOption) {
605+
let readlineStdin = readline.createInterface({
606+
input: process.stdin,
607+
});
608+
readlineStdin.on("close", () => {
609+
process.exit();
610+
});
611+
}
612+
showPort = app.commandLine.hasSwitch("showPort");
613+
quiet = app.commandLine.hasSwitch("quiet");
564614
}
565615

566616
function rotateLogfile() {
@@ -575,42 +625,62 @@ function rotateLogfile() {
575625
return file;
576626
}
577627

578-
const logFilename = rotateLogfile();
579628
const os = require("os");
580629

630+
const logFilename = rotateLogfile();
631+
632+
(function () {
633+
origConsoleLog = console.log;
634+
var _error = console.error;
635+
var _warning = console.warning;
636+
637+
console.error = function (line) {
638+
fs.appendFileSync(logFilename, line + os.EOL);
639+
_error.apply(console, arguments);
640+
};
641+
642+
console.log = function (line) {
643+
fs.appendFileSync(logFilename, line + os.EOL);
644+
if (!quiet)
645+
origConsoleLog.apply(console, arguments);
646+
};
647+
648+
console.warning = function (warnMessage) {
649+
fs.appendFileSync(logFilename, line + os.EOL);
650+
if (!quiet)
651+
_warning.apply(console, arguments);
652+
};
653+
})();
654+
581655
function start_cbe() {
582-
583656
const { spawn } = require("child_process");
584657

585658
var instDir = path.dirname(app.getPath("exe"));
586659
let filename = `${app.getPath("userData")}/config.json`;
587660
const cbe = spawn(instDir + "/customjre/bin/java", [
661+
`-Dserver.port=${cbePort}`,
588662
"-jar",
589663
`${instDir}/backend/console.jar`,
664+
"--showPort",
590665
"--stdin",
591666
"--properties",
592667
filename,
593668
]);
594669

595-
let rl = readline.createInterface({
670+
let readlineStderr = readline.createInterface({
596671
input: cbe.stderr,
597672
});
598673

599-
let rl2 = readline.createInterface({
674+
let readlineStdout = readline.createInterface({
600675
input: cbe.stdout,
601676
});
602677

603-
rl.on("line", (line) => {
678+
readlineStderr.on("line", (line) => {
604679
console.log(line);
605-
fs.appendFileSync(logFilename, line + os.EOL);
606680
lines.push(line);
607-
if (line.includes("Started in")) {
608-
started = true;
609-
doit();
610-
}
611681
});
612682

613-
rl.on("close", () => {
683+
readlineStderr.on("close", () => {
614684
if (!started) {
615685
let i = lines.length - 40;
616686
if (i < 0) i = 0;
@@ -626,17 +696,23 @@ function start_cbe() {
626696
process.exit();
627697
});
628698

629-
rl2.on("line", (line) => {
699+
readlineStdout.on("line", (line) => {
630700
console.log(line);
631-
fs.appendFileSync(logFilename, line + os.EOL);
701+
if (line.startsWith("Port=")) {
702+
if (showPort)
703+
origConsoleLog(line);
704+
cbePort = line.replace("Port=", "");
705+
started = true;
706+
doit();
707+
}
632708
});
633709
}
634710

635711
function readWDTModelFile(filepath) {
636712
return {
637713
file: filepath,
638714
fileContents: fs.readFileSync(filepath, 'utf8'),
639-
mediaType: (filepath.endsWith(".json") ? "application/json" : "application/yaml")
715+
mediaType: (filepath.endsWith(".json") ? "application/json" : (filepath.endsWith(".props") ? "text/plain" : "application/yaml"))
640716
};
641717
}
642718

@@ -732,14 +808,14 @@ ipcMain.handle('file-creating', async (event, arg) => {
732808
}
733809
});
734810

735-
ipcMain.handle('file-reading', async (event, filepath) => {
736-
return createFileReadingResponse(filepath)
811+
ipcMain.handle('file-reading', async (event, arg) => {
812+
return createFileReadingResponse(arg.filepath)
737813
.catch(response => {
738-
if (response.failureType === "NOT_FOUND") {
814+
if (arg.allowDialog && (response.failureType === "NOT_FOUND")) {
739815
const dialogParams = {
740-
defaultPath: filepath,
816+
defaultPath: arg.filepath,
741817
properties: ['openFile'],
742-
filters: { name: 'Supported Formats', extensions: ['yml', 'yaml', 'json']}
818+
filters: { name: 'Supported Formats', extensions: ['yml', 'yaml', 'json', 'props']}
743819
};
744820
return dialog.showOpenDialog(window, dialogParams)
745821
.then(dialogReturnValue => {
@@ -755,7 +831,7 @@ ipcMain.handle('file-reading', async (event, filepath) => {
755831
})
756832
}
757833
else {
758-
return Promise.reject(response);
834+
return Promise.reject(response.failureReason);
759835
}
760836
});
761837
});
@@ -917,8 +993,25 @@ ipcMain.handle('credentials-requesting', async (event, arg) => {
917993

918994
});
919995

996+
ipcMain.handle('window-app-quit', async (event, arg) => {
997+
((line) => {
998+
console.log(line);
999+
})(`[MAIN] 'window-app-quit' reply=${JSON.stringify(arg)}`);
1000+
if (!arg.preventQuit) {
1001+
// Set module-scoped window variable to null, so
1002+
// the check in the 'close' event handler, won't
1003+
// do an event.preventDefault().
1004+
window = null;
1005+
// Calling app.quit() will generate another 'close'
1006+
// event, but the app will exit because the module-scoped
1007+
// window variable has been set to null.
1008+
app.quit();
1009+
}
1010+
});
1011+
9201012
app.whenReady()
9211013
.then(() => {
1014+
processOptions();
9221015
if (!app.commandLine.hasSwitch("headless")) {
9231016
/**
9241017
* Creates a new instance of the ``BrowserWindow`` class, using the specified parameter values.
@@ -958,12 +1051,28 @@ app.whenReady()
9581051
});
9591052
}
9601053

1054+
function setOnWindowCloseListener() {
1055+
window.on('close', (event) => {
1056+
if (window) {
1057+
// Cancel the close, because we want to
1058+
// allow the JET side to do stuff (like
1059+
// attempt to save a "dirty" form) before
1060+
// closing.
1061+
event.preventDefault();
1062+
// 1. Send notification to JET side saying
1063+
// that the app is closing.
1064+
window.webContents.send('start-app-quit');
1065+
// 2. Write out the auto-prefs.json file.
1066+
writeAutoPrefs();
1067+
}
1068+
});
1069+
}
1070+
9611071
try {
9621072
readAutoPrefs();
9631073
} catch (error) {
9641074
((line) => {
9651075
console.log(line);
966-
fs.appendFileSync(logFilename, line + os.EOL);
9671076
})(error);
9681077
dialog.showMessageBoxSync(window, {
9691078
title: "Failure reading auto prefs",
@@ -978,17 +1087,19 @@ app.whenReady()
9781087
window = createBrowserWindow("Initializing...", width, height);
9791088
window.webContents.session.clearCache();
9801089
window.on('resize', () => {
1090+
width = window.getSize()[0];
1091+
height = window.getSize()[1];
9811092
writeAutoPrefs();
9821093
});
9831094
setAboutPanelFields();
9841095
makeMenu();
1096+
setOnWindowCloseListener();
9851097
}
9861098
start_cbe();
9871099
})
9881100
.catch(err => {
9891101
((line) => {
9901102
console.log(line);
991-
fs.appendFileSync(logFilename, line + os.EOL);
9921103
})(`[MAIN] err=${err}`);
9931104

9941105
dialog.showMessageBoxSync(window, {

0 commit comments

Comments
 (0)