From ffabba52fc95598081ae169c50a738125842c958 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Thu, 19 Oct 2023 10:48:16 -0400 Subject: [PATCH 1/4] Start of edit view --- src/views/jobManager/editJob/index.ts | 124 +++++++++++--------- src/views/jobManager/editJob/simpleView.ts | 127 +++++++++++++++++++++ 2 files changed, 200 insertions(+), 51 deletions(-) create mode 100644 src/views/jobManager/editJob/simpleView.ts diff --git a/src/views/jobManager/editJob/index.ts b/src/views/jobManager/editJob/index.ts index c4b38c3d..b1e3b4b2 100644 --- a/src/views/jobManager/editJob/index.ts +++ b/src/views/jobManager/editJob/index.ts @@ -2,6 +2,7 @@ import { loadBase } from "../../../base"; import { JDBCOptions } from "../../../connection/types"; import { ComplexTab } from "@halcyontech/vscode-ibmi-types/api/CustomUI"; +import getSimpleView from "./simpleView"; import getPerfTab from "./perfTab"; import getFormatTab from "./formatTab"; import getSystemTab from "./systemTab"; @@ -15,63 +16,84 @@ export function formatDescription(text: string): string { .replace(/\s/g, " "); // Replace spaces with non-breaking spaces } +let useSimpleView = true; + export async function editJobUi( options: JDBCOptions, jobName?: string ): Promise { - const base = loadBase(); - const ui = base.customUI(); - - const syspropsTab = getSystemTab(options); - const otherpropsTab = getOtherTab(options); - const formatpropsTab = getFormatTab(options); - const performancepropsTab = getPerfTab(options); - const sortPropsTab = getSortTab(options); - - let tabs: ComplexTab[] = [ - { label: `System`, fields: syspropsTab.fields }, - { label: `Format`, fields: formatpropsTab.fields }, - { label: `Performance`, fields: performancepropsTab.fields }, - { label: `Sort`, fields: sortPropsTab.fields }, - { label: `Other`, fields: otherpropsTab.fields }, - ]; - - ui.addComplexTabs(tabs).addButtons( - { id: `apply`, label: `Apply changes` }, - { id: `cancel`, label: `Cancel` } - ); - - const page = await ui.loadPage<{ [key: string]: string }>( - `Edit ${jobName} options` - ); - - if (page && page.data) { - page.panel.dispose(); - - if (page.data.buttons === `apply`) { - const keys = Object.keys(page.data); - - // We need to play with some of the form data to put it back into JDBCOptions - for (const key of keys) { - switch (key) { - case `libraries`: - options.libraries = page.data[key].split(`,`).map((v) => v.trim()); - break; - case `buttons`: - // Do nothing with buttons - break; - - default: - // Handle of true/false values back into boolean types - switch (page.data[key]) { - case `true`: options[key] = true; break; - case `false`: options[key] = false; break; - default: options[key] = page.data[key]; break; + + while (true) { + const base = loadBase(); + const ui = base.customUI(); + + if (useSimpleView) { + getSimpleView(ui, options); + + } else { + const syspropsTab = getSystemTab(options); + const otherpropsTab = getOtherTab(options); + const formatpropsTab = getFormatTab(options); + const performancepropsTab = getPerfTab(options); + const sortPropsTab = getSortTab(options); + + let tabs: ComplexTab[] = [ + { label: `System`, fields: syspropsTab.fields }, + { label: `Format`, fields: formatpropsTab.fields }, + { label: `Performance`, fields: performancepropsTab.fields }, + { label: `Sort`, fields: sortPropsTab.fields }, + { label: `Other`, fields: otherpropsTab.fields }, + ]; + + ui.addComplexTabs(tabs); + } + + ui.addButtons( + { id: `apply`, label: `Apply changes` }, + { id: `cancel`, label: `Cancel` }, + { id: `swap`, label: `Use ${useSimpleView ? `Detailed` : `Simple`} view` }, + ); + + const page = await ui.loadPage<{ [key: string]: string }>( + `Edit ${jobName} options` + ); + + if (page && page.data) { + page.panel.dispose(); + + switch (page.data.buttons) { + case `apply`: + const keys = Object.keys(page.data); + + // We need to play with some of the form data to put it back into JDBCOptions + for (const key of keys) { + switch (key) { + case `libraries`: + options.libraries = page.data[key].split(`,`).map((v) => v.trim()); + break; + case `buttons`: + // Do nothing with buttons + break; + + default: + // Handle of true/false values back into boolean types + switch (page.data[key]) { + case `true`: options[key] = true; break; + case `false`: options[key] = false; break; + default: options[key] = page.data[key]; break; + } } - } - } + } + + return options; - return options; + case `swap`: + useSimpleView = !useSimpleView; + break; + + default: + return; + } } } diff --git a/src/views/jobManager/editJob/simpleView.ts b/src/views/jobManager/editJob/simpleView.ts new file mode 100644 index 00000000..b31a9645 --- /dev/null +++ b/src/views/jobManager/editJob/simpleView.ts @@ -0,0 +1,127 @@ +import { JDBCOptions } from "../../../connection/types"; +import { getInstance, loadBase } from "../../../base"; +import { formatDescription } from "."; +import { CustomUI } from "@halcyontech/vscode-ibmi-types/api/CustomUI"; + +const dbNameText = ` +Specifies the database to use for a connection to an independent auxiliary storage pool (ASP). When you specify +a database name, the name must exist in the relational database directory on the system and correspond to either +an independent ASP or the system default database. The following criteria determine which database is accessed: + +- When this property is used to specify a database which corresponds to an independent ASP, + the connection is made to the independent ASP. When the specified database does not exist, the connection fails. +- When this property is used to specify *SYSBAS as the database name, the system default database is used. +- When this property is omitted, the initial ASP group specified in the job description for the user profile + is used. When the job description does not specify an initial ASP group, the system default database is used. + +`; + +export default function getSimpleView(ui: CustomUI, options: JDBCOptions) { + const connection = getInstance().getConnection() + + ui + .addSelect( + `naming`, + `Naming`, + [ + { + value: `system`, + text: `as in schema/table`, + description: `System naming`, + selected: options.naming === `system`, + }, + { + value: `sql`, + text: `as in schema.table`, + description: `SQL naming`, + selected: options.naming === `sql`, + }, + ], + `Specifies the naming convention used when referring to tables.` + ) + .addInput( + `libraries`, + `Library list`, + `List of system libraries, separated by commas or spaces`, + { rows: 2, default: options.libraries.join(`, `) } + ) + .addSelect(`database name`, `Database name`, [ + {text: `System Base`, description: `*SYSBAS`, value: ``, selected: options["database name"] === ``}, + ...Object.values(connection.aspInfo).map(asp => ({text: asp, description: asp, value: asp, selected: options["database name"] === asp})) + ], formatDescription(dbNameText)) + .addSelect( + `auto commit`, + `Auto commit`, + [ + { + value: `true`, + description: `True`, + text: `Commit (true)`, + selected: options["auto commit"] === true, + }, + { + value: `false`, + description: `False`, + text: `No commit (false)`, + selected: options["auto commit"] === false, + }, + ], + `Specifies whether auto-commit mode is the default connection mode for new connections. Note that, in order to use transaction isolation levels other than *NONE when using auto-commit mode, the property "true autocommit" needs to be set to true.` + ) + .addSelect( + `transaction isolation`, + `Transaction isolation`, + [ + { + value: `none`, + description: `None`, + text: `No commit (none)`, + selected: options["transaction isolation"] === `none`, + }, + { + value: `read committed`, + description: `Read committed`, + text: `read committed`, + selected: options["transaction isolation"] === `read committed`, + }, + { + value: `read uncommitted`, + description: `Read uncommitted`, + text: `read uncommitted`, + selected: options["transaction isolation"] === `read uncommitted`, + }, + { + value: `repeatable read`, + description: `Repeatable read`, + text: `repeatable read`, + selected: options["transaction isolation"] === `repeatable read`, + }, + { + value: `serializable`, + description: `Serializable`, + text: `serializable`, + selected: options["transaction isolation"] === `serializable`, + }, + ], + `Specifies the default transaction isolation.` + ) + .addSelect( + `true autocommit`, + `True autocommit`, + [ + { + value: `false`, + text: `Do not use true autocommit`, + description: `false`, + selected: options["true autocommit"] === false, + }, + { + value: `true`, + text: `Use true autocommit`, + description: `true`, + selected: options["true autocommit"] === true, + }, + ], + `Specifies whether the connection should use true auto commit support. True autocommit means that autocommit is on and is running under a isolation level other than *NONE. By default, the driver handles autocommit by running under the system isolation level of *NONE.` + ) +} \ No newline at end of file From fbbdf8a27baa4fe90da3dcb2d29d69cf1b3011ec Mon Sep 17 00:00:00 2001 From: worksofliam Date: Thu, 19 Oct 2023 10:52:22 -0400 Subject: [PATCH 2/4] Smaller ASP text on simple view --- src/views/jobManager/editJob/simpleView.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/views/jobManager/editJob/simpleView.ts b/src/views/jobManager/editJob/simpleView.ts index b31a9645..782f2ced 100644 --- a/src/views/jobManager/editJob/simpleView.ts +++ b/src/views/jobManager/editJob/simpleView.ts @@ -1,20 +1,11 @@ import { JDBCOptions } from "../../../connection/types"; -import { getInstance, loadBase } from "../../../base"; +import { getInstance } from "../../../base"; import { formatDescription } from "."; import { CustomUI } from "@halcyontech/vscode-ibmi-types/api/CustomUI"; -const dbNameText = ` -Specifies the database to use for a connection to an independent auxiliary storage pool (ASP). When you specify +const dbNameText = `Specifies the database to use for a connection to an independent auxiliary storage pool (ASP). When you specify a database name, the name must exist in the relational database directory on the system and correspond to either -an independent ASP or the system default database. The following criteria determine which database is accessed: - -- When this property is used to specify a database which corresponds to an independent ASP, - the connection is made to the independent ASP. When the specified database does not exist, the connection fails. -- When this property is used to specify *SYSBAS as the database name, the system default database is used. -- When this property is omitted, the initial ASP group specified in the job description for the user profile - is used. When the job description does not specify an initial ASP group, the system default database is used. - -`; +an independent ASP or the system default database.`; export default function getSimpleView(ui: CustomUI, options: JDBCOptions) { const connection = getInstance().getConnection() From cf280f08d00279f217e28287235b9ab5899d97b6 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Thu, 19 Oct 2023 11:39:30 -0400 Subject: [PATCH 3/4] SQL naming as default --- src/connection/manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connection/manager.ts b/src/connection/manager.ts index 281e3917..91e6122e 100644 --- a/src/connection/manager.ts +++ b/src/connection/manager.ts @@ -25,7 +25,7 @@ export class SQLJobManager { const newJob = predefinedJob || (new SQLJob({ libraries: [config.currentLibrary, ...config.libraryList], - naming: `system`, + naming: `sql`, "full open": false, "transaction isolation": "none", "query optimize goal": "1", From 67d364025b97d70d19322c471851081113cc7b97 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Thu, 19 Oct 2023 11:58:22 -0400 Subject: [PATCH 4/4] Job counter in brackets --- src/connection/manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connection/manager.ts b/src/connection/manager.ts index 91e6122e..c1a5f1e6 100644 --- a/src/connection/manager.ts +++ b/src/connection/manager.ts @@ -38,7 +38,7 @@ export class SQLJobManager { this.totalJobs += 1; this.jobs.push({ - name: `${name || 'New job'} ${this.totalJobs}`, + name: `${name || 'New job'} (${this.totalJobs})`, job: newJob });