Skip to content

Commit

Permalink
Merge pull request #46 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.3.0
  • Loading branch information
antifree authored Jul 26, 2021
2 parents 8e6469d + aacb1bf commit 335bb0b
Showing 226 changed files with 8,356 additions and 1,024 deletions.
39 changes: 38 additions & 1 deletion EasyData.Samples.sln
Original file line number Diff line number Diff line change
@@ -7,7 +7,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPages.NetCore31", "samples\EasyDataBasicDemo.RazorPages.NetCore31\EasyDataBasicDemo.RazorPages.NetCore31.csproj", "{A7B1EF24-2DDF-4512-AF72-34102913BF78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyDataBasicDemo.MVC.Net5", "samples\EasyDataBasicDemo.MVC.Net5\EasyDataBasicDemo.MVC.Net5.csproj", "{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.MVC.Net5", "samples\EasyDataBasicDemo.MVC.Net5\EasyDataBasicDemo.MVC.Net5.csproj", "{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorAppServer.Net5", "samples\EasyDataBasicDemo.BlazorAppServer.Net5\EasyDataBasicDemo.BlazorAppServer.Net5.csproj", "{F75567B4-C067-46E3-8F2E-5E79CB95DF61}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EasyDataBasicDemo.BlazorWebAsm.Net5", "EasyDataBasicDemo.BlazorWebAsm.Net5", "{D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Server", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Server\EasyDataBasicDemo.BlazorWebAsm.Net5.Server.csproj", "{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Client", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Client\EasyDataBasicDemo.BlazorWebAsm.Net5.Client.csproj", "{47705E5D-F94B-4143-9457-4E67AC30FCA4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Shared", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Shared\EasyDataBasicDemo.BlazorWebAsm.Net5.Shared.csproj", "{6D213867-AC44-4789-8B30-C6C551ED30FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyDataBasicDemo.Angular.Net5", "samples\EasyDataBasicDemo.Angular.Net5\EasyDataBasicDemo.Angular.Net5.csproj", "{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,10 +39,35 @@ Global
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Release|Any CPU.Build.0 = Release|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Release|Any CPU.Build.0 = Release|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Release|Any CPU.Build.0 = Release|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Release|Any CPU.Build.0 = Release|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Release|Any CPU.Build.0 = Release|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
{47705E5D-F94B-4143-9457-4E67AC30FCA4} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
{6D213867-AC44-4789-8B30-C6C551ED30FA} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {15562A42-D965-4A8E-B708-CF2E36429B26}
EndGlobalSection
2 changes: 1 addition & 1 deletion easydata.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "EasyData.JS",
"version": "1.2.0",
"version": "1.3.0",
"description": "",
"scripts": {
"installall": "cd packs/core && npm install && cd ../ui && npm install && cd ../crud && npm install && cd ../.. && npm run linkall",
203 changes: 203 additions & 0 deletions easydata.js/packs/core/src/data/aggr_calculator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
export interface CalculateOptions {
maxLevel?: number;
resultsObtained?(level?: number);
}

export interface AggregatesCalculator {
getAggrContainer(): AggregatesContainer;
calculate(options?: CalculateOptions): Promise<void>;
}

export interface GroupKeys {
[key: string]: any;
}

export interface GroupValues {
[key: string]: any;
}

type LevelData = Map<string, GroupValues>;

export interface AggregatesContainer {
setAggregates(level: number, data: LevelData);
getAggregates(level: number, key: GroupKeys): Promise<GroupValues>;
}

export interface GroupSettings {
name?: string;
columns?: string[],
from?: number;
to?: number;
}

export interface GroupData {
name?: string;
columns: Array<string>;
aggregates: Array<AggregateInfo>;
}

export type AggregateInfo = { colId: string, funcId: string };

export interface AggregationColumnStore {
getColumnIds(from: number, to?: number): string[];
validateColumns(colIds: string[]): boolean;
validateAggregate(colId: string, funcId: string): boolean;
}

/**
* Represents AggregationSettings structure prepared for saving into a storage.
*/
export interface AggregationData {
groups: Array<GroupData>,
ugt: boolean;
uc: boolean;
aggregates: Array<AggregateInfo>;
}

/**
* Defines aggregations settings for the current context.
* Group, aggregate columns, grand totals, etc.
*/
export class AggregationSettings {

public readonly COUNT_FIELD_NAME: string;

private aggregates: Array<AggregateInfo> = []

private groups: GroupData[] = [];

private useGrandTotals = false;

private useCounts = false;

constructor(private colStore: AggregationColumnStore) {
this.COUNT_FIELD_NAME = '__count';
}

public addGroup(settings: GroupSettings) {
const cols = settings.columns || this.colStore.getColumnIds(settings.from, settings.to);
if (!this.colStore.validateColumns(cols) || !this.areUnusedColumns(cols))
throw "Invalid group of columns";

this.groups.push({ columns: cols, aggregates: null, ...settings })
return this;
}

public addAggregateColumn(colIndexOrId: number | string, funcId: string) {
const colId = typeof colIndexOrId == 'string'
? colIndexOrId
: this.colStore.getColumnIds(colIndexOrId, colIndexOrId)[0];

if (!this.areUnusedColumns([colId]) || !this.colStore.validateAggregate(colId, funcId))
throw "Invalid aggregate function for such column";

this.aggregates.push({ colId, funcId });
return this;
}

public addGrandTotals() {
this.useGrandTotals = true;
return this;
}

public addCounts() {
this.useCounts = true;
return this;
}

public getGroups() {
let cols = [];
const mappedGrops = this.groups.map(grp => {
cols = cols.concat(grp.columns);
return {
...grp,
columns: Array.from(cols),
aggregates: Array.from(this.aggregates)
};
});

return mappedGrops;
}

public getInternalGroups() {
return this.groups;
}

public lastGroup() {
const groups = this.getGroups();
return groups[groups.length - 1];
}

public getAggregates(): Array<AggregateInfo> {
return this.aggregates;
}

public hasAggregates(): boolean {
return this.aggregates.length > 0;
}

public hasGroups(): boolean {
return this.groups.length > 0;
}

public hasGrandTotals(): boolean {
return this.useGrandTotals;
}

public hasCounts(): boolean {
return this.useCounts;
}

public isEmpty(): boolean {
return !(this.hasAggregates() || this.hasGroups() ||
this.hasAggregates() || this.hasCounts());
}

public drop() {
this.groups = [];
this.aggregates = [];
this.useGrandTotals = false;
this.useCounts = false;
}

private areUnusedColumns(cols: string[]): boolean {
for (const group of this.groups) {
const interCols = group.columns
.filter(c => cols.indexOf(c) >= 0);

if (interCols.length > 0)
return false;
}

for(const aggr of this.aggregates) {
if (cols.indexOf(aggr.colId) >= 0)
return false;
}

return true;
}

public saveToData(): AggregationData {
return {
groups: Array.from(this.groups),
ugt: this.useGrandTotals,
uc: this.useCounts,
aggregates: Array.from(this.aggregates)
}
}

public loadFromData(data: AggregationData) {
if (data) {
this.useGrandTotals = data.ugt || false;
this.useCounts = data.uc || false;

if (data.groups) {
this.groups = Array.from(data.groups);
}

if (data.aggregates) {
this.aggregates = Array.from(data.aggregates);
}
}
}
}
4 changes: 4 additions & 0 deletions easydata.js/packs/core/src/data/data_column.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export interface DataColumnDescriptor {
label: string;
isAggr?: boolean;
dfmt?: string;
gfct?: string;
style?: DataColumnStyle;
}

@@ -38,6 +39,8 @@ export class DataColumn {

public displayFormat?: string;

public groupFooterColumnTemplate?: string;

public style?: DataColumnStyle;

constructor(desc: DataColumnDescriptor) {
@@ -56,6 +59,7 @@ export class DataColumn {
this.originAttrId = desc.originAttrId;
this.isAggr = desc.isAggr || false;
this.displayFormat = desc.dfmt;
this.groupFooterColumnTemplate = desc.gfct;
this.style = desc.style || {};
}
}
Loading

0 comments on commit 335bb0b

Please sign in to comment.