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.

667 lines
15 KiB

3 years ago
class globalFunc {
3 years ago
DataCheck(arg1, arg2) {
3 years ago
var iarg1 = arg1
if (moment(iarg1).isValid()) {iarg1 = arg1.toString()}
var iarg2 = arg2
if (moment(iarg2).isValid()) {iarg2 = arg2.toString()}
3 years ago
if (!Array.isArray(iarg2) && !Array.isArray(iarg1)) {
var resultdc = iarg1.search(new RegExp(iarg2, "i")) > -1
3 years ago
} else if (!Array.isArray(iarg1)) {
3 years ago
let tempresult = false
for (let i = 0; i < iarg2.length; i++) {
tempresult = tempresult || iarg1.search(new RegExp(iarg2[i], "i")) > -1
}
var resultdc = tempresult
} else if (!Array.isArray(iarg2)) {
let tempresult = false
for (let i = 0; i < iarg1.length; i++) {
tempresult = tempresult || iarg1[i].search(new RegExp(iarg2, "i")) > -1
}
var resultdc = tempresult
3 years ago
} else {
let tempresult = false
3 years ago
for (let i = 0; i < arg2.length; i++) {
for (let j = 0; j < arg1.length; j++) {
tempresult = tempresult || iarg1[j].search(new RegExp(iarg2[i], "i")) > -1
}
3 years ago
}
var resultdc = tempresult
}
return resultdc
}
3 years ago
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 {
3 years ago
result = result && this.DataCheck(pProp, iarray[i])
3 years ago
}
} 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 {
3 years ago
result = result && this.DataCheck(pProp, iarray[i])
3 years ago
}
} 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!')
}
3 years ago
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;
3 years ago
case 'Server':
switch(TableT) {
case 'overview':
TempData = ["Name", "Provider", "Service", "Location", "IP Address"]
break;
case 'technical':
TempData = ["Name", "OS", "CPU", "RAM", "Disk size", "Disk type", "Bandwidth", "Speed"]
break;
case 'usage':
TempData = ["Name", "Disk size", "Used space", "Date updated"]
break;
}
break;
case 'Recipe':
3 years ago
TempData = ["Name", "Category", "Cuisine", "Cooking time", "Rating (1-5)"]
3 years ago
break;
3 years ago
}
return TempData
}
GetTableMap(DataT, TableT, p) {
let TempData = [p.file.link]
switch(DataT) {
case 'Investment':
switch(TableT) {
case 'overview':
3 years ago
TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "style"), this.GetPoint(p, DataT, "stage"), this.GetPoint(p, "main", "tag")]
3 years ago
break;
case 'trading':
3 years ago
TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "tradingd"), this.GetPoint(p, DataT, "tradingp")]
3 years ago
break;
}
break;
case 'Source':
3 years ago
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")]
3 years ago
break;
case 'Place':
switch(TableT) {
case 'Restaurant':
case 'Brunch':
case 'Hotel':
case 'Bar':
3 years ago
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")]
3 years ago
break;
case 'Sport':
3 years ago
TempData = [p.file.link, this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")]
3 years ago
break;
case 'Café':
3 years ago
TempData = [p.file.link, this.GetPoint(p, DataT, "subtype"), this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")]
3 years ago
break;
}
break;
case 'Product':
3 years ago
TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "link"), this.GetPoint(p, DataT, "value"), this.GetPoint(p, "main", "tag")]
3 years ago
break;
3 years ago
case 'Server':
switch(TableT) {
case 'overview':
TempData = [p.file.link, this.GetPoint(p, DataT, "host"), this.GetPoint(p, DataT, "subdomain"), this.GetPoint(p, DataT, "dom"), this.GetPoint(p, DataT, "ipv4")]
break;
case 'technical':
TempData = [p.file.link, this.GetPoint(p, DataT, "os"), this.GetPoint(p, DataT, "cpu"), this.GetPoint(p, DataT, "ram"), this.GetPoint(p, DataT, "capa"), this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "bw"), this.GetPoint(p, DataT, "speed")]
break;
case 'usage':
TempData = [p.file.link, this.GetPoint(p, DataT, "capa"), this.GetPoint(p, DataT, "usedspace"), this.GetPoint(p, DataT, "timestamp")]
break;
}
break;
case 'Recipe':
TempData = [p.file.link, this.GetPoint(p, DataT, "category"), this.GetPoint(p, DataT, "collection"), this.GetPoint(p, DataT, "cooking") + " min", this.GetPoint(p, DataT, "rating")]
break;
3 years ago
}
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':
3 years ago
case 'disktype':
3 years ago
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;
3 years ago
case 'host':
result = this.GetPoint(pobj, DocType, "host")
break;
case 'subdomain':
result = this.GetPoint(pobj, DocType, "subdomain")
break;
case 'OS':
result = this.GetPoint(pobj, DocType, "os")
break;
case 'CPU':
result = this.GetPoint(pobj, DocType, "cpu")
break;
case 'RAM':
result = this.GetPoint(pobj, DocType, "ram")
break;
case 'Capa':
result = this.GetPoint(pobj, DocType, "capa")
break;
case 'BW':
result = this.GetPoint(pobj, DocType, "bw")
break;
case 'speed':
result = this.GetPoint(pobj, DocType, "speed")
break;
case 'dom':
result = this.GetPoint(pobj, DocType, "dom")
break;
case 'course':
result = this.GetPoint(pobj, DocType, "course")
break;
case 'category':
result = this.GetPoint(pobj, DocType, "category")
break;
case 'cuisine':
result = this.GetPoint(pobj, DocType, "collection")
break;
case 'ingredient':
result = this.GetPoint(pobj, DocType, "ingredient")
break;
case 'isfavourite':
result = this.GetPoint(pobj, DocType, "isfavourite")
break;
case 'rating':
result = this.GetPoint(pobj, DocType, "rating")
break;
3 years ago
}
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':
3 years ago
result = pobj.Trading.PDate
3 years ago
break;
case 'tradingp':
3 years ago
result = pobj.Trading.PPrice
3 years ago
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;
3 years ago
case 'Recipe':
switch(dPoint) {
case 'course':
result = pobj.Recipe.Courses
break;
case 'category':
result = pobj.Recipe.Categories
break;
case 'collection':
result = pobj.Recipe.Collections
break;
case 'source':
result = pobj.Recipe.Source
break;
case 'preparation':
result = pobj.Recipe.PreparationTime
break;
case 'cooking':
result = pobj.Recipe.CookingTime
break;
case 'ingredient':
result = pobj.Ingredients
break;
case 'isfavourite':
result = pobj.Meta.IsFavourite
break;
case 'rating':
result = pobj.Meta.Rating
break;
}
break;
3 years ago
}
return result
}
}