File

lib/examples/src/example-report-preparator/example-report-preparator-report-store.service.ts

Extends

ReportStore

Index

Properties
Methods

Constructor

constructor()

Methods

Protected addConfig
addConfig(config: ConfigOf<I>)
Inherited from ItemStore
Defined in ItemStore:201
Parameters :
Name Type Optional
config ConfigOf<I> No
Returns : I
Protected addItem
addItem(item: I)
Inherited from ItemStore
Defined in ItemStore:211
Parameters :
Name Type Optional
item I No
Returns : I
Protected addUpdateSubscription
addUpdateSubscription(item: I)
Inherited from ItemStore
Defined in ItemStore:148
Parameters :
Name Type Optional
item I No
Returns : void
Public Async get
get(id: string)
Inherited from ItemStore
Defined in ItemStore:251
Parameters :
Name Type Optional
id string No
Returns : Promise<I | null>
Protected getIdentifyItemFn
getIdentifyItemFn(identifyItemBy: undefined | string | )
Inherited from ItemStore
Defined in ItemStore:167
Parameters :
Name Type Optional
identifyItemBy undefined | string | No
Returns : string
Protected Async init
init(config: ItemStoreConfig<I>)
Inherited from ItemStore
Defined in ItemStore:132
Parameters :
Name Type Optional
config ItemStoreConfig<I> No
Returns : Promise<void>
Protected removeItem
removeItem(item: I)
Inherited from ItemStore
Defined in ItemStore:227
Parameters :
Name Type Optional
item I No
Returns : I
Protected removeUpdateSubscription
removeUpdateSubscription(item: I)
Inherited from ItemStore
Defined in ItemStore:157
Parameters :
Name Type Optional
item I No
Returns : void
Protected Async restoreFromStorage
restoreFromStorage()
Inherited from ItemStore
Defined in ItemStore:193
Returns : Promise<any>
Protected Async storeAll
storeAll()
Inherited from ItemStore
Defined in ItemStore:244
Returns : Promise<void>

Properties

Public Readonly name
Type : string
Default value : "EXAMPLE_REPORT_PREPARATOR.REPORT_STORE_NAME"
Inherited from ItemStore
Defined in ItemStore:16
Protected _map
Default value : new Map<string,I>()
Inherited from ItemStore
Defined in ItemStore:90
Public addition$
Default value : this.additionSubject.asObservable()
Inherited from ItemStore
Defined in ItemStore:113
Protected additionSubject
Default value : new Subject<I>()
Inherited from ItemStore
Defined in ItemStore:107
Public change$
Default value : merge(this.addition$, this.removal$, this.update$) .pipe( share() )
Inherited from ItemStore
Defined in ItemStore:118
Protected identifyItem
Type : function
Inherited from ItemStore
Defined in ItemStore:104
Public itemClass
Inherited from ItemStore
Defined in ItemStore:101
Public ready
Type : Promise<void>
Inherited from ItemStore
Defined in ItemStore:111
Public removal$
Default value : this.removalSubject.asObservable()
Inherited from ItemStore
Defined in ItemStore:114
Protected removalSubject
Default value : new Subject<I>()
Inherited from ItemStore
Defined in ItemStore:108
Protected storage
Type : ItemStorage<I>
Inherited from ItemStore
Defined in ItemStore:102
Public update$
Default value : this.updateSubject.asObservable()
Inherited from ItemStore
Defined in ItemStore:115
Protected updateSubject
Default value : new Subject<I>()
Inherited from ItemStore
Defined in ItemStore:109
Protected updateSubscriptions
Default value : new Map<string, Subscription>()
Inherited from ItemStore
Defined in ItemStore:97
import  {   Injectable          }   from '@angular/core'

import  {
				ReportConfig,
				ReportStore,
				EntryConfig,
				DateString,
				Schedule

		}                           from '@rcc/core'


@Injectable()
export class ExampleReportPreparatorReportStore extends ReportStore {

		public readonly name = "EXAMPLE_REPORT_PREPARATOR.REPORT_STORE_NAME"

		constructor(){
				super(staticStorage)
		}
}

function randomValue(last = 1): number {

	if( Math.random() < 0.25) 	return 1
	if( Math.random() < 0.3) 	return last

	if(last == 0) return Math.random() < 0.8 ? 1 :3
	if(last == 1) return Math.random() < 0.8 ? 2 :0
	if(last == 2) return Math.random() < 0.8 ? 3 :1
	if(last == 3) return Math.random() < 0.8 ? 2 :1
}

function getValueRun(length: number): number[]{

	const result = new Array<number>()

	let last_value = Math.floor( Math.random()*2 )+1

	for(let i = 0; i<length; i++){
		result[i] = last_value = randomValue(last_value)
	}

	return result
}

function getBooleanRun(length: number): boolean[] {
	return new Array(length).fill(false).map( () => Math.random() < 0.5 )
}

const staticStorage = { getAll: () => Promise.resolve([config]) }
const now			= Schedule.getIsoStringWithTimezone()
const value_runs	= Array(3).fill(0).map( () => getValueRun(200) )
const boolean_run	= getBooleanRun(200)

const endDate		= DateString.today()
const startDate		= DateString.before(endDate, 28)

const config:  ReportConfig = [
		"Example Report (preparators)",
		now,
		DateString.getRange(startDate, endDate).map(
			(dateStr,i)	=>	[
								...[0,1,2].map( num => [
									`physical-state-00${num}`,
									value_runs[num][i],
									now,
									null,
									dateStr
								] as EntryConfig),

								[
									`example-breakfast`,
									boolean_run[i],
									now,
									null,
									dateStr
								] as EntryConfig
							]
		)
		.flat()
		.filter( () => Math.random() > 0.12)
]

results matching ""

    No results matching ""