New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migration to HttpClient #6951
migration to HttpClient #6951
Changes from 17 commits
740ec9e
960e785
e1104d4
7c294e9
31a769c
047dc8d
041fb50
049e012
5a7d16c
3f59491
542d094
073cce3
fdcc558
3d330cc
1e92bed
84fcd68
2adcb39
b9ec610
5e1edd7
ebf9f0a
0468bd9
4a35965
4607784
efa0c25
bfdbe06
4bc7b07
f1b711b
109fe55
a927fd9
ed9e5b2
59cd3f2
4145332
1169abd
db11427
02b506b
6f09f1f
1657f29
79f2113
be00c6f
534b49e
bc0eaf3
7a20baf
0fa3f1f
23f15fc
f8cabdd
a5633b1
5421b43
98bb775
18f0104
450045f
f143214
c232cdd
adc4d3c
d4e3e49
a1d8ebd
6cbfad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,20 @@ | |
-%> | ||
import './vendor.ts'; | ||
|
||
import { NgModule } from '@angular/core'; | ||
import { NgModule, Injector } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { Ng2Webstorage } from 'ngx-webstorage'; | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { Ng2Webstorage<% if (authenticationType === 'jwt') { %>, LocalStorageService, SessionStorageService <% } %> } from 'ngx-webstorage'; | ||
import { JhiEventManager } from 'ng-jhipster'; | ||
|
||
<%_ if (authenticationType === 'jwt') { _%> | ||
import { AuthInterceptor } from './blocks/interceptor/auth.interceptor'; | ||
<%_ } _%> | ||
<%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%> | ||
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor'; | ||
<% } %> | ||
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor'; | ||
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor'; | ||
|
||
import { <%=angularXAppName%>SharedModule, UserRouteAccessService } from './shared'; | ||
import { <%=angularXAppName%>AppRoutingModule} from './app-routing.module'; | ||
|
@@ -30,9 +41,15 @@ import { <%=angularXAppName%>AdminModule } from './admin/admin.module'; | |
import { <%=angularXAppName%>AccountModule } from './account/account.module'; | ||
<%_ } _%> | ||
import { <%=angularXAppName%>EntityModule } from './entities/entity.module'; | ||
import { customHttpProvider } from './blocks/interceptor/http.provider'; | ||
import { PaginationConfig } from './blocks/config/uib-pagination.config'; | ||
|
||
<%_ if (authenticationType === 'session' || authenticationType === 'oauth2') { _%> | ||
<%_ if (authenticationType === 'session') { _%> | ||
import { LoginModalService } from './shared/login/login-modal.service'; | ||
<%_ } _%> | ||
import { StateStorageService } from './shared/auth/state-storage.service'; | ||
<%_ } _%> | ||
|
||
// jhipster-needle-angular-add-module-import JHipster will add new module here | ||
|
||
import { | ||
|
@@ -73,9 +90,66 @@ import { | |
], | ||
providers: [ | ||
ProfileService, | ||
customHttpProvider(), | ||
PaginationConfig, | ||
UserRouteAccessService | ||
UserRouteAccessService, | ||
<%_ if (authenticationType === 'jwt') { _%> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this template seems wrong compared to existing logic, correct one should be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can shrink them to only switch the dependencies i removed the Modal to solve cyclic dependencies in case of session based auth There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. merged them |
||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (localStorageService, sessionStorageService) => new AuthInterceptor(localStorageService, sessionStorageService), | ||
multi: true, | ||
deps: [ | ||
LocalStorageService, | ||
SessionStorageService | ||
] | ||
}, | ||
<%_ } _%> | ||
<%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%> | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (injector) => new AuthExpiredInterceptor(injector), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you checked, this part? (I am not sure)AOT is handling this correctly in the new version... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we use |
||
multi: true, | ||
deps: [ | ||
Injector | ||
] | ||
}, | ||
<%_ } else if (authenticationType === 'session') { _%> | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (injector, stateStorageService, loginModalService) => new AuthExpiredInterceptor(injector, stateStorageService, loginModalService), | ||
multi: true, | ||
deps: [ | ||
Injector, | ||
StateStorageService, | ||
LoginModalService | ||
] | ||
}, | ||
<%_ } else if (authenticationType === 'oauth2') { _%> | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (injector, stateStorageService) => new AuthExpiredInterceptor(injector, stateStorageService), | ||
multi: true, | ||
deps: [ | ||
Injector, | ||
StateStorageService, | ||
] | ||
}, | ||
<%_ } _%> | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (eventManager) => new ErrorHandlerInterceptor(eventManager), | ||
multi: true, | ||
deps: [ | ||
JhiEventManager, | ||
] | ||
}, | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useFactory: (injector) => new NotificationInterceptor(injector), | ||
multi: true, | ||
deps: [ | ||
Injector | ||
] | ||
} | ||
], | ||
bootstrap: [ <%=jhiPrefixCapitalized%>MainComponent ] | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
limitations under the License. | ||
-%> | ||
import { Injectable } from '@angular/core'; | ||
import { Http, Response } from '@angular/http'; | ||
import { HttpClient, HttpResponse } from '@angular/common/http'; | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
import { Session } from './session.model'; | ||
|
@@ -30,10 +30,10 @@ export class SessionsService { | |
constructor(private http: Http) { } | ||
|
||
findAll(): Observable<Session[]> { | ||
return this.http.get(this.resourceUrl).map((res: Response) => res.json()); | ||
return this.http.get<Session[]>(this.resourceUrl); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really liked this one 👍 It clearly states what is gonna be there ❤️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i tried to type everything i stubled over not sure though if i really did it eveywhere so far |
||
} | ||
|
||
delete(series: string): Observable<Response> { | ||
return this.http.delete(`${this.resourceUrl}${series}`); | ||
delete(series: string): Observable<HttpResponse<any>> { | ||
return this.http.delete(`${this.resourceUrl}${series}`, { observe: 'response' }); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
['session', 'oauth2'].includes(authenticationType)
syntax as its easier to read