re base code
[sdc.git] / catalog-ui / src / app / ng2 / utils / ng1-upgraded-provider.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 /**
22  * Created by rc2122 on 4/6/2017.
23  */
24 import { DataTypesService } from "../../services/data-types-service";
25 import ICacheObject = angular.ICacheObject;
26 import { SharingService } from "../../services/sharing-service";
27 import { CookieService } from "../../services/cookie-service";
28 import { CacheService } from "../../services/cache-service";
29 import {ComponentFactory} from "../../utils/component-factory"
30 import { EventListenerService } from "app/services/event-listener-service";
31 import { ModalsHandler } from "app/utils";
32 import IScope = angular.IScope;
33
34 /** Services we need to upgrade from angular1 to angular2 - in the future we need to rewrite them all to angular2 **/
35
36 export function dataTypesServiceFactory(cacheObj: ICacheObject) {
37     return cacheObj.get('Sdc.Services.DataTypesService');
38 }
39
40 export function sharingServiceFactory(cacheObj: ICacheObject) {
41     return cacheObj.get('Sdc.Services.SharingService');
42 }
43
44 export function componentServiceFactory(cacheObj: ICacheObject) {
45     return cacheObj.get('Sdc.Services.ComponentFactory');
46 }
47
48 export function cookieServiceFactory(cacheObj: ICacheObject) {
49     return cacheObj.get('Sdc.Services.CookieService');
50 }
51
52 export function stateServiceFactory(cacheObj: ICacheObject) {
53     return cacheObj.get('$state');
54 }
55
56 export function stateParamsServiceFactory(cacheObj: ICacheObject) {
57     return cacheObj.get('$stateParams');
58 }
59
60 export function scopeServiceFactory(cacheObj: ICacheObject) {
61     return cacheObj.get('$scope');
62 }
63
64 export function cacheServiceFactory(cacheObj: ICacheObject) {
65     return cacheObj.get('Sdc.Services.CacheService');
66 }
67
68 export function eventListenerServiceServiceFactory(cacheObj: ICacheObject) {
69     return cacheObj.get('EventListenerService');
70 }
71
72 export function notificationServiceFactory(cacheObj: ICacheObject) {
73     return cacheObj.get('Notification');
74 }
75
76
77 export const ComponentFactoryProvider = {
78     provide: ComponentFactory,
79     useFactory: componentServiceFactory,
80     deps: ['$injector']
81 };
82
83
84 export function ModalsHandlerFactory(cacheObj: ICacheObject) {
85     return cacheObj.get('ModalsHandler');
86 }
87
88 export const DataTypesServiceProvider = {
89     provide: DataTypesService,
90     useFactory: dataTypesServiceFactory,
91     deps: ['$injector']
92 };
93
94
95 export const SharingServiceProvider = {
96     provide: SharingService,
97     useFactory: sharingServiceFactory,
98     deps: ['$injector']
99 };
100
101
102 export const CookieServiceProvider = {
103     provide: CookieService,
104     useFactory: cookieServiceFactory,
105     deps: ['$injector']
106 };
107
108 export const StateServiceFactory = {
109     provide: '$state',
110     useFactory: stateServiceFactory,
111     deps: ['$injector']
112 };
113
114 export const ScopeServiceFactory = {
115     provide: '$scope',
116     useFactory: scopeServiceFactory,
117     deps: ['$injector']
118 };
119
120 export const StateParamsServiceFactory = {
121     provide: '$stateParams',
122     useFactory: stateParamsServiceFactory,
123     deps: ['$injector']
124 };
125 export const CacheServiceProvider = {
126     provide: CacheService,
127     useFactory: cacheServiceFactory,
128     deps: ['$injector']
129 };
130
131 export const EventListenerServiceProvider = {
132     provide: EventListenerService,
133     useFactory: eventListenerServiceServiceFactory,
134     deps: ['$injector']
135 };
136
137 export const NotificationServiceProvider = {
138     provide: 'Notification',
139     useFactory: notificationServiceFactory,
140     deps: ['$injector']
141 };
142
143 export const ModalsHandlerProvider = {
144     provide: ModalsHandler,
145     useFactory: ModalsHandlerFactory,
146     deps: ['$injector']
147 }