You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

533 lines
12 KiB

class globalFunc {
PDataCheck(arg1, arg2) {
var iarg1 = arg1
if (moment(iarg1).isValid()) {iarg1 = arg1.toString()}
var iarg2 = arg2
if (moment(iarg2).isValid()) {iarg2 = arg2.toString()}
if (!Array.isArray(iarg2)) {
var resultdc = iarg1.contains(iarg2)
} else if (!Array.isArray(iarg1)) {
var resultdc = iarg2.contains(iarg1)
} else {
let count = iarg2.length
let tempresult = false
for (let i = 0; i < count; i++) {
tempresult = tempresult || iarg1.contains(iarg2[i])
}
var resultdc = tempresult
}
return resultdc
}
BuildList(arg1, construct) {
let ilength = arg1.length
let TempS = ""
for (let i = 0; i < ilength; i++) {
if (Boolean(arg1[i])) {
if (TempS == "") {
TempS = arg1[i]
} else {
TempS = TempS + construct + arg1[i]
}
}
}
return TempS
}
Get1stArg(arg3) {
if (!Array.isArray(arg3)) {
return arg3
} else {
return arg3[0]
}
}
topLevelFilter(pobj, DocType, subType) {
let result = true
let folderExcl = (DocType == 'Source') ? '00.01' : '00.';
result = !pobj.file.path.contains(folderExcl) && this.GetPoint(pobj, "main", "type") !== undefined && this.GetPoint(pobj, "main", "type") !== null && this.GetPoint(pobj, "main", "type").contains(DocType)
if (Boolean(subType)) {
result = result && this.GetPoint(pobj, DocType, "type") !== undefined && this.GetPoint(pobj, DocType, "type") !== null && this.GetPoint(pobj, DocType, "type").contains(subType)
}
return result
}
IsInSearch(pobj, DocType, darray, iarray) {
let ilength = iarray.length;
let result = true
for (let i = 0; i < iarray.length; i++) {
if (iarray[i] == undefined || darray[i] == undefined) {result = result && true} else {
switch(darray[i]) {
case 'readingd':
if (iarray[i] == true || iarray[i] == false) {result = result && (Boolean(this.GetpProp(pobj, DocType, darray[i])) == iarray[i])} else {
if (Boolean(iarray[i])) {
let pProp = this.GetpProp(pobj, DocType, darray[i])
if (!Boolean(pProp)) { result = result && false } else {
result = result && this.PDataCheck(pProp, iarray[i])
}
} else {result = result && true}
}
break;
default:
if (Boolean(iarray[i])) {
let pProp = this.GetpProp(pobj, DocType, darray[i])
if (!Boolean(pProp)) { result = result && false } else {
result = result && this.PDataCheck(pProp, iarray[i])
}
} else {result = result && true}
break;
}
}
}
return result
}
getTable(dv, DocType, darray, iarray, tabletype) {
// let tablet = (darray.contains('tabletype')) ? iarray[0] : 0;
let page = dv.pages()
.filter(p => p && this.topLevelFilter(p, DocType, 0))
.where(p => p && this.IsInSearch(p, DocType, darray, iarray))
if (page.length === 0) {
return this.EmptyQueryMessage()
}
dv.table(this.GetTableHeaders(DocType, tabletype), page
.sort(p => p.file.name, `asc`)
.map(p => this.GetTableMap(DocType, tabletype,p)));
}
EmptyQueryMessage() {
return dv.el('b', '⚠️ Warning:\nNo result matching your query!')
}
GetTableHeaders(DataT, TableT) {
let TempData = ["Name"]
switch(DataT) {
case 'Investment':
switch(TableT) {
case 'overview':
TempData = ["Name", "Currency", "Style", "Stage", "Themes"]
break;
case 'trading':
TempData = ["Name", "Currency", "Trading date", "Trading price"]
break;
}
break;
case 'Source':
TempData = ["Title", "Author", "Published date", "Language", "Themes", "Date read"]
break;
case 'Place':
switch(TableT) {
case 'Restaurant':
case 'Brunch':
TempData = ["Name", "Style", "Cuisine", "Phone", "Email", "Website"]
break;
case 'Hotel':
case 'Bar':
TempData = ["Name", "Type", "Influence", "Phone", "Email", "Website"]
break;
case 'Sport':
TempData = ["Name", "Phone", "Email", "Website"]
break;
case 'Café':
TempData = ["Name", "Style", "Phone", "Email", "Website"]
break;
}
break;
case 'Product':
TempData = ["Name", "Category", "Link", "Value", "Themes"]
break;
}
return TempData
}
GetTableMap(DataT, TableT, p) {
let TempData = [p.file.link]
switch(DataT) {
case 'Investment':
switch(TableT) {
case 'overview':
TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "style"), this.GetPoint(p, DataT, "stage"), this.GetPoint(p, "main", "tag")]
break;
case 'trading':
TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "tradingd"), this.GetPoint(p, DataT, "tradingp")]
break;
}
break;
case 'Source':
TempData = [p.file.link, this.GetPoint(p, DataT, "author"), this.GetPoint(p, DataT, "published"), this.GetPoint(p, DataT, "lang"), this.GetPoint(p, "main", "tag"), this.GetPoint(p, DataT, "read")]
break;
case 'Place':
switch(TableT) {
case 'Restaurant':
case 'Brunch':
case 'Hotel':
case 'Bar':
TempData = [p.file.link, this.GetPoint(p, DataT, "subtype"), this.GetPoint(p, DataT, "style"), this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")]
break;
case 'Sport':
TempData = [p.file.link, this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")]
break;
case 'Café':
TempData = [p.file.link, this.GetPoint(p, DataT, "subtype"), this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")]
break;
}
break;
case 'Product':
TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "link"), this.GetPoint(p, DataT, "value"), this.GetPoint(p, "main", "tag")]
break;
}
return TempData
}
GetpProp(pobj, DocType, dPoint) {
let result = null
switch(dPoint) {
case 'dateadded':
result = this.GetPoint(pobj, "main", "date")
break;
case 'theme':
result = this.GetPoint(pobj, "main", "tag")
break;
case 'invtype':
case 'sourcetype':
case 'placetype':
case 'prodtype':
result = this.GetPoint(pobj, DocType, "type")
break;
case 'style':
result = this.GetPoint(pobj, DocType, "style")
break;
case 'stage':
result = this.GetPoint(pobj, DocType, "stage")
break;
case 'ccy':
result = this.GetPoint(pobj, DocType, "ccy")
break;
case 'tradingd':
result = this.GetPoint(pobj, DocType, "tradingd")
break;
case 'tradingp':
result = this.GetPoint(pobj, DocType, "tradingp")
break;
case 'language':
result = this.GetPoint(pobj, DocType, "lang")
break;
case 'author':
result = this.GetPoint(pobj, DocType, "author")
break;
case 'publicationd':
result = this.GetPoint(pobj, DocType, "published")
break;
case 'readingd':
result = this.GetPoint(pobj, DocType, "read")
break;
case 'country':
result = this.GetPoint(pobj, DocType, "country")
break;
case 'area':
result = this.GetPoint(pobj, DocType, "location")
break;
case 'ambiance':
result = this.GetPoint(pobj, DocType, "subtype")
break;
case 'status':
result = this.GetPoint(pobj, DocType, "status")
break;
case 'prodvalue':
result = this.GetPoint(pobj, DocType, "value")
break;
}
return result
}
GetPoint(pobj, fstline, dPoint) {
let result = null
switch(fstline) {
case 'main':
switch(dPoint) {
case 'alias':
result = pobj.Alias
break;
case 'tag':
result = pobj.Tag
break;
case 'date':
result = pobj.Date
break;
case 'type':
result = pobj.DocType
break;
case 'hierarchy':
result = pobj.Hierarchy
break;
case 'location':
result = pobj.location
break;
case 'meatatable':
result = pobj.CollapseMetaTable
break;
case 'timestamp':
result = pobj.TimeStamp
break;
}
break;
case 'Investment':
switch(dPoint) {
case 'style':
result = pobj.Investment.Style
break;
case 'stage':
result = pobj.Investment.Stage
break;
case 'ccy':
result = pobj.Investment.Ccy
break;
case 'type':
result = pobj.Investment.Type
break;
case 'tradingd':
result = pobj.Trading.PDate
break;
case 'tradingp':
result = pobj.Trading.PPrice
break;
}
break;
case 'Place':
switch(dPoint) {
case 'style':
result = pobj.Place.Style
break;
case 'subtype':
result = pobj.Place.SubType
break;
case 'location':
result = pobj.Place.Location
break;
case 'type':
result = pobj.Place.Type
break;
case 'country':
result = pobj.Place.Country
break;
case 'status':
result = pobj.Place.Status
break;
case 'phone':
result = pobj.Phone
break;
case 'email':
result = pobj.Email
break;
case 'website':
result = pobj.Website
break;
}
break;
case 'Source':
switch(dPoint) {
case 'author':
result = pobj.Source.Author
break;
case 'lang':
result = pobj.Source.Language
break;
case 'published':
result = pobj.Source.Published
break;
case 'type':
result = pobj.Source.Type
break;
case 'link':
result = pobj.Source.Link
break;
case 'read':
result = pobj.Source.Read
break;
}
break;
case 'Product':
switch(dPoint) {
case 'value':
result = pobj.Product.Value
break;
case 'type':
result = pobj.Product.Type
break;
case 'link':
result = pobj.Product.Link
break;
}
break;
case 'Server':
switch(dPoint) {
case 'cpu':
result = pobj.Performance.CPU
break;
case 'ram':
result = pobj.Performance.RAM
break;
case 'bw':
result = pobj.Performance.Bandwidth
break;
case 'speed':
result = pobj.Performance.Speed
break;
case 'os':
result = pobj.Characteristics.OS
break;
case 'dom':
result = pobj.Characteristics.Domiciliation
break;
case 'ipv4':
result = pobj.Characteristics.IPv4
break;
case 'hostname':
result = pobj.Characteristics.Hostname
break;
case 'host':
result = pobj.Characteristics.Host
break;
case 'subdomain':
result = pobj.Characteristics.SubDomain
break;
case 'capa':
result = pobj.Disk.Capa
break;
case 'type':
result = pobj.Disk.Type
break;
case 'usedspace':
result = pobj.Disk.UsedSpace
break;
case 'timestamp':
result = pobj.Disk.TimeStamp
break;
}
break;
case 'Task':
switch(dPoint) {
case 'priority':
result = pobj.Task.Priority
break;
case 'status':
result = pobj.Task.Status
break;
case 'startdate':
result = pobj.Task.StartDate
break;
case 'duedate':
result = pobj.Task.DueDate
break;
case 'nextreviewdate':
result = pobj.Task.NextReviewDate
break;
}
break;
case 'Travel':
switch(dPoint) {
case 'country':
result = pobj.Travel.Country
break;
case 'duration':
result = pobj.Travel.Duration
break;
case 'budget':
result = pobj.Travel.Budget
break;
case 'type':
result = pobj.Travel.Type
break;
case 'lbestseason':
result = pobj.Travel.BestSeason
break;
case 'departuredate':
result = pobj.Travel.DepartureDate
break;
}
break;
}
return result
}
}