Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/object_locks
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	src/views/schemaBrowser/contributes.json
#	src/views/schemaBrowser/index.ts
#	src/views/schemaBrowser/statements.ts
  • Loading branch information
janfh committed Jan 7, 2025
2 parents 683e31a + 1d028cd commit a6be167
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 254 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
"title": "Get Indexes",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getAuthorities",
"title": "Get Authorities",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getObjectLocks",
"title": "Get Object Locks",
Expand Down Expand Up @@ -925,6 +930,11 @@
"when": "viewItem == table || viewItem == schema",
"group": "db2workWith@3"
},
{
"command": "vscode-db2i.getAuthorities",
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == constraint || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
"group": "db2workWith@4"
},
{
"command": "vscode-db2i.getObjectLocks",
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == constraint || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
Expand Down
7 changes: 6 additions & 1 deletion src/notebooks/logic/chartJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function generateChartHTMLEmbedded(id: number, detail: ChartDetail, label

const hasYaxis = detail.type === `bar` || detail.type === `line`;

const script = /*javascript*/`
const script = /*javascript*/ `
if (!window.ibmicharts) {
window.ibmicharts = {};
}
Expand All @@ -41,6 +41,11 @@ export function generateChartHTMLEmbedded(id: number, detail: ChartDetail, label
if (!theChart) {
const chartEle = document.getElementById('myChart${id}');
if (chartEle) {
const maxHeight = window.innerHeight * 0.8;
const maxWidth = window.innerWidth * 0.8;
const targetSize = Math.min(maxHeight, maxWidth);
chartEle.style.maxHeight = targetSize + 'px';
chartEle.style.maxWidth = targetSize + 'px';
try {
window.ibmicharts['myChart${id}'] = new Chart(chartEle.getContext('2d'), {
type: '${detail.type}',
Expand Down
50 changes: 32 additions & 18 deletions src/notebooks/logic/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,38 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
}

if (fallbackToTable) {
cellContents.push([
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
`<thead>`,
`<tr>`,
columns.map(c => `<th>${c}</th>`).join(``),
`</tr>`,
`</thead>`,
`<tbody>`,
table.map(row => {
return [
`<tr>`,
keys.map(key => `<td>${row[key]}</td>`).join(``),
`</tr>`
].join(``);
}).join(``),
`</tbody>`,
`</table>`
].join(``));
cellContents.push(
[
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
`<thead>`,
`<tr>`,
columns
.map(
(c) =>
`<th style="text-align: left;">${c}</th>`
)
.join(``),
`</tr>`,
`</thead>`,
`<tbody>`,
table
.map((row) => {
return [
`<tr>`,
keys
.map(
(key) =>
`<td style="text-align: left;">${row[key]}</td>`
)
.join(``),
`</tr>`,
].join(``);
})
.join(``),
`</tbody>`,
`</table>`,
].join(``)
);
}
} else {
// items.push(vscode.NotebookCellOutputItem.stderr(`No rows returned from statement.`));
Expand Down
10 changes: 10 additions & 0 deletions src/views/schemaBrowser/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"title": "Get Indexes",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getAuthorities",
"title": "Get Authorities",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getObjectLocks",
"title": "Get Object Locks",
Expand Down Expand Up @@ -162,6 +167,11 @@
"when": "viewItem == table || viewItem == schema",
"group": "db2workWith@3"
},
{
"command": "vscode-db2i.getAuthorities",
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == constraint || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
"group": "db2workWith@4"
},
{
"command": "vscode-db2i.getObjectLocks",
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == constraint || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
Expand Down
15 changes: 13 additions & 2 deletions src/views/schemaBrowser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Configuration from "../../configuration";
import Types from "../types";
import Statement from "../../database/statement";
import { copyUI } from "./copyUI";
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getObjectLocksStatement } from "./statements";
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getAuthoritiesStatement, getObjectLocksStatement } from "./statements";

const viewItem = {
"tables": `table`,
Expand Down Expand Up @@ -187,6 +187,17 @@ export default class schemaBrowser {
}
}),

vscode.commands.registerCommand(`vscode-db2i.getAuthorities`, async (object: SQLObject) => {
if (object) {
const content = getAuthoritiesStatement(object.schema, object.name, object.type.toUpperCase(), object.tableType);
vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, {
content,
qualifier: `statement`,
open: false,
});
}
}),

vscode.commands.registerCommand(`vscode-db2i.getObjectLocks`, async (object: SQLObject) => {
if (object) {
const content = getObjectLocksStatement(object.schema, object.name, object.type.toUpperCase(), object.tableType);
Expand All @@ -197,7 +208,7 @@ export default class schemaBrowser {
});
}
}),

vscode.commands.registerCommand(`vscode-db2i.advisedIndexes`, async (object: SQLObject|SchemaItem) => { //table
if (object) {
let content: string|undefined;
Expand Down
Loading

0 comments on commit a6be167

Please sign in to comment.