Commit c5b9bc29 by Tuukka Kivilahti

infomap ready, and also one viplist change

1 parent f7b7e90c
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<version>1.0.6</version> <version>1.0.7-rc1</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
...@@ -11,6 +11,8 @@ public class SimplePlacePojo { ...@@ -11,6 +11,8 @@ public class SimplePlacePojo {
private Integer y; private Integer y;
private Integer width; private Integer width;
private Integer height; private Integer height;
private String userDescription;
public SimplePlacePojo() { public SimplePlacePojo() {
super(); super();
...@@ -80,4 +82,11 @@ public class SimplePlacePojo { ...@@ -80,4 +82,11 @@ public class SimplePlacePojo {
this.height = height; this.height = height;
} }
public String getUserDescription() {
return userDescription;
}
public void setUserDescription(String userDescription) {
this.userDescription = userDescription;
}
} }
...@@ -8,10 +8,18 @@ ...@@ -8,10 +8,18 @@
<ui:param name="ignorenavigationleft" value="true" /> <ui:param name="ignorenavigationleft" value="true" />
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{ajaxMapView.initViewMap()}" /> <f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{cardlessIncomingView.initView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<reader:backendReader selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{cardlessIncomingView.polledRead}" />
<br /><br />
<infoview:usermultisearch />
<br /><br />
<h1>Showing places to user: #{userView.selectedUser.user.nick}</h1>
<br /><br />
<h:outputScript target="head" library="seatjs" name="d3.min.js" /> <h:outputScript target="head" library="seatjs" name="d3.min.js" />
<h:outputScript target="head" library="seatjs" name="d3-tip.js" /> <h:outputScript target="head" library="seatjs" name="d3-tip.js" />
<h:outputScript target="head" library="seatjs" name="seatmap.js" /> <h:outputScript target="head" library="seatjs" name="seatmap.js" />
...@@ -28,8 +36,11 @@ ...@@ -28,8 +36,11 @@
moyaurl : "#{request.contextPath}", moyaurl : "#{request.contextPath}",
map_id : #{ajaxMapView.map.id}, map_id : #{ajaxMapView.map.id},
placereserve: false, placereserve: false,
onclick : function(d) { onclick: function(d) {},
hilightUser: #{userView.selectedUser.user.id},
tooltip: function(d) {
return '<span style="font-size: 180%; font-weight: bold;">' + d.name +"</span><br /><br />"+
((d.userDescription)?d.userDescription:" - ") ;
} }
}); });
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
</p:outputPanel> </p:outputPanel>
</f:facet> </f:facet>
<p:column headerText="#{i18n['vip.hostsName']}" filterBy="#{vip.host.wholeName}" filterMatchMode="contains"> <p:column headerText="#{i18n['vip.hostsName']}" filterBy="#{vip.host.wholeName}" filterMatchMode="contains">
<h:outputText value="#{vip.host.wholeName}" /> <h:outputText id="viphostsname" value="#{vip.host.wholeName}" />
<p:tooltip id="viphostsnamephone" for="viphostsname" value="#{vip.host.phone}" />
</p:column> </p:column>
<p:column headerText="#{i18n['vip.description']}" filterBy="#{vip.description}" filterMatchMode="contains"> <p:column headerText="#{i18n['vip.description']}" filterBy="#{vip.description}" filterMatchMode="contains">
<h:outputText id="vipdescr" value="#{vip.shortDisplayDescr}" title="#{vip.description}" /> <h:outputText id="vipdescr" value="#{vip.shortDisplayDescr}" title="#{vip.description}" />
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
// Returns a tip // Returns a tip
tip.show = function() { tip.show = function() {
var args = Array.prototype.slice.call(arguments) var args = Array.prototype.slice.call(arguments)
if(args[args.length - 1] instanceof SVGElement) target = args.pop() if(args[args.length - 1] instanceof SVGElement) target = args.pop()
var content = html.apply(this, args), var content = html.apply(this, args),
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
.style({ opacity: 1, 'pointer-events': 'all' }) .style({ opacity: 1, 'pointer-events': 'all' })
while(i--) nodel.classed(directions[i], false) while(i--) nodel.classed(directions[i], false)
coords = direction_callbacks.get(dir).apply(this) coords = direction_callbacks.get(dir).apply(this)
nodel.classed(dir, true).style({ nodel.classed(dir, true).style({
top: (coords.top + poffset[0]) + scrollTop + 'px', top: (coords.top + poffset[0]) + scrollTop + 'px',
......
...@@ -35,9 +35,13 @@ function placemap(opts) ...@@ -35,9 +35,13 @@ function placemap(opts)
{ {
opts.placereserve = false; opts.placereserve = false;
} }
if(opts.tooltip === undefined) { if(opts.tooltip === undefined) {
opts.tooltip = function(d) {
return "<strong>" + d.name + "</strong>";
};
}
if(opts.hilightUser === undefined) {
opts.hilightUser = false;
} }
// px is returned object // px is returned object
...@@ -113,17 +117,13 @@ function placemap(opts) ...@@ -113,17 +117,13 @@ function placemap(opts)
var tip = d3.tip() var tip = d3.tip()
.attr('class', 'place-tooltip') .attr('class', 'place-tooltip')
.offset([-10, 0]) .offset([-10, 0])
.html(function(d) { .html(opts.tooltip);
return "<strong>" + d.name + "</strong>";
});
// TODO: Fix this tip layout // TODO: Fix this tip layout
var tip_updown = d3.tip().direction("s") var tip_updown = d3.tip().direction("s")
.attr('class', 'place-tooltip-upside') .attr('class', 'place-tooltip-upside')
.offset([10, 0]) .offset([10, 0])
.html(function(d) { .html(opts.tooltip);
return "<strong>" + d.name + "</strong>";
});
function draw_guides(x1, y1, x2, y2, fade) function draw_guides(x1, y1, x2, y2, fade)
{ {
...@@ -216,6 +216,8 @@ function placemap(opts) ...@@ -216,6 +216,8 @@ function placemap(opts)
function show_tooltip(d, i) { function show_tooltip(d, i) {
var object = { var object = {
x: d3.select(this).attr('x'), x: d3.select(this).attr('x'),
y: d3.select(this).attr('y'), y: d3.select(this).attr('y'),
...@@ -407,7 +409,13 @@ function placemap(opts) ...@@ -407,7 +409,13 @@ function placemap(opts)
} }
px.update = function() { px.update = function() {
d3.json(px.moyaurl + "/rest/placemap/v1/" + px.map_id + "/places", function(data) { var url = px.moyaurl + "/rest/placemap/v1/" + px.map_id + "/places";
if(opts.hilightUser) {
url = px.moyaurl + "/rest/placemap/v1/" + px.map_id + "/hilightedPlaces/"+opts.hilightUser;
}
d3.json(url, function(data) {
draw_places(data.places, true); draw_places(data.places, true);
}); });
}; };
...@@ -436,7 +444,7 @@ function placemap(opts) ...@@ -436,7 +444,7 @@ function placemap(opts)
else if (data.places[0].state == "T") else if (data.places[0].state == "T")
{ {
// tän korjaus sotki ehkä jotain, otetaan poies // tän korjaus sotki ehkä jotain, otetaan poies
//PF("messages_growl").show([{"summary":px.locales[px.locale].success_reserve, "detail":"", "severity":"info"}]); //PF("messages_growl").show([{"summary":px.locales[x.locale].success_reserve, "detail":"", "severity":"info"}]);
px.selected_count++; px.selected_count++;
} }
else if (data.places[0].state == "F") { else if (data.places[0].state == "F") {
......
...@@ -318,5 +318,9 @@ label { ...@@ -318,5 +318,9 @@ label {
padding: 10px; padding: 10px;
} }
.place-tooltip {
text-align: center;
}
\ No newline at end of file
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<version>1.0.5</version> <version>1.0.7-rc1</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -219,47 +219,66 @@ public class PojoUtils { ...@@ -219,47 +219,66 @@ public class PojoUtils {
} }
public static SimplePlacelistRoot parseSimplePlaces(List<Place> places, EventUser user) public static SimplePlacelistRoot parseSimplePlaces(List<Place> places, EventUser user, boolean hasPermissionViewAllusers) {
return parseSimplePlaces(places, user, hasPermissionViewAllusers, false);
}
public static SimplePlacelistRoot parseSimplePlaces(List<Place> places, EventUser user, boolean hasPermissionViewAllusers, boolean onlyHilightPlaces)
{ {
SimplePlacelistRoot ret = new SimplePlacelistRoot(); SimplePlacelistRoot ret = new SimplePlacelistRoot();
ArrayList<SimplePlacePojo> placeList = new ArrayList<SimplePlacePojo>(); ArrayList<SimplePlacePojo> placeList = new ArrayList<>();
ret.setPlaces(placeList); ret.setPlaces(placeList);
for (Place p : places) { for (Place p : places) {
placeList.add(initSimplePlacePojo(p, user)); placeList.add(initSimplePlacePojo(p, user, hasPermissionViewAllusers, onlyHilightPlaces));
} }
return ret; return ret;
} }
private static SimplePlacePojo initSimplePlacePojo(Place p, EventUser user) { private static SimplePlacePojo initSimplePlacePojo(Place p, EventUser user, boolean hasPermissionViewAllusers, boolean onlyHilightPlaces) {
SimplePlacePojo ret = new SimplePlacePojo(); SimplePlacePojo ret = new SimplePlacePojo();
ret.setId(p.getId()); ret.setId(p.getId());
ret.setName(p.getName()); ret.setName(p.getName());
String state = null; String state = null;
if(hasPermissionViewAllusers) {
if(p.getPlaceReserver() != null) {
if(p.getPlaceReserver().getUser() != null) {
ret.setUserDescription(p.getPlaceReserver().getUser().getUser().getShortUserDescriptor());
} else if(p.getPlaceReserver().getPlaceGroup() != null && p.getPlaceReserver().getPlaceGroup().getCreator() != null) {
ret.setUserDescription(p.getPlaceReserver().getPlaceGroup().getCreator().getUser().getShortUserDescriptor());
}
}
}
switch (p.getState(user)) switch (p.getState(user))
{ {
case DISABLED: case DISABLED:
state = "D"; state = (onlyHilightPlaces)?"F":"D";
break; break;
case FREE: case FREE:
state = "F"; state = "F";
break; break;
case LOCKED: case LOCKED:
state = "L"; state = (onlyHilightPlaces)?"F":"L";
break; break;
case MY_PLACE: case MY_PLACE:
state = "P"; state = "P";
break; break;
case RESERVED: case RESERVED:
state = "R"; state = (onlyHilightPlaces)?"F":"R";
break; break;
case TEMP_RESERVED_FORME: case TEMP_RESERVED_FORME:
state = "T"; state = (onlyHilightPlaces)?"F":"T";
break; break;
default: default:
break; break;
} }
if(onlyHilightPlaces) {
}
ret.setState(state); ret.setState(state);
ret.setX(p.getMapX()); ret.setX(p.getMapX());
......
...@@ -17,6 +17,8 @@ import javax.ws.rs.core.MediaType; ...@@ -17,6 +17,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.ResponseBuilder;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -94,6 +96,28 @@ public class PlacemapRestViewV1 { ...@@ -94,6 +96,28 @@ public class PlacemapRestViewV1 {
} }
@GET
@Path("{id}/hilightedPlaces/{userid}")
public Response getHilightedPlaces(@PathParam("id") Integer mapId, @PathParam("userid") Integer userId)
{
EventMap map = placebean.findMap(mapId);
if(!permbean.hasPermission(UserPermission.VIEW_ALL)) {
return Response.status(Response.Status.FORBIDDEN).entity("Try to login first!").build();
}
EventUser user = userbean.findByUserId(userId,false);
if (user == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("No User found for id: "+userId).build();
}
return Response.ok(PojoUtils.parseSimplePlaces(map.getPlaces(), user, permbean.hasPermission(UserPermission.VIEW_ALL), true)).build();
}
@GET @GET
@Path("{id}/places") @Path("{id}/places")
public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId) public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId)
...@@ -104,16 +128,16 @@ public class PlacemapRestViewV1 { ...@@ -104,16 +128,16 @@ public class PlacemapRestViewV1 {
if (userView != null) { if (userView != null) {
user = userView.getSelectedUser(); user = userView.getSelectedUser();
} }
return PojoUtils.parseSimplePlaces(map.getPlaces(), user); return PojoUtils.parseSimplePlaces(map.getPlaces(), user, permbean.hasPermission(UserPermission.VIEW_ALL));
} }
@GET @GET
@Path("/place/{place}") @Path("/place/{place}")
public SimplePlacelistRoot getPlace(@PathParam("place") Integer placeId) public SimplePlacelistRoot getPlace(@PathParam("place") Integer placeId)
{ {
List<Place> thisplace = new ArrayList<Place>(); List<Place> thisplace = new ArrayList<>();
thisplace.add(placebean.find(placeId)); thisplace.add(placebean.find(placeId));
return PojoUtils.parseSimplePlaces(thisplace, permbean.getCurrentUser()); return PojoUtils.parseSimplePlaces(thisplace, permbean.getCurrentUser(), permbean.hasPermission(UserPermission.VIEW_ALL));
} }
@GET @GET
...@@ -169,7 +193,7 @@ public class PlacemapRestViewV1 { ...@@ -169,7 +193,7 @@ public class PlacemapRestViewV1 {
p = placebean.find(placeId); p = placebean.find(placeId);
List<Place> thisplace = new ArrayList<Place>(); List<Place> thisplace = new ArrayList<Place>();
thisplace.add(p); thisplace.add(p);
resp = Response.ok(PojoUtils.parseSimplePlaces(thisplace, user)); resp = Response.ok(PojoUtils.parseSimplePlaces(thisplace, user, permbean.hasPermission(UserPermission.VIEW_ALL)));
} else { } else {
resp = Response.status(Response.Status.FORBIDDEN); resp = Response.status(Response.Status.FORBIDDEN);
} }
......
...@@ -255,6 +255,9 @@ public class AjaxMapView extends GenericCDIView { ...@@ -255,6 +255,9 @@ public class AjaxMapView extends GenericCDIView {
} }
public EventMap getMap() { public EventMap getMap() {
if(map == null)
return initMap();
return map; return map;
} }
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.web.flow;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.TicketBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.map.AjaxMapView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.cdiview.user.UserView;
import fi.codecrew.moya.web.helpers.ProductSummaryWrapper;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;
@Named
@ConversationScoped
public class UserMapSearchView extends GenericCDIView {
private static final long serialVersionUID = -715517L;
private static final Logger logger = LoggerFactory.getLogger(UserMapSearchView.class);
@Inject
private UserView userview;
@Inject
private InfoView infoView;
@Inject
private AjaxMapView ajaxMapView;
boolean initialized = false;
public void initView() {
if(!initialized) {
super.beginConversation();
initialized = true;
}
ajaxMapView.initViewMap();
}
}
...@@ -510,3 +510,4 @@ vipProduct.quantity = Lukum\u00E4\u00E4r\u00E4 ...@@ -510,3 +510,4 @@ vipProduct.quantity = Lukum\u00E4\u00E4r\u00E4
yes = Kyll\u00E4 yes = Kyll\u00E4
vip.backToList=Takaisin listaukseen vip.backToList=Takaisin listaukseen
submenu.info.viplist=Vippilista submenu.info.viplist=Vippilista
submenu.info.usermapsearch=Karttahaku
...@@ -1727,3 +1727,4 @@ voting.create.voteStart = Voting start ...@@ -1727,3 +1727,4 @@ voting.create.voteStart = Voting start
yes = Yes yes = Yes
vip.backToList=Back to viplist list vip.backToList=Back to viplist list
submenu.info.viplist=Viplist submenu.info.viplist=Viplist
submenu.info.usermapsearch=Mapsearch
...@@ -1710,3 +1710,4 @@ voting.create.voteStart = \u00C4\u00E4nestys auki ...@@ -1710,3 +1710,4 @@ voting.create.voteStart = \u00C4\u00E4nestys auki
yes = Kyll\u00E4 yes = Kyll\u00E4
vip.backToList=Takaisin listaukseen vip.backToList=Takaisin listaukseen
submenu.info.viplist=Vippilista submenu.info.viplist=Vippilista
submenu.info.usermapsearch=Karttahaku
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!