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 0d127765
authored
Apr 01, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed xeii's comments
1 parent
9a876f0a
Pipeline
#34
passed
in 0 seconds
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
239 additions
and
828 deletions
code/moya-angular/.gitignore
code/moya-angular/README.md
code/moya-angular/e2e/tsconfig.json
code/moya-angular/src/app/app.component.js
code/moya-angular/src/app/app.component.spec.ts
code/moya-angular/src/app/app.component.ts
code/moya-angular/src/app/app.module.js
code/moya-angular/src/app/app.module.ts
code/moya-angular/src/app/components/moya-locale/moya-locale.component.ts
code/moya-angular/src/app/components/moya-locale/moya-locale.service.ts
code/moya-angular/src/app/menu/defines/menu.ts
code/moya-angular/src/app/menu/info-menu/info-menu.component.ts
code/moya-angular/src/app/menu/user-menu/user-menu.component.ts
code/moya-angular/src/app/moya-rest/index.ts
code/moya-angular/src/app/moya-rest/moya-rest.module.js
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
code/moya-angular/src/app/pages/old-moya/old-moya.component.js
code/moya-angular/src/app/pages/old-moya/old-moya.component.ts
code/moya-angular/src/app/shared/interceptors/error.interceptor.ts
code/moya-angular/src/app/shared/models/user.model.js
code/moya-angular/src/app/shared/models/vip-product-delivery.model.js
code/moya-angular/src/app/shared/models/vip-product.model.js
code/moya-angular/src/app/shared/models/vip-product.model.ts
code/moya-angular/src/app/shared/models/vip.model.js
code/moya-angular/src/app/shared/models/vip.model.ts
code/moya-angular/src/app/shared/services/cache.service.js
code/moya-angular/src/app/shared/services/cache.service.ts
code/moya-angular/src/app/shared/services/moya-rest.service.spec.ts
code/moya-angular/src/app/shared/services/moya-rest.service.ts
code/moya-angular/src/app/shared/services/user.service.js
code/moya-angular/src/app/shared/services/user.service.ts
code/moya-angular/src/app/shared/services/viplist.service.js
code/moya-angular/src/app/shared/services/viplist.service.ts
code/moya-angular/src/app/shared/tools/moya-rest.tool.ts
code/moya-angular/src/app/test/test.component.js
code/moya-angular/src/app/viplist/viplist.component.js
code/moya-angular/src/app/viplist/viplist.component.ts
code/moya-angular/src/test.ts
code/moya-angular/tslint.json
code/moya-angular/.gitignore
View file @
0d12776
...
@@ -40,3 +40,4 @@ package-lock.json
...
@@ -40,3 +40,4 @@ package-lock.json
#System Files
#System Files
.DS_Store
.DS_Store
Thumbs.db
Thumbs.db
code/moya-angular/README.md
View file @
0d12776
...
@@ -12,10 +12,10 @@ Kehittäminen on nopeampaa jos saa muutokset suoraan käyttöön, tämän takia
...
@@ -12,10 +12,10 @@ Kehittäminen on nopeampaa jos saa muutokset suoraan käyttöön, tämän takia
ng-palvelimessa on bugi, ja se ei osaa jakaa tavaraa muusta hakemistosta kuin /.
ng-palvelimessa on bugi, ja se ei osaa jakaa tavaraa muusta hakemistosta kuin /.
moyaproxy.conf.json sisältää proxyasetukset porttiin 8080.
moyaproxy.conf.json sisältää proxyasetukset
localhostin
porttiin 8080.
Käyttö:
Käyttö:
`n
g serve --preserve-symlinks --proxy-config=moyaproxy.conf.json --base-href=/
`
`n
pm run start
`
Tämän jälkeen kirjaa selaimesi sisään moyaan: http://localhost:4200/MoyaWeb/ ja surffata softaan: http://localhost:4200/
Tämän jälkeen kirjaa selaimesi sisään moyaan: http://localhost:4200/MoyaWeb/ ja surffata softaan: http://localhost:4200/
...
...
code/moya-angular/e2e/tsconfig.json
deleted
100644 → 0
View file @
9a876f0
{
"compileOnSave"
:
false
,
"compilerOptions"
:
{
"declaration"
:
false
,
"emitDecoratorMetadata"
:
true
,
"experimentalDecorators"
:
true
,
"module"
:
"commonjs"
,
"moduleResolution"
:
"node"
,
"outDir"
:
"../dist/out-tsc-e2e"
,
"sourceMap"
:
true
,
"target"
:
"es5"
,
"typeRoots"
:
[
"../node_modules/@types"
]
}
}
code/moya-angular/src/app/app.component.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
'@angular/core'
);
var
AppComponent
=
(
function
()
{
function
AppComponent
(
router
,
zone
)
{
this
.
router
=
router
;
this
.
zone
=
zone
;
this
.
counter
=
4
;
this
.
title
=
'app works!'
;
window
.
angularRoute
=
(
function
(
url
)
{
zone
.
run
(
function
()
{
router
.
navigateByUrl
(
url
);
});
});
// Enable change detection sometimes to see that it's not overflooded.
// bcause it takes time
//zone.onMicrotaskEmpty.subscribe(() => {console.log(".");}); // <-- Print "." everytime change detection is possibly
}
AppComponent
=
__decorate
([
core_1
.
Component
({
selector
:
'app-root'
,
templateUrl
:
'./app.component.html'
,
styleUrls
:
[
'./app.component.css'
]
})
],
AppComponent
);
return
AppComponent
;
}());
exports
.
AppComponent
=
AppComponent
;
code/moya-angular/src/app/app.component.spec.ts
View file @
0d12776
...
@@ -14,21 +14,21 @@ describe('AppComponent', () => {
...
@@ -14,21 +14,21 @@ describe('AppComponent', () => {
});
});
it
(
'should create the app'
,
async
(()
=>
{
it
(
'should create the app'
,
async
(()
=>
{
le
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
cons
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
le
t
app
=
fixture
.
debugElement
.
componentInstance
;
cons
t
app
=
fixture
.
debugElement
.
componentInstance
;
expect
(
app
).
toBeTruthy
();
expect
(
app
).
toBeTruthy
();
}));
}));
it
(
`should have as title 'app works!'`
,
async
(()
=>
{
it
(
`should have as title 'app works!'`
,
async
(()
=>
{
le
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
cons
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
le
t
app
=
fixture
.
debugElement
.
componentInstance
;
cons
t
app
=
fixture
.
debugElement
.
componentInstance
;
expect
(
app
.
title
).
toEqual
(
'app works!'
);
expect
(
app
.
title
).
toEqual
(
'app works!'
);
}));
}));
it
(
'should render title in a h1 tag'
,
async
(()
=>
{
it
(
'should render title in a h1 tag'
,
async
(()
=>
{
le
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
cons
t
fixture
=
TestBed
.
createComponent
(
AppComponent
);
fixture
.
detectChanges
();
fixture
.
detectChanges
();
le
t
compiled
=
fixture
.
debugElement
.
nativeElement
;
cons
t
compiled
=
fixture
.
debugElement
.
nativeElement
;
expect
(
compiled
.
querySelector
(
'h1'
).
textContent
).
toContain
(
'app works!'
);
expect
(
compiled
.
querySelector
(
'h1'
).
textContent
).
toContain
(
'app works!'
);
}));
}));
});
});
code/moya-angular/src/app/app.component.ts
View file @
0d12776
import
{
Component
,
NgZone
}
from
'@angular/core'
;
import
{
Component
,
NgZone
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Router
}
from
'@angular/router'
;
import
{
TranslateService
}
from
"@ngx-translate/core"
;
import
{
TranslateService
}
from
'@ngx-translate/core'
;
import
{
DEFAULT_LOCALE
,
MoyaLocaleService
}
from
"./components/moya-locale/moya-locale.service"
;
import
{
DEFAULT_LOCALE
,
MoyaLocaleService
}
from
'./components/moya-locale/moya-locale.service'
;
declare
var
window
:
any
;
declare
var
window
:
any
;
...
...
code/moya-angular/src/app/app.module.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
platform_browser_1
=
require
(
'@angular/platform-browser'
);
var
core_1
=
require
(
'@angular/core'
);
var
forms_1
=
require
(
'@angular/forms'
);
var
http_1
=
require
(
'@angular/http'
);
var
app_component_1
=
require
(
'./app.component'
);
var
viplist_component_1
=
require
(
'./viplist/viplist.component'
);
var
ng2_bootstrap_1
=
require
(
"ng2-bootstrap"
);
var
moya_angular_common_1
=
require
(
"moya-angular-common"
);
var
router_1
=
require
(
'@angular/router'
);
var
test_component_1
=
require
(
"./test/test.component"
);
var
old_moya_component_1
=
require
(
'./old-moya/old-moya.component'
);
var
safe_pipe_1
=
require
(
'./safe.pipe'
);
var
appRoutes
=
[
{
path
:
'vip/viplist'
,
component
:
viplist_component_1
.
ViplistComponent
},
{
path
:
'test'
,
component
:
test_component_1
.
TestComponent
},
{
path
:
'old'
,
component
:
old_moya_component_1
.
OldMoyaComponent
}
];
var
AppModule
=
(
function
()
{
function
AppModule
()
{
}
AppModule
=
__decorate
([
core_1
.
NgModule
({
declarations
:
[
app_component_1
.
AppComponent
,
viplist_component_1
.
ViplistComponent
,
test_component_1
.
TestComponent
,
old_moya_component_1
.
OldMoyaComponent
,
safe_pipe_1
.
SafePipe
,
],
imports
:
[
platform_browser_1
.
BrowserModule
,
forms_1
.
FormsModule
,
http_1
.
HttpModule
,
ng2_bootstrap_1
.
AlertModule
.
forRoot
(),
moya_angular_common_1
.
MoyaRestModule
.
forRoot
(),
router_1
.
RouterModule
.
forRoot
(
appRoutes
)
],
providers
:
[],
bootstrap
:
[
app_component_1
.
AppComponent
]
})
],
AppModule
);
return
AppModule
;
}());
exports
.
AppModule
=
AppModule
;
code/moya-angular/src/app/app.module.ts
View file @
0d12776
...
@@ -18,15 +18,17 @@ import {UserMenuComponent} from './menu/user-menu/user-menu.component';
...
@@ -18,15 +18,17 @@ import {UserMenuComponent} from './menu/user-menu/user-menu.component';
import
{
UserComponent
}
from
'./pages/user/user.component'
;
import
{
UserComponent
}
from
'./pages/user/user.component'
;
import
{
InfoComponent
}
from
'./pages/info/info.component'
;
import
{
InfoComponent
}
from
'./pages/info/info.component'
;
import
{
AdminComponent
}
from
'./pages/admin/admin.component'
;
import
{
AdminComponent
}
from
'./pages/admin/admin.component'
;
import
{
HttpClient
,
HttpClientModule
}
from
'@angular/common/http'
;
import
{
HTTP_INTERCEPTORS
,
HttpClient
,
HttpClientModule
}
from
'@angular/common/http'
;
import
{
CommonModule
}
from
"@angular/common"
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
CacheService
}
from
"./shared/services/cache.service"
;
import
{
CacheService
}
from
'./shared/services/cache.service'
;
import
{
MoyaRestModule
}
from
"./moya-rest"
;
import
{
SafePipe
}
from
'./shared/pipes/safe.pipe'
;
import
{
SafePipe
}
from
"./shared/pipes/safe.pipe"
;
import
{
TranslateLoader
,
TranslateModule
}
from
'@ngx-translate/core'
;
import
{
TranslateLoader
,
TranslateModule
}
from
"@ngx-translate/core"
;
import
{
TranslateHttpLoader
}
from
'@ngx-translate/http-loader'
;
import
{
TranslateHttpLoader
}
from
"@ngx-translate/http-loader"
;
import
{
MoyaLocaleService
}
from
'./components/moya-locale/moya-locale.service'
;
import
{
MoyaLocaleService
}
from
"./components/moya-locale/moya-locale.service"
;
import
{
MoyaLocaleComponent
}
from
'./components/moya-locale/moya-locale.component'
;
import
{
MoyaLocaleComponent
}
from
'./components/moya-locale/moya-locale.component'
;
import
{
ErrorInterceptor
}
from
'./shared/interceptors/error.interceptor'
;
import
{
ViplistService
}
from
'./shared/services/viplist.service'
;
import
{
UserService
}
from
'./shared/services/user.service'
;
const
appRoutes
:
Routes
=
[
const
appRoutes
:
Routes
=
[
{
{
...
@@ -83,19 +85,22 @@ const appRoutes: Routes = [
...
@@ -83,19 +85,22 @@ const appRoutes: Routes = [
FormsModule
,
FormsModule
,
HttpClientModule
,
HttpClientModule
,
AlertModule
.
forRoot
(),
AlertModule
.
forRoot
(),
MoyaRestModule
,
RouterModule
.
forRoot
(
appRoutes
),
RouterModule
.
forRoot
(
appRoutes
),
TranslateModule
.
forRoot
({
TranslateModule
.
forRoot
({
loader
:
{
loader
:
{
provide
:
TranslateLoader
,
provide
:
TranslateLoader
,
useFactory
:
function
(
http
:
HttpClient
)
{
useFactory
:
function
(
http
:
HttpClient
)
{
return
new
TranslateHttpLoader
(
http
,
"assets/i18n/"
,
".json"
);
return
new
TranslateHttpLoader
(
http
,
'assets/i18n/'
,
'.json'
);
},
},
deps
:
[
HttpClient
]
deps
:
[
HttpClient
]
}
}
})
})
],
],
providers
:
[
CacheService
,
MoyaLocaleService
],
providers
:
[
CacheService
,
MoyaLocaleService
,
{
provide
:
HTTP_INTERCEPTORS
,
useClass
:
ErrorInterceptor
,
multi
:
true
},
UserService
],
bootstrap
:
[
AppComponent
]
bootstrap
:
[
AppComponent
]
})
})
export
class
AppModule
{
export
class
AppModule
{
...
...
code/moya-angular/src/app/components/moya-locale/moya-locale.component.ts
View file @
0d12776
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
DEFAULT_LOCALE
,
MoyaLocaleService
}
from
"./moya-locale.service"
;
import
{
DEFAULT_LOCALE
,
MoyaLocaleService
}
from
'./moya-locale.service'
;
import
{
TranslateService
}
from
"@ngx-translate/core"
;
import
{
TranslateService
}
from
'@ngx-translate/core'
;
const
ENGLISH
=
"en"
;
const
ENGLISH
=
'en'
;
const
FINNISH
=
"fi"
;
const
FINNISH
=
'fi'
;
const
SWEDISH
=
"sv"
;
const
SWEDISH
=
'sv'
;
...
@@ -16,24 +16,24 @@ const SWEDISH = "sv";
...
@@ -16,24 +16,24 @@ const SWEDISH = "sv";
})
})
export
class
MoyaLocaleComponent
implements
OnInit
{
export
class
MoyaLocaleComponent
implements
OnInit
{
fiSelected
:
boolean
=
true
;
fiSelected
=
true
;
svSelected
:
boolean
=
true
;
svSelected
=
true
;
enSelected
:
boolean
=
true
;
enSelected
=
true
;
constructor
(
private
localeService
:
MoyaLocaleService
,
private
translate
:
TranslateService
)
{
constructor
(
private
localeService
:
MoyaLocaleService
,
private
translate
:
TranslateService
)
{
// fallback language
// fallback language
translate
.
setDefaultLang
(
DEFAULT_LOCALE
);
translate
.
setDefaultLang
(
DEFAULT_LOCALE
);
this
.
selectLocale
(
DEFAULT_LOCALE
);
this
.
selectLocale
(
DEFAULT_LOCALE
);
}
}
ngOnInit
()
{
ngOnInit
()
{
this
.
localeService
.
getUserLocale
().
subscribe
(
locale
=>
{
this
.
selectLocale
(
locale
)}
);
this
.
localeService
.
getUserLocale
().
subscribe
(
locale
=>
{
this
.
selectLocale
(
locale
)
;
}
);
}
}
selectLocale
(
locale
:
string
,
save
:
boolean
=
false
):
void
{
selectLocale
(
locale
:
string
,
save
=
false
):
void
{
if
(
!
[
ENGLISH
,
FINNISH
,
SWEDISH
].
includes
(
locale
))
{
if
(
!
[
ENGLISH
,
FINNISH
,
SWEDISH
].
includes
(
locale
))
{
return
;
return
;
}
}
...
@@ -53,7 +53,7 @@ export class MoyaLocaleComponent implements OnInit {
...
@@ -53,7 +53,7 @@ export class MoyaLocaleComponent implements OnInit {
break
;
break
;
}
}
if
(
save
)
{
if
(
save
)
{
this
.
localeService
.
setUserLocale
(
locale
).
subscribe
();
this
.
localeService
.
setUserLocale
(
locale
).
subscribe
();
}
}
...
...
code/moya-angular/src/app/components/moya-locale/moya-locale.service.ts
View file @
0d12776
import
{
Injectable
}
from
'@angular/core'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
MoyaRestService
}
from
"../../shared/services/moya-rest.service"
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
MoyaLocale
}
from
'./moya-locale.model'
;
import
{
MoyaLocale
}
from
"./moya-locale.model"
;
import
{
MOYA_BASE_URL
,
MoyaRestTool
}
from
'../../shared/tools/moya-rest.tool'
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
'rxjs/add/operator/catch'
;
export
const
DEFAULT_LOCALE
=
"fi"
;
export
const
DEFAULT_LOCALE
=
'fi'
;
const
LOCALSTORAGE_NAME
=
"currently used locale code"
;
const
LOCALSTORAGE_NAME
=
'currently used locale code'
;
@
Injectable
()
@
Injectable
()
export
class
MoyaLocaleService
{
export
class
MoyaLocaleService
{
constructor
(
private
moyaRest
:
MoyaRestService
)
{
}
constructor
(
private
http
:
HttpClient
)
{
}
/**
/**
...
@@ -24,21 +26,20 @@ export class MoyaLocaleService {
...
@@ -24,21 +26,20 @@ export class MoyaLocaleService {
* @return {Observable<string>} Return current locale as a string. No errors.
* @return {Observable<string>} Return current locale as a string. No errors.
*/
*/
public
getUserLocale
():
Observable
<
string
>
{
public
getUserLocale
():
Observable
<
string
>
{
return
this
.
moyaRest
.
get
(
"/v3/locale/"
).
catch
(
x
=>
null
).
map
(
untypedLocale
=>
{
const
locale
=
untypedLocale
as
MoyaLocale
;
return
this
.
http
.
get
<
MoyaLocale
>
(
MOYA_BASE_URL
+
'/v3/locale/'
).
catch
(
x
=>
Observable
.
of
(
new
MoyaLocale
())).
map
(
locale
=>
{
if
(
locale
&&
locale
.
userLocale
)
{
if
(
locale
&&
locale
.
userLocale
)
{
return
locale
.
userLocale
;
return
locale
.
userLocale
;
}
}
le
t
storageLocale
=
localStorage
.
getItem
(
LOCALSTORAGE_NAME
);
cons
t
storageLocale
=
localStorage
.
getItem
(
LOCALSTORAGE_NAME
);
if
(
storageLocale
)
{
if
(
storageLocale
)
{
return
storageLocale
;
return
storageLocale
;
}
}
if
(
locale
.
eventLocale
)
{
if
(
locale
.
eventLocale
)
{
return
locale
.
eventLocale
;
return
locale
.
eventLocale
;
}
}
...
@@ -56,14 +57,14 @@ export class MoyaLocaleService {
...
@@ -56,14 +57,14 @@ export class MoyaLocaleService {
*/
*/
public
setUserLocale
(
locale
:
string
):
Observable
<
any
>
{
public
setUserLocale
(
locale
:
string
):
Observable
<
any
>
{
le
t
newLocale
:
MoyaLocale
=
new
MoyaLocale
();
cons
t
newLocale
:
MoyaLocale
=
new
MoyaLocale
();
newLocale
.
userLocale
=
locale
;
newLocale
.
userLocale
=
locale
;
// let's save locale to database, if it fails, we save it into localstorage. No errors to show for user.
// let's save locale to database, if it fails, we save it into localstorage. No errors to show for user.
return
this
.
moyaRest
.
post
(
"/v3/locale/"
,
newLocale
).
first
().
catch
(
x
=>
{
return
this
.
http
.
post
(
MOYA_BASE_URL
+
'/v3/locale/'
,
newLocale
).
first
().
catch
(
x
=>
{
localStorage
.
setItem
(
LOCALSTORAGE_NAME
,
locale
);
localStorage
.
setItem
(
LOCALSTORAGE_NAME
,
locale
);
return
"ok"
;
return
'ok'
;
});
});
}
}
...
...
code/moya-angular/src/app/menu/defines/menu.ts
View file @
0d12776
...
@@ -6,7 +6,7 @@ import {MenuGroup} from '../models/menu-group.model';
...
@@ -6,7 +6,7 @@ import {MenuGroup} from '../models/menu-group.model';
export
class
MENU
{
export
class
MENU
{
static
ADMIN
:
MenuGroup
[]
=
[
static
ADMIN
:
MenuGroup
[]
=
[
{
{
'name'
:
'Kauppa'
,
'name'
:
'Kauppa'
,
'items'
:
[
'items'
:
[
...
...
code/moya-angular/src/app/menu/info-menu/info-menu.component.ts
View file @
0d12776
...
@@ -9,7 +9,7 @@ import {MENU} from '../defines/menu';
...
@@ -9,7 +9,7 @@ import {MENU} from '../defines/menu';
})
})
export
class
InfoMenuComponent
implements
OnInit
{
export
class
InfoMenuComponent
implements
OnInit
{
menu
:
MenuGroup
[]
=
MENU
.
INFO
;
menu
:
MenuGroup
[]
=
MENU
.
INFO
;
constructor
()
{
}
constructor
()
{
}
...
...
code/moya-angular/src/app/menu/user-menu/user-menu.component.ts
View file @
0d12776
...
@@ -9,7 +9,7 @@ import {MENU} from '../defines/menu';
...
@@ -9,7 +9,7 @@ import {MENU} from '../defines/menu';
})
})
export
class
UserMenuComponent
implements
OnInit
{
export
class
UserMenuComponent
implements
OnInit
{
menu
:
MenuGroup
[]
=
MENU
.
USER
;
menu
:
MenuGroup
[]
=
MENU
.
USER
;
constructor
()
{
}
constructor
()
{
}
...
...
code/moya-angular/src/app/moya-rest/index.ts
deleted
100644 → 0
View file @
9a876f0
export
*
from
"./moya-rest.module"
code/moya-angular/src/app/moya-rest/moya-rest.module.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
'@angular/core'
);
var
common_1
=
require
(
'@angular/common'
);
var
http_1
=
require
(
"@angular/http"
);
var
moya_rest_service_1
=
require
(
"../shared/services/moya-rest.service"
);
var
viplist_service_1
=
require
(
"../shared/services/viplist.service"
);
var
cache_service_1
=
require
(
"../shared/services/cache.service"
);
var
user_service_1
=
require
(
"../shared/services/user.service"
);
var
MoyaRestModule
=
(
function
()
{
function
MoyaRestModule
()
{
}
MoyaRestModule
.
forRoot
=
function
()
{
return
{
ngModule
:
MoyaRestModule
,
providers
:
[
moya_rest_service_1
.
MoyaRestService
,
viplist_service_1
.
ViplistService
,
cache_service_1
.
CacheService
,
user_service_1
.
UserService
]
};
};
MoyaRestModule
=
__decorate
([
core_1
.
NgModule
({
imports
:
[
common_1
.
CommonModule
,
http_1
.
HttpModule
],
declarations
:
[]
})
],
MoyaRestModule
);
return
MoyaRestModule
;
}());
exports
.
MoyaRestModule
=
MoyaRestModule
;
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
deleted
100644 → 0
View file @
9a876f0
import
{
NgModule
,
ModuleWithProviders
,
NgZone
,
Injector
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
MoyaRestService
}
from
"../shared/services/moya-rest.service"
;
import
{
ViplistService
}
from
"../shared/services/viplist.service"
;
import
{
CacheService
}
from
"../shared/services/cache.service"
;
import
{
UserService
}
from
"../shared/services/user.service"
;
import
{
HttpClientModule
}
from
"@angular/common/http"
;
import
{
HttpModule
}
from
"@angular/http"
;
export
*
from
"../shared/services/moya-rest.service"
;
export
*
from
"../shared/services/viplist.service"
;
export
*
from
"../shared/services/cache.service"
;
export
*
from
"../shared/services/user.service"
;
export
*
from
"../shared/models/user.model"
;
export
*
from
"../shared/models/vip.model"
;
export
*
from
"../shared/models/vip-product.model"
;
export
*
from
"../shared/models/vip-product-delivery.model"
;
@
NgModule
({
imports
:
[
CommonModule
,
HttpClientModule
],
declarations
:
[
],
providers
:
[
MoyaRestService
,
ViplistService
,
CacheService
,
UserService
,
HttpClientModule
/*{ provide: NgZone, useFactory: () => new NgZone({}) },
{ provide: Injector, useFactory: () => Injector.create({providers: []}) } */
],
exports
:
[
],
})
export
class
MoyaRestModule
{
/*
static forRoot(): ModuleWithProviders {
return {
ngModule: MoyaRestModule,
providers: [
MoyaRestService,
ViplistService,
CacheService,
UserService,
HttpClientModule
/*{ provide: NgZone, useFactory: () => new NgZone({}) },
{ provide: Injector, useFactory: () => Injector.create({providers: []}) }
]
};
}*/
}
code/moya-angular/src/app/pages/old-moya/old-moya.component.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
'@angular/core'
);
var
common_1
=
require
(
"@angular/common"
);
var
OldMoyaComponent
=
(
function
()
{
function
OldMoyaComponent
(
location
)
{
this
.
location
=
location
;
this
.
frameUrl
=
"/MoyaWeb/"
;
}
OldMoyaComponent
.
prototype
.
ngOnInit
=
function
()
{
};
OldMoyaComponent
.
prototype
.
logIt
=
function
()
{
console
.
log
(
this
.
frameUrl
);
console
.
log
(
this
.
frametus
.
nativeElement
.
contentWindow
.
location
.
href
);
console
.
log
(
location
.
path
(
true
));
};
__decorate
([
core_1
.
ViewChild
(
'frametus'
)
],
OldMoyaComponent
.
prototype
,
"frametus"
,
void
0
);
OldMoyaComponent
=
__decorate
([
core_1
.
Component
({
selector
:
'app-old-moya'
,
providers
:
[
common_1
.
Location
,
{
provide
:
common_1
.
LocationStrategy
,
useClass
:
common_1
.
PathLocationStrategy
}],
templateUrl
:
'./old-moya.component.html'
,
styleUrls
:
[
'./old-moya.component.css'
]
})
],
OldMoyaComponent
);
return
OldMoyaComponent
;
}());
exports
.
OldMoyaComponent
=
OldMoyaComponent
;
code/moya-angular/src/app/pages/old-moya/old-moya.component.ts
View file @
0d12776
...
@@ -25,7 +25,7 @@ export class OldMoyaComponent implements OnInit {
...
@@ -25,7 +25,7 @@ export class OldMoyaComponent implements OnInit {
route
.
queryParamMap
.
map
(
a
=>
a
.
get
(
'p'
)).
subscribe
(
x
=>
{
route
.
queryParamMap
.
map
(
a
=>
a
.
get
(
'p'
)).
subscribe
(
x
=>
{
console
.
log
(
x
);
console
.
log
(
x
);
if
(
x
)
{
if
(
x
)
{
this
.
frameUrl
=
'/MoyaWeb/'
+
x
.
replace
(
"::"
,
"?"
);
this
.
frameUrl
=
'/MoyaWeb/'
+
x
.
replace
(
'::'
,
'?'
);
}
}
});
});
}
}
...
@@ -34,10 +34,10 @@ export class OldMoyaComponent implements OnInit {
...
@@ -34,10 +34,10 @@ export class OldMoyaComponent implements OnInit {
ngOnInit
()
{
}
ngOnInit
()
{
}
changeUrl
()
{
changeUrl
()
{
le
t
tmpFrameUrl
=
this
.
iframe
.
nativeElement
.
contentWindow
.
location
.
href
.
split
(
'/MoyaWeb/'
,
2
);
cons
t
tmpFrameUrl
=
this
.
iframe
.
nativeElement
.
contentWindow
.
location
.
href
.
split
(
'/MoyaWeb/'
,
2
);
if
(
tmpFrameUrl
.
length
>
1
)
{
if
(
tmpFrameUrl
.
length
>
1
)
{
this
.
location
.
replaceState
(
this
.
location
.
path
(
false
).
split
(
'?'
,
1
)[
0
]
+
'?p='
+
tmpFrameUrl
[
1
].
replace
(
"?"
,
"::"
)
);
this
.
location
.
replaceState
(
this
.
location
.
path
(
false
).
split
(
'?'
,
1
)[
0
]
+
'?p='
+
tmpFrameUrl
[
1
].
replace
(
'?'
,
'::'
)
);
}
}
...
...
code/moya-angular/src/app/shared/interceptors/error.interceptor.ts
0 → 100644
View file @
0d12776
import
{
HttpEvent
,
HttpEventType
,
HttpHandler
,
HttpInterceptor
,
HttpRequest
,
HttpResponse
}
from
'@angular/common/http'
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
'rxjs/add/operator/catch'
;
export
class
ErrorInterceptor
implements
HttpInterceptor
{
intercept
(
req
:
HttpRequest
<
any
>
,
next
:
HttpHandler
):
Observable
<
HttpEvent
<
HttpEventType
.
Response
>>
{
return
next
.
handle
(
req
).
catch
(
this
.
handleException
);
}
private
handleException
(
error
:
HttpResponse
<
any
>
)
{
console
.
log
(
'error on MOYA 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/shared/models/user.model.js
deleted
100644 → 0
View file @
9a876f0
/**
* Created by tuukka on 15/02/17.
*/
"use strict"
;
// vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/
(
function
(
UserGender
)
{
UserGender
[
UserGender
[
"MALE"
]
=
0
]
=
"MALE"
;
UserGender
[
UserGender
[
"FEMALE"
]
=
1
]
=
"FEMALE"
;
UserGender
[
UserGender
[
"UNSPECIFIED"
]
=
2
]
=
"UNSPECIFIED"
;
})(
exports
.
UserGender
||
(
exports
.
UserGender
=
{}));
var
UserGender
=
exports
.
UserGender
;
var
User
=
(
function
()
{
function
User
()
{
}
return
User
;
}());
exports
.
User
=
User
;
code/moya-angular/src/app/shared/models/vip-product-delivery.model.js
deleted
100644 → 0
View file @
9a876f0
/**
* Created by tuukka on 04/02/17.
*/
"use strict"
;
var
VipProductDelivery
=
(
function
()
{
function
VipProductDelivery
()
{
}
return
VipProductDelivery
;
}());
exports
.
VipProductDelivery
=
VipProductDelivery
;
code/moya-angular/src/app/shared/models/vip-product.model.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
/**
* Created by tuukka on 04/02/17.
*/
var
VipProduct
=
(
function
()
{
function
VipProduct
()
{
}
return
VipProduct
;
}());
exports
.
VipProduct
=
VipProduct
;
code/moya-angular/src/app/shared/models/vip-product.model.ts
View file @
0d12776
import
{
VipProductDelivery
}
from
"./vip-product-delivery.model"
;
import
{
VipProductDelivery
}
from
'./vip-product-delivery.model'
;
/**
/**
* Created by tuukka on 04/02/17.
* Created by tuukka on 04/02/17.
*/
*/
...
@@ -25,7 +25,7 @@ export class VipProduct {
...
@@ -25,7 +25,7 @@ export class VipProduct {
notes
:
string
;
notes
:
string
;
quantity
:
number
;
quantity
:
number
;
delivered
:
number
;
delivered
:
number
;
deliveries
:
VipProductDelivery
[];
deliveries
:
VipProductDelivery
[];
constructor
()
{}
constructor
()
{}
...
...
code/moya-angular/src/app/shared/models/vip.model.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
/**
* Created by tuukka on 04/02/17.
*/
var
Vip
=
(
function
()
{
function
Vip
()
{
}
return
Vip
;
}());
exports
.
Vip
=
Vip
;
code/moya-angular/src/app/shared/models/vip.model.ts
View file @
0d12776
import
{
VipProduct
}
from
"./vip-product.model"
;
import
{
VipProduct
}
from
'./vip-product.model'
;
import
{
User
}
from
"./user.model"
;
import
{
User
}
from
'./user.model'
;
/**
/**
* Created by tuukka on 04/02/17.
* Created by tuukka on 04/02/17.
*/
*/
...
...
code/moya-angular/src/app/shared/services/cache.service.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
"@angular/core"
);
var
rxjs_1
=
require
(
"rxjs"
);
var
DEFAULT_EXPIRE_MS
=
300000
;
// 5min
var
CachedItem
=
(
function
()
{
function
CachedItem
(
moduleName
,
path
,
value
,
isObservable
)
{
this
.
moduleName
=
moduleName
;
this
.
path
=
path
;
this
.
value
=
value
;
this
.
expires
=
new
Date
();
this
.
expires
.
setTime
(
Date
.
now
()
+
DEFAULT_EXPIRE_MS
);
this
.
isObservable
=
isObservable
;
}
CachedItem
.
prototype
.
isExpired
=
function
()
{
return
this
.
expires
.
getTime
()
<
Date
.
now
();
};
return
CachedItem
;
}());
/**
* Basic cacheService.
*
* First this was part of moyaRestService, but I thinked that if cache is too easy to use, someone will kill this application with it.
* So let's make it litlebit harder
*/
var
CacheService
=
(
function
()
{
// TODO: timed clearup for cache to save memory
function
CacheService
(
zone
)
{
this
.
zone
=
zone
;
this
.
cache
=
new
Map
();
this
.
timerObservable
=
rxjs_1
.
Observable
.
timer
(
30000
,
30000
);
// afther 0.5min, every 0.5min.
}
/**
* This will return observable with value from cache, or cache value from your observable and return it in observable.
*
* example: return cacheService.cacheObservable("mymodule",<url>, http.get(<url>).map(v => v.json()));
*
* @param moduleName
* @param cachePath
* @param source: {Observable<any>} Observable where the values, which are cached, is coming from
* @return {Observable<any>}: if value is in cache, this is observable made from this value. Otherwise this is source observable.
*/
CacheService
.
prototype
.
cacheObservable
=
function
(
moduleName
,
cachePath
,
source
)
{
var
_this
=
this
;
var
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
console
.
log
(
cacheName
,
" Expired version in cache"
);
this
.
cache
.
delete
(
cacheName
);
}
if
(
!
this
.
cache
.
has
(
cacheName
))
{
/*
not in cache, let's change source to hot -observable, and return one instance from it
problem is, that before this observable is runned, there can be queries for this value from cache.
So, let's change this to hot-observable, and put that hot-observable into the cache.
And in first run, we change this hot observable to it's value.
Javascript is asynchronous, so there is no need to worry some weird things that could happen in multithreaded languages.
*/
console
.
log
(
cacheName
,
" not in cache"
);
var
hotSource
=
source
.
do
(
function
(
val
)
{
return
_this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
val
));
})
.
publishLast
().
refCount
();
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
hotSource
,
true
));
this
.
checkCleanTimer
();
return
hotSource
;
}
var
cacheItem
=
this
.
cache
.
get
(
cacheName
);
// if value is hotObservable, return it, otherwise create observable from value
if
(
cacheItem
.
isObservable
)
{
console
.
log
(
cacheName
,
" hot observable in cache "
);
return
cacheItem
.
value
;
}
console
.
log
(
cacheName
,
" value in cache"
);
this
.
checkCleanTimer
();
return
rxjs_1
.
Observable
.
of
(
cacheItem
.
value
);
};
CacheService
.
prototype
.
clean
=
function
()
{
this
.
cache
.
clear
();
this
.
checkCleanTimer
();
};
CacheService
.
prototype
.
cleanExpired
=
function
()
{
var
_this
=
this
;
this
.
cache
.
forEach
(
function
(
v
,
k
)
{
if
(
v
.
isExpired
())
{
console
.
log
(
k
,
" Cache expired"
);
_this
.
cache
.
delete
(
k
);
}
});
this
.
checkCleanTimer
();
};
CacheService
.
prototype
.
checkCleanTimer
=
function
()
{
var
_this
=
this
;
if
(
this
.
cache
.
size
>
0
)
{
if
(
!
this
.
timerSubscription
)
{
console
.
log
(
"adding clearing timer"
);
this
.
zone
.
runOutsideAngular
(
function
()
{
_this
.
timerSubscription
=
_this
.
timerObservable
.
subscribe
(
function
(
v
)
{
_this
.
cleanExpired
();
});
});
}
}
else
{
if
(
this
.
timerSubscription
)
{
console
.
log
(
"removing clearing timer"
);
this
.
timerSubscription
.
unsubscribe
();
}
}
};
/**
*
* @param moduleName
* @param cachePath
* @param value
*/
CacheService
.
prototype
.
set
=
function
(
moduleName
,
cachePath
,
value
)
{
var
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
value
));
};
/**
* Get one value from cache.
*
* Now when there is this observablethingy. Make public afther rethinking this.
*
* @param moduleName
* @param cachePath
* @return {any|null} Null if nothing is in cache.
*/
CacheService
.
prototype
.
get
=
function
(
moduleName
,
cachePath
)
{
var
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
this
.
cache
.
delete
(
cacheName
);
}
if
(
this
.
cache
.
has
(
cacheName
))
{
return
this
.
cache
.
get
(
cacheName
);
}
return
null
;
};
CacheService
.
prototype
.
generateCachename
=
function
(
moduleName
,
cachePath
)
{
return
moduleName
+
"::"
+
cachePath
;
};
CacheService
=
__decorate
([
core_1
.
Injectable
()
],
CacheService
);
return
CacheService
;
}());
exports
.
CacheService
=
CacheService
;
code/moya-angular/src/app/shared/services/cache.service.ts
View file @
0d12776
import
{
Injectable
,
NgZone
}
from
"@angular/core"
;
import
{
Injectable
,
NgZone
}
from
'@angular/core'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
'rxjs/add/observable/timer'
;
import
'rxjs/add/observable/timer'
;
import
{
forkJoin
}
from
"rxjs/observable/forkJoin"
;
import
{
forkJoin
}
from
'rxjs/observable/forkJoin'
;
import
"rxjs/add/operator/do"
;
import
'rxjs/add/operator/do'
;
import
"rxjs/add/operator/publishLast"
;
import
'rxjs/add/operator/publishLast'
;
import
"rxjs/add/observable/of"
;
import
'rxjs/add/observable/of'
;
import
{
Subscription
}
from
"rxjs/Subscription"
;
import
{
Subscription
}
from
'rxjs/Subscription'
;
const
DEFAULT_EXPIRE_MS
=
300000
;
// 5min
const
DEFAULT_EXPIRE_MS
=
300000
;
// 5min
...
@@ -17,7 +17,7 @@ class CachedItem {
...
@@ -17,7 +17,7 @@ class CachedItem {
expires
:
Date
;
expires
:
Date
;
isObservable
:
boolean
;
isObservable
:
boolean
;
constructor
(
moduleName
:
string
,
path
:
string
,
value
:
any
,
isObservable
?
:
boolean
)
{
constructor
(
moduleName
:
string
,
path
:
string
,
value
:
any
,
isObservable
?:
boolean
)
{
this
.
moduleName
=
moduleName
;
this
.
moduleName
=
moduleName
;
this
.
path
=
path
;
this
.
path
=
path
;
this
.
value
=
value
;
this
.
value
=
value
;
...
@@ -42,7 +42,7 @@ class CachedItem {
...
@@ -42,7 +42,7 @@ class CachedItem {
@
Injectable
()
@
Injectable
()
export
class
CacheService
{
export
class
CacheService
{
private
timerSubscription
:
Subscription
;
private
timerSubscription
:
Subscription
;
private
timerObservable
:
Observable
<
any
>
;
private
timerObservable
:
Observable
<
any
>
;
...
@@ -50,7 +50,7 @@ export class CacheService {
...
@@ -50,7 +50,7 @@ export class CacheService {
// TODO: timed clearup for cache to save memory
// TODO: timed clearup for cache to save memory
constructor
(
private
zone
:
NgZone
)
{
constructor
(
private
zone
:
NgZone
)
{
this
.
cache
=
new
Map
<
string
,
CachedItem
>
();
this
.
cache
=
new
Map
<
string
,
CachedItem
>
();
this
.
timerObservable
=
Observable
.
timer
(
30000
,
30000
);
// afther 0.5min, every 0.5min.
this
.
timerObservable
=
Observable
.
timer
(
30000
,
30000
);
// afther 0.5min, every 0.5min.
...
@@ -68,15 +68,15 @@ export class CacheService {
...
@@ -68,15 +68,15 @@ export class CacheService {
* @return {Observable<any>}: if value is in cache, this is observable made from this value. Otherwise this is source observable.
* @return {Observable<any>}: if value is in cache, this is observable made from this value. Otherwise this is source observable.
*/
*/
public
cacheObservable
(
moduleName
:
string
,
cachePath
:
string
,
source
:
Observable
<
any
>
):
Observable
<
any
>
{
public
cacheObservable
(
moduleName
:
string
,
cachePath
:
string
,
source
:
Observable
<
any
>
):
Observable
<
any
>
{
le
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
cons
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
console
.
log
(
cacheName
,
" Expired version in cache"
);
console
.
log
(
cacheName
,
' Expired version in cache'
);
this
.
cache
.
delete
(
cacheName
);
this
.
cache
.
delete
(
cacheName
);
}
}
if
(
!
this
.
cache
.
has
(
cacheName
))
{
if
(
!
this
.
cache
.
has
(
cacheName
))
{
/*
/*
not in cache, let's change source to hot -observable, and return one instance from it
not in cache, let's change source to hot -observable, and return one instance from it
problem is, that before this observable is runned, there can be queries for this value from cache.
problem is, that before this observable is runned, there can be queries for this value from cache.
...
@@ -86,13 +86,13 @@ export class CacheService {
...
@@ -86,13 +86,13 @@ export class CacheService {
Javascript is asynchronous, so there is no need to worry some weird things that could happen in multithreaded languages.
Javascript is asynchronous, so there is no need to worry some weird things that could happen in multithreaded languages.
*/
*/
console
.
log
(
cacheName
,
" not in cache"
);
console
.
log
(
cacheName
,
' not in cache'
);
le
t
hotSource
=
source
cons
t
hotSource
=
source
.
do
(
val
=>
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
val
)))
.
do
(
val
=>
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
val
)))
.
publishLast
().
refCount
();
.
publishLast
().
refCount
();
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
hotSource
,
true
));
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
hotSource
,
true
));
this
.
checkCleanTimer
();
this
.
checkCleanTimer
();
...
@@ -101,15 +101,15 @@ export class CacheService {
...
@@ -101,15 +101,15 @@ export class CacheService {
le
t
cacheItem
=
this
.
cache
.
get
(
cacheName
);
cons
t
cacheItem
=
this
.
cache
.
get
(
cacheName
);
// if value is hotObservable, return it, otherwise create observable from value
// if value is hotObservable, return it, otherwise create observable from value
if
(
cacheItem
.
isObservable
)
{
if
(
cacheItem
.
isObservable
)
{
console
.
log
(
cacheName
,
" hot observable in cache "
);
console
.
log
(
cacheName
,
' hot observable in cache '
);
return
cacheItem
.
value
;
return
cacheItem
.
value
;
}
}
console
.
log
(
cacheName
,
" value in cache"
);
console
.
log
(
cacheName
,
' value in cache'
);
this
.
checkCleanTimer
();
this
.
checkCleanTimer
();
return
Observable
.
of
(
cacheItem
.
value
);
return
Observable
.
of
(
cacheItem
.
value
);
...
@@ -124,9 +124,9 @@ export class CacheService {
...
@@ -124,9 +124,9 @@ export class CacheService {
public
cleanExpired
():
void
{
public
cleanExpired
():
void
{
this
.
cache
.
forEach
((
v
,
k
)
=>
{
this
.
cache
.
forEach
((
v
,
k
)
=>
{
if
(
v
.
isExpired
())
{
if
(
v
.
isExpired
())
{
console
.
log
(
k
,
" Cache expired"
);
console
.
log
(
k
,
' Cache expired'
);
this
.
cache
.
delete
(
k
);
this
.
cache
.
delete
(
k
);
}});
}});
...
@@ -134,9 +134,9 @@ export class CacheService {
...
@@ -134,9 +134,9 @@ export class CacheService {
}
}
private
checkCleanTimer
()
{
private
checkCleanTimer
()
{
if
(
this
.
cache
.
size
>
0
)
{
if
(
this
.
cache
.
size
>
0
)
{
if
(
!
this
.
timerSubscription
)
{
if
(
!
this
.
timerSubscription
)
{
console
.
log
(
"adding clearing timer"
);
console
.
log
(
'adding clearing timer'
);
this
.
zone
.
runOutsideAngular
(()
=>
{
this
.
zone
.
runOutsideAngular
(()
=>
{
this
.
timerSubscription
=
this
.
timerObservable
.
subscribe
(
v
=>
{
this
.
timerSubscription
=
this
.
timerObservable
.
subscribe
(
v
=>
{
...
@@ -146,9 +146,9 @@ export class CacheService {
...
@@ -146,9 +146,9 @@ export class CacheService {
}
}
}
else
{
}
else
{
if
(
this
.
timerSubscription
)
{
if
(
this
.
timerSubscription
)
{
console
.
log
(
"removing clearing timer"
);
console
.
log
(
'removing clearing timer'
);
this
.
timerSubscription
.
unsubscribe
();
this
.
timerSubscription
.
unsubscribe
();
}
}
}
}
...
@@ -163,9 +163,9 @@ export class CacheService {
...
@@ -163,9 +163,9 @@ export class CacheService {
* @param value
* @param value
*/
*/
private
set
(
moduleName
:
string
,
cachePath
:
string
,
value
:
any
):
void
{
private
set
(
moduleName
:
string
,
cachePath
:
string
,
value
:
any
):
void
{
le
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
cons
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
value
));
this
.
cache
.
set
(
cacheName
,
new
CachedItem
(
moduleName
,
cachePath
,
value
));
}
}
/**
/**
...
@@ -178,14 +178,14 @@ export class CacheService {
...
@@ -178,14 +178,14 @@ export class CacheService {
* @return {any|null} Null if nothing is in cache.
* @return {any|null} Null if nothing is in cache.
*/
*/
private
get
(
moduleName
:
string
,
cachePath
:
string
):
CachedItem
{
private
get
(
moduleName
:
string
,
cachePath
:
string
):
CachedItem
{
le
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
cons
t
cacheName
=
this
.
generateCachename
(
moduleName
,
cachePath
);
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
if
(
this
.
cache
.
has
(
cacheName
)
&&
this
.
cache
.
get
(
cacheName
).
expires
.
getTime
()
<
Date
.
now
())
{
this
.
cache
.
delete
(
cacheName
);
this
.
cache
.
delete
(
cacheName
);
}
}
if
(
this
.
cache
.
has
(
cacheName
))
{
if
(
this
.
cache
.
has
(
cacheName
))
{
return
this
.
cache
.
get
(
cacheName
);
return
this
.
cache
.
get
(
cacheName
);
}
}
...
@@ -194,7 +194,7 @@ export class CacheService {
...
@@ -194,7 +194,7 @@ export class CacheService {
private
generateCachename
(
moduleName
:
string
,
cachePath
:
string
):
string
{
private
generateCachename
(
moduleName
:
string
,
cachePath
:
string
):
string
{
return
moduleName
+
"::"
+
cachePath
;
return
moduleName
+
'::'
+
cachePath
;
}
}
}
}
code/moya-angular/src/app/shared/services/moya-rest.service.spec.ts
deleted
100644 → 0
View file @
9a876f0
/* 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/shared/services/moya-rest.service.ts
deleted
100644 → 0
View file @
9a876f0
import
{
Injectable
}
from
'@angular/core'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
HttpClient
,
HttpResponse
}
from
"@angular/common/http"
;
import
"rxjs/add/operator/catch"
;
import
"rxjs/add/observable/throw"
;
@
Injectable
()
export
class
MoyaRestService
{
constructor
(
private
http
:
HttpClient
)
{
}
post
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Object
>
{
return
this
.
http
.
post
(
this
.
genUrl
(
subUrl
,
pathParameters
),
body
)
.
catch
(
this
.
handleException
);
}
put
(
subUrl
:
string
,
body
:
any
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Object
>
{
return
this
.
http
.
put
(
this
.
genUrl
(
subUrl
,
pathParameters
),
body
)
.
catch
(
this
.
handleException
);
}
delete
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Object
>
{
return
this
.
http
.
delete
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
catch
(
this
.
handleException
);
}
get
(
subUrl
:
string
,
pathParameters
?:
Map
<
string
,
string
>
):
Observable
<
Object
>
{
return
this
.
http
.
get
(
this
.
genUrl
(
subUrl
,
pathParameters
))
.
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
handleException
(
error
:
HttpResponse
<
any
>
|
any
)
{
console
.
log
(
"error on MOYA 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/shared/services/user.service.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
"@angular/core"
);
var
rxjs_1
=
require
(
"rxjs"
);
var
UserService
=
(
function
()
{
function
UserService
(
moyaRest
,
cacheService
)
{
this
.
moyaRest
=
moyaRest
;
this
.
cacheService
=
cacheService
;
}
UserService
.
prototype
.
get
=
function
(
id
)
{
if
(
!
id
||
id
<
0
)
{
return
rxjs_1
.
Observable
.
throw
(
"There should be userid"
);
}
var
path
=
"v2/user/"
+
id
;
return
this
.
cacheService
.
cacheObservable
(
"moya:UserService"
,
path
,
this
.
moyaRest
.
get
(
path
)
.
do
(
function
(
v
)
{
console
.
log
(
"getting user outside of cache"
,
path
);
})
.
map
(
function
(
res
)
{
return
(
res
.
json
());
}));
};
UserService
=
__decorate
([
core_1
.
Injectable
()
],
UserService
);
return
UserService
;
}());
exports
.
UserService
=
UserService
;
code/moya-angular/src/app/shared/services/user.service.ts
View file @
0d12776
import
{
Injectable
}
from
"@angular/core"
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
User
}
from
"../models/user.model"
;
import
{
User
}
from
'../models/user.model'
;
import
{
MoyaRestService
}
from
"./moya-rest.service"
;
import
{
CacheService
}
from
'./cache.service'
;
import
{
CacheService
}
from
"./cache.service"
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
{
MOYA_BASE_URL
}
from
'../tools/moya-rest.tool'
;
@
Injectable
()
@
Injectable
()
export
class
UserService
{
export
class
UserService
{
constructor
(
private
moyaRest
:
MoyaRestService
,
private
cacheService
:
CacheService
)
{
}
constructor
(
private
http
:
HttpClient
,
private
cacheService
:
CacheService
)
{
}
public
get
(
id
:
number
):
Observable
<
User
>
{
public
get
(
id
:
number
):
Observable
<
User
>
{
if
(
!
id
||
id
<
0
)
{
if
(
!
id
||
id
<
0
)
{
return
Observable
.
throw
(
"There should be userid"
);
return
Observable
.
throw
(
'There should be userid'
);
}
}
let
path
=
"v2/user/"
+
id
;
const
path
=
MOYA_BASE_URL
+
'v2/user/'
+
id
;
return
this
.
cacheService
.
cacheObservable
(
"moya:UserService"
,
path
,
return
this
.
cacheService
.
cacheObservable
(
'moya:UserService'
,
path
,
this
.
moyaRest
.
get
(
path
)
this
.
http
.
get
<
User
>
(
path
)
.
do
(
v
=>
{
console
.
log
(
"getting user outside of cache"
,
path
)})
.
do
(
v
=>
{
console
.
log
(
'getting user outside of cache'
,
path
);
}));
.
map
(
res
=>
(
<
User
>
res
)));
}
}
}
}
code/moya-angular/src/app/shared/services/viplist.service.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
.
throw
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
new
P
(
function
(
resolve
)
{
resolve
(
result
.
value
);
}).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
)).
next
());
});
};
var
core_1
=
require
(
'@angular/core'
);
var
rxjs_1
=
require
(
"rxjs"
);
var
ViplistService
=
(
function
()
{
function
ViplistService
(
moyaRestService
,
userService
)
{
this
.
moyaRestService
=
moyaRestService
;
this
.
userService
=
userService
;
}
/**
* get vips
* @param searchString: searchString, skip to return all vips
*/
ViplistService
.
prototype
.
get
=
function
(
searchString
)
{
var
_this
=
this
;
if
(
!
searchString
)
{
return
this
.
moyaRestService
.
get
(
"v3/vip/all"
)
.
switchMap
(
function
(
res
)
{
return
rxjs_1
.
Observable
.
forkJoin
.
apply
(
rxjs_1
.
Observable
,
res
.
json
().
map
(
function
(
apiRow
)
{
return
_this
.
hostPopulator
(
apiRow
);
}));
});
}
return
this
.
moyaRestService
.
get
(
"v3/vip/search/"
+
searchString
)
.
switchMap
(
function
(
v
)
{
return
rxjs_1
.
Observable
.
forkJoin
.
apply
(
rxjs_1
.
Observable
,
v
.
json
().
map
(
function
(
x
)
{
return
_this
.
hostPopulator
(
x
);
}));
});
};
/**
* Delete vip.
*
* @param vip
* @return Observable
*/
ViplistService
.
prototype
.
delete
=
function
(
vip
)
{
return
__awaiter
(
this
,
void
0
,
Promise
,
function
*
()
{
if
(
!
vip
.
id
)
throw
new
Error
(
"TODO: errori, tyhmä vippi"
);
var
res
=
yield
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);
}
*/
ViplistService
.
prototype
.
getWithId
=
function
(
id
)
{
return
this
.
moyaRestService
.
get
(
"v3/vip/"
+
id
)
.
map
(
function
(
v
)
{
return
v
.
json
();
});
};
ViplistService
.
prototype
.
create
=
function
(
vip
)
{
return
this
.
moyaRestService
.
post
(
"v3/vip/create"
,
vip
)
.
map
(
function
(
v
)
{
return
v
.
json
();
});
};
ViplistService
.
prototype
.
hostPopulator
=
function
(
rawVip
)
{
return
this
.
userService
.
get
(
rawVip
.
hostId
)
.
map
(
function
(
u
)
{
rawVip
.
host
=
u
;
return
rawVip
;
});
};
ViplistService
=
__decorate
([
core_1
.
Injectable
()
],
ViplistService
);
return
ViplistService
;
}());
exports
.
ViplistService
=
ViplistService
;
code/moya-angular/src/app/shared/services/viplist.service.ts
View file @
0d12776
import
{
Injectable
}
from
'@angular/core'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
MoyaRestService
}
from
"./moya-rest.service"
;
import
{
Vip
}
from
'../models/vip.model'
;
import
{
Vip
}
from
"../models/vip.model"
;
import
{
User
}
from
'../models/user.model'
;
import
{
Response
}
from
"@angular/http"
;
import
{
UserService
}
from
'./user.service'
;
import
{
User
}
from
"../models/user.model"
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
{
UserService
}
from
"./user.service"
;
import
'rxjs/add/operator/map'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
'rxjs/add/operator/switchMap'
;
import
"rxjs/add/operator/map"
;
import
'rxjs/add/observable/forkJoin'
;
import
"rxjs/add/operator/switchMap"
;
import
'rxjs/add/operator/first'
;
import
"rxjs/add/observable/forkJoin"
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
"rxjs/add/operator/first"
;
import
{
MOYA_BASE_URL
}
from
'../tools/moya-rest.tool'
;
import
{
HttpResponse
}
from
"@angular/common/http"
;
@
Injectable
()
@
Injectable
()
export
class
ViplistService
{
export
class
ViplistService
{
constructor
(
private
moyaRestService
:
MoyaRestService
,
private
userService
:
UserService
)
{
constructor
(
private
http
:
HttpClient
,
private
userService
:
UserService
)
{
}
}
...
@@ -26,11 +25,11 @@ export class ViplistService {
...
@@ -26,11 +25,11 @@ export class ViplistService {
public
get
(
searchString
?:
string
):
Observable
<
Array
<
Vip
>>
{
public
get
(
searchString
?:
string
):
Observable
<
Array
<
Vip
>>
{
if
(
!
searchString
)
{
if
(
!
searchString
)
{
return
this
.
moyaRestService
.
get
(
"v3/vip/all"
)
return
this
.
http
.
get
(
MOYA_BASE_URL
+
'v3/vip/all'
)
.
switchMap
(
res
=>
Observable
.
forkJoin
(...(
res
as
Array
<
any
>
).
map
(
apiRow
=>
this
.
hostPopulator
(
apiRow
))));
.
switchMap
(
res
=>
Observable
.
forkJoin
(...(
res
as
Array
<
any
>
).
map
(
apiRow
=>
this
.
hostPopulator
(
apiRow
))));
}
}
return
this
.
moyaRestService
.
get
(
"v3/vip/search/"
+
searchString
)
return
this
.
http
.
get
(
MOYA_BASE_URL
+
'v3/vip/search/'
+
searchString
)
.
switchMap
(
v
=>
Observable
.
forkJoin
(...(
v
as
Array
<
any
>
).
map
(
x
=>
this
.
hostPopulator
(
x
))));
.
switchMap
(
v
=>
Observable
.
forkJoin
(...(
v
as
Array
<
any
>
).
map
(
x
=>
this
.
hostPopulator
(
x
))));
}
}
...
@@ -43,10 +42,11 @@ export class ViplistService {
...
@@ -43,10 +42,11 @@ export class ViplistService {
*/
*/
public
async
delete
(
vip
:
Vip
):
Promise
<
boolean
>
{
public
async
delete
(
vip
:
Vip
):
Promise
<
boolean
>
{
if
(
!
vip
.
id
)
if
(
!
vip
.
id
)
{
throw
new
Error
(
"TODO: errori, tyhmä vippi"
);
throw
new
Error
(
'TODO: errori, tyhmä vippi'
);
}
let
res
:
any
=
await
this
.
moyaRestService
.
delete
(
"v3/vip/"
+
vip
.
id
)
const
res
:
any
=
await
this
.
http
.
delete
(
MOYA_BASE_URL
+
'v3/vip/'
+
vip
.
id
)
.
first
()
.
first
()
.
toPromise
();
.
toPromise
();
...
@@ -55,19 +55,19 @@ export class ViplistService {
...
@@ -55,19 +55,19 @@ export class ViplistService {
public
getWithId
(
id
:
number
):
Observable
<
Vip
>
{
public
getWithId
(
id
:
number
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
get
(
"v3/vip/"
+
id
).
map
(
x
=>
x
as
Vip
);
return
this
.
http
.
get
(
MOYA_BASE_URL
+
'v3/vip/'
+
id
).
map
(
x
=>
x
as
Vip
);
}
}
public
create
(
vip
:
Vip
):
Observable
<
Vip
>
{
public
create
(
vip
:
Vip
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
post
(
"v3/vip/create"
,
vip
).
map
(
x
=>
x
as
Vip
);
return
this
.
http
.
post
(
MOYA_BASE_URL
+
'v3/vip/create'
,
vip
).
map
(
x
=>
x
as
Vip
);
}
}
private
hostPopulator
(
rawVip
:
any
):
Observable
<
Vip
>
{
private
hostPopulator
(
rawVip
:
any
):
Observable
<
Vip
>
{
return
this
.
userService
.
get
(
rawVip
.
hostId
)
return
this
.
userService
.
get
(
rawVip
.
hostId
)
.
map
((
u
:
User
)
=>
{
rawVip
.
host
=
u
;
return
<
Vip
>
rawVip
}).
map
(
x
=>
x
as
Vip
);
.
map
((
u
:
User
)
=>
{
rawVip
.
host
=
u
;
return
<
Vip
>
rawVip
;
}).
map
(
x
=>
x
as
Vip
);
}
}
...
...
code/moya-angular/src/app/shared/tools/moya-rest.tool.ts
0 → 100644
View file @
0d12776
export
const
MOYA_BASE_URL
=
'/MoyaWeb/rest/'
;
export
abstract
class
MoyaRestTool
{
/*
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
} */
}
code/moya-angular/src/app/test/test.component.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
'@angular/core'
);
var
TestComponent
=
(
function
()
{
function
TestComponent
()
{
this
.
counter
=
0
;
}
TestComponent
.
prototype
.
ngOnInit
=
function
()
{
};
TestComponent
.
prototype
.
addOne
=
function
()
{
this
.
counter
++
;
};
__decorate
([
core_1
.
Input
()
],
TestComponent
.
prototype
,
"counter"
,
void
0
);
TestComponent
=
__decorate
([
core_1
.
Component
({
selector
:
'app-test'
,
templateUrl
:
'./test.component.html'
,
styleUrls
:
[
'./test.component.css'
]
})
],
TestComponent
);
return
TestComponent
;
}());
exports
.
TestComponent
=
TestComponent
;
code/moya-angular/src/app/viplist/viplist.component.js
deleted
100644 → 0
View file @
9a876f0
"use strict"
;
var
__decorate
=
(
this
&&
this
.
__decorate
)
||
function
(
decorators
,
target
,
key
,
desc
)
{
var
c
=
arguments
.
length
,
r
=
c
<
3
?
target
:
desc
===
null
?
desc
=
Object
.
getOwnPropertyDescriptor
(
target
,
key
)
:
desc
,
d
;
if
(
typeof
Reflect
===
"object"
&&
typeof
Reflect
.
decorate
===
"function"
)
r
=
Reflect
.
decorate
(
decorators
,
target
,
key
,
desc
);
else
for
(
var
i
=
decorators
.
length
-
1
;
i
>=
0
;
i
--
)
if
(
d
=
decorators
[
i
])
r
=
(
c
<
3
?
d
(
r
)
:
c
>
3
?
d
(
target
,
key
,
r
)
:
d
(
target
,
key
))
||
r
;
return
c
>
3
&&
r
&&
Object
.
defineProperty
(
target
,
key
,
r
),
r
;
};
var
core_1
=
require
(
'@angular/core'
);
var
ViplistComponent
=
(
function
()
{
function
ViplistComponent
(
viplistService
)
{
this
.
viplistService
=
viplistService
;
}
ViplistComponent
.
prototype
.
ngOnInit
=
function
()
{
this
.
vips
=
this
.
viplistService
.
get
();
};
ViplistComponent
=
__decorate
([
core_1
.
Component
({
selector
:
'moya-viplist'
,
templateUrl
:
'./viplist.component.html'
,
styleUrls
:
[
'./viplist.component.css'
]
})
],
ViplistComponent
);
return
ViplistComponent
;
}());
exports
.
ViplistComponent
=
ViplistComponent
;
code/moya-angular/src/app/viplist/viplist.component.ts
View file @
0d12776
import
{
Component
,
NgZone
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
NgZone
,
OnInit
}
from
'@angular/core'
;
import
{
Observable
}
from
"rxjs/Observable"
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
{
Vip
}
from
"../shared/models/vip.model"
;
import
{
Vip
}
from
'../shared/models/vip.model'
;
import
{
ViplistService
}
from
"../shared/services/viplist.service"
;
import
{
ViplistService
}
from
'../shared/services/viplist.service'
;
@
Component
({
@
Component
({
selector
:
'moya-viplist'
,
selector
:
'moya-viplist'
,
templateUrl
:
'./viplist.component.html'
,
templateUrl
:
'./viplist.component.html'
,
styleUrls
:
[
'./viplist.component.scss'
]
styleUrls
:
[
'./viplist.component.scss'
],
providers
:
[
ViplistService
]
})
})
export
class
ViplistComponent
implements
OnInit
{
export
class
ViplistComponent
implements
OnInit
{
...
...
code/moya-angular/src/test.ts
View file @
0d12776
...
@@ -25,7 +25,7 @@ getTestBed().initTestEnvironment(
...
@@ -25,7 +25,7 @@ getTestBed().initTestEnvironment(
platformBrowserDynamicTesting
()
platformBrowserDynamicTesting
()
);
);
// Then we find all the tests.
// Then we find all the tests.
le
t
context
=
require
.
context
(
'./'
,
true
,
/
\.
spec
\.
ts$/
);
cons
t
context
=
require
.
context
(
'./'
,
true
,
/
\.
spec
\.
ts$/
);
// And load the modules.
// And load the modules.
context
.
keys
().
map
(
context
);
context
.
keys
().
map
(
context
);
// Finally, start Karma to run the tests.
// Finally, start Karma to run the tests.
...
...
code/moya-angular/tslint.json
View file @
0d12776
...
@@ -3,18 +3,30 @@
...
@@ -3,18 +3,30 @@
"node_modules/codelyzer"
"node_modules/codelyzer"
],
],
"rules"
:
{
"rules"
:
{
"arrow-return-shorthand"
:
true
,
"callable-types"
:
true
,
"class-name"
:
true
,
"class-name"
:
true
,
"comment-format"
:
[
"comment-format"
:
[
true
,
true
,
"check-space"
"check-space"
],
],
"curly"
:
true
,
"curly"
:
true
,
"deprecation"
:
{
"severity"
:
"warn"
},
"eofline"
:
true
,
"eofline"
:
true
,
"forin"
:
true
,
"forin"
:
true
,
"import-blacklist"
:
[
true
,
"rxjs"
,
"rxjs/Rx"
],
"import-spacing"
:
true
,
"indent"
:
[
"indent"
:
[
true
,
true
,
"spaces"
"spaces"
],
],
"interface-over-type-literal"
:
true
,
"label-position"
:
true
,
"label-position"
:
true
,
"max-line-length"
:
[
"max-line-length"
:
[
true
,
true
,
...
@@ -23,8 +35,14 @@
...
@@ -23,8 +35,14 @@
"member-access"
:
false
,
"member-access"
:
false
,
"member-ordering"
:
[
"member-ordering"
:
[
true
,
true
,
"static-before-instance"
,
{
"variables-before-functions"
"order"
:
[
"static-field"
,
"instance-field"
,
"static-method"
,
"instance-method"
]
}
],
],
"no-arg"
:
true
,
"no-arg"
:
true
,
"no-bitwise"
:
true
,
"no-bitwise"
:
true
,
...
@@ -38,14 +56,22 @@
...
@@ -38,14 +56,22 @@
],
],
"no-construct"
:
true
,
"no-construct"
:
true
,
"no-debugger"
:
true
,
"no-debugger"
:
true
,
"no-duplicate-
variable
"
:
true
,
"no-duplicate-
super
"
:
true
,
"no-empty"
:
false
,
"no-empty"
:
false
,
"no-empty-interface"
:
true
,
"no-eval"
:
true
,
"no-eval"
:
true
,
"no-inferrable-types"
:
true
,
"no-inferrable-types"
:
[
true
,
"ignore-params"
],
"no-misused-new"
:
true
,
"no-non-null-assertion"
:
true
,
"no-shadowed-variable"
:
true
,
"no-shadowed-variable"
:
true
,
"no-string-literal"
:
false
,
"no-string-literal"
:
false
,
"no-string-throw"
:
true
,
"no-switch-case-fall-through"
:
true
,
"no-switch-case-fall-through"
:
true
,
"no-trailing-whitespace"
:
true
,
"no-trailing-whitespace"
:
true
,
"no-unnecessary-initializer"
:
true
,
"no-unused-expression"
:
true
,
"no-unused-expression"
:
true
,
"no-use-before-declare"
:
true
,
"no-use-before-declare"
:
true
,
"no-var-keyword"
:
true
,
"no-var-keyword"
:
true
,
...
@@ -57,12 +83,14 @@
...
@@ -57,12 +83,14 @@
"check-else"
,
"check-else"
,
"check-whitespace"
"check-whitespace"
],
],
"prefer-const"
:
true
,
"quotemark"
:
[
"quotemark"
:
[
true
,
true
,
"single"
"single"
],
],
"radix"
:
true
,
"radix"
:
true
,
"semicolon"
:
[
"semicolon"
:
[
true
,
"always"
"always"
],
],
"triple-equals"
:
[
"triple-equals"
:
[
...
@@ -79,6 +107,7 @@
...
@@ -79,6 +107,7 @@
"variable-declaration"
:
"nospace"
"variable-declaration"
:
"nospace"
}
}
],
],
"unified-signatures"
:
true
,
"variable-name"
:
false
,
"variable-name"
:
false
,
"whitespace"
:
[
"whitespace"
:
[
true
,
true
,
...
@@ -88,9 +117,19 @@
...
@@ -88,9 +117,19 @@
"check-separator"
,
"check-separator"
,
"check-type"
"check-type"
],
],
"directive-selector"
:
[
"directive-selector"
:
[
true
,
"attribute"
,
""
,
"camelCase"
],
true
,
"component-selector"
:
[
true
,
"element"
,
""
,
"kebab-case"
],
"attribute"
,
"moya"
,
"camelCase"
],
"component-selector"
:
[
true
,
"element"
,
"moya"
,
"kebab-case"
],
"no-output-on-prefix"
:
true
,
"use-input-property-decorator"
:
true
,
"use-input-property-decorator"
:
true
,
"use-output-property-decorator"
:
true
,
"use-output-property-decorator"
:
true
,
"use-host-property-decorator"
:
true
,
"use-host-property-decorator"
:
true
,
...
@@ -99,9 +138,6 @@
...
@@ -99,9 +138,6 @@
"use-life-cycle-interface"
:
true
,
"use-life-cycle-interface"
:
true
,
"use-pipe-transform-interface"
:
true
,
"use-pipe-transform-interface"
:
true
,
"component-class-suffix"
:
true
,
"component-class-suffix"
:
true
,
"directive-class-suffix"
:
true
,
"directive-class-suffix"
:
true
"no-access-missing-member"
:
true
,
"templates-use-public"
:
true
,
"invoke-injectable"
:
true
}
}
}
}
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