Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 622edeef
authored
Feb 10, 2017
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jotain unohtui
1 parent
9a117212
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
360 additions
and
0 deletions
code/moya-angular/src/app/moya-rest/models/vip-product-delivery.model.ts
code/moya-angular/src/app/moya-rest/models/vip-product.model.ts
code/moya-angular/src/app/moya-rest/models/vip.model.ts
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
code/moya-angular/src/app/moya-rest/services/moya-rest.service.spec.ts
code/moya-angular/src/app/moya-rest/services/moya-rest.service.ts
code/moya-angular/src/app/moya-rest/services/viplist.service.spec.ts
code/moya-angular/src/app/moya-rest/services/viplist.service.ts
code/moya-angular/src/app/test/test.component.css
code/moya-angular/src/app/test/test.component.html
code/moya-angular/src/app/test/test.component.spec.ts
code/moya-angular/src/app/test/test.component.ts
code/moya-angular/src/app/moya-rest/models/vip-product-delivery.model.ts
0 → 100644
View file @
622edee
/**
* Created by tuukka on 04/02/17.
*/
export
class
VipProductDelivery
{
/*
public Integer id;
public Integer delivererId;
public BigDecimal quantity;
public Date deliveryTime;
public String notes;
*/
id
:
number
;
delivererId
:
number
;
quantity
:
number
;
deliveryTime
:
Date
;
notes
:
string
;
constructor
()
{}
}
code/moya-angular/src/app/moya-rest/models/vip-product.model.ts
0 → 100644
View file @
622edee
import
{
VipProductDelivery
}
from
"./vip-product-delivery.model"
;
/**
* Created by tuukka on 04/02/17.
*/
export
class
VipProduct
{
/*
public Integer id;
public String name;
public Integer productId;
public String notes;
public BigDecimal quantity;
public BigDecimal delivered;
public List<VipProductDeliveryPojo> deliveries = new ArrayList<>();
*/
id
:
number
;
name
:
string
;
productId
:
number
;
notes
:
string
;
quantity
:
number
;
delivered
:
number
;
deliveries
:
VipProductDelivery
[];
constructor
()
{}
}
code/moya-angular/src/app/moya-rest/models/vip.model.ts
0 → 100644
View file @
622edee
import
{
VipProduct
}
from
"./vip-product.model"
;
/**
* Created by tuukka on 04/02/17.
*/
export
class
Vip
{
/*
public Integer id;
public String description;
public String shortdescr;
public Date created;
public Integer eventuserId;
public Integer creatorId;
public Integer hostId;
public List<VipProductPojo> products = new ArrayList<>();
*/
id
:
number
;
description
:
string
;
shortdescr
:
string
;
created
:
Date
;
eventuserId
:
number
;
creatorId
:
number
;
hostId
:
number
;
products
:
VipProduct
[];
constructor
()
{}
}
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
0 → 100644
View file @
622edee
import
{
NgModule
,
ModuleWithProviders
}
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"
;
@
NgModule
({
imports
:
[
CommonModule
,
HttpModule
],
declarations
:
[]
})
export
class
MoyaRestModule
{
static
forRoot
():
ModuleWithProviders
{
return
{
ngModule
:
MoyaRestModule
,
providers
:
[
MoyaRestService
,
ViplistService
]
};
}
}
code/moya-angular/src/app/moya-rest/services/moya-rest.service.spec.ts
0 → 100644
View file @
622edee
/* tslint:disable:no-unused-variable */
import
{
TestBed
,
async
,
inject
}
from
'@angular/core/testing'
;
import
{
MoyaRestService
}
from
'./moya-rest.service'
;
describe
(
'MoyaRestService'
,
()
=>
{
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
providers
:
[
MoyaRestService
]
});
});
it
(
'should ...'
,
inject
([
MoyaRestService
],
(
service
:
MoyaRestService
)
=>
{
expect
(
service
).
toBeTruthy
();
}));
});
code/moya-angular/src/app/moya-rest/services/moya-rest.service.ts
0 → 100644
View file @
622edee
import
{
Injectable
}
from
'@angular/core'
;
import
{
Http
,
Response
}
from
"@angular/http"
;
import
{
Observable
}
from
"rxjs"
;
@
Injectable
()
export
class
MoyaRestService
{
constructor
(
private
http
:
Http
)
{
}
post
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
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
>
{
return
this
.
http
.
put
(
this
.
genUrl
(
subUrl
,
pathParameters
),
body
)
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
delete
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
return
this
.
http
.
delete
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
get
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Response
>
{
return
this
.
http
.
get
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
map
(
this
.
handleResponse
)
.
catch
(
this
.
handleException
);
}
private
genUrl
(
subUrl
:
string
,
urlParams
?
:
Map
<
string
,
string
>
):
string
{
let
suffix
=
""
;
if
(
urlParams
)
{
urlParams
.
forEach
(
function
(
value
:
string
,
key
:
string
)
{
if
(
suffix
.
length
<=
0
)
{
suffix
=
"?"
;
}
else
{
suffix
+=
"&"
;
}
suffix
+=
key
+
"="
+
value
;
});
}
return
"/MoyaWeb/rest/"
+
subUrl
+
suffix
;
// <-- TODO: kauneista
}
private
handleResponse
(
res
:
Response
)
{
// basicly, 200 statuscodes means success
if
(
!
(
res
.
status
>=
200
&&
res
.
status
<=
299
))
{
console
.
log
(
"statuscode not between 200 and 299"
,
res
.
status
);
// next stop: handlerException
throw
res
;
// <-- javakoodarin aivot nyrjähtivät juuri ympäri
}
return
res
;
}
private
handleException
(
error
:
Response
|
any
)
{
console
.
log
(
"error on jira rest connection"
,
error
);
// TODO: add handlers to 403's and other "not logged in" or "invalid permissions" -statuscodes, and route them using some nice global parameter
return
Observable
.
throw
(
error
);
}
}
code/moya-angular/src/app/moya-rest/services/viplist.service.spec.ts
0 → 100644
View file @
622edee
/* tslint:disable:no-unused-variable */
import
{
TestBed
,
async
,
inject
}
from
'@angular/core/testing'
;
import
{
ViplistService
}
from
'./viplist.service'
;
describe
(
'ViplistService'
,
()
=>
{
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
providers
:
[
ViplistService
]
});
});
it
(
'should ...'
,
inject
([
ViplistService
],
(
service
:
ViplistService
)
=>
{
expect
(
service
).
toBeTruthy
();
}));
});
code/moya-angular/src/app/moya-rest/services/viplist.service.ts
0 → 100644
View file @
622edee
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"
;
@
Injectable
()
export
class
ViplistService
{
constructor
(
private
moyaRestService
:
MoyaRestService
)
{
}
/**
* get vips
* @param searchString: searchString, skip to return all vips
*/
public
get
(
searchString
?:
string
):
Observable
<
Array
<
Vip
>>
{
if
(
!
searchString
)
{
return
this
.
moyaRestService
.
get
(
"v2/vip/all"
)
.
map
(
v
=>
v
.
json
());
}
return
this
.
moyaRestService
.
get
(
"v2/vip/search/"
+
searchString
)
.
map
(
v
=>
v
.
json
());
}
/**
* Delete vip.
*
* @param vip
* @return Observable
*/
public
async
delete
(
vip
:
Vip
):
Promise
<
boolean
>
{
if
(
!
vip
.
id
)
throw
new
Error
(
"TODO: errori, tyhmä vippi"
);
let
res
:
Response
=
await
this
.
moyaRestService
.
delete
(
"v2/vip/"
+
vip
.
id
)
.
first
()
.
toPromise
();
return
res
.
ok
;
}
public
getWithId
(
id
:
number
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
get
(
"v2/vip/"
+
id
)
.
map
(
v
=>
v
.
json
());
}
public
create
(
vip
:
Vip
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
post
(
"v2/vip/create"
,
vip
)
.
map
(
v
=>
v
.
json
());
}
}
code/moya-angular/src/app/test/test.component.css
0 → 100644
View file @
622edee
File mode changed
code/moya-angular/src/app/test/test.component.html
0 → 100644
View file @
622edee
<p>
test works!
</p>
code/moya-angular/src/app/test/test.component.spec.ts
0 → 100644
View file @
622edee
/* tslint:disable:no-unused-variable */
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
By
}
from
'@angular/platform-browser'
;
import
{
DebugElement
}
from
'@angular/core'
;
import
{
TestComponent
}
from
'./test.component'
;
describe
(
'TestComponent'
,
()
=>
{
let
component
:
TestComponent
;
let
fixture
:
ComponentFixture
<
TestComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
TestComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
TestComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
code/moya-angular/src/app/test/test.component.ts
0 → 100644
View file @
622edee
import
{
Component
,
OnInit
}
from
'@angular/core'
;
@
Component
({
selector
:
'app-test'
,
templateUrl
:
'./test.component.html'
,
styleUrls
:
[
'./test.component.css'
]
})
export
class
TestComponent
implements
OnInit
{
constructor
()
{
}
ngOnInit
()
{
}
}
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