aab531d205c2b48701b5453b4add14813883391e
[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 { CookieService } from "../../services/cookie-service";
27 import {ComponentFactory} from "../../utils/component-factory"
28 import { EventListenerService } from "app/services/event-listener-service";
29 import { ModalsHandler } from "app/utils";
30 import IScope = angular.IScope;
31 import { SharingService } from "../services/sharing.service";
32
33 /** Services we need to upgrade from angular1 to angular2 - in the future we need to rewrite them all to angular2 **/
34
35 export function dataTypesServiceFactory(cacheObj: ICacheObject) {
36     return cacheObj.get('Sdc.Services.DataTypesService');
37 }
38
39 export function sharingServiceFactory(cacheObj: ICacheObject) {
40     return cacheObj.get('Sdc.Services.SharingService');
41 }
42
43 export function componentServiceFactory(cacheObj: ICacheObject) {
44     return cacheObj.get('Sdc.Services.ComponentFactory');
45 }
46
47 export function cookieServiceFactory(cacheObj: ICacheObject) {
48     return cacheObj.get('Sdc.Services.CookieService');
49 }
50
51 export function stateServiceFactory(cacheObj: ICacheObject) {
52     return cacheObj.get('$state');
53 }
54
55 export function stateParamsServiceFactory(cacheObj: ICacheObject) {
56     return cacheObj.get('$stateParams');
57 }
58
59 export function scopeServiceFactory(cacheObj: ICacheObject) {
60     return cacheObj.get('$scope');
61 }
62
63 export function eventListenerServiceServiceFactory(cacheObj: ICacheObject) {
64     return cacheObj.get('EventListenerService');
65 }
66
67 export function notificationServiceFactory(cacheObj: ICacheObject) {
68     return cacheObj.get('Notification');
69 }
70
71 export function ModalsHandlerFactory(cacheObj: ICacheObject) {
72     return cacheObj.get('ModalsHandler');
73 }
74
75
76 export const ComponentFactoryProvider = {
77     provide: ComponentFactory,
78     useFactory: componentServiceFactory,
79     deps: ['$injector']
80 };
81
82 export const DataTypesServiceProvider = {
83     provide: DataTypesService,
84     useFactory: dataTypesServiceFactory,
85     deps: ['$injector']
86 };
87
88 export const SharingServiceProvider = {
89     provide: SharingService,
90     useFactory: sharingServiceFactory,
91     deps: ['$injector']
92 };
93
94
95 export const CookieServiceProvider = {
96     provide: CookieService,
97     useFactory: cookieServiceFactory,
98     deps: ['$injector']
99 };
100
101 export const StateServiceFactory = {
102     provide: '$state',
103     useFactory: stateServiceFactory,
104     deps: ['$injector']
105 };
106
107 export const ScopeServiceFactory = {
108     provide: '$scope',
109     useFactory: scopeServiceFactory,
110     deps: ['$injector']
111 };
112
113 export const StateParamsServiceFactory = {
114     provide: '$stateParams',
115     useFactory: stateParamsServiceFactory,
116     deps: ['$injector']
117 };
118 //
119 // export const EventListenerServiceProvider = {
120 //     provide: EventListenerService,
121 //     useFactory: eventListenerServiceServiceFactory,
122 //     deps: ['$injector']
123 // };
124
125 export const NotificationServiceProvider = {
126     provide: 'Notification',
127     useFactory: notificationServiceFactory,
128     deps: ['$injector']
129 };
130
131 export const ModalsHandlerProvider = {
132     provide: ModalsHandler,
133     useFactory: ModalsHandlerFactory,
134     deps: ['$injector']
135 };