@osovitny/anatoly 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/ng-package.json +7 -0
  2. package/package.json +2 -13
  3. package/src/lib/billing/billing.module.ts +62 -0
  4. package/src/lib/billing/components/buyaccess/buyaccess-button.component.html +15 -0
  5. package/src/lib/billing/components/buyaccess/buyaccess-button.component.ts +70 -0
  6. package/src/lib/billing/components/subscriptions/subscribe-plan-button.component.html +21 -0
  7. package/src/lib/billing/components/subscriptions/subscribe-plan-button.component.ts +60 -0
  8. package/src/lib/billing/components/subscriptions/upgrade-plan-button.component.html +3 -0
  9. package/src/lib/billing/components/subscriptions/upgrade-plan-button.component.ts +47 -0
  10. package/{lib/billing/index.d.ts → src/lib/billing/index.ts} +6 -1
  11. package/src/lib/billing/services/base-billing-api.service.ts +56 -0
  12. package/src/lib/core/consts.ts +7 -0
  13. package/src/lib/core/core.module.ts +45 -0
  14. package/{lib/core/index.d.ts → src/lib/core/index.ts} +6 -1
  15. package/src/lib/core/services/appcontext.service.ts +81 -0
  16. package/src/lib/core/services/base-api.service.ts +87 -0
  17. package/src/lib/core/services/base-go.service.ts +33 -0
  18. package/src/lib/core/services/base-gridedit.service.ts +124 -0
  19. package/src/lib/identity/components/signin-button.component.html +1 -0
  20. package/src/lib/identity/components/signin-button.component.ts +27 -0
  21. package/src/lib/identity/components/signout-button.component.html +1 -0
  22. package/src/lib/identity/components/signout-button.component.ts +27 -0
  23. package/src/lib/identity/components/signup-button.component.html +1 -0
  24. package/src/lib/identity/components/signup-button.component.ts +28 -0
  25. package/src/lib/identity/identity.module.ts +41 -0
  26. package/{lib/identity/index.d.ts → src/lib/identity/index.ts} +4 -1
  27. package/src/lib/ui/components/base-edit.component.ts +77 -0
  28. package/src/lib/ui/components/base.component.ts +45 -0
  29. package/src/lib/ui/components/content-header/content-header.component.html +4 -0
  30. package/src/lib/ui/components/content-header/content-header.component.ts +32 -0
  31. package/src/lib/ui/components/html-editor/base-html-editor.component.ts +97 -0
  32. package/src/lib/ui/components/html-editor/forms-html-editor.component.html +14 -0
  33. package/src/lib/ui/components/html-editor/forms-html-editor.component.ts +35 -0
  34. package/src/lib/ui/components/html-editor/html-editor.component.html +6 -0
  35. package/src/lib/ui/components/html-editor/html-editor.component.ts +51 -0
  36. package/src/lib/ui/components/html-editor/html-editor.defaultoptions.ts +38 -0
  37. package/src/lib/ui/components/validation/form-validation-summary.component.html +4 -0
  38. package/src/lib/ui/components/validation/form-validation-summary.component.ts +36 -0
  39. package/src/lib/ui/components/validation/item-validation-summary.component.html +5 -0
  40. package/src/lib/ui/components/validation/item-validation-summary.component.ts +32 -0
  41. package/src/lib/ui/components/validation/validation-summary.component.ts +74 -0
  42. package/src/lib/ui/index.js +13 -0
  43. package/src/lib/ui/index.js.map +1 -0
  44. package/{lib/ui/index.d.ts → src/lib/ui/index.ts} +7 -1
  45. package/src/lib/ui/ui.module.ts +83 -0
  46. package/{public-api.d.ts → src/public-api.ts} +4 -4
  47. package/tsconfig.lib.json +32 -0
  48. package/tsconfig.lib.prod.json +6 -0
  49. package/tslint.json +17 -0
  50. package/typings/osovitny-ui/index.d.ts +24 -0
  51. package/bundles/osovitny-anatoly.umd.js +0 -1434
  52. package/bundles/osovitny-anatoly.umd.js.map +0 -1
  53. package/bundles/osovitny-anatoly.umd.min.js +0 -16
  54. package/bundles/osovitny-anatoly.umd.min.js.map +0 -1
  55. package/esm2015/lib/billing/billing.module.js +0 -60
  56. package/esm2015/lib/billing/components/buyaccess/buyaccess-button.component.js +0 -73
  57. package/esm2015/lib/billing/components/subscriptions/subscribe-plan-button.component.js +0 -63
  58. package/esm2015/lib/billing/components/subscriptions/upgrade-plan-button.component.js +0 -55
  59. package/esm2015/lib/billing/index.js +0 -9
  60. package/esm2015/lib/billing/services/base-billing-api.service.js +0 -53
  61. package/esm2015/lib/core/consts.js +0 -11
  62. package/esm2015/lib/core/core.module.js +0 -45
  63. package/esm2015/lib/core/index.js +0 -9
  64. package/esm2015/lib/core/services/appcontext.service.js +0 -72
  65. package/esm2015/lib/core/services/base-api.service.js +0 -71
  66. package/esm2015/lib/core/services/base-go.service.js +0 -36
  67. package/esm2015/lib/core/services/base-gridedit.service.js +0 -98
  68. package/esm2015/lib/identity/components/signin-button.component.js +0 -30
  69. package/esm2015/lib/identity/components/signout-button.component.js +0 -30
  70. package/esm2015/lib/identity/components/signup-button.component.js +0 -31
  71. package/esm2015/lib/identity/identity.module.js +0 -41
  72. package/esm2015/lib/identity/index.js +0 -7
  73. package/esm2015/lib/ui/components/base-edit.component.js +0 -63
  74. package/esm2015/lib/ui/components/base.component.js +0 -37
  75. package/esm2015/lib/ui/components/content-header/content-header.component.js +0 -35
  76. package/esm2015/lib/ui/components/html-editor/html-editor.component.js +0 -121
  77. package/esm2015/lib/ui/components/html-editor/html-editor.consts.js +0 -47
  78. package/esm2015/lib/ui/components/validation/form-validation-summary.component.js +0 -39
  79. package/esm2015/lib/ui/components/validation/item-validation-summary.component.js +0 -37
  80. package/esm2015/lib/ui/components/validation/validation-summary.component.js +0 -60
  81. package/esm2015/lib/ui/index.js +0 -12
  82. package/esm2015/lib/ui/ui.module.js +0 -74
  83. package/esm2015/osovitny-anatoly.js +0 -5
  84. package/esm2015/public-api.js +0 -5
  85. package/esm5/lib/billing/billing.module.js +0 -63
  86. package/esm5/lib/billing/components/buyaccess/buyaccess-button.component.js +0 -75
  87. package/esm5/lib/billing/components/subscriptions/subscribe-plan-button.component.js +0 -65
  88. package/esm5/lib/billing/components/subscriptions/upgrade-plan-button.component.js +0 -56
  89. package/esm5/lib/billing/index.js +0 -9
  90. package/esm5/lib/billing/services/base-billing-api.service.js +0 -56
  91. package/esm5/lib/core/consts.js +0 -11
  92. package/esm5/lib/core/core.module.js +0 -48
  93. package/esm5/lib/core/index.js +0 -9
  94. package/esm5/lib/core/services/appcontext.service.js +0 -76
  95. package/esm5/lib/core/services/base-api.service.js +0 -72
  96. package/esm5/lib/core/services/base-go.service.js +0 -37
  97. package/esm5/lib/core/services/base-gridedit.service.js +0 -104
  98. package/esm5/lib/identity/components/signin-button.component.js +0 -32
  99. package/esm5/lib/identity/components/signout-button.component.js +0 -32
  100. package/esm5/lib/identity/components/signup-button.component.js +0 -32
  101. package/esm5/lib/identity/identity.module.js +0 -44
  102. package/esm5/lib/identity/index.js +0 -7
  103. package/esm5/lib/ui/components/base-edit.component.js +0 -67
  104. package/esm5/lib/ui/components/base.component.js +0 -39
  105. package/esm5/lib/ui/components/content-header/content-header.component.js +0 -38
  106. package/esm5/lib/ui/components/html-editor/html-editor.component.js +0 -124
  107. package/esm5/lib/ui/components/html-editor/html-editor.consts.js +0 -47
  108. package/esm5/lib/ui/components/validation/form-validation-summary.component.js +0 -42
  109. package/esm5/lib/ui/components/validation/item-validation-summary.component.js +0 -39
  110. package/esm5/lib/ui/components/validation/validation-summary.component.js +0 -65
  111. package/esm5/lib/ui/index.js +0 -12
  112. package/esm5/lib/ui/ui.module.js +0 -77
  113. package/esm5/osovitny-anatoly.js +0 -5
  114. package/esm5/public-api.js +0 -5
  115. package/fesm2015/osovitny-anatoly.js +0 -1171
  116. package/fesm2015/osovitny-anatoly.js.map +0 -1
  117. package/fesm5/osovitny-anatoly.js +0 -1226
  118. package/fesm5/osovitny-anatoly.js.map +0 -1
  119. package/lib/billing/billing.module.d.ts +0 -2
  120. package/lib/billing/components/buyaccess/buyaccess-button.component.d.ts +0 -16
  121. package/lib/billing/components/subscriptions/subscribe-plan-button.component.d.ts +0 -15
  122. package/lib/billing/components/subscriptions/upgrade-plan-button.component.d.ts +0 -9
  123. package/lib/billing/services/base-billing-api.service.d.ts +0 -9
  124. package/lib/core/consts.d.ts +0 -5
  125. package/lib/core/core.module.d.ts +0 -2
  126. package/lib/core/services/appcontext.service.d.ts +0 -14
  127. package/lib/core/services/base-api.service.d.ts +0 -18
  128. package/lib/core/services/base-go.service.d.ts +0 -7
  129. package/lib/core/services/base-gridedit.service.d.ts +0 -19
  130. package/lib/identity/components/signin-button.component.d.ts +0 -4
  131. package/lib/identity/components/signout-button.component.d.ts +0 -4
  132. package/lib/identity/components/signup-button.component.d.ts +0 -4
  133. package/lib/identity/identity.module.d.ts +0 -2
  134. package/lib/ui/components/base-edit.component.d.ts +0 -14
  135. package/lib/ui/components/base.component.d.ts +0 -7
  136. package/lib/ui/components/content-header/content-header.component.d.ts +0 -5
  137. package/lib/ui/components/html-editor/html-editor.component.d.ts +0 -19
  138. package/lib/ui/components/html-editor/html-editor.consts.d.ts +0 -1
  139. package/lib/ui/components/validation/form-validation-summary.component.d.ts +0 -6
  140. package/lib/ui/components/validation/item-validation-summary.component.d.ts +0 -6
  141. package/lib/ui/components/validation/validation-summary.component.d.ts +0 -6
  142. package/lib/ui/ui.module.d.ts +0 -2
  143. package/osovitny-anatoly.d.ts +0 -4
  144. package/osovitny-anatoly.metadata.json +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/anatoly",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,18 +1,7 @@
1
1
  {
2
2
  "name": "@osovitny/anatoly",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
- "tslib": "^1.10.0"
7
- },
8
- "main": "bundles/osovitny-anatoly.umd.js",
9
- "module": "fesm5/osovitny-anatoly.js",
10
- "es2015": "fesm2015/osovitny-anatoly.js",
11
- "esm5": "esm5/osovitny-anatoly.js",
12
- "esm2015": "esm2015/osovitny-anatoly.js",
13
- "fesm5": "fesm5/osovitny-anatoly.js",
14
- "fesm2015": "fesm2015/osovitny-anatoly.js",
15
- "typings": "osovitny-anatoly.d.ts",
16
- "metadata": "osovitny-anatoly.metadata.json",
17
- "sideEffects": false
6
+ }
18
7
  }
@@ -0,0 +1,62 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 10 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { NgModule } from '@angular/core';
18
+ import { CommonModule } from '@angular/common';
19
+ import { HttpClientModule, HttpClientXsrfModule, HttpClientJsonpModule, HttpClient } from '@angular/common/http';
20
+
21
+ //@osovitny/anatoly
22
+ import { AnatolyIdentityModule } from '../identity'
23
+
24
+ //Components/subscriptions
25
+ import { SubscribePlanButtonComponent } from './components/subscriptions/subscribe-plan-button.component';
26
+ import { UpgradePlanButtonComponent } from './components/subscriptions/upgrade-plan-button.component';
27
+
28
+ //Components/buyaccess
29
+ import { BuyAccessButtonComponent } from './components/buyaccess/buyaccess-button.component';
30
+
31
+ //Services
32
+ import { BaseBillingApiService } from './services/base-billing-api.service';
33
+
34
+ @NgModule({
35
+ imports: [
36
+ CommonModule,
37
+ HttpClientModule,
38
+ HttpClientXsrfModule,
39
+ HttpClientJsonpModule,
40
+ AnatolyIdentityModule
41
+ ],
42
+ exports: [
43
+ CommonModule,
44
+ HttpClientModule,
45
+ HttpClientXsrfModule,
46
+ HttpClientJsonpModule,
47
+ SubscribePlanButtonComponent,
48
+ UpgradePlanButtonComponent,
49
+ BuyAccessButtonComponent
50
+ ],
51
+ declarations: [
52
+ SubscribePlanButtonComponent,
53
+ UpgradePlanButtonComponent,
54
+ BuyAccessButtonComponent
55
+ ],
56
+ providers: [
57
+ BaseBillingApiService
58
+ ]
59
+ })
60
+
61
+ export class AnatolyBillingModule {
62
+ }
@@ -0,0 +1,15 @@
1
+ <div *ngIf="contextUpdated">
2
+ <div *ngIf="!isUserSignedIn">
3
+ <anatoly-signup-button classbtn="btn btn-block btn-primary"></anatoly-signup-button>
4
+ </div>
5
+
6
+ <div *ngIf="isUserSignedIn">
7
+ <button class="btn btn-block btn-success selectPlan" *ngIf="plan == currentPlan">
8
+ Your Plan
9
+ </button>
10
+
11
+ <button class="btn btn-block btn-warning selectPlan" *ngIf="plan != currentPlan && currentPlan == 1" (click)="onBuyPlan()">
12
+ Buy Now
13
+ </button>
14
+ </div>
15
+ </div>
@@ -0,0 +1,70 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 14 Aug 2018
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { Component, Input, OnInit } from '@angular/core';
18
+
19
+ //Services
20
+ import { AppContextService } from '../../../core/services/appcontext.service';
21
+ import { BaseBillingApiService } from '../../services/base-billing-api.service';
22
+
23
+ @Component({
24
+ selector: 'anatoly-buyaccess-button',
25
+ templateUrl: './buyaccess-button.component.html'
26
+ })
27
+
28
+ export class BuyAccessButtonComponent implements OnInit {
29
+ public contextUpdated: boolean = false;
30
+ public isUserSignedIn: boolean = false;
31
+ public currentPlan: number = 0;
32
+ public currentPlanTitle: string = "";
33
+
34
+ @Input() plan: number;
35
+ @Input() plantitle: string;
36
+
37
+ constructor(private appcontext: AppContextService, private api: BaseBillingApiService) {
38
+ }
39
+
40
+ ngOnInit() {
41
+ if (!this.appcontext.isUserSignedIn()) {
42
+ this.contextUpdated = true;
43
+ return;
44
+ }
45
+
46
+ this.appcontext.getCurrent((current) => {
47
+ this.isUserSignedIn = current.isUserSignedIn;
48
+
49
+ if (this.isUserSignedIn) {
50
+ this.currentPlan = current.account.billingPlan;
51
+ this.currentPlanTitle = current.account.billingPlanAsString;
52
+ }
53
+
54
+ this.contextUpdated = true;
55
+ });
56
+ }
57
+
58
+ onBuyPlan() {
59
+ const text = `Requested plan: ${this.plantitle} `;
60
+
61
+ var that = this;
62
+ osovitny.ui.areYouSure(text, 'Buying access', 'Confirm change', 'Cancel', () => {
63
+ that.api.buyAccess(that.plan, () => {
64
+ osovitny.ui.alertSuccess('Access Granted', null, () => {
65
+ (<any>window).location.reload();
66
+ });
67
+ });
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,21 @@
1
+ <div *ngIf="contextUpdated">
2
+ <div *ngIf="!isUserSignedIn">
3
+ <anatoly-signup-button classbtn="btn btn-block btn-primary"></anatoly-signup-button>
4
+ </div>
5
+
6
+ <div *ngIf="isUserSignedIn">
7
+ <button class="btn btn-block btn-success selectPlan" *ngIf="plan == currentPlan">
8
+ Your Plan
9
+ </button>
10
+
11
+ <button class="btn btn-block btn-warning selectPlan" *ngIf="requestedPlan != null && requestedPlan != 0 && plan == requestedPlan">
12
+ Requested
13
+ </button>
14
+
15
+ <anatoly-upgrade-plan-button *ngIf="plan != currentPlan && plan != requestedPlan"
16
+ [currentplantitle]="currentPlanTitle"
17
+ [requestedplan]=plan
18
+ [requestedplantitle]="plantitle">
19
+ </anatoly-upgrade-plan-button>
20
+ </div>
21
+ </div>
@@ -0,0 +1,60 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 1 Jun 2018
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { Component, Input, OnInit } from '@angular/core';
18
+
19
+ //Services
20
+ import { AppContextService } from '../../../core/services/appcontext.service';
21
+
22
+ @Component({
23
+ selector: 'anatoly-subscribe-plan-button',
24
+ templateUrl: './subscribe-plan-button.component.html'
25
+ })
26
+
27
+ export class SubscribePlanButtonComponent implements OnInit {
28
+ public contextUpdated: boolean = false;
29
+ public isUserSignedIn: boolean = false;
30
+ public currentPlan: number = 0;
31
+ public currentPlanTitle: string = "";
32
+ public requestedPlan: number = 0;
33
+ public requestedPlanTitle: string = "";
34
+
35
+ @Input() plan: number;
36
+ @Input() plantitle: string;
37
+
38
+ constructor(private appcontext: AppContextService) {
39
+ }
40
+
41
+ ngOnInit() {
42
+ if (!this.appcontext.isUserSignedIn()) {
43
+ this.contextUpdated = true;
44
+ return;
45
+ }
46
+
47
+ this.appcontext.getCurrent((current) => {
48
+ this.isUserSignedIn = current.isUserSignedIn;
49
+
50
+ if (this.isUserSignedIn) {
51
+ this.currentPlan = current.account.billingPlan;
52
+ this.currentPlanTitle = current.account.billingPlanAsString;
53
+ this.requestedPlan = current.account.requestedBillingPlan;
54
+ this.requestedPlanTitle = current.account.requestedBillingPlanAsString;
55
+ }
56
+
57
+ this.contextUpdated = true;
58
+ });
59
+ }
60
+ }
@@ -0,0 +1,3 @@
1
+ <button class="btn btn-block btn-primary" (click)="onUpgradePlan()">
2
+ Upgrade
3
+ </button>
@@ -0,0 +1,47 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 12 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { Component, Input } from '@angular/core';
18
+
19
+ //Services
20
+ import { BaseBillingApiService } from '../../services/base-billing-api.service';
21
+
22
+ @Component({
23
+ selector: 'anatoly-upgrade-plan-button',
24
+ templateUrl: './upgrade-plan-button.component.html'
25
+ })
26
+
27
+ export class UpgradePlanButtonComponent {
28
+ @Input() currentplantitle: string;
29
+ @Input() requestedplan: number;
30
+ @Input() requestedplantitle: string;
31
+
32
+ constructor(private api: BaseBillingApiService) {
33
+ }
34
+
35
+ onUpgradePlan() {
36
+ const text = `Current plan: ${this.currentplantitle} New plan: ${this.requestedplantitle}`;
37
+
38
+ var that = this;
39
+ osovitny.ui.areYouSure(text, 'Change billing plan', 'Confirm change', 'Cancel', () => {
40
+ that.api.requestNewSubscription(that.requestedplan, () => {
41
+ osovitny.ui.alertSuccess('Your request for changing plan has been sent.', null, () => {
42
+ (<any>window).location.reload();
43
+ });
44
+ });
45
+ });
46
+ }
47
+ }
@@ -1,5 +1,10 @@
1
+ // Components
1
2
  export * from './components/buyaccess/buyaccess-button.component';
2
3
  export * from './components/subscriptions/subscribe-plan-button.component';
3
4
  export * from './components/subscriptions/upgrade-plan-button.component';
5
+
6
+ // Services
4
7
  export * from './services/base-billing-api.service';
5
- export { AnatolyBillingModule } from './billing.module';
8
+
9
+ //Module
10
+ export { AnatolyBillingModule } from './billing.module';
@@ -0,0 +1,56 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 12 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { Injectable } from '@angular/core';
18
+ import { HttpClient } from '@angular/common/http';
19
+
20
+ //@osovitny/anatoly
21
+ import { BaseApiService } from '../../core'
22
+
23
+ @Injectable()
24
+ export class BaseBillingApiService extends BaseApiService {
25
+ constructor(protected http: HttpClient) {
26
+ super(http);
27
+ this.baseUrl += 'billing/';
28
+ }
29
+
30
+ public requestNewSubscription(requestedPlan: Number, success?: Function, error?: Function) {
31
+ this.postQS('requestNewSubscription', { requestedPlan: requestedPlan })
32
+ .subscribe(
33
+ data => { },
34
+ e => { if (error) error() },
35
+ () => { if (success) success() }
36
+ );
37
+ }
38
+
39
+ public cancelRequestedSubscription(success?: Function, error?: Function) {
40
+ this.postQS('cancelRequestedSubscription', null)
41
+ .subscribe(
42
+ data => { },
43
+ e => { if (error) error() },
44
+ () => { if (success) success() }
45
+ );
46
+ }
47
+
48
+ public buyAccess(requestedPlan: Number, success?: Function, error?: Function) {
49
+ this.postQS('buyAccess', { requestedPlan: requestedPlan })
50
+ .subscribe(
51
+ data => { },
52
+ e => { if (error) error() },
53
+ () => { if (success) success() }
54
+ );
55
+ }
56
+ }
@@ -0,0 +1,7 @@
1
+ namespace anatoly.consts {
2
+ export const jsonUrl: string = "/dist/json/";
3
+ export const appUrl = "/";
4
+ export const apiUrl = "/api/";
5
+ }
6
+
7
+ (<any>window).anatoly = anatoly;
@@ -0,0 +1,45 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 10 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { NgModule } from '@angular/core';
18
+ import { CommonModule } from '@angular/common';
19
+ import { HttpClientModule, HttpClientXsrfModule, HttpClientJsonpModule, HttpClient } from '@angular/common/http';
20
+
21
+ //Services
22
+ import { AppContextService } from './services/appcontext.service';
23
+
24
+ @NgModule({
25
+ imports: [
26
+ CommonModule,
27
+ HttpClientModule,
28
+ HttpClientXsrfModule,
29
+ HttpClientJsonpModule
30
+ ],
31
+ exports: [
32
+ CommonModule,
33
+ HttpClientModule,
34
+ HttpClientXsrfModule,
35
+ HttpClientJsonpModule
36
+ ],
37
+ declarations: [
38
+ ],
39
+ providers: [
40
+ AppContextService
41
+ ]
42
+ })
43
+
44
+ export class AnatolyCoreModule {
45
+ }
@@ -1,5 +1,10 @@
1
+ // Base
1
2
  export * from './services/base-api.service';
2
3
  export * from './services/base-gridedit.service';
3
4
  export * from './services/base-go.service';
5
+
6
+ // Services
4
7
  export * from './services/appcontext.service';
5
- export { AnatolyCoreModule } from './core.module';
8
+
9
+ //Module
10
+ export { AnatolyCoreModule } from './core.module';
@@ -0,0 +1,81 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 13 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ //Node
17
+ import { Injectable } from '@angular/core';
18
+ import { HttpClient } from '@angular/common/http';
19
+ import { Subscription } from 'rxjs';
20
+
21
+ //Custom
22
+ import { BaseApiService } from './base-api.service';
23
+ import '../consts';
24
+
25
+ @Injectable()
26
+ export class AppContextService extends BaseApiService {
27
+ private current = null;
28
+ private successes = [];
29
+ private subscription: Subscription = null;
30
+
31
+ constructor(protected http: HttpClient) {
32
+ super(http);
33
+ this.baseUrl = anatoly.consts.apiUrl + 'appcontext/';
34
+ }
35
+
36
+ getCurrent(success: Function) {
37
+ if (typeof success == "undefined") {
38
+ return;
39
+ }
40
+
41
+ if (this.current != null) {
42
+ success(this.current);
43
+ return;
44
+ }
45
+
46
+ this.successes.push(success);
47
+
48
+ if (this.subscription != null) {
49
+ return;
50
+ }
51
+
52
+ this.subscription = this.get('GetCurrentContext', null).subscribe(
53
+ data => {
54
+ this.dataReceived(data);
55
+ },
56
+ e => { }
57
+ );
58
+ }
59
+
60
+ dataReceived(data) {
61
+ this.current = data;
62
+
63
+ for (var i = 0; i < this.successes.length; i++) {
64
+ var success = this.successes[i];
65
+ success(data);
66
+ }
67
+
68
+ this.successes = [];
69
+ this.subscription.unsubscribe();
70
+ this.subscription = null;
71
+ this.current = null;
72
+ }
73
+
74
+ isUserSignedIn() {
75
+ return (<any>window).__context_isUserSignedIn;
76
+ }
77
+
78
+ isUserAdmin() {
79
+ return (<any>window).__context_isUserAdmin;
80
+ }
81
+ }
@@ -0,0 +1,87 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 13 Nov 2017
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ import { Injectable } from '@angular/core';
17
+ import { HttpClient } from '@angular/common/http';
18
+
19
+ //RxJs
20
+ import { Observable } from 'rxjs';
21
+ import { map } from 'rxjs/operators';
22
+
23
+ import '../consts';
24
+
25
+ @Injectable()
26
+ export class BaseApiService {
27
+ protected baseUrl: string;
28
+ protected jsonUrl: string;
29
+
30
+ constructor(protected http: HttpClient) {
31
+ this.baseUrl = anatoly.consts.apiUrl;
32
+ }
33
+
34
+ private serializeParams(data?: any): string {
35
+ return data ? ('?' + $.param(data)) : '';
36
+ }
37
+
38
+ //webApi
39
+ public get<T>(action: String, data?: any): Observable<T> {
40
+ var url = this.baseUrl + `${action}${this.serializeParams(data)}`;
41
+ return this.http.get(url).pipe(
42
+ map(res => <T>res)
43
+ );
44
+ }
45
+
46
+ public post(action: String, data?: any): Observable<any> {
47
+ var url = this.baseUrl + `${action}`;
48
+ return this.http.post(url, data, { responseType: 'text' });
49
+ }
50
+
51
+ public postQS(action: String, data?: any): Observable<any> {
52
+ var url = this.baseUrl + `${action}${this.serializeParams(data)}`;
53
+ return this.http.post(url, null, { responseType: 'text' });
54
+ }
55
+
56
+ //gets
57
+ public getAll<T>(data?: any): Observable<T[]> {
58
+ return this.get('getall', data).pipe(
59
+ map(res => <T[]>res)
60
+ );
61
+ }
62
+
63
+ public getJsonFile(fileName: string, jsonVersion: string): Observable<any[]> {
64
+ if (!jsonVersion) {
65
+ jsonVersion = "1.0";
66
+ }
67
+
68
+ var url = anatoly.consts.jsonUrl + fileName + '?' + jsonVersion;
69
+ return this.http.get(url).pipe(
70
+ map(res => <any[]>res)
71
+ );
72
+ }
73
+
74
+ public getNewGuid(): Observable<string> {
75
+ var url = this.baseUrl + 'getNewGuid';
76
+ return this.http.get(url, { responseType: 'text' });
77
+ }
78
+
79
+ //CRUD function
80
+ public getById<T>(id: any): Observable<T> {
81
+ return this.get<T>('getById', { id: id });
82
+ }
83
+
84
+ public remove(id: any): Observable<string> {
85
+ return this.postQS('remove', { id: id });
86
+ }
87
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ <file>
3
+ Authors:
4
+ Vadim Osovitny
5
+
6
+ Created:
7
+ 17 Jun 2018
8
+
9
+ Version:
10
+ 1.0
11
+
12
+ Copyright (c) 2016-2019 Osovitny Inc. All rights reserved.
13
+ </file>
14
+ */
15
+
16
+ import { Injectable } from '@angular/core';
17
+ import { ActivatedRoute, Router } from '@angular/router';
18
+
19
+ @Injectable()
20
+ export class BaseGoService {
21
+ protected route: ActivatedRoute;
22
+ protected router: Router;
23
+
24
+ constructor(route: ActivatedRoute, router: Router) {
25
+ this.route = route;
26
+ this.router = router;
27
+ }
28
+
29
+ locationReload() {
30
+ //this.router.navigate([this.route.url]);
31
+ (<any>window).location.reload();
32
+ }
33
+ }