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