Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltip for objects in object browser #1872

Merged
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
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
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
12 changes: 11 additions & 1 deletion src/views/objectBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,17 @@ class ObjectBrowserObjectItem extends ObjectBrowserItem implements ObjectItem {
this.updateDescription();

this.contextValue = `object.${type.toLowerCase()}${object.attribute ? `.${object.attribute}` : ``}${isProtected(this.filter) ? `_readonly` : ``}`;
this.tooltip = new vscode.MarkdownString(``);
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