Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c87cf192
authored
Feb 17, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nagular 5 is now working
1 parent
29ceaba7
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
124 additions
and
64 deletions
code/moya-angular-common/.editorconfig
code/moya-angular-common/src/index.ts
code/moya-angular-common/src/moya-rest/moya-rest.module.ts
code/moya-angular-common/src/moya-rest/services/cache.service.ts
code/moya-angular-common/src/moya-rest/services/moya-rest.service.ts
code/moya-angular-common/src/moya-rest/services/user.service.ts
code/moya-angular-common/src/moya-rest/services/viplist.service.ts
code/moya-angular-common/src/package.json
code/moya-angular-common/src/tsconfig.json
code/moya-angular/package.json
code/moya-angular/src/app/app.module.ts
code/moya-angular/src/app/menu/defines/menu.ts
code/moya-angular/src/app/old-moya/old-moya.component.ts
code/moya-angular/src/app/viplist/viplist.component.ts
code/moya-angular/src/tsconfig.json
code/moya-angular-common/.editorconfig
0 → 100644
View file @
c87cf19
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
code/moya-angular-common/src/index.ts
View file @
c87cf19
...
...
@@ -8,11 +8,13 @@ const MODULES = [
MoyaRestModule
];
/*
@NgModule({
imports: [MoyaRestModule.forRoot()],
exports: MODULES
})
@
NgModule
({
exports
:
MODULES
})
})
*/
/*
@NgModule({
imports: MODULES,
exports: MODULES})
export class MoyaAngularCommonModule {
}
\ No newline at end of file
}
*/
code/moya-angular-common/src/moya-rest/moya-rest.module.ts
View file @
c87cf19
import
{
NgModule
,
ModuleWithProviders
,
NgZone
}
from
'@angular/core'
;
import
{
NgModule
,
ModuleWithProviders
,
NgZone
,
Injector
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
HttpModule
}
from
"@angular/http"
;
import
{
MoyaRestService
}
from
"./services/moya-rest.service"
;
import
{
ViplistService
}
from
"./services/viplist.service"
;
import
{
CacheService
}
from
"./services/cache.service"
;
import
{
UserService
}
from
"./services/user.service"
;
import
{
HttpClientModule
}
from
"@angular/common/http"
;
import
{
HttpModule
}
from
"@angular/http"
;
export
*
from
"./services/moya-rest.service"
;
export
*
from
"./services/viplist.service"
;
...
...
@@ -20,14 +21,25 @@ export * from "./models/vip-product-delivery.model";
@
NgModule
({
imports
:
[
CommonModule
,
HttpModule
HttpClientModule
],
declarations
:
[
],
providers
:
[
MoyaRestService
,
ViplistService
,
CacheService
,
UserService
,
HttpClientModule
/*{ provide: NgZone, useFactory: () => new NgZone({}) },
{ provide: Injector, useFactory: () => Injector.create({providers: []}) } */
],
exports
:
[
],
declarations
:
[]
})
export
class
MoyaRestModule
{
/*
static forRoot(): ModuleWithProviders {
return {
ngModule: MoyaRestModule,
...
...
@@ -35,9 +47,12 @@ export class MoyaRestModule {
MoyaRestService,
ViplistService,
CacheService,
UserService
UserService,
HttpClientModule
/*{ provide: NgZone, useFactory: () => new NgZone({}) },
{ provide: Injector, useFactory: () => Injector.create({providers: []}) }
]
};
}
}
*/
}
code/moya-angular-common/src/moya-rest/services/cache.service.ts
View file @
c87cf19
import
{
Injectable
,
NgZone
}
from
"@angular/core"
;
import
{
Observable
,
Subscriber
,
Subscription
}
from
"rxjs"
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
'rxjs/add/observable/timer'
;
import
{
forkJoin
}
from
"rxjs/observable/forkJoin"
;
import
"rxjs/add/operator/do"
;
import
"rxjs/add/operator/publishLast"
;
import
"rxjs/add/observable/of"
;
import
{
Subscription
}
from
"rxjs/Subscription"
;
const
DEFAULT_EXPIRE_MS
=
300000
;
// 5min
...
...
code/moya-angular-common/src/moya-rest/services/moya-rest.service.ts
View file @
c87cf19
import
{
Injectable
}
from
'@angular/core'
;
import
{
Http
,
Response
}
from
"@angular/http"
;
import
{
Observable
,
Observer
}
from
"rxjs"
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
"rxjs/add/operator/catch"
;
import
{
HttpClient
,
HttpResponse
}
from
"@angular/common/http"
;
@
Injectable
()
export
class
MoyaRestService
{
constructor
(
private
http
:
Http
)
{
}
constructor
(
private
http
:
Http
Client
)
{
}
post
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
post
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
HttpResponse
<
any
>
>
{
return
this
.
http
.
post
(
this
.
genUrl
(
subUrl
,
pathParameters
),
body
)
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
put
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
put
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
HttpResponse
<
any
>
>
{
return
this
.
http
.
put
(
this
.
genUrl
(
subUrl
,
pathParameters
),
body
)
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
delete
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
delete
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
HttpResponse
<
any
>
>
{
return
this
.
http
.
delete
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
get
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
get
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
HttpResponse
<
any
>
>
{
return
this
.
http
.
get
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
...
...
@@ -54,7 +55,7 @@ export class MoyaRestService {
return
"/MoyaWeb/rest/"
+
subUrl
+
suffix
;
// <-- TODO: kauneista
}
private
handleResponse
(
res
:
Response
)
{
private
handleResponse
(
res
:
HttpResponse
<
any
>
)
{
// basicly, 200 statuscodes means success
if
(
!
(
res
.
status
>=
200
&&
res
.
status
<=
299
))
{
...
...
@@ -67,7 +68,7 @@ export class MoyaRestService {
return
res
;
}
private
handleException
(
error
:
Response
|
any
)
{
private
handleException
(
error
:
HttpResponse
<
any
>
|
any
)
{
console
.
log
(
"error on jira rest connection"
,
error
);
...
...
code/moya-angular-common/src/moya-rest/services/user.service.ts
View file @
c87cf19
import
{
Injectable
}
from
"@angular/core"
;
import
{
Observable
}
from
"rxjs"
;
import
{
User
}
from
"../models/user.model"
;
import
{
MoyaRestService
}
from
"./moya-rest.service"
;
import
{
CacheService
}
from
"./cache.service"
;
import
{
Observable
}
from
"rxjs/Observable"
;
@
Injectable
()
export
class
UserService
{
...
...
@@ -20,8 +21,7 @@ export class UserService {
return
this
.
cacheService
.
cacheObservable
(
"moya:UserService"
,
path
,
this
.
moyaRest
.
get
(
path
)
.
do
(
v
=>
{
console
.
log
(
"getting user outside of cache"
,
path
)})
.
map
(
res
=>
(
<
User
>
res
.
json
()))
);
.
map
(
res
=>
(
<
User
>
res
.
body
)));
}
}
code/moya-angular-common/src/moya-rest/services/viplist.service.ts
View file @
c87cf19
import
{
Injectable
}
from
'@angular/core'
;
import
{
MoyaRestService
}
from
"./moya-rest.service"
;
import
{
Observable
}
from
"rxjs"
;
import
{
Vip
}
from
"../models/vip.model"
;
import
{
Response
}
from
"@angular/http"
;
import
{
User
}
from
"../models/user.model"
;
import
{
UserService
}
from
"./user.service"
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
"rxjs/add/operator/map"
;
import
"rxjs/add/operator/switchMap"
;
import
"rxjs/add/observable/forkJoin"
;
import
"rxjs/add/operator/first"
;
import
{
HttpResponse
}
from
"@angular/common/http"
;
@
Injectable
()
export
class
ViplistService
{
...
...
@@ -22,11 +27,11 @@ export class ViplistService {
if
(
!
searchString
)
{
return
this
.
moyaRestService
.
get
(
"v3/vip/all"
)
.
switchMap
(
res
=>
Observable
.
forkJoin
(...
res
.
json
()
.
map
(
apiRow
=>
this
.
hostPopulator
(
apiRow
))));
.
switchMap
(
res
=>
Observable
.
forkJoin
(...
res
.
body
.
map
(
apiRow
=>
this
.
hostPopulator
(
apiRow
))));
}
return
this
.
moyaRestService
.
get
(
"v3/vip/search/"
+
searchString
)
.
switchMap
(
v
=>
Observable
.
forkJoin
(...
v
.
json
()
.
map
(
x
=>
this
.
hostPopulator
(
x
))));
.
switchMap
(
v
=>
Observable
.
forkJoin
(...
v
.
body
.
map
(
x
=>
this
.
hostPopulator
(
x
))));
}
...
...
@@ -34,45 +39,30 @@ export class ViplistService {
* Delete vip.
*
* @param vip
* @return
Observabl
e
* @return
Promis
e
*/
public
async
delete
(
vip
:
Vip
):
Promise
<
boolean
>
{
if
(
!
vip
.
id
)
throw
new
Error
(
"TODO: errori, tyhmä vippi"
);
let
res
:
Response
=
await
this
.
moyaRestService
.
delete
(
"v3/vip/"
+
vip
.
id
)
let
res
:
HttpResponse
<
any
>
=
await
this
.
moyaRestService
.
delete
(
"v3/vip/"
+
vip
.
id
)
.
first
()
.
toPromise
();
return
res
.
ok
;
}
/*
public deleteProm(vip: Vip): Promise<boolean> {
if (!vip.id)
throw new Error("TODO: errori, tyhmä vippi");
return this.moyaRestService.delete("v3/vip/" + vip.id)
.first()
.toPromise()
.then(r => r.ok);
}
*/
public
getWithId
(
id
:
number
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
get
(
"v3/vip/"
+
id
)
.
map
(
v
=>
v
.
json
()
);
.
map
(
v
=>
v
.
body
);
}
public
create
(
vip
:
Vip
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
post
(
"v3/vip/create"
,
vip
)
.
map
(
v
=>
v
.
json
()
);
.
map
(
v
=>
v
.
body
);
}
private
hostPopulator
(
rawVip
:
any
):
Observable
<
Vip
>
{
...
...
code/moya-angular-common/src/package.json
View file @
c87cf19
...
...
@@ -3,5 +3,33 @@
"version"
:
"0.0.1"
,
"license"
:
"UNLICENSED"
,
"scripts"
:
{},
"private"
:
true
"private"
:
true
,
"peerDependencies"
:
{
"@angular/http"
:
"^5.2.4"
,
"rxjs"
:
"^5.5.6"
,
"@angular/core"
:
"^5.2.4"
,
"@angular/animations"
:
"^5.2.4"
,
"@angular/common"
:
"^5.2.4"
,
"@angular/compiler"
:
"^5.2.4"
,
"@angular/forms"
:
"^5.2.4"
,
"@angular/platform-browser"
:
"^5.2.4"
,
"@angular/platform-browser-dynamic"
:
"^5.2.4"
,
"@angular/router"
:
"^5.2.4"
,
"core-js"
:
"^2.4.1"
,
"zone.js"
:
"^0.8.19"
},
"devDependencies"
:
{
"@angular/http"
:
"^5.2.4"
,
"rxjs"
:
"^5.5.6"
,
"@angular/core"
:
"^5.2.4"
,
"@angular/animations"
:
"^5.2.4"
,
"@angular/common"
:
"^5.2.4"
,
"@angular/compiler"
:
"^5.2.4"
,
"@angular/forms"
:
"^5.2.4"
,
"@angular/platform-browser"
:
"^5.2.4"
,
"@angular/platform-browser-dynamic"
:
"^5.2.4"
,
"@angular/router"
:
"^5.2.4"
,
"core-js"
:
"^2.4.1"
,
"zone.js"
:
"^0.8.19"
}
}
code/moya-angular-common/src/tsconfig.json
View file @
c87cf19
...
...
@@ -4,7 +4,7 @@
"declaration"
:
false
,
"emitDecoratorMetadata"
:
true
,
"experimentalDecorators"
:
true
,
"lib"
:
[
"es
6
"
,
"dom"
],
"lib"
:
[
"es
2017
"
,
"dom"
],
"mapRoot"
:
"./"
,
"module"
:
"es6"
,
"moduleResolution"
:
"node"
,
...
...
code/moya-angular/package.json
View file @
c87cf19
...
...
@@ -30,10 +30,10 @@
"ng2-bootstrap"
:
"^1.3.3"
,
"rxjs"
:
"^5.4.3"
,
"ts-helpers"
:
"^1.1.1"
,
"zone.js"
:
"^0.8.1
8
"
"zone.js"
:
"^0.8.1
9
"
},
"devDependencies"
:
{
"@angular/cli"
:
"^1.
4.5
"
,
"@angular/cli"
:
"^1.
6.8
"
,
"@angular/compiler-cli"
:
"^5.2.4"
,
"@angularclass/hmr"
:
"^2.1.3"
,
"@types/jasmine"
:
"2.8.6"
,
...
...
code/moya-angular/src/app/app.module.ts
View file @
c87cf19
import
{
BrowserModule
}
from
'@angular/platform-browser'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
Injector
,
NgModule
,
ReflectiveInjector
}
from
'@angular/core'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
HttpModule
}
from
'@angular/http'
;
import
{
AppComponent
}
from
'./app.component'
;
import
{
ViplistComponent
}
from
'./viplist/viplist.component'
;
...
...
@@ -21,6 +20,11 @@ import {UserComponent} from './user/user.component';
import
{
InfoComponent
}
from
'./info/info.component'
;
import
{
AdminComponent
}
from
'./admin/admin.component'
;
import
{
I18nPipe
}
from
'./pipes/i18n.pipe'
;
import
{
HttpClientModule
,
HttpHandler
}
from
'@angular/common/http'
;
import
{
HttpModule
}
from
'@angular/http'
;
import
{
CacheService
}
from
"moya-angular-common"
;
import
{
StaticInjector
}
from
"@angular/core/src/di/injector"
;
import
{
CommonModule
}
from
"@angular/common"
;
const
appRoutes
:
Routes
=
[
{
...
...
@@ -69,16 +73,20 @@ const appRoutes: Routes = [
InfoComponent
,
AdminComponent
,
I18nPipe
],
imports
:
[
CommonModule
,
BrowserModule
,
FormsModule
,
HttpModule
,
Http
Client
Module
,
AlertModule
.
forRoot
(),
MoyaRestModule
.
forRoot
(),
MoyaRestModule
,
//MoyaRestModule.forRoot(),
RouterModule
.
forRoot
(
appRoutes
)
],
providers
:
[],
providers
:
[
CacheService
,
{
provide
:
Injector
,
useFactory
:
()
=>
Injector
.
create
({
providers
:
[]})
}],
bootstrap
:
[
AppComponent
]
})
export
class
AppModule
{
...
...
code/moya-angular/src/app/menu/defines/menu.ts
View file @
c87cf19
...
...
@@ -14,7 +14,7 @@ export class MENU {
]}
];
static
INFO
:
MenuGroup
[]
=
[
static
INFO
:
MenuGroup
[]
=
[
{
'name'
:
'Users'
,
'items'
:
[
...
...
code/moya-angular/src/app/old-moya/old-moya.component.ts
View file @
c87cf19
import
{
Component
,
OnInit
,
ViewChild
,
ElementRef
}
from
'@angular/core'
;
import
{
Location
,
LocationStrategy
,
HashLocationStrategy
,
PathLocationStrategy
}
from
'@angular/common'
;
import
{
NavigationExtras
,
ActivatedRoute
,
Router
}
from
'@angular/router'
;
import
{
Observable
}
from
'rxjs'
;
@
Component
({
selector
:
'old-moya'
,
...
...
@@ -43,7 +42,7 @@ export class OldMoyaComponent implements OnInit {
console
.
log
(
this
.
iframe
.
nativeElement
.
contentWindow
.
document
.
body
.
height
);
this
.
height
=
this
.
iframe
.
nativeElement
.
contentWindow
.
document
.
body
.
scrollHeight
+
'px'
;
this
.
height
=
(
this
.
iframe
.
nativeElement
.
contentWindow
.
document
.
body
.
scrollHeight
+
50
)
+
'px'
;
...
...
code/moya-angular/src/app/viplist/viplist.component.ts
View file @
c87cf19
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Observable
}
from
'rxjs'
;
import
{
Component
,
NgZone
,
OnInit
}
from
'@angular/core'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
ViplistService
,
Vip
}
from
'moya-angular-common'
;
@
Component
({
...
...
@@ -14,7 +14,6 @@ export class ViplistComponent implements OnInit {
constructor
(
private
viplistService
:
ViplistService
)
{
}
ngOnInit
()
{
this
.
vips
=
this
.
viplistService
.
get
();
}
...
...
code/moya-angular/src/tsconfig.json
View file @
c87cf19
...
...
@@ -20,6 +20,7 @@
},
"include"
:
[
"**/*.ts"
,
"../node_modules/moya-angular-common/**/*.ts"
"../node_modules/moya-angular-common/*.ts"
,
"../node_modules/moya-angular-common/moya-rest/**/*.ts"
]
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment