diff --git a/.gitignore b/.gitignore index bdbfda835..09710ff35 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ derby.log !releng/buildpacks/**/bin/ # Ignore Neo SDK -resources/resources-neo-sdk/src/main/resources/META-INF/dirigible/resources-neo-sdk/ \ No newline at end of file +resources/resources-neo-sdk/src/main/resources/META-INF/dirigible/resources-neo-sdk/* +!resources/resources-neo-sdk/src/main/resources/META-INF/dirigible/resources-neo-sdk/differ.sh diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/changes.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/changes.js new file mode 100644 index 000000000..07e9325f0 --- /dev/null +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/changes.js @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2022 SAP SE or an SAP affiliate company and XSK contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, v2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and XSK contributors + * SPDX-License-Identifier: Apache-2.0 + */ +require.config({ paths: { vs: "/services/v4/web/ide-monaco/monaco-editor/min/vs" } }); +let editors = []; +migrationLaunchView.controller("ChangesViewController", [ + "$scope", + "$http", + "$messageHub", + "$timeout", + "migrationDataState", + function ($scope, $http, $messageHub, $timeout, migrationDataState) { + $scope.migrationDataState = migrationDataState; + $scope.isVisible = false; + $scope.dataLoaded = false; + let viewWidth = document.querySelectorAll(".changes-body")[0].clientWidth | 100; + $scope.isDiffViewSplit = viewWidth > 1100 ? true : false; + $scope.data = []; + + function startMigration() { + body = { + neo: { + hostName: migrationDataState.neoHostName, + subaccount: migrationDataState.neoSubaccount, + }, + hana: { + databaseSchema: migrationDataState.schemaName, + username: migrationDataState.dbUsername, + password: migrationDataState.dbPassword, + }, + connectionId: migrationDataState.connectionId, + workspace: migrationDataState.selectedWorkspace, + du: migrationDataState.selectedDeliveryUnits, + processInstanceId: migrationDataState.processInstanceId, + }; + + $http + .post("/services/v4/js/ide-migration/server/migration/api/migration-rest-api.mjs/continue-process", JSON.stringify(body), { + headers: { "Content-Type": "application/json" }, + }) + .then((response) => { + const timer = setInterval(function () { + $http + .post( + "/services/v4/js/ide-migration/server/migration/api/migration-rest-api.mjs/get-process", + JSON.stringify(body), + { + headers: { "Content-Type": "application/json" }, + } + ) + .then( + function (response) { + clearInterval(timer); + let diffViewData = response.data.diffViewData; + // Add additional keys needed by AngularJS + for (let i = 0; i < diffViewData.length; i++) { + diffViewData[i]["id"] = `m-${i}`; + diffViewData[i]["collapsed"] = false; + diffViewData[i]["excluded"] = false; + } + // Set data variable + $scope.data = diffViewData; + // Set full width for better experience + $scope.$parent.setFullWidthEnabled(true); + // Show data + $scope.dataLoaded = true; + $scope.$apply(); + }, + function (response) { + clearInterval(timer); + if (response.data) { + if ("error" in response.data) { + if ("message" in response.data.error) { + $messageHub.announceAlertError(defaultErrorTitle, response.data.error.message); + } else { + $messageHub.announceAlertError(defaultErrorTitle, defaultErrorDesc); + } + console.error(`HTTP $response.status`, response.data.error); + } else { + $messageHub.announceAlertError(defaultErrorTitle, defaultErrorDesc); + } + } else { + $messageHub.announceAlertError(defaultErrorTitle, defaultErrorDesc); + } + errorOccurred(); + } + ); + }, 1000); + }); + } + + $scope.createDiffEditor = function (index) { + $timeout(function () { + createDiffView( + $scope.data[index].id, + $scope.data[index].type, + $scope.data[index].original, + $scope.data[index].modified, + $scope.isDiffViewSplit + ); + }); + }; + + $scope.startMigration = function () { + // TODO + for (let i = 0; i < $scope.data.length; i++) { + if (!$scope.data[i].excluded) { + console.log("Migrating file:", $scope.data[i].file); + } + } + $scope.$parent.migrateClicked(); + }; + + $scope.splitDiffView = function () { + $scope.isDiffViewSplit = true; + for (let i = 0; i < editors.length; i++) { + editors[i].updateOptions({ renderSideBySide: true }); + } + }; + + $scope.inlineDiffView = function () { + $scope.isDiffViewSplit = false; + for (let i = 0; i < editors.length; i++) { + editors[i].updateOptions({ renderSideBySide: false }); + } + }; + + $scope.previousClicked = function () { + $scope.$parent.previousClicked(); + }; + + $messageHub.on( + "migration.changes", + function (msg) { + if ("isVisible" in msg.data) { + $scope.$apply(function () { + $scope.dataLoaded = false; + $scope.isVisible = msg.data.isVisible; + if (msg.data.isVisible) { + $scope.$parent.setBottomNavEnabled(false); + } else { + $scope.data = []; + editors = []; + } + }); + if (msg.data.isVisible) { + startMigration(); + } + } + }.bind(this) + ); + }, +]); + +function createDiffView(containerId, filetype, originalTxt, modifiedTxt, renderSideBySide = true) { + require(["vs/editor/editor.main"], function () { + let container = document.getElementById(containerId); + let containerLoading = document.querySelector(`#${containerId} > p:first-of-type`); + monaco.editor.setTheme(monacoTheme); + let diffEditor = monaco.editor.createDiffEditor(container, { + automaticLayout: true, + readOnly: true, + scrollBeyondLastLine: false, + enableSplitViewResizing: false, + renderSideBySide: renderSideBySide, + }); + + const updateHeight = () => { + const topBorder = parseInt(getComputedStyle(container).getPropertyValue("border-top-width"), 10); + const bottomBorder = parseInt(getComputedStyle(container).getPropertyValue("border-bottom-width"), 10); + const contentHeight = diffEditor.getModifiedEditor().getContentHeight() + topBorder + bottomBorder; + container.style.height = `${contentHeight}px`; + }; + + diffEditor.getModifiedEditor().onDidContentSizeChange(updateHeight); + diffEditor.setModel({ + original: monaco.editor.createModel(originalTxt, filetype), + modified: monaco.editor.createModel(modifiedTxt, filetype), + }); + + editors.push(diffEditor); + containerLoading.remove(); + }); +} diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/delivery-unit.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/delivery-unit.js index 79c0014ef..f98a6932e 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/delivery-unit.js +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/delivery-unit.js @@ -186,7 +186,7 @@ migrationLaunchView.controller("DeliveryUnitViewController", [ $scope.duDropdownText = $scope.duSelectedUItext.length ? $scope.duSelectedUItext.join(", ") : $scope.duDropdownInitText; $scope.selectAllText = migrationDataState.selectedDeliveryUnits.length == $scope.deliveryUnitList.length ? "Unselect all" : "Select all"; - $scope.$parent.setFinishEnabled(true); + $scope.$parent.setNextEnabled(true); }; $messageHub.on( @@ -201,16 +201,12 @@ migrationLaunchView.controller("DeliveryUnitViewController", [ $scope.descriptionText = descriptionList[0]; $scope.isVisible = msg.data.isVisible; if (msg.data.isVisible) { - if (migrationDataState.selectedDeliveryUnits) { - $scope.$parent.setFinishEnabled(true); - } else { - $scope.$parent.setFinishEnabled(false); - } + $scope.$parent.setFullWidthEnabled(false); $scope.$parent.setBottomNavEnabled(false); $scope.$parent.setPreviousVisible(true); $scope.$parent.setPreviousEnabled(true); - $scope.$parent.setNextVisible(false); - $scope.$parent.setFinishVisible(true); + $scope.$parent.setNextEnabled(false); + $scope.$parent.setNextVisible(true); } }); if (msg.data.isVisible) { diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/hana-credentials.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/hana-credentials.js index 1e8c7f65a..5b8373fbb 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/hana-credentials.js +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/hana-credentials.js @@ -111,6 +111,7 @@ migrationLaunchView.controller("HanaCredentialsViewController", [ $scope.databaseSelected = function (database) { migrationDataState.schemaName = database; $scope.databasesDropdownText = database; + $scope.userInput(); }; $messageHub.on( diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/migration-launch.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/migration-launch.js index 8067e9129..195f22bcb 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/migration-launch.js +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/migration-launch.js @@ -9,7 +9,7 @@ * SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and XSK contributors * SPDX-License-Identifier: Apache-2.0 */ -var migrationLaunchView = angular.module("migration-launch", ['angularFileUpload']); +var migrationLaunchView = angular.module("migration-launch", ["angularFileUpload"]); migrationLaunchView.factory("$messageHub", [ function () { @@ -83,12 +83,15 @@ migrationLaunchView.controller("MigrationLaunchViewController", [ topicId: "migration.hana-credentials", }, { id: 3, name: "Delivery Units", topicId: "migration.delivery-unit" }, - { id: 4, name: "Migration", topicId: "migration.start-migration" }, + { id: 4, name: "Changes", topicId: "migration.changes" }, + { id: 5, name: "Migration", topicId: "migration.start-migration" }, ]; $scope.zipsteps = [ { id: 1, name: "Upload ZIP file", topicId: "migration.upload-zip-migration" }, { id: 2, name: "Migration", topicId: "migration.start-zip-migration" }, ]; + + $scope.fullWidthEnabled = false; $scope.onStatisticsPage = true; $scope.migrationFromZip = false; $scope.bottomNavHidden = false; @@ -112,7 +115,7 @@ migrationLaunchView.controller("MigrationLaunchViewController", [ $scope.setFinishVisible(true); $scope.setBottomNavEnabled(false); $scope.currentStep = $scope.zipsteps[0]; - } + }; $scope.setFinishVisible = function (visible) { $scope.finishVisible = visible; @@ -122,6 +125,10 @@ migrationLaunchView.controller("MigrationLaunchViewController", [ $scope.finishDisabled = !enabled; }; + $scope.setFullWidthEnabled = function (enabled) { + $scope.fullWidthEnabled = enabled; + }; + $scope.setNextVisible = function (visible) { $scope.nextVisible = visible; }; @@ -185,7 +192,7 @@ migrationLaunchView.controller("MigrationLaunchViewController", [ } }; - $scope.finishClicked = function () { + $scope.migrateClicked = function () { $messageHub.message($scope.currentStep.topicId, { isVisible: false }); $scope.currentStep = $scope.steps[$scope.steps.length - 1]; $messageHub.message($scope.currentStep.topicId, { isVisible: true }); @@ -204,6 +211,6 @@ migrationLaunchView.controller("MigrationLaunchViewController", [ else return "inactive"; }; - $messageHub.on("migration.launch", function (msg) { }.bind(this)); + $messageHub.on("migration.launch", function (msg) {}.bind(this)); }, ]); diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/neo-credentials.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/neo-credentials.js index 6cd7b9d42..07f679652 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/neo-credentials.js +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/neo-credentials.js @@ -77,8 +77,6 @@ migrationLaunchView.controller("NeoCredentialsViewController", [ $scope.regionSelected = function (regionObject) { migrationDataState.neoHostName = regionObject.region; $scope.regionDropdownText = regionObject.name; - - $scope.$parent.setFinishEnabled(true); }; $scope.filterRegions = function () { @@ -120,7 +118,6 @@ migrationLaunchView.controller("NeoCredentialsViewController", [ $scope.$parent.setPreviousVisible(false); $scope.$parent.setPreviousEnabled(true); $scope.$parent.setNextVisible(true); - $scope.$parent.setFinishVisible(false); } }); } diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/start-migration.js b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/start-migration.js index 440ff8948..28e8a10a4 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/start-migration.js +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/js/start-migration.js @@ -98,6 +98,7 @@ migrationLaunchView.controller("StartMigrationViewController", [ if ("isVisible" in msg.data) { $scope.$apply(function () { $scope.isVisible = msg.data.isVisible; + if (msg.data.isVisible) $scope.$parent.setFullWidthEnabled(false); }); if (msg.data.isVisible) { startMigration(); @@ -105,24 +106,28 @@ migrationLaunchView.controller("StartMigrationViewController", [ } }.bind(this) ); - $messageHub.on('migration.start-zip-migration', function (msg) { - if ("isVisible" in msg.data) { - $scope.$apply(function () { - $scope.isZipMigrationVisible = msg.data.isVisible; - }); - } - if ("migrationFinished" in msg.data) { - $scope.$apply(function () { - $scope.migrationFinished = msg.data.migrationFinished; - if ("workspace" in msg.data) - migrationDataState.selectedWorkspace = msg.data.workspace; - $scope.progressTitle = titleList[1]; - $scope.statusMessage = ("status" in msg.data) ? msg.data.status : ("workspace" in msg.data) - ? `Successfully migrated uploaded Delivery Unit(s)! Go to workspace "${msg.data.workspace}" and publish them.` : - "Successfully migrated uploaded Delivery Unit(s)!"; - - }); - } - }.bind(this)); + $messageHub.on( + "migration.start-zip-migration", + function (msg) { + if ("isVisible" in msg.data) { + $scope.$apply(function () { + $scope.isZipMigrationVisible = msg.data.isVisible; + }); + } + if ("migrationFinished" in msg.data) { + $scope.$apply(function () { + $scope.migrationFinished = msg.data.migrationFinished; + if ("workspace" in msg.data) migrationDataState.selectedWorkspace = msg.data.workspace; + $scope.progressTitle = titleList[1]; + $scope.statusMessage = + "status" in msg.data + ? msg.data.status + : "workspace" in msg.data + ? `Successfully migrated uploaded Delivery Unit(s)! Go to workspace "${msg.data.workspace}" and publish them.` + : "Successfully migrated uploaded Delivery Unit(s)!"; + }); + } + }.bind(this) + ); }, ]); diff --git a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/migration-launch.html b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/migration-launch.html index d93f21906..ccdd57d90 100644 --- a/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/migration-launch.html +++ b/modules/ide/ide-migration/src/main/resources/META-INF/dirigible/ide-migration/migration-launch.html @@ -38,6 +38,9 @@ + + + @@ -45,6 +48,7 @@ + @@ -83,11 +87,12 @@
Please wait while we calculate what changes need to be made +
+{{ data.length }} file(s) will be changed.
+{{ file.file }}
+ +Loading...
+