Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

export class TableColumnModel {
public defaultStyle(arg) {
if (arg === null) {
// don't leave style null
return {}; // or {'text-align': 'center'}, say.
} else if (typeof arg === 'string') {
// assume it is an alignment, for easy case
return {'text-align': arg};
}
return arg;
}

constructor(public title: string, public property: string, public thStyle?: any, public tdStyle?: any) {
this.title = title; // column heading
this.property = property; // data property name

// thStyle being optional, we don't have to update callers not specifying a thStyle
// this thStyle is applied to a column in each row of the table, in the thead, not the tbody
this.thStyle = this.defaultStyle(thStyle);

// tdStyle being optional, we don't have to update callers not specifying a tdStyle
// this tdStyle is applied to a column in each row of the table, in the tbody, not the thead
this.tdStyle = this.defaultStyle(tdStyle);
}
}

export class TableSettings {

// despite the generic name "table" this is a highly-specialized component.
// it ties in pagination, a fixed set of column types: checkbox, row[column], button[], link, img[], extImg.
// the TableColumnModel has been extended to handle alignment in the <th/> and <td/>
// It would be nice to allow pipes in the row columns. But by the time you do all this, you may as well just
// format each table separately, using copy/paste, instead of trying to make it all fit one master pattern.
//
pagination = true;
rowNumberDisplay = false;

buttonShow = false;
buttonNames: string[] = [''];

checkBoxesShow = false;

linkColumn = false;
linkProperty = '';

imgColumn = false;
imageColumnNames: string[] = [];
imageUrls: string[] = [];

imgCounterView = false;
imgProperty = '';

// Currently only one fixed "ext" column
extShow = false;
extCol: string;
// methods come after fields
imgTitle = (row: any, idx: number) => this.imageColumnNames[idx]; // Use imageColumnNames for title, or override it
extSrc = (row: any) => null as string; // convert a row into an icon URL
extTitle = (row: any) => null as string; // convert a row into a title. Here we don't know how

// Could have multiple columns, but then you have to take col into account
// xxxShow = false;
// xxxCols: string[] = [];
// xxxSrc: (row: any, col: number) => string = null; // convert a row into an icon Url
// xxxTitle: (row: any, col: number) => string = null; // convert a row into a title

// another idea is to depend on the sort-column
}