Skip to content

Commit

Permalink
Merge branch 'master' into feature/deleteHotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
sebjulliand authored Feb 25, 2024
2 parents 85c0194 + 725454f commit c3f1768
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 9 deletions.
38 changes: 33 additions & 5 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export default class IBMiContent {
/**
* @param filters
* @param sortOrder
* @returns an array of IBMiFile
* @returns an array of IBMiObject
*/
async getObjectList(filters: { library: string; object?: string; types?: string[]; filterType?: FilterType }, sortOrder?: SortOrder): Promise<IBMiObject[]> {
const library = filters.library.toUpperCase();
Expand Down Expand Up @@ -521,7 +521,18 @@ export default class IBMiContent {
`ODOBTP as TYPE, ` +
`ODOBAT as ATTRIBUTE, ` +
`ODOBTX as TEXT, ` +
`0 as IS_SOURCE ` +
`0 as IS_SOURCE, ` +
`ODOBSZ as SIZE, ` +
`ODCCEN, ` +
`ODCDAT, ` +
`ODCTIM, ` +
`ODLCEN, ` +
`ODLDAT, ` +
`ODLTIM, ` +
`ODOBOW as OWNER, ` +
`ODCRTU as CREATED_BY, ` +
`ODSIZU as SIZE_IN_UNITS, ` +
`ODBPUN as BYTES_PER_UNIT ` +
`from QTEMP.CODE4IOBJD`;
}
else {
Expand All @@ -533,7 +544,18 @@ export default class IBMiContent {
`Case When PHDTAT = 'S' Then 1 Else 0 End as IS_SOURCE, ` +
`PHNOMB as NB_MBR, ` +
'PHMXRL as SOURCE_LENGTH, ' +
'PHCSID as CCSID ' +
'PHCSID as CCSID, ' +
`ODOBSZ as SIZE, ` +
`ODCCEN, ` +
`ODCDAT, ` +
`ODCTIM, ` +
`ODLCEN, ` +
`ODLDAT, ` +
`ODLTIM, ` +
`ODOBOW as OWNER, ` +
`ODCRTU as CREATED_BY, ` +
`ODSIZU as SIZE_IN_UNITS, ` +
`ODBPUN as BYTES_PER_UNIT ` +
`from QTEMP.CODE4IOBJD ` +
`left join QTEMP.CODE4IFD on PHFILE = ODOBNM And PHDTAT = 'S'`;
}
Expand All @@ -550,7 +572,12 @@ export default class IBMiContent {
memberCount: object.NB_MBR !== undefined ? Number(object.NB_MBR) : undefined,
sourceFile: Boolean(object.IS_SOURCE),
sourceLength: object.SOURCE_LENGTH !== undefined ? Number(object.SOURCE_LENGTH) : undefined,
CCSID: object.CCSID !== undefined ? Number(object.CCSID) : undefined
CCSID: object.CCSID !== undefined ? Number(object.CCSID) : undefined,
size: Number(object.SIZE) !== 9999999999 ? Number(object.SIZE) : Number(object.SIZE_IN_UNITS) * Number(object.BYTES_PER_UNIT),
created: this.getDspObjDdDate(String(object.ODCCEN), String(object.ODCDAT), String(object.ODCTIM)),
changed: this.getDspObjDdDate(String(object.ODLCEN), String(object.ODLDAT), String(object.ODLTIM)),
created_by: object.CREATED_BY,
owner: object.OWNER,
} as IBMiObject))
.filter(object => !typeFilter || typeFilter(object.type))
.filter(object => nameFilter.test(object.name))
Expand Down Expand Up @@ -806,8 +833,9 @@ export default class IBMiContent {
* @param timeString: string in HHMMSS
* @returns date
*/
getDspfdDate(century: string = `0`, YYMMDD: string = `010101`, HHMMSS: string = `000000`): Date {
getDspObjDdDate(century: string = `0`, MMDDYY: string = `010101`, HHMMSS: string = `000000`): Date {
let year: string, month: string, day: string, hours: string, minutes: string, seconds: string;
let YYMMDD: string = MMDDYY.slice(4,).concat(MMDDYY.slice(0, 4));
let dateString: string = (century === `1` ? `20` : `19`).concat(YYMMDD.padStart(6, `0`)).concat(HHMMSS.padStart(6, `0`));
[, year, month, day, hours, minutes, seconds] = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/.exec(dateString) || [];
return new Date(Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hours), Number(minutes), Number(seconds)));
Expand Down
7 changes: 7 additions & 0 deletions src/api/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export class GlobalStorage extends Storage {
await this.set(SERVER_SETTINGS_CACHE_KEY(name), serverSettings);
}

async setServerSettingsCacheSpecific(name: string, newSettings: Partial<CachedServerSettings>) {
await this.set(SERVER_SETTINGS_CACHE_KEY(name), {
...this.getServerSettingsCache(name),
...newSettings
});
}

async deleteServerSettingsCache(name: string) {
await this.set(SERVER_SETTINGS_CACHE_KEY(name), undefined);
}
Expand Down
6 changes: 5 additions & 1 deletion src/languages/clle/clApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { window } from "vscode";
import { instance } from "../../instantiate";

import * as gencmdxml from "./gencmdxml";
import { GlobalStorage } from "../../api/Storage";

export async function init() {
const clComponentsInstalled = checkRequirements();
Expand Down Expand Up @@ -46,7 +47,10 @@ async function install() {
noLibList: true
});

if (createResult.code !== 0) {
if (createResult.code === 0) {
connection.remoteFeatures[`GENCMDXML.PGM`] = `GENCMDXML`;
await GlobalStorage.get().setServerSettingsCacheSpecific(connection.currentConnectionName, { remoteFeatures: connection.remoteFeatures });
} else {
throw new Error(`Failed to create GENCMDXML program.`);
}
}
3 changes: 3 additions & 0 deletions src/locale/ids/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const da: Locale = {
'size': 'Størrelse',
'modified': 'Ændret',
'owner': 'Ejer',
'type': 'Type',
'attribute': 'Attribut',
'created_by': 'Oprettet af',
// Sandbox:
'sandbox.input.user.title': `Bruger for server`,
'sandbox.input.user.prompt': `Indtast brugernavn for {0}`,
Expand Down
3 changes: 3 additions & 0 deletions src/locale/ids/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const en: Locale = {
'size': 'Size',
'modified': 'Modified',
'owner': 'Owner',
'type': 'Type',
'attribute': 'Attribute',
'created_by': 'Created by',
// Sandbox:
'sandbox.input.user.title': `User for server`,
'sandbox.input.user.prompt': `Enter username for {0}`,
Expand Down
3 changes: 3 additions & 0 deletions src/locale/ids/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const fr: Locale = {
'size': 'Taille',
'modified': 'Modifié',
'owner': 'Propriétaire',
'type': 'Type',
'attribute': 'Attribut',
'created_by': 'Créé par',
// Sandbox:
'sandbox.input.user.title': `Nom d'utilisateur`,
'sandbox.input.user.prompt': `Entrez le nom d'utilisateur pour {0}`,
Expand Down
5 changes: 5 additions & 0 deletions src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export interface IBMiObject extends QsysPath {
memberCount?: number
sourceLength?: number
CCSID?: number
size?: number
created?: Date
changed?: Date
created_by?: string
owner?: string
}

export interface IBMiMember {
Expand Down
16 changes: 13 additions & 3 deletions src/views/objectBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,18 @@ class ObjectBrowserObjectItem extends ObjectBrowserItem implements ObjectItem {
this.path = [object.library, object.name].join(`/`);
this.updateDescription();

this.contextValue = `object.${type.toLowerCase()}${object.attribute ? `.${object.attribute}` : ``}${this.isProtected() ? `_readonly` : ``}`;
this.tooltip = new vscode.MarkdownString(``);
this.contextValue = `object.${type.toLowerCase()}${object.attribute ? `.${object.attribute}` : ``}${isProtected(this.filter) ? `_readonly` : ``}`;
this.tooltip = new vscode.MarkdownString(Tools.generateTooltipHtmlTable(this.path, {
type: object.type,
attribute: object.attribute,
text: object.text,
size: object.size,
created: object.created?.toISOString().slice(0, 19).replace(`T`, ` `),
changed: object.changed?.toISOString().slice(0, 19).replace(`T`, ` `),
created_by: object.created_by,
owner: object.owner,
}));
this.tooltip.supportHtml = true;

this.resourceUri = vscode.Uri.from({
scheme: `object`,
Expand Down Expand Up @@ -636,7 +646,7 @@ export function initializeObjectBrowser(context: vscode.ExtensionContext) {
})

const copyMessages = Tools.parseMessages(copyResult.stderr);
if (copyMessages.messages.length && !copyMessages.findId(`CPF2869`)) {
if (copyResult.code !== 0 && copyMessages.messages.length && !(copyMessages.findId(`CPF2869`) && copyMessages.findId(`CPF2817`))) {
throw (copyResult.stderr)
}

Expand Down

0 comments on commit c3f1768

Please sign in to comment.