Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

System groups #146

Merged
merged 19 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/filterAllProgramsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function getFilterAllProgramsCommand(tree: CICSTree) {
}
await persistentStorage.addProgramSearchHistory(pattern!);
node.setFilter(pattern!);
await node.loadContents(tree);
await node.loadContents(tree, node.getParent().getGroupName());
tree._onDidChangeTreeData.fire(undefined);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/filterAllTransactionsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function getFilterAllTransactionsCommand(tree: CICSTree) {
}
await persistentStorage.addTransactionSearchHistory(pattern!);
node.setFilter(pattern!);
await node.loadContents(tree);
await node.loadContents(tree, node.getParent().getGroupName());
tree._onDidChangeTreeData.fire(undefined);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/getFilterAllLocalFilesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function getFilterAllLocalFilesCommand(tree: CICSTree) {
}
await persistentStorage.addLocalFileSearchHistory(pattern!);
node.setFilter(pattern!);
await node.loadContents(tree);
await node.loadContents(tree, node.getParent().getGroupName());
tree._onDidChangeTreeData.fire(undefined);
}
}
Expand Down
85 changes: 16 additions & 69 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ import { getEnableLocalFileCommand } from "./commands/enableLocalFileCommand";
import { getDisableLocalFileCommand } from "./commands/disableLocalFileCommand";
import { getCloseLocalFileCommand } from "./commands/closeLocalFileCommand";
import { getOpenLocalFileCommand } from "./commands/openLocalFileCommand";
import { CICSRegionTree } from "./trees/CICSRegionTree";
import { CICSSessionTree } from "./trees/CICSSessionTree";
import { CICSCombinedProgramTree } from "./trees/CICSCombinedProgramTree";
import { viewMoreCommand } from "./commands/viewMoreCommand";
import { CICSCombinedTransactionsTree } from "./trees/CICSCombinedTransactionTree";
import { CICSCombinedLocalFileTree } from "./trees/CICSCombinedLocalFileTree";
import { getFilterAllProgramsCommand } from "./commands/filterAllProgramsCommand";
import { getFilterAllTransactionsCommand } from "./commands/filterAllTransactionsCommand";
import { getFilterAllLocalFilesCommand } from "./commands/getFilterAllLocalFilesCommand";
import { getIconPathInResources } from "./utils/getIconPath";
import { plexExpansionHandler } from "./utils/plexExpansionHandler";
import { sessionExpansionHandler } from "./utils/sessionExpansionHandler";
import { regionContainerExpansionHandler } from "./utils/regionContainerExpansionHandler";

export async function activate(context: ExtensionContext) {

Expand All @@ -75,75 +74,20 @@ export async function activate(context: ExtensionContext) {

treeview.onDidExpandElement(async (node) => {
if (node.element.contextValue.includes("cicssession.")) {
let profile : any;
try {
profile = await ProfileManagement.getProfilesCache().loadNamedProfile(node.element.label?.toString()!, 'cics');
await treeDataProv.loadProfile(profile, treeDataProv.getLoadedProfiles().indexOf(node.element), node.element);
await sessionExpansionHandler(node.element, treeDataProv);
} catch (error) {
console.log(error);
}
} else if (node.element.contextValue.includes("cicsplex.")) {
try {
const plexProfile = node.element.getProfile();
const combinedProgramTree = new CICSCombinedProgramTree(node.element);
const combinedTransactionTree = new CICSCombinedTransactionsTree(node.element);
const combinedLocalFileTree = new CICSCombinedLocalFileTree(node.element);
if (plexProfile.profile.regionName && plexProfile.profile.cicsPlex) {
window.withProgress({
title: 'Loading region',
location: ProgressLocation.Notification,
cancellable: false
}, async (_, token) => {
token.onCancellationRequested(() => {
console.log("Cancelling the loading of the region");
});
await node.element.loadOnlyRegion();
treeDataProv._onDidChangeTreeData.fire(undefined);
});
} else {
window.withProgress({
title: 'Loading regions',
location: ProgressLocation.Notification,
cancellable: false
}, async (_, token) => {
token.onCancellationRequested(() => {
console.log("Cancelling the loading of regions");
});
const regionInfo = await ProfileManagement.getRegionInfoInPlex(node.element);
if (regionInfo) {
node.element.clearChildren();
let activeCount = 0;
let totalCount = 0;
const regionFilterRegex = node.element.getActiveFilter() ? RegExp(node.element.getActiveFilter()) : undefined;
node.element.addRegionContainer();
const regionContainer = node.element.getChildren().filter((child:any) => child.contextValue.includes("cicsregionscontainer."))[0];
for (const region of regionInfo) {
// If region filter exists then match it
if (!regionFilterRegex || region.cicsname.match(regionFilterRegex)) {
const newRegionTree = new CICSRegionTree(region.cicsname, region, node.element.getParent(), node.element);
regionContainer.addRegion(newRegionTree);
totalCount += 1;
if (region.cicsstate === 'ACTIVE') {
activeCount += 1;
}
}
}
if (regionContainer.getChildren().length > 1) {
node.element.addCombinedTree(combinedProgramTree);
node.element.addCombinedTree(combinedTransactionTree);
node.element.addCombinedTree(combinedLocalFileTree);
}
regionContainer.setLabel(`Regions [${activeCount}/${totalCount}]`);
// Keep plex open after label change
node.element.collapsibleState = TreeItemCollapsibleState.Expanded;
}
treeDataProv._onDidChangeTreeData.fire(undefined);
});
}
treeDataProv._onDidChangeTreeData.fire(undefined);
await plexExpansionHandler(node.element, treeDataProv);
} catch (error) {
console.log(error);
const newSessionTree = new CICSSessionTree(node.element.getParent().profile, getIconPathInResources("profile-disconnected-dark.svg","profile-disconnected-light.svg"));
const newSessionTree = new CICSSessionTree(
node.element.getParent().profile,
getIconPathInResources("profile-disconnected-dark.svg","profile-disconnected-light.svg")
);
treeDataProv.loadedProfiles.splice(treeDataProv.getLoadedProfiles().indexOf(node.element.getParent()), 1, newSessionTree);
treeDataProv._onDidChangeTreeData.fire(undefined);
}
Expand Down Expand Up @@ -189,21 +133,25 @@ export async function activate(context: ExtensionContext) {
node.element.collapsibleState = TreeItemCollapsibleState.Expanded;
} else if (node.element.contextValue.includes("cicscombinedprogramtree.")) {
if (node.element.getActiveFilter()) {
node.element.loadContents(treeDataProv);
const group = node.element.getParent().getGroupName();
node.element.loadContents(treeDataProv, group);
}
node.element.collapsibleState = TreeItemCollapsibleState.Expanded;
} else if (node.element.contextValue.includes("cicscombinedtransactiontree.")) {
if (node.element.getActiveFilter()) {
node.element.loadContents(treeDataProv);
const group = node.element.getParent().getGroupName();
node.element.loadContents(treeDataProv, group);
}
node.element.collapsibleState = TreeItemCollapsibleState.Expanded;
} else if (node.element.contextValue.includes("cicscombinedlocalfiletree.")) {
if (node.element.getActiveFilter()) {
node.element.loadContents(treeDataProv);
const group = node.element.getParent().getGroupName();
node.element.loadContents(treeDataProv, group);
}
node.element.collapsibleState = TreeItemCollapsibleState.Expanded;
} else if (node.element.contextValue.includes("cicsregionscontainer.")) {
node.element.iconPath = getIconPathInResources("folder-open-dark.svg", "folder-open-light.svg");
await regionContainerExpansionHandler(node.element, treeDataProv);
treeDataProv._onDidChangeTreeData.fire(undefined);
}
});
Expand Down Expand Up @@ -275,4 +223,3 @@ export async function activate(context: ExtensionContext) {
);
}

export function deactivate() { }
23 changes: 19 additions & 4 deletions src/trees/CICSCombinedLocalFileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

import { TreeItemCollapsibleState, TreeItem, window, ProgressLocation } from "vscode";
import { join } from "path";
import { CICSPlexTree } from "./CICSPlexTree";
import { CICSRegionTree } from "./CICSRegionTree";
import { CICSTree } from "./CICSTree";
Expand Down Expand Up @@ -44,7 +43,7 @@ export class CICSCombinedLocalFileTree extends TreeItem {
this.constant = "CICSLocalFile";
}

public async loadContents(tree : CICSTree){
public async loadContents(tree : CICSTree, group?: string){
window.withProgress({
title: 'Loading Local Files',
location: ProgressLocation.Notification,
Expand All @@ -59,13 +58,25 @@ export class CICSCombinedLocalFileTree extends TreeItem {
}
let count;
try {
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(),this.parentPlex.getPlexName(),this.constant, criteria);
const cacheTokenInfo = await ProfileManagement.generateCacheToken(
this.parentPlex.getProfile(),
this.parentPlex.getPlexName(),
this.constant,
criteria,
group
);
if (cacheTokenInfo) {
const recordsCount = cacheTokenInfo.recordCount;
if (parseInt(recordsCount, 10)) {
let allLocalFiles;
if (recordsCount <= 500) {
allLocalFiles = await ProfileManagement.getAllResourcesInPlex(this.parentPlex, this.constant, criteria);
allLocalFiles = await ProfileManagement.getCachedResources(
this.parentPlex.getProfile(),
cacheTokenInfo.cacheToken,
this.constant,
1,
parseInt(recordsCount, 10)
);
} else {
allLocalFiles = await ProfileManagement.getCachedResources(this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, this.constant, 1, this.incrementCount);
count = parseInt(recordsCount);
Expand Down Expand Up @@ -164,4 +175,8 @@ export class CICSCombinedLocalFileTree extends TreeItem {
public getActiveFilter() {
return this.activeFilter;
}

public getParent() {
return this.parentPlex;
}
}
28 changes: 23 additions & 5 deletions src/trees/CICSCombinedProgramTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CICSCombinedProgramTree extends TreeItem {
this.constant = CicsCmciConstants.CICS_PROGRAM_RESOURCE;
}

public async loadContents(tree : CICSTree){
public async loadContents(tree: CICSTree, group?: string){
window.withProgress({
title: 'Loading Programs',
location: ProgressLocation.Notification,
Expand All @@ -59,13 +59,19 @@ export class CICSCombinedProgramTree extends TreeItem {
criteria = toEscapedCriteriaString(this.activeFilter, 'PROGRAM');
}
let count;
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(),this.parentPlex.getPlexName(),this.constant,criteria);
const cacheTokenInfo = await ProfileManagement.generateCacheToken(
this.parentPlex.getProfile(),
this.parentPlex.getPlexName(),
this.constant,
criteria,
group
);
if (cacheTokenInfo) {
const recordsCount = cacheTokenInfo.recordCount;
if (parseInt(recordsCount, 10)) {
let allPrograms;
if (recordsCount <= 500) {
allPrograms = await ProfileManagement.getAllResourcesInPlex(this.parentPlex, this.constant, criteria);
allPrograms = await ProfileManagement.getCachedResources(this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, this.constant, 1, parseInt(recordsCount, 10));
} else {
allPrograms = await ProfileManagement.getCachedResources(this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, this.constant, 1, this.incrementCount);
count = parseInt(recordsCount);
Expand Down Expand Up @@ -127,7 +133,12 @@ export class CICSCombinedProgramTree extends TreeItem {
if (this.activeFilter) {
criteria = toEscapedCriteriaString(this.activeFilter, 'PROGRAM');
}
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(),this.parentPlex.getPlexName(),this.constant,criteria);
const cacheTokenInfo = await ProfileManagement.generateCacheToken(
this.parentPlex.getProfile(),
this.parentPlex.getPlexName(),
this.constant,
criteria
);
if (cacheTokenInfo) {
// record count may have updated
const recordsCount = cacheTokenInfo.recordCount;
Expand All @@ -141,7 +152,10 @@ export class CICSCombinedProgramTree extends TreeItem {
);
if (allPrograms) {
// @ts-ignore
this.addProgramsUtil(this.getChildren() ? this.getChildren().filter((child) => child instanceof CICSProgramTreeItem):[], allPrograms, count);
this.addProgramsUtil(this.getChildren() ? this.getChildren().filter((child) => child instanceof CICSProgramTreeItem):[],
allPrograms,
count
);
tree._onDidChangeTreeData.fire(undefined);
}
}
Expand Down Expand Up @@ -169,4 +183,8 @@ export class CICSCombinedProgramTree extends TreeItem {
public getActiveFilter() {
return this.activeFilter;
}

public getParent() {
return this.parentPlex;
}
}
21 changes: 16 additions & 5 deletions src/trees/CICSCombinedTransactionTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CICSCombinedTransactionsTree extends TreeItem {
this.constant = CicsCmciConstants.CICS_LOCAL_TRANSACTION;
}

public async loadContents(tree : CICSTree){
public async loadContents(tree: CICSTree, group?: string){
window.withProgress({
title: 'Loading Local Transactions',
location: ProgressLocation.Notification,
Expand All @@ -59,13 +59,13 @@ export class CICSCombinedTransactionsTree extends TreeItem {
criteria = toEscapedCriteriaString(this.activeFilter, 'tranid');
}
let count;
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(),this.parentPlex.getPlexName(),this.constant,criteria);
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(), this.parentPlex.getPlexName(), this.constant, criteria, group);
if (cacheTokenInfo) {
const recordsCount = cacheTokenInfo.recordCount;
if (parseInt(recordsCount, 10)) {
let allLocalTransactions;
if (recordsCount <= 500) {
allLocalTransactions = await ProfileManagement.getAllResourcesInPlex(this.parentPlex, this.constant, criteria);
allLocalTransactions = await ProfileManagement.getCachedResources(this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, this.constant, 1, parseInt(recordsCount, 10));
} else {
allLocalTransactions = await ProfileManagement.getCachedResources(this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, this.constant, 1, this.incrementCount);
count = parseInt(recordsCount);
Expand Down Expand Up @@ -122,7 +122,11 @@ export class CICSCombinedTransactionsTree extends TreeItem {
location: ProgressLocation.Notification,
cancellable: false
}, async () => {
const cacheTokenInfo = await ProfileManagement.generateCacheToken(this.parentPlex.getProfile(),this.parentPlex.getPlexName(),this.constant);
const cacheTokenInfo = await ProfileManagement.generateCacheToken(
this.parentPlex.getProfile(),
this.parentPlex.getPlexName(),
this.constant
);
if (cacheTokenInfo) {
// record count may have updated
const recordsCount = cacheTokenInfo.recordCount;
Expand All @@ -136,7 +140,10 @@ export class CICSCombinedTransactionsTree extends TreeItem {
);
if (allLocalTransactions) {
// @ts-ignore
this.addLocalTransactionsUtil(this.getChildren() ? this.getChildren().filter((child) => child instanceof CICSTransactionTreeItem):[], allLocalTransactions, count);
this.addLocalTransactionsUtil(this.getChildren() ? this.getChildren().filter((child) => child instanceof CICSTransactionTreeItem) : [],
allLocalTransactions,
count
);
tree._onDidChangeTreeData.fire(undefined);
}
}
Expand Down Expand Up @@ -164,4 +171,8 @@ export class CICSCombinedTransactionsTree extends TreeItem {
public getActiveFilter() {
return this.activeFilter;
}

public getParent() {
return this.parentPlex;
}
}
Loading