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 ed2f73b9
authored
Feb 13, 2017
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu navigation
1 parent
8c88b25b
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
214 additions
and
21 deletions
code/moya-angular/README.md
code/moya-angular/src/app/app.component.ts
code/moya-angular/src/app/app.module.ts
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
code/moya-angular/src/app/moya-rest/services/viplist.service.ts
code/moya-angular/test.js
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/MenuitemFacade.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Menuitem.java
code/moya-web/WebContent/WEB-INF/pretty-config.xml
code/moya-web/WebContent/angular.xhtml
code/moya-web/WebContent/resources/script/menufix.js
code/moya-web/WebContent/resources/templates/adduser/template.xhtml
code/moya-web/WebContent/resources/templates/blipview/template.xhtml
code/moya-web/WebContent/resources/templates/fullprimelayout/template.xhtml
code/moya-web/WebContent/resources/templates/infoview/template.xhtml
code/moya-web/WebContent/resources/templates/insomnia1/template.xhtml
code/moya-web/WebContent/resources/templates/insomnia2/template.xhtml
code/moya-web/WebContent/resources/templates/moyav2/template.xhtml
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
code/moya-web/WebContent/resources/templates/template1/template.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/AngularPageName.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/LayoutView.java
code/moya-angular/README.md
View file @
ed2f73b
...
...
@@ -15,6 +15,33 @@ Jos tulee muita järkeviä kokonaisuuksia, joita voi käyttää muualla, jaa oma
## TODO
Tekemistä jota voi esim kämpissä säätää
### I18N
I18N loaderi webpackkiin. Esim. muuntaa properties-filun taulukoksi ja siihen joku localisointikirjasto, tai jotain.
### Paketointi
Miten paketoidaan moya niin että mukaan kääntyy myös angular -jutukkeet?
### Lazy loading
Lazy loading niin että se toimii vielä moyan kanssa, vaatinnee säätöä.
### Travis yms. autotestit
oma travis-palvelin, ja siihen autotestit
Ehkä greenkeeper, jos sitä voi hostata ite
### Testit
Integraatio jne. testit, aloitteliat ei riko asioita niin todennäköisesti.
### WebPack ja buildin minimointi
aot-kääntäminen ja siihen comperssointia jne.
# MoyaAngular, generoidut ohjeet
This project was generated with
[
angular-cli
](
https://github.com/angular/angular-cli
)
version 1.0.0-beta.24.
...
...
code/moya-angular/src/app/app.component.ts
View file @
ed2f73b
import
{
Component
}
from
'@angular/core'
;
import
{
Component
,
NgZone
}
from
'@angular/core'
;
import
{
Router
}
from
"@angular/router"
;
declare
var
window
:
any
;
@
Component
({
selector
:
'app-root'
,
templateUrl
:
'./app.component.html'
,
...
...
@@ -9,11 +11,19 @@ import {Router} from "@angular/router";
export
class
AppComponent
{
constructor
(
private
router
:
Router
)
{
(
<
any
>
window
).
router
=
router
;
constructor
(
private
router
:
Router
,
private
zone
:
NgZone
)
{
window
.
angularRoute
=
(
url
=>
{
zone
.
run
(()
=>
{
router
.
navigateByUrl
(
url
);
});
});
}
title
=
'app works!'
;
}
code/moya-angular/src/app/app.module.ts
View file @
ed2f73b
...
...
@@ -13,7 +13,7 @@ import {TestComponent} from "./test/test.component";
const
appRoutes
:
Routes
=
[
{
path
:
'viplist'
,
component
:
ViplistComponent
},
{
path
:
'vip
/vip
list'
,
component
:
ViplistComponent
},
{
path
:
'test'
,
component
:
TestComponent
}
];
...
...
code/moya-angular/src/app/moya-rest/moya-rest.module.ts
View file @
ed2f73b
...
...
@@ -17,7 +17,6 @@ export class MoyaRestModule {
static
forRoot
():
ModuleWithProviders
{
return
{
ngModule
:
MoyaRestModule
,
providers
:
[
MoyaRestService
,
...
...
code/moya-angular/src/app/moya-rest/services/viplist.service.ts
View file @
ed2f73b
...
...
@@ -47,6 +47,20 @@ export class ViplistService {
}
public
deleteProm
(
vip
:
Vip
):
Promise
<
boolean
>
{
if
(
!
vip
.
id
)
throw
new
Error
(
"TODO: errori, tyhmä vippi"
);
return
this
.
moyaRestService
.
delete
(
"v2/vip/"
+
vip
.
id
)
.
first
()
.
toPromise
()
.
then
(
r
=>
r
.
ok
);
}
public
getWithId
(
id
:
number
):
Observable
<
Vip
>
{
return
this
.
moyaRestService
.
get
(
"v2/vip/"
+
id
)
.
map
(
v
=>
v
.
json
());
...
...
code/moya-angular/test.js
0 → 100755
View file @
ed2f73b
console
.
log
(
"foo"
);
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
ed2f73b
...
...
@@ -442,7 +442,11 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE account_events DROP COLUMN delivered_count;"
});
}
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE menuitem ADD COLUMN angularpage BOOLEAN NOT NULL DEFAULT false;"
});
}
public
BootstrapBean
()
{
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
ed2f73b
...
...
@@ -113,6 +113,7 @@ public class MenuBean implements MenuBeanLocal {
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/frontpage"
),
UserPermission
.
ANYUSER
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/checkout/return"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/checkout/delayed"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/checkout/reject"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/checkout/cancel"
),
null
).
setVisible
(
false
);
...
...
@@ -139,6 +140,9 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation
helpmenu
=
usermenu
.
addPage
(
null
,
null
);
helpmenu
.
setKey
(
"topnavi.help"
);
helpmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/help"
),
UserPermission
.
HELPPAGE
);
helpmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/angular"
,
true
),
null
).
setVisible
(
false
);
MenuNavigation
userkauppa
=
usermenu
.
addPage
(
null
,
null
);
userkauppa
.
setKey
(
"topnavi.usershop"
);
...
...
@@ -260,6 +264,7 @@ public class MenuBean implements MenuBeanLocal {
vips
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/vip/multiadd"
),
VipPermission
.
EDIT
);
vips
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/vip/deliver"
),
VipPermission
.
VIEW
).
setVisible
(
false
);
vips
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/vip/edit"
),
VipPermission
.
VIEW
).
setVisible
(
false
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/angular/vip/viplist"
,
true
),
null
);
MenuNavigation
adminAssociation
=
adminmenu
.
addPage
(
null
,
null
);
adminAssociation
.
setKey
(
"topnavi.adminassoc"
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/facade/MenuitemFacade.java
View file @
ed2f73b
...
...
@@ -41,7 +41,12 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
super
(
Menuitem
.
class
);
}
public
Menuitem
findOrCreate
(
String
url
)
{
return
findOrCreate
(
url
,
false
);
}
public
Menuitem
findOrCreate
(
String
url
,
boolean
angularPage
)
{
if
(
url
==
null
||
url
.
isEmpty
())
{
return
null
;
}
...
...
@@ -56,6 +61,7 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
if
(
ret
==
null
)
{
ret
=
new
Menuitem
();
ret
.
setUrl
(
url
);
ret
.
setAngularPage
(
angularPage
);
create
(
ret
);
}
return
ret
;
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Menuitem.java
View file @
ed2f73b
...
...
@@ -38,6 +38,9 @@ public class Menuitem extends GenericEntity {
@Column
(
nullable
=
false
,
unique
=
true
)
private
String
url
;
@Column
(
nullable
=
false
,
name
=
"angularpage"
)
private
boolean
angularPage
=
false
;
@Lob
private
String
description
;
...
...
@@ -69,4 +72,11 @@ public class Menuitem extends GenericEntity {
this
.
navigations
=
navigations
;
}
public
boolean
isAngularPage
()
{
return
angularPage
;
}
public
void
setAngularPage
(
boolean
angularPage
)
{
this
.
angularPage
=
angularPage
;
}
}
code/moya-web/WebContent/WEB-INF/pretty-config.xml
View file @
ed2f73b
...
...
@@ -3,6 +3,6 @@
xsi:schemaLocation=
"http://ocpsoft.org/schema/rewrite-config-prettyfaces
http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd"
>
<rewrite
match=
"^
/angular/.*"
substitute=
"/angular.jsf
"
redirect=
"chain"
/>
<rewrite
match=
"^
(/angular/.*)$"
substitute=
"/angular.jsf?pagename=$1
"
redirect=
"chain"
/>
</pretty-config>
\ No newline at end of file
code/moya-web/WebContent/angular.xhtml
View file @
ed2f73b
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:p=
"http://primefaces.org/ui"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:viewParam
name=
"pagename"
value=
"#{angularPageName.pagename}"
/>
<f:event
type=
"preRenderView"
listener=
"#{angularPageName.init()}"
/>
</f:metadata>
<ui:define
name=
"headerdata"
>
<!-- base href="/MoyaWeb/resources/angular-dist/"></base-->
<base
href=
"/MoyaWeb/angular/"
></base>
</ui:define>
<ui:define
name=
"content"
>
<h:form>
<p:remoteCommand
name=
"pageNameSetter"
actionListener=
"#{angularPageName.pagenameRemoteCommand}"
update=
":mainMenu:panelmenu"
/>
</h:form>
<link
rel=
"stylesheet"
href=
"/MoyaWeb/resources/angular-dist/styles.bundle.css"
/>
<app-root>
Lattaillaans
</app-root>
...
...
@@ -18,8 +32,6 @@
<script
type=
"text/javascript"
src=
"/MoyaWeb/resources/angular-dist/vendor.bundle.js"
></script>
<script
type=
"text/javascript"
src=
"/MoyaWeb/resources/angular-dist/main.bundle.js"
></script>
</ui:define>
</ui:composition>
...
...
code/moya-web/WebContent/resources/script/menufix.js
View file @
ed2f73b
$
(
document
).
ready
(
function
()
{
if
(
PrimeFaces
.
getCookie
(
"moyaLeftMenu"
)
!=
null
)
{
var
menuToExpand
=
PrimeFaces
.
getCookie
(
"moyaLeftMenu"
).
split
(
","
);
for
(
i
=
0
;
i
<
menuToExpand
.
length
;
++
i
)
{
$
(
"#"
+
menuToExpand
[
i
]).
css
(
"display"
,
"block"
);
}
}
});
\ No newline at end of file
$
(
document
).
ready
(
function
()
{
if
(
PrimeFaces
.
getCookie
(
"moyaLeftMenu"
)
!=
null
)
{
var
menuToExpand
=
PrimeFaces
.
getCookie
(
"moyaLeftMenu"
).
split
(
","
);
for
(
i
=
0
;
i
<
menuToExpand
.
length
;
++
i
)
{
$
(
"#"
+
menuToExpand
[
i
]).
css
(
"display"
,
"block"
);
}
}
});
/**
* One might wonder why this is there.
*
* It would be really nice just link to the angular -page, but there is this "nice" prettyfaces -rewriter
* and it does somehow catch my menulinks, and rewrite them to the .jsf -file, what is JUST what we need. PRKL!
*
* So let's make it the hard and dirty way.
*/
var
angularMenuNavigation
=
function
(
url
)
{
if
(
window
.
angularRoute
)
{
var
ngUrl
=
url
.
substring
(
8
);
window
.
angularRoute
(
ngUrl
);
pageNameSetter
(
url
);
}
else
{
window
.
location
.
href
=
window
.
CONTEXTPATH
+
url
;
}
};
\ No newline at end of file
code/moya-web/WebContent/resources/templates/adduser/template.xhtml
View file @
ed2f73b
...
...
@@ -43,6 +43,7 @@
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
$
(
function
(){
$
(
window
).
resize
(
function
()
{
...
...
code/moya-web/WebContent/resources/templates/blipview/template.xhtml
View file @
ed2f73b
...
...
@@ -16,6 +16,9 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"#{request.contextPath}/resources/templates/blipview/css/general.css"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"#{request.contextPath}/resources/templates/custom_components.css"
/>
<ui:insert
name=
"headerdata"
/>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
</script>
</h:head>
...
...
code/moya-web/WebContent/resources/templates/fullprimelayout/template.xhtml
View file @
ed2f73b
...
...
@@ -39,6 +39,7 @@
<h:body>
<!-- Javascript-lokalisaatiolippupuljausta -->
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
$
(
document
)
.
ready
(
function
()
{
...
...
code/moya-web/WebContent/resources/templates/infoview/template.xhtml
View file @
ed2f73b
...
...
@@ -17,6 +17,9 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"#{request.contextPath}/resources/templates/custom_components.css"
/>
<ui:insert
name=
"headerdata"
/>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
</script>
</h:head>
...
...
code/moya-web/WebContent/resources/templates/insomnia1/template.xhtml
View file @
ed2f73b
...
...
@@ -16,6 +16,9 @@
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"#{request.contextPath}/resources/templates/insomnia1/style.css"
/>
<ui:insert
name=
"headerdata"
/>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
</script>
</h:head>
<h:body
>
...
...
code/moya-web/WebContent/resources/templates/insomnia2/template.xhtml
View file @
ed2f73b
...
...
@@ -15,6 +15,9 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"#{request.contextPath}/resources/templates/insomnia2/css/general.css"
/>
<ui:insert
name=
"headerdata"
/>
<h:outputScript
name=
"prime_calendar.js"
library=
"script"
/>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
</script>
</h:head>
<h:body>
<div
id=
"header"
>
...
...
code/moya-web/WebContent/resources/templates/moyav2/template.xhtml
View file @
ed2f73b
...
...
@@ -20,6 +20,7 @@
<ui:insert
name=
"headerdata"
/>
<script
language=
"javascript"
type=
"text/javascript"
src=
"#{request.contextPath}/resources/templates/moyav2/js/main.js"
></script>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
$
(
document
).
ready
(
function
()
{
<
ui
:
repeat
value
=
"#{localeSelectorView.availableLocales}"
var
=
"loc"
varStatus
=
"idx"
>
$
(
...
...
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
View file @
ed2f73b
...
...
@@ -57,6 +57,9 @@
</p:dialog>
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
$
(
document
)
.
ready
(
function
()
{
...
...
code/moya-web/WebContent/resources/templates/template1/template.xhtml
View file @
ed2f73b
...
...
@@ -39,6 +39,7 @@
<h:body>
<!-- Javascript-lokalisaatiolippupuljausta -->
<script
type=
"text/javascript"
>
window
.
CONTEXTPATH
=
"#{request.contextPath}"
;
$
(
document
)
.
ready
(
function
()
{
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
View file @
ed2f73b
...
...
@@ -287,7 +287,13 @@ public class PrimeMenuView extends GenericCDIView {
item
.
setValue
(
key
);
item
.
setOutcome
(
outcome
);
if
(
m
.
getItem
().
isAngularPage
())
{
// item.setHref(outcome);
item
.
setOnclick
(
"angularMenuNavigation('"
+
outcome
+
"');"
);
}
else
{
item
.
setOutcome
(
outcome
);
}
}
return
item
;
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/AngularPageName.java
0 → 100644
View file @
ed2f73b
package
fi
.
codecrew
.
moya
.
web
.
helper
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Named
;
import
java.io.Serializable
;
import
java.util.Map
;
/**
*
* Class to store current page when we are on angular -pages.
*
* Created by tuukka on 12/02/17.
*/
@Named
@ConversationScoped
public
class
AngularPageName
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
pagename
;
public
void
init
()
{
if
(
pagename
==
null
)
{
super
.
beginConversation
();
}
}
public
String
getPagename
()
{
init
();
return
pagename
;
}
public
void
setPagename
(
String
pagename
)
{
init
();
this
.
pagename
=
pagename
;
}
public
void
pagenameRemoteCommand
()
{
init
();
setPagename
(((
Map
<
String
,
String
>)
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getRequestParameterMap
()).
get
(
"pagename"
));
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/LayoutView.java
View file @
ed2f73b
...
...
@@ -61,6 +61,10 @@ public class LayoutView implements Serializable {
private
transient
PermissionBeanLocal
permbean
;
@Inject
private
SessionStore
sessionStore
;
@Inject
private
AngularPageName
angularPageName
;
@EJB
private
transient
MenuBeanLocal
menubean
;
...
...
@@ -96,11 +100,15 @@ public class LayoutView implements Serializable {
{
selectedSet
=
new
HashSet
<>();
selectedTop
=
menubean
.
findNavigation
(
getPagepath
());
if
(
selectedTop
!=
null
&&
selectedTop
.
getItem
().
isAngularPage
()
&&
angularPageName
.
getPagename
()
!=
null
)
{
selectedTop
=
menubean
.
findNavigation
(
angularPageName
.
getPagename
());
}
if
(
selectedTop
==
null
)
return
null
;
while
(
selectedTop
.
getParent
()
!=
null
)
{
// logger.debug("Traversing to top {}, key {}", selectedTop, selectedTop.getKey());
selectedSet
.
add
(
selectedTop
);
selectedTop
=
selectedTop
.
getParent
();
}
...
...
@@ -117,6 +125,7 @@ public class LayoutView implements Serializable {
}
public
String
getPagepath
()
{
FacesContext
context
=
FacesContext
.
getCurrentInstance
();
if
(
pagename
==
null
&&
context
!=
null
&&
...
...
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