mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
Merge branch 'develop' into feature/remove_mootols
This commit is contained in:
commit
6048b6ae14
@ -1,7 +1,8 @@
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
creation_date DATE);
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL IDENTITY,
|
||||
@ -31,22 +32,40 @@ CREATE TABLE MINDMAP (
|
||||
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL IDENTITY,
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
|
||||
title VARCHAR(30),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id));
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES
|
||||
(id INTEGER NOT NULL IDENTITY,
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
starred BOOLEAN NOT NULL,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION
|
||||
(id INTEGER NOT NULL IDENTITY,
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
@ -57,8 +76,8 @@ CREATE TABLE COLLABORATION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE TAG
|
||||
(id INTEGER NOT NULL IDENTITY,
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
--FOREIGN KEY(user_id) REFERENCES USER(colaborator_id)
|
||||
|
@ -3,6 +3,8 @@ DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
|
@ -51,6 +51,30 @@ CREATE TABLE MINDMAP (
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
|
@ -3,7 +3,9 @@ DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
@ -5,3 +5,30 @@ ALTER TABLE `ACCESS_AUDITORY`
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
|
||||
|
@ -18,6 +18,22 @@ CREATE TABLE "user" (
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
|
@ -3,6 +3,8 @@ DROP TABLE ACCESS_AUDITORY;
|
||||
DROP TABLE COLLABORATION;
|
||||
DROP TABLE COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE R_LABEL_MINDMAP;
|
||||
DROP TABLE LABEL;
|
||||
DROP TABLE MINDMAP;
|
||||
DROP TABLE "user";
|
||||
DROP TABLE COLLABORATOR;
|
||||
|
@ -594,7 +594,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabelManager {
|
||||
|
||||
void addLabel(@NotNull final Label label);
|
||||
|
||||
void saveLabel(@NotNull final Label label);
|
||||
|
||||
@NotNull
|
||||
List<Label> getAllLabels(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id, @NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
||||
|
||||
void removeLabel(@NotNull final Label label);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LabelManagerImpl extends HibernateDaoSupport
|
||||
implements LabelManager {
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
saveLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLabel(@NotNull final Label label) {
|
||||
getSession().save(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Label> getAllLabels(@NotNull final User user) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where creator_id=?", user.getId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelById(int id, @NotNull final User user) {
|
||||
List<Label> labels = getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where id=? and creator=?", new Object[]{id, user});
|
||||
return getFirst(labels);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
final List<Label> labels = getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where title=? and creator=?", new Object[]{title, user});
|
||||
return getFirst(labels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Label label) {
|
||||
getHibernateTemplate().delete(label);
|
||||
}
|
||||
|
||||
@Nullable private Label getFirst(List<Label> labels) {
|
||||
Label result = null;
|
||||
if (labels != null && !labels.isEmpty()) {
|
||||
result = labels.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelCouldNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_CAN_NOT_BE_FOUND";
|
||||
|
||||
public LabelCouldNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelMindmapRelationshipNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_MINDMAP_RELATION_NOT_BE_FOUND";
|
||||
|
||||
public LabelMindmapRelationshipNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ package com.wisemapping.model;
|
||||
public class Constants {
|
||||
|
||||
public static final int MAX_MAP_NAME_LENGTH = 512;
|
||||
public static final int MAX_LABEL_NAME_LENGTH = 30;
|
||||
public static final int MAX_MAP_DESCRIPTION_LENGTH = 512;
|
||||
public static final int MAX_USER_LASTNAME_LENGTH = 255;
|
||||
public static final int MAX_USER_FIRSTNAME_LENGTH = 255;
|
||||
|
79
wise-webapp/src/main/java/com/wisemapping/model/Label.java
Normal file
79
wise-webapp/src/main/java/com/wisemapping/model/Label.java
Normal file
@ -0,0 +1,79 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Label {
|
||||
|
||||
//~ Instance fields ......................................................................................
|
||||
private int id;
|
||||
@NotNull private String title;
|
||||
@NotNull private User creator;
|
||||
@Nullable private Label parent;
|
||||
@NotNull private String color;
|
||||
|
||||
public void setParent(@Nullable Label parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(@NotNull String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(@NotNull String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Label)) return false;
|
||||
|
||||
Label label = (Label) o;
|
||||
|
||||
return id == label.id && creator.getId() == label.creator.getId()
|
||||
&& !(parent != null ? !parent.equals(label.parent) : label.parent != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + title.hashCode();
|
||||
result = 31 * result + creator.hashCode();
|
||||
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class LabelMindmap implements Serializable{
|
||||
|
||||
private int mindmapId;
|
||||
private int labelId;
|
||||
|
||||
public LabelMindmap(int labelId, int mindmapId) {
|
||||
this.mindmapId = mindmapId;
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
public LabelMindmap() {}
|
||||
|
||||
public int getMindmapId() {
|
||||
return mindmapId;
|
||||
}
|
||||
|
||||
public void setMindmapId(int mindmapId) {
|
||||
this.mindmapId = mindmapId;
|
||||
}
|
||||
|
||||
public int getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public void setLabelId(int labelId) {
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof LabelMindmap)) return false;
|
||||
|
||||
LabelMindmap that = (LabelMindmap) o;
|
||||
|
||||
return labelId == that.labelId && mindmapId == that.mindmapId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = mindmapId;
|
||||
result = 31 * result + labelId;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Mindmap {
|
||||
@ -44,6 +45,7 @@ public class Mindmap {
|
||||
private User lastEditor;
|
||||
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private Set<Label> labels = new LinkedHashSet<>();
|
||||
|
||||
private User creator;
|
||||
private String tags;
|
||||
@ -118,6 +120,18 @@ public class Mindmap {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
@NotNull public Set<Label> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(@NotNull final Set<Label> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
this.labels.add(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
|
||||
Collaboration result = null;
|
||||
@ -229,9 +243,6 @@ public class Mindmap {
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
if (creator == null) {
|
||||
throw new IllegalArgumentException("Owner can not be null");
|
||||
}
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@ -307,4 +318,28 @@ public class Mindmap {
|
||||
return result;
|
||||
|
||||
}
|
||||
//creo que no se usa mas
|
||||
public boolean hasLabel(@NotNull final String name) {
|
||||
for (Label label : this.labels) {
|
||||
if (label.getTitle().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable public Label findLabel(int labelId) {
|
||||
Label result = null;
|
||||
for (Label label : this.labels) {
|
||||
if (label.getId() == labelId) {
|
||||
result = label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void removeLabel(@NotNull final Label label) {
|
||||
this.labels.remove(label);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.validator.LabelValidator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class LabelController extends BaseController {
|
||||
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createLabel(@RequestBody RestLabel restLabel, @NotNull HttpServletResponse response, @RequestParam(required = false) String title) throws WiseMappingException {
|
||||
// Overwrite title if it was specified by parameter.
|
||||
if (title != null && !title.isEmpty()) {
|
||||
restLabel.setTitle(title);
|
||||
}
|
||||
|
||||
// Validate ...
|
||||
validate(restLabel);
|
||||
|
||||
final Label label = createLabel(restLabel);
|
||||
|
||||
// Return the new created label ...
|
||||
response.setHeader("Location", "/service/labels/" + label.getId());
|
||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json", "application/xml"})
|
||||
public RestLabelList retrieveList() {
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
final List<Label> all = labelService.getAll(user);
|
||||
return new RestLabelList(all);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Label label = labelService.getLabelById(id, user);
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
|
||||
}
|
||||
assert user != null;
|
||||
labelService.removeLabel(label, user);
|
||||
}
|
||||
|
||||
@NotNull private Label createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
|
||||
final Label label = restLabel.getDelegated();
|
||||
// Add new label ...
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
labelService.addLabel(label, user);
|
||||
return label;
|
||||
}
|
||||
|
||||
private void validate(@NotNull final RestLabel restLabel) throws ValidationException {
|
||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
||||
new LabelValidator(labelService).validate(restLabel.getDelegated(), result);
|
||||
if (result.hasErrors()) {
|
||||
throw new ValidationException(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ package com.wisemapping.rest;
|
||||
|
||||
import com.mangofactory.swagger.annotations.ApiIgnore;
|
||||
import com.wisemapping.exceptions.ImportUnexpectedException;
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MultipleSessionsOpenException;
|
||||
import com.wisemapping.exceptions.SessionExpiredException;
|
||||
@ -31,11 +32,13 @@ import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.CollaborationProperties;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestCollaboration;
|
||||
import com.wisemapping.rest.model.RestCollaborationList;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapHistory;
|
||||
import com.wisemapping.rest.model.RestMindmapHistoryList;
|
||||
@ -43,6 +46,7 @@ import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.CollaborationException;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.LockInfo;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
@ -86,6 +90,10 @@ public class MindmapController extends BaseController {
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"})
|
||||
@ResponseBody
|
||||
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
||||
@ -617,4 +625,37 @@ public class MindmapController extends BaseController {
|
||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||
return new ValidationException(result);
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/maps/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void removeLabel(@RequestBody RestLabel restLabel, @PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User currentUser = Utils.getUser();
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
assert currentUser != null;
|
||||
delegated.setCreator(currentUser);
|
||||
mindmapService.removeLabel(mindmap, delegated);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = { "application/xml","application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void addLabel(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
|
||||
int labelId = restLabel.getId();
|
||||
final User user = Utils.getUser();
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
delegated.setCreator(user);
|
||||
final Label found = labelService.getLabelById(labelId, user);
|
||||
if (found == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + labelId);
|
||||
}
|
||||
for (String id : ids.split(",")) {
|
||||
final int mindmapId = Integer.parseInt(id);
|
||||
final Mindmap mindmap = findMindmapById(mindmapId);
|
||||
final Label label = mindmap.findLabel(labelId);
|
||||
if (label == null) {
|
||||
mindmapService.addLabel(mindmap, delegated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,57 +25,77 @@ import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum MindmapFilter {
|
||||
ALL("all") {
|
||||
public abstract class MindmapFilter {
|
||||
|
||||
public static final MindmapFilter ALL = new MindmapFilter("all") {
|
||||
@Override
|
||||
public boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
},
|
||||
MY_MAPS("my_maps") {
|
||||
};
|
||||
public static final MindmapFilter MY_MAPS = new MindmapFilter("my_maps") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.getCreator().identityEquality(user);
|
||||
}
|
||||
},
|
||||
STARRED("starred") {
|
||||
};
|
||||
public static final MindmapFilter STARRED = new MindmapFilter("starred") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.isStarred(user);
|
||||
}
|
||||
},
|
||||
SHARED_WITH_ME("shared_with_me") {
|
||||
};
|
||||
public static final MindmapFilter SHARED_WITH_ME = new MindmapFilter("shared_with_me") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return !MY_MAPS.accept(mindmap, user);
|
||||
}
|
||||
},
|
||||
PUBLIC("public") {
|
||||
};
|
||||
public static final MindmapFilter PUBLIC = new MindmapFilter("public") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.isPublic();
|
||||
}
|
||||
};
|
||||
|
||||
private String id;
|
||||
protected String id;
|
||||
private static MindmapFilter[] values = {ALL, MY_MAPS, PUBLIC, STARRED, SHARED_WITH_ME};
|
||||
|
||||
MindmapFilter(@NotNull String id) {
|
||||
private MindmapFilter(@NotNull String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
static public MindmapFilter parse(@Nullable String valueStr) {
|
||||
MindmapFilter result = ALL;
|
||||
final MindmapFilter[] values = MindmapFilter.values();
|
||||
for (MindmapFilter value : values) {
|
||||
if (value.id.equals(valueStr)) {
|
||||
result = value;
|
||||
break;
|
||||
static public MindmapFilter parse(@Nullable final String valueStr) {
|
||||
MindmapFilter result = null;
|
||||
if (valueStr != null) {
|
||||
for (MindmapFilter value : MindmapFilter.values) {
|
||||
if (value.id.equals(valueStr)) {
|
||||
result = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// valueStr is not a default filter
|
||||
if (result == null) {
|
||||
result = new LabelFilter(valueStr);
|
||||
}
|
||||
} else {
|
||||
result = ALL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user);
|
||||
|
||||
private static final class LabelFilter extends MindmapFilter {
|
||||
|
||||
private LabelFilter(@NotNull String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.hasLabel(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
|
||||
|
||||
@XmlRootElement(name = "label")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = NONE,
|
||||
setterVisibility = PUBLIC_ONLY,
|
||||
isGetterVisibility = NONE,
|
||||
getterVisibility = PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestLabel {
|
||||
|
||||
@JsonIgnore
|
||||
private Label label;
|
||||
|
||||
public RestLabel() {
|
||||
this(new Label());
|
||||
}
|
||||
|
||||
public RestLabel(@NotNull final Label label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setParent(@NotNull final Label parent) {
|
||||
this.label.setParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
return this.label.getParent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return this.label.getTitle();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return label.getId();
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
label.setId(id);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
label.setTitle(title);
|
||||
}
|
||||
|
||||
public void setColor(@NotNull final String color) {
|
||||
label.setColor(color);
|
||||
}
|
||||
|
||||
@Nullable public String getColor() {
|
||||
return label.getColor();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Label getDelegated() {
|
||||
return label;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "labels")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestLabelList {
|
||||
|
||||
@NotNull private final List<RestLabel> restLabels;
|
||||
|
||||
public RestLabelList(){
|
||||
this.restLabels = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RestLabelList(@NotNull final List<Label> labels) {
|
||||
this.restLabels = new ArrayList<>(labels.size());
|
||||
for (Label label : labels) {
|
||||
this.restLabels.add(new RestLabel(label));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull @XmlElement(name = "label")
|
||||
public List<RestLabel> getLabels() {
|
||||
return restLabels;
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
@ -35,6 +36,9 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@XmlRootElement(name = "map")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@ -93,6 +97,13 @@ public class RestMindmapInfo {
|
||||
public void setTitle(String title) {
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
public Set<RestLabel> getLabels() {
|
||||
final Set<RestLabel> result = new LinkedHashSet<>();
|
||||
for (Label label : mindmap.getLabels()) {
|
||||
result.add(new RestLabel(label));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return mindmap.getId();
|
||||
|
@ -48,7 +48,7 @@ public class RestMindmapList {
|
||||
}
|
||||
|
||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
|
||||
this.mindmapsInfo = new ArrayList<RestMindmapInfo>();
|
||||
this.mindmapsInfo = new ArrayList<>(mindmaps.size());
|
||||
for (Mindmap mindMap : mindmaps) {
|
||||
this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator));
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabelService {
|
||||
|
||||
void addLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||
|
||||
@NotNull List<Label> getAll(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id, @NotNull final User user);
|
||||
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
||||
|
||||
void removeLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.dao.LabelManager;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LabelServiceImpl implements LabelService {
|
||||
|
||||
private LabelManager labelManager;
|
||||
|
||||
public void setLabelManager(LabelManager labelManager) {
|
||||
this.labelManager = labelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException {
|
||||
|
||||
label.setCreator(user);
|
||||
labelManager.addLabel(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Label> getAll(@NotNull final User user) {
|
||||
return labelManager.getAllLabels(user);
|
||||
}
|
||||
|
||||
@Override @Nullable
|
||||
public Label getLabelById(int id, @NotNull final User user) {
|
||||
return labelManager.getLabelById(id, user);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
return labelManager.getLabelByTitle(title, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Label label, @NotNull User user) throws WiseMappingException {
|
||||
if (label.getCreator().equals(user)) {
|
||||
labelManager.removeLabel(label);
|
||||
} else {
|
||||
throw new WiseMappingException("User: "+ user.getFullName() + "has no ownership on label " + label.getTitle());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -67,4 +67,8 @@ public interface MindmapService {
|
||||
boolean isAdmin(@Nullable User user);
|
||||
|
||||
void purgeHistory(int mapId) throws IOException;
|
||||
|
||||
void addLabel(@NotNull final Mindmap mindmap, @NotNull final Label label);
|
||||
|
||||
void removeLabel(@NotNull final Mindmap mindmap, @NotNull final Label label);
|
||||
}
|
||||
|
@ -87,6 +87,16 @@ public class MindmapServiceImpl
|
||||
mindmapManager.purgeHistory(mapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull Mindmap mindmap, @NotNull final Label label) {
|
||||
mindmap.addLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Mindmap mindmap, @NotNull Label label) {
|
||||
mindmap.removeLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mindmap getMindmapByTitle(String title, User user) {
|
||||
return mindmapManager.getMindmapByTitle(title, user);
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.wisemapping.validator;
|
||||
|
||||
import com.wisemapping.model.Constants;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
public class LabelValidator implements Validator {
|
||||
|
||||
private final LabelService service;
|
||||
|
||||
public LabelValidator(@NotNull final LabelService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return clazz.equals(Label.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@Nullable final Object target, @NotNull final Errors errors) {
|
||||
final Label label = (Label) target;
|
||||
if (label == null) {
|
||||
errors.rejectValue("map", "error.not-specified", null, "Value required.");
|
||||
} else {
|
||||
validateLabel(label, errors);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED);
|
||||
final String title = label.getTitle();
|
||||
ValidatorUtils.rejectIfExceeded(
|
||||
errors,
|
||||
"title",
|
||||
"The description must have less than " + Constants.MAX_LABEL_NAME_LENGTH + " characters.",
|
||||
title,
|
||||
Constants.MAX_LABEL_NAME_LENGTH);
|
||||
final User user = com.wisemapping.security.Utils.getUser();
|
||||
assert user != null;
|
||||
final Label foundLabel = service.getLabelByTitle(title, user);
|
||||
if (foundLabel != null) {
|
||||
errors.rejectValue("title", Messages.LABEL_TITLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ public interface Messages {
|
||||
String FIELD_REQUIRED = "FIELD_REQUIRED";
|
||||
String IMPORT_MAP_ERROR = "IMPORT_MAP_ERROR";
|
||||
String MAP_TITLE_ALREADY_EXISTS = "MAP_TITLE_ALREADY_EXISTS";
|
||||
String LABEL_TITLE_ALREADY_EXISTS = "LABEL_TITLE_ALREADY_EXISTS";
|
||||
String PASSWORD_MISSMATCH = "PASSWORD_MISSMATCH";
|
||||
String CAPTCHA_ERROR = "CAPTCHA_ERROR";
|
||||
String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR";
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<class name="com.wisemapping.model.Label" table="LABEL">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="title"/>
|
||||
<property name="color"/>
|
||||
<many-to-one name="parent" column="parent_label_id" not-null="false"/>
|
||||
<many-to-one name="creator" column="creator_id" unique="true" not-null="false" lazy="proxy"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
@ -25,6 +25,12 @@
|
||||
<key column="mindmap_id" not-null="true"/>
|
||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||
</set>
|
||||
|
||||
<set name = "labels"
|
||||
table="R_LABEL_MINDMAP" order-by="label_id" fetch="select" cascade="none">
|
||||
<key column="mindmap_id" not-null="true"/>
|
||||
<many-to-many column="label_id" class="com.wisemapping.model.Label"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
@ -74,6 +74,7 @@ SHARED=Shared
|
||||
ONLY_VIEW_PRIVATE = This mindmap can be viewed by you only.
|
||||
ALL_VIEW_PUBLIC = This mindmap can be viewed by any user.
|
||||
NEW_MAP_MSG=Create a new map
|
||||
NEW_LABEL_MSG=Create a new label
|
||||
PUBLISH=Publish
|
||||
PUBLISH_DETAILS=By publishing the map you make it visible to everyone on the Internet.
|
||||
ACCOUNT_DETAIL=Do you want to change you user options?. Here is the place.
|
||||
@ -106,6 +107,7 @@ IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 and WiseMapping maps to your lis
|
||||
PRINT=Print
|
||||
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
|
||||
MAP_TITLE_ALREADY_EXISTS=You have already a map with the same name
|
||||
LABEL_TITLE_ALREADY_EXISTS=You have already a label with the same name
|
||||
#####FOOTER
|
||||
COPYRIGHT=Powered by WiseMapping
|
||||
TERMS_AND_CONDITIONS=Terms and Conditions
|
||||
@ -136,17 +138,25 @@ LANGUAGE=Language
|
||||
FILTERS=Filter
|
||||
MORE=More
|
||||
ADD_NEW_MAP=Add New Map
|
||||
ADD_NEW_LABEL=Add New Label
|
||||
LABEL=Label
|
||||
IMPORTING=Importing ...
|
||||
NEW=New
|
||||
MIND_FILE=File
|
||||
PARENT_LABEL=Nest label under
|
||||
COLOR=Color
|
||||
CHOOSE_LABEL=Choose a label
|
||||
SELECT_LABEL=Please select a label
|
||||
NO_SEARCH_RESULT=No mindmap available for the selected filter criteria
|
||||
SEARCH=Search
|
||||
GENERAL=General
|
||||
SECURITY=Security
|
||||
MAP_NAME_HINT=Name of the new map to create
|
||||
LABEL_NAME_HINT=Name of the new label to create
|
||||
MAP_DESCRIPTION_HINT=Some description for your map
|
||||
WARNING=Warning
|
||||
DELETE_MAPS_WARNING=Deleted mindmap can not be recovered. Do you want to continue ?.
|
||||
DELETE_LABELS_WARNING=All labelled mindmaps will be untagged. Do you want to continue ?.
|
||||
THANKS_FOR_SIGN_UP=Thanks for signing up\!
|
||||
SIGN_UP_CONFIRMATION_EMAIL=\ You will receive a confirmation message shortly from WiseMapping. This message will ask you to activate your WiseMapping account.</br>Please select the link to activate and start creating and sharing maps.
|
||||
SIGN_UP_SUCCESS=Your account has been created successfully, click <a href\="c/login">here</a> to sign in and start enjoying WiseMapping.
|
||||
@ -246,6 +256,7 @@ CONTACT_US=Contact Us
|
||||
CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Google ReCaptcha service.
|
||||
ACCESS_HAS_BEEN_REVOKED= Upps. your access permissions to this map has been revoked. Contact map owner.
|
||||
MAP_CAN_NOT_BE_FOUND= Upps. The map can not be found. It must have been deleted.
|
||||
LABEL_CAN_NOT_BE_FOUND= Upps. The label can not be found. It must have been deleted.
|
||||
LICENSE=License
|
||||
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
||||
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>
|
||||
|
@ -33,6 +33,7 @@
|
||||
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
|
||||
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
|
||||
<value>com/wisemapping/model/Label.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
|
@ -13,5 +13,10 @@
|
||||
<bean id="mindmapManager" class="com.wisemapping.dao.MindmapManagerImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate"/>
|
||||
</bean>
|
||||
|
||||
<bean id="labelManager" class="com.wisemapping.dao.LabelManagerImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
@ -44,6 +44,8 @@
|
||||
<value>com.wisemapping.rest.model.RestCollaborationList</value>
|
||||
<value>com.wisemapping.rest.model.RestLogItem</value>
|
||||
<value>com.wisemapping.rest.model.RestLockInfo</value>
|
||||
<value>com.wisemapping.rest.model.RestLabel</value>
|
||||
<value>com.wisemapping.rest.model.RestLabelList</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
@ -55,6 +55,23 @@
|
||||
<property name="target" ref="mindMapServiceTarget"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="labelServiceTarget" class="com.wisemapping.service.LabelServiceImpl">
|
||||
<property name="labelManager" ref="labelManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="labelService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="target">
|
||||
<ref local="labelServiceTarget"/>
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRED</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="${mail.smtp.host}"/>
|
||||
<property name="port" value="${mail.smtp.port}"/>
|
||||
|
214
wise-webapp/src/main/webapp/bootstrap/css/bootstrap-colorpicker.css
vendored
Normal file
214
wise-webapp/src/main/webapp/bootstrap/css/bootstrap-colorpicker.css
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker
|
||||
* http://mjolnic.github.io/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
*/
|
||||
|
||||
.colorpicker-saturation {
|
||||
float: left;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
cursor: crosshair;
|
||||
background-image: url("../img/bootstrap-colorpicker/saturation.png");
|
||||
}
|
||||
|
||||
.colorpicker-saturation i {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin: -4px 0 0 -4px;
|
||||
border: 1px solid #000;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.colorpicker-saturation i b {
|
||||
display: block;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border: 1px solid #fff;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.colorpicker-hue,
|
||||
.colorpicker-alpha {
|
||||
float: left;
|
||||
width: 15px;
|
||||
height: 100px;
|
||||
margin-bottom: 4px;
|
||||
margin-left: 4px;
|
||||
cursor: row-resize;
|
||||
}
|
||||
|
||||
.colorpicker-hue i,
|
||||
.colorpicker-alpha i {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
margin-top: -1px;
|
||||
background: #000;
|
||||
border-top: 1px solid #fff;
|
||||
}
|
||||
|
||||
.colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue.png");
|
||||
}
|
||||
|
||||
.colorpicker-alpha {
|
||||
display: none;
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
}
|
||||
|
||||
.colorpicker {
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2500;
|
||||
min-width: 130px;
|
||||
padding: 4px;
|
||||
margin-top: 1px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.colorpicker:before,
|
||||
.colorpicker:after {
|
||||
display: table;
|
||||
line-height: 0;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.colorpicker:after {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.colorpicker:before {
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
left: 6px;
|
||||
display: inline-block;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
border-left: 7px solid transparent;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.colorpicker:after {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 7px;
|
||||
display: inline-block;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #ffffff;
|
||||
border-left: 6px solid transparent;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.colorpicker div {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-with-alpha {
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-with-alpha .colorpicker-alpha {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.colorpicker-color {
|
||||
height: 10px;
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
background-position: 0 100%;
|
||||
}
|
||||
|
||||
.colorpicker-color div {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.colorpicker-element .input-group-addon i {
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-inline {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
float: none;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal {
|
||||
width: 110px;
|
||||
height: auto;
|
||||
min-width: 110px;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-saturation {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-color {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
float: left;
|
||||
width: 100px;
|
||||
height: 15px;
|
||||
margin-bottom: 4px;
|
||||
margin-left: 0;
|
||||
cursor: col-resize;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue i,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha i {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: 1px;
|
||||
height: 15px;
|
||||
margin-top: 0;
|
||||
background: #ffffff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue-horizontal.png");
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha-horizontal.png");
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.colorpicker.colorpicker-visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.colorpicker-inline.colorpicker-visible {
|
||||
display: inline-block;
|
||||
}
|
9
wise-webapp/src/main/webapp/bootstrap/css/bootstrap-colorpicker.min.css
vendored
Normal file
9
wise-webapp/src/main/webapp/bootstrap/css/bootstrap-colorpicker.min.css
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker
|
||||
* http://mjolnic.github.io/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
*/.colorpicker-saturation{float:left;width:100px;height:100px;cursor:crosshair;background-image:url("../img/bootstrap-colorpicker/saturation.png")}.colorpicker-saturation i{position:absolute;top:0;left:0;display:block;width:5px;height:5px;margin:-4px 0 0 -4px;border:1px solid #000;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.colorpicker-saturation i b{display:block;width:5px;height:5px;border:1px solid #fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.colorpicker-hue,.colorpicker-alpha{float:left;width:15px;height:100px;margin-bottom:4px;margin-left:4px;cursor:row-resize}.colorpicker-hue i,.colorpicker-alpha i{position:absolute;top:0;left:0;display:block;width:100%;height:1px;margin-top:-1px;background:#000;border-top:1px solid #fff}.colorpicker-hue{background-image:url("../img/bootstrap-colorpicker/hue.png")}.colorpicker-alpha{display:none;background-image:url("../img/bootstrap-colorpicker/alpha.png")}.colorpicker{top:0;left:0;z-index:2500;min-width:130px;padding:4px;margin-top:1px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*zoom:1}.colorpicker:before,.colorpicker:after{display:table;line-height:0;content:""}.colorpicker:after{clear:both}.colorpicker:before{position:absolute;top:-7px;left:6px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.colorpicker:after{position:absolute;top:-6px;left:7px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.colorpicker div{position:relative}.colorpicker.colorpicker-with-alpha{min-width:140px}.colorpicker.colorpicker-with-alpha .colorpicker-alpha{display:block}.colorpicker-color{height:10px;margin-top:5px;clear:both;background-image:url("../img/bootstrap-colorpicker/alpha.png");background-position:0 100%}.colorpicker-color div{height:10px}.colorpicker-element .input-group-addon i{display:block;width:16px;height:16px;cursor:pointer}.colorpicker.colorpicker-inline{position:relative;display:inline-block;float:none}.colorpicker.colorpicker-horizontal{width:110px;height:auto;min-width:110px}.colorpicker.colorpicker-horizontal .colorpicker-saturation{margin-bottom:4px}.colorpicker.colorpicker-horizontal .colorpicker-color{width:100px}.colorpicker.colorpicker-horizontal .colorpicker-hue,.colorpicker.colorpicker-horizontal .colorpicker-alpha{float:left;width:100px;height:15px;margin-bottom:4px;margin-left:0;cursor:col-resize}.colorpicker.colorpicker-horizontal .colorpicker-hue i,.colorpicker.colorpicker-horizontal .colorpicker-alpha i{position:absolute;top:0;left:0;display:block;width:1px;height:15px;margin-top:0;background:#fff;border:0}.colorpicker.colorpicker-horizontal .colorpicker-hue{background-image:url("../img/bootstrap-colorpicker/hue-horizontal.png")}.colorpicker.colorpicker-horizontal .colorpicker-alpha{background-image:url("../img/bootstrap-colorpicker/alpha-horizontal.png")}.colorpicker.colorpicker-hidden{display:none}.colorpicker.colorpicker-visible{display:block}.colorpicker-inline.colorpicker-visible{display:inline-block}
|
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
951
wise-webapp/src/main/webapp/bootstrap/js/bootstrap-colorpicker.js
vendored
Normal file
951
wise-webapp/src/main/webapp/bootstrap/js/bootstrap-colorpicker.js
vendored
Normal file
@ -0,0 +1,951 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker
|
||||
* http://mjolnic.github.io/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
* @todo Update DOCS
|
||||
*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
// Color object
|
||||
var Color = function(val) {
|
||||
this.value = {
|
||||
h: 0,
|
||||
s: 0,
|
||||
b: 0,
|
||||
a: 1
|
||||
};
|
||||
this.origFormat = null; // original string format
|
||||
if (val) {
|
||||
if (val.toLowerCase !== undefined) {
|
||||
this.setColor(val);
|
||||
} else if (val.h !== undefined) {
|
||||
this.value = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Color.prototype = {
|
||||
constructor: Color,
|
||||
_sanitizeNumber: function(val) {
|
||||
if (typeof val === 'number') {
|
||||
return val;
|
||||
}
|
||||
if (isNaN(val) || (val === null) || (val === '') || (val === undefined)) {
|
||||
return 1;
|
||||
}
|
||||
if (val.toLowerCase !== undefined) {
|
||||
return parseFloat(val);
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
//parse a string to HSB
|
||||
setColor: function(strVal) {
|
||||
strVal = strVal.toLowerCase();
|
||||
this.value = this.stringToHSB(strVal) || {
|
||||
h: 0,
|
||||
s: 0,
|
||||
b: 0,
|
||||
a: 1
|
||||
};
|
||||
},
|
||||
stringToHSB: function(strVal) {
|
||||
strVal = strVal.toLowerCase();
|
||||
var that = this,
|
||||
result = false;
|
||||
$.each(this.stringParsers, function(i, parser) {
|
||||
var match = parser.re.exec(strVal),
|
||||
values = match && parser.parse.apply(that, [match]),
|
||||
format = parser.format || 'rgba';
|
||||
if (values) {
|
||||
if (format.match(/hsla?/)) {
|
||||
result = that.RGBtoHSB.apply(that, that.HSLtoRGB.apply(that, values));
|
||||
} else {
|
||||
result = that.RGBtoHSB.apply(that, values);
|
||||
}
|
||||
that.origFormat = format;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
setHue: function(h) {
|
||||
this.value.h = 1 - h;
|
||||
},
|
||||
setSaturation: function(s) {
|
||||
this.value.s = s;
|
||||
},
|
||||
setBrightness: function(b) {
|
||||
this.value.b = 1 - b;
|
||||
},
|
||||
setAlpha: function(a) {
|
||||
this.value.a = parseInt((1 - a) * 100, 10) / 100;
|
||||
},
|
||||
toRGB: function(h, s, v, a) {
|
||||
h = h || this.value.h;
|
||||
s = s || this.value.s;
|
||||
v = v || this.value.b;
|
||||
a = a || this.value.a;
|
||||
|
||||
var r, g, b, i, f, p, q, t;
|
||||
if (h && s === undefined && v === undefined) {
|
||||
s = h.s, v = h.v, h = h.h;
|
||||
}
|
||||
i = Math.floor(h * 6);
|
||||
f = h * 6 - i;
|
||||
p = v * (1 - s);
|
||||
q = v * (1 - f * s);
|
||||
t = v * (1 - (1 - f) * s);
|
||||
switch (i % 6) {
|
||||
case 0:
|
||||
r = v, g = t, b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q, g = v, b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p, g = v, b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p, g = q, b = v;
|
||||
break;
|
||||
case 4:
|
||||
r = t, g = p, b = v;
|
||||
break;
|
||||
case 5:
|
||||
r = v, g = p, b = q;
|
||||
break;
|
||||
}
|
||||
return {
|
||||
r: Math.floor(r * 255),
|
||||
g: Math.floor(g * 255),
|
||||
b: Math.floor(b * 255),
|
||||
a: a
|
||||
};
|
||||
},
|
||||
toHex: function(h, s, b, a) {
|
||||
var rgb = this.toRGB(h, s, b, a);
|
||||
return '#' + ((1 << 24) | (parseInt(rgb.r) << 16) | (parseInt(rgb.g) << 8) | parseInt(rgb.b)).toString(16).substr(1);
|
||||
},
|
||||
toHSL: function(h, s, b, a) {
|
||||
h = h || this.value.h;
|
||||
s = s || this.value.s;
|
||||
b = b || this.value.b;
|
||||
a = a || this.value.a;
|
||||
|
||||
var H = h,
|
||||
L = (2 - s) * b,
|
||||
S = s * b;
|
||||
if (L > 0 && L <= 1) {
|
||||
S /= L;
|
||||
} else {
|
||||
S /= 2 - L;
|
||||
}
|
||||
L /= 2;
|
||||
if (S > 1) {
|
||||
S = 1;
|
||||
}
|
||||
return {
|
||||
h: isNaN(H) ? 0 : H,
|
||||
s: isNaN(S) ? 0 : S,
|
||||
l: isNaN(L) ? 0 : L,
|
||||
a: isNaN(a) ? 0 : a,
|
||||
};
|
||||
},
|
||||
RGBtoHSB: function(r, g, b, a) {
|
||||
r /= 255;
|
||||
g /= 255;
|
||||
b /= 255;
|
||||
|
||||
var H, S, V, C;
|
||||
V = Math.max(r, g, b);
|
||||
C = V - Math.min(r, g, b);
|
||||
H = (C === 0 ? null :
|
||||
V === r ? (g - b) / C :
|
||||
V === g ? (b - r) / C + 2 :
|
||||
(r - g) / C + 4
|
||||
);
|
||||
H = ((H + 360) % 6) * 60 / 360;
|
||||
S = C === 0 ? 0 : C / V;
|
||||
return {
|
||||
h: this._sanitizeNumber(H),
|
||||
s: S,
|
||||
b: V,
|
||||
a: this._sanitizeNumber(a)
|
||||
};
|
||||
},
|
||||
HueToRGB: function(p, q, h) {
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
} else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
if ((h * 6) < 1) {
|
||||
return p + (q - p) * h * 6;
|
||||
} else if ((h * 2) < 1) {
|
||||
return q;
|
||||
} else if ((h * 3) < 2) {
|
||||
return p + (q - p) * ((2 / 3) - h) * 6;
|
||||
} else {
|
||||
return p;
|
||||
}
|
||||
},
|
||||
HSLtoRGB: function(h, s, l, a) {
|
||||
if (s < 0) {
|
||||
s = 0;
|
||||
}
|
||||
var q;
|
||||
if (l <= 0.5) {
|
||||
q = l * (1 + s);
|
||||
} else {
|
||||
q = l + s - (l * s);
|
||||
}
|
||||
|
||||
var p = 2 * l - q;
|
||||
|
||||
var tr = h + (1 / 3);
|
||||
var tg = h;
|
||||
var tb = h - (1 / 3);
|
||||
|
||||
var r = Math.round(this.HueToRGB(p, q, tr) * 255);
|
||||
var g = Math.round(this.HueToRGB(p, q, tg) * 255);
|
||||
var b = Math.round(this.HueToRGB(p, q, tb) * 255);
|
||||
return [r, g, b, this._sanitizeNumber(a)];
|
||||
},
|
||||
toString: function(format) {
|
||||
format = format || 'rgba';
|
||||
switch (format) {
|
||||
case 'rgb':
|
||||
{
|
||||
var rgb = this.toRGB();
|
||||
return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
||||
}
|
||||
break;
|
||||
case 'rgba':
|
||||
{
|
||||
var rgb = this.toRGB();
|
||||
return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + rgb.a + ')';
|
||||
}
|
||||
break;
|
||||
case 'hsl':
|
||||
{
|
||||
var hsl = this.toHSL();
|
||||
return 'hsl(' + Math.round(hsl.h * 360) + ',' + Math.round(hsl.s * 100) + '%,' + Math.round(hsl.l * 100) + '%)';
|
||||
}
|
||||
break;
|
||||
case 'hsla':
|
||||
{
|
||||
var hsl = this.toHSL();
|
||||
return 'hsla(' + Math.round(hsl.h * 360) + ',' + Math.round(hsl.s * 100) + '%,' + Math.round(hsl.l * 100) + '%,' + hsl.a + ')';
|
||||
}
|
||||
break;
|
||||
case 'hex':
|
||||
{
|
||||
return this.toHex();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
// a set of RE's that can match strings and generate color tuples.
|
||||
// from John Resig color plugin
|
||||
// https://github.com/jquery/jquery-color/
|
||||
stringParsers: [{
|
||||
re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
|
||||
format: 'hex',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
parseInt(execResult[1], 16),
|
||||
parseInt(execResult[2], 16),
|
||||
parseInt(execResult[3], 16),
|
||||
1
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
|
||||
format: 'hex',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
parseInt(execResult[1] + execResult[1], 16),
|
||||
parseInt(execResult[2] + execResult[2], 16),
|
||||
parseInt(execResult[3] + execResult[3], 16),
|
||||
1
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,
|
||||
format: 'rgb',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
execResult[1],
|
||||
execResult[2],
|
||||
execResult[3],
|
||||
1
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /rgb\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
|
||||
format: 'rgb',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
2.55 * execResult[1],
|
||||
2.55 * execResult[2],
|
||||
2.55 * execResult[3],
|
||||
1
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
||||
format: 'rgba',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
execResult[1],
|
||||
execResult[2],
|
||||
execResult[3],
|
||||
execResult[4]
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /rgba\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
||||
format: 'rgba',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
2.55 * execResult[1],
|
||||
2.55 * execResult[2],
|
||||
2.55 * execResult[3],
|
||||
execResult[4]
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
|
||||
format: 'hsl',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
execResult[1] / 360,
|
||||
execResult[2] / 100,
|
||||
execResult[3] / 100,
|
||||
execResult[4]
|
||||
];
|
||||
}
|
||||
}, {
|
||||
re: /hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
||||
format: 'hsla',
|
||||
parse: function(execResult) {
|
||||
return [
|
||||
execResult[1] / 360,
|
||||
execResult[2] / 100,
|
||||
execResult[3] / 100,
|
||||
execResult[4]
|
||||
];
|
||||
}
|
||||
}, {
|
||||
//predefined color name
|
||||
re: /^([a-z]{3,})$/,
|
||||
format: 'alias',
|
||||
parse: function(execResult) {
|
||||
var hexval = this.colorNameToHex(execResult[0]) || '#000000';
|
||||
var match = this.stringParsers[0].re.exec(hexval),
|
||||
values = match && this.stringParsers[0].parse.apply(this, [match]);
|
||||
return values;
|
||||
}
|
||||
}],
|
||||
colorNameToHex: function(name) {
|
||||
// 140 predefined colors from the HTML Colors spec
|
||||
var colors = {
|
||||
"aliceblue": "#f0f8ff",
|
||||
"antiquewhite": "#faebd7",
|
||||
"aqua": "#00ffff",
|
||||
"aquamarine": "#7fffd4",
|
||||
"azure": "#f0ffff",
|
||||
"beige": "#f5f5dc",
|
||||
"bisque": "#ffe4c4",
|
||||
"black": "#000000",
|
||||
"blanchedalmond": "#ffebcd",
|
||||
"blue": "#0000ff",
|
||||
"blueviolet": "#8a2be2",
|
||||
"brown": "#a52a2a",
|
||||
"burlywood": "#deb887",
|
||||
"cadetblue": "#5f9ea0",
|
||||
"chartreuse": "#7fff00",
|
||||
"chocolate": "#d2691e",
|
||||
"coral": "#ff7f50",
|
||||
"cornflowerblue": "#6495ed",
|
||||
"cornsilk": "#fff8dc",
|
||||
"crimson": "#dc143c",
|
||||
"cyan": "#00ffff",
|
||||
"darkblue": "#00008b",
|
||||
"darkcyan": "#008b8b",
|
||||
"darkgoldenrod": "#b8860b",
|
||||
"darkgray": "#a9a9a9",
|
||||
"darkgreen": "#006400",
|
||||
"darkkhaki": "#bdb76b",
|
||||
"darkmagenta": "#8b008b",
|
||||
"darkolivegreen": "#556b2f",
|
||||
"darkorange": "#ff8c00",
|
||||
"darkorchid": "#9932cc",
|
||||
"darkred": "#8b0000",
|
||||
"darksalmon": "#e9967a",
|
||||
"darkseagreen": "#8fbc8f",
|
||||
"darkslateblue": "#483d8b",
|
||||
"darkslategray": "#2f4f4f",
|
||||
"darkturquoise": "#00ced1",
|
||||
"darkviolet": "#9400d3",
|
||||
"deeppink": "#ff1493",
|
||||
"deepskyblue": "#00bfff",
|
||||
"dimgray": "#696969",
|
||||
"dodgerblue": "#1e90ff",
|
||||
"firebrick": "#b22222",
|
||||
"floralwhite": "#fffaf0",
|
||||
"forestgreen": "#228b22",
|
||||
"fuchsia": "#ff00ff",
|
||||
"gainsboro": "#dcdcdc",
|
||||
"ghostwhite": "#f8f8ff",
|
||||
"gold": "#ffd700",
|
||||
"goldenrod": "#daa520",
|
||||
"gray": "#808080",
|
||||
"green": "#008000",
|
||||
"greenyellow": "#adff2f",
|
||||
"honeydew": "#f0fff0",
|
||||
"hotpink": "#ff69b4",
|
||||
"indianred ": "#cd5c5c",
|
||||
"indigo ": "#4b0082",
|
||||
"ivory": "#fffff0",
|
||||
"khaki": "#f0e68c",
|
||||
"lavender": "#e6e6fa",
|
||||
"lavenderblush": "#fff0f5",
|
||||
"lawngreen": "#7cfc00",
|
||||
"lemonchiffon": "#fffacd",
|
||||
"lightblue": "#add8e6",
|
||||
"lightcoral": "#f08080",
|
||||
"lightcyan": "#e0ffff",
|
||||
"lightgoldenrodyellow": "#fafad2",
|
||||
"lightgrey": "#d3d3d3",
|
||||
"lightgreen": "#90ee90",
|
||||
"lightpink": "#ffb6c1",
|
||||
"lightsalmon": "#ffa07a",
|
||||
"lightseagreen": "#20b2aa",
|
||||
"lightskyblue": "#87cefa",
|
||||
"lightslategray": "#778899",
|
||||
"lightsteelblue": "#b0c4de",
|
||||
"lightyellow": "#ffffe0",
|
||||
"lime": "#00ff00",
|
||||
"limegreen": "#32cd32",
|
||||
"linen": "#faf0e6",
|
||||
"magenta": "#ff00ff",
|
||||
"maroon": "#800000",
|
||||
"mediumaquamarine": "#66cdaa",
|
||||
"mediumblue": "#0000cd",
|
||||
"mediumorchid": "#ba55d3",
|
||||
"mediumpurple": "#9370d8",
|
||||
"mediumseagreen": "#3cb371",
|
||||
"mediumslateblue": "#7b68ee",
|
||||
"mediumspringgreen": "#00fa9a",
|
||||
"mediumturquoise": "#48d1cc",
|
||||
"mediumvioletred": "#c71585",
|
||||
"midnightblue": "#191970",
|
||||
"mintcream": "#f5fffa",
|
||||
"mistyrose": "#ffe4e1",
|
||||
"moccasin": "#ffe4b5",
|
||||
"navajowhite": "#ffdead",
|
||||
"navy": "#000080",
|
||||
"oldlace": "#fdf5e6",
|
||||
"olive": "#808000",
|
||||
"olivedrab": "#6b8e23",
|
||||
"orange": "#ffa500",
|
||||
"orangered": "#ff4500",
|
||||
"orchid": "#da70d6",
|
||||
"palegoldenrod": "#eee8aa",
|
||||
"palegreen": "#98fb98",
|
||||
"paleturquoise": "#afeeee",
|
||||
"palevioletred": "#d87093",
|
||||
"papayawhip": "#ffefd5",
|
||||
"peachpuff": "#ffdab9",
|
||||
"peru": "#cd853f",
|
||||
"pink": "#ffc0cb",
|
||||
"plum": "#dda0dd",
|
||||
"powderblue": "#b0e0e6",
|
||||
"purple": "#800080",
|
||||
"red": "#ff0000",
|
||||
"rosybrown": "#bc8f8f",
|
||||
"royalblue": "#4169e1",
|
||||
"saddlebrown": "#8b4513",
|
||||
"salmon": "#fa8072",
|
||||
"sandybrown": "#f4a460",
|
||||
"seagreen": "#2e8b57",
|
||||
"seashell": "#fff5ee",
|
||||
"sienna": "#a0522d",
|
||||
"silver": "#c0c0c0",
|
||||
"skyblue": "#87ceeb",
|
||||
"slateblue": "#6a5acd",
|
||||
"slategray": "#708090",
|
||||
"snow": "#fffafa",
|
||||
"springgreen": "#00ff7f",
|
||||
"steelblue": "#4682b4",
|
||||
"tan": "#d2b48c",
|
||||
"teal": "#008080",
|
||||
"thistle": "#d8bfd8",
|
||||
"tomato": "#ff6347",
|
||||
"turquoise": "#40e0d0",
|
||||
"violet": "#ee82ee",
|
||||
"wheat": "#f5deb3",
|
||||
"white": "#ffffff",
|
||||
"whitesmoke": "#f5f5f5",
|
||||
"yellow": "#ffff00",
|
||||
"yellowgreen": "#9acd32"
|
||||
};
|
||||
|
||||
if (typeof colors[name.toLowerCase()] !== 'undefined') {
|
||||
return colors[name.toLowerCase()];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var defaults = {
|
||||
horizontal: false, // horizontal mode layout ?
|
||||
inline: false, //forces to show the colorpicker as an inline element
|
||||
color: false, //forces a color
|
||||
format: false, //forces a format
|
||||
input: 'input', // children input selector
|
||||
container: false, // container selector
|
||||
component: '.add-on, .input-group-addon', // children component selector
|
||||
sliders: {
|
||||
saturation: {
|
||||
maxLeft: 100,
|
||||
maxTop: 100,
|
||||
callLeft: 'setSaturation',
|
||||
callTop: 'setBrightness'
|
||||
},
|
||||
hue: {
|
||||
maxLeft: 0,
|
||||
maxTop: 100,
|
||||
callLeft: false,
|
||||
callTop: 'setHue'
|
||||
},
|
||||
alpha: {
|
||||
maxLeft: 0,
|
||||
maxTop: 100,
|
||||
callLeft: false,
|
||||
callTop: 'setAlpha'
|
||||
}
|
||||
},
|
||||
slidersHorz: {
|
||||
saturation: {
|
||||
maxLeft: 100,
|
||||
maxTop: 100,
|
||||
callLeft: 'setSaturation',
|
||||
callTop: 'setBrightness'
|
||||
},
|
||||
hue: {
|
||||
maxLeft: 100,
|
||||
maxTop: 0,
|
||||
callLeft: 'setHue',
|
||||
callTop: false
|
||||
},
|
||||
alpha: {
|
||||
maxLeft: 100,
|
||||
maxTop: 0,
|
||||
callLeft: 'setAlpha',
|
||||
callTop: false
|
||||
}
|
||||
},
|
||||
template: '<div class="colorpicker dropdown-menu">' +
|
||||
'<div class="colorpicker-saturation"><i><b></b></i></div>' +
|
||||
'<div class="colorpicker-hue"><i></i></div>' +
|
||||
'<div class="colorpicker-alpha"><i></i></div>' +
|
||||
'<div class="colorpicker-color"><div /></div>' +
|
||||
'</div>'
|
||||
};
|
||||
|
||||
var Colorpicker = function(element, options) {
|
||||
this.element = $(element).addClass('colorpicker-element');
|
||||
this.options = $.extend({}, defaults, this.element.data(), options);
|
||||
this.component = this.options.component;
|
||||
this.component = (this.component !== false) ? this.element.find(this.component) : false;
|
||||
if (this.component && (this.component.length === 0)) {
|
||||
this.component = false;
|
||||
}
|
||||
this.container = (this.options.container === true) ? this.element : this.options.container;
|
||||
this.container = (this.container !== false) ? $(this.container) : false;
|
||||
|
||||
// Is the element an input? Should we search inside for any input?
|
||||
this.input = this.element.is('input') ? this.element : (this.options.input ?
|
||||
this.element.find(this.options.input) : false);
|
||||
if (this.input && (this.input.length === 0)) {
|
||||
this.input = false;
|
||||
}
|
||||
// Set HSB color
|
||||
this.color = new Color(this.options.color !== false ? this.options.color : this.getValue());
|
||||
this.format = this.options.format !== false ? this.options.format : this.color.origFormat;
|
||||
|
||||
// Setup picker
|
||||
this.picker = $(this.options.template);
|
||||
if (this.options.inline) {
|
||||
this.picker.addClass('colorpicker-inline colorpicker-visible');
|
||||
} else {
|
||||
this.picker.addClass('colorpicker-hidden');
|
||||
}
|
||||
if (this.options.horizontal) {
|
||||
this.picker.addClass('colorpicker-horizontal');
|
||||
}
|
||||
if (this.format === 'rgba' || this.format === 'hsla') {
|
||||
this.picker.addClass('colorpicker-with-alpha');
|
||||
}
|
||||
this.picker.on('mousedown.colorpicker', $.proxy(this.mousedown, this));
|
||||
this.picker.appendTo(this.container ? this.container : $('body'));
|
||||
|
||||
// Bind events
|
||||
if (this.input !== false) {
|
||||
this.input.on({
|
||||
'keyup.colorpicker': $.proxy(this.keyup, this)
|
||||
});
|
||||
if (this.component === false) {
|
||||
this.element.on({
|
||||
'focus.colorpicker': $.proxy(this.show, this)
|
||||
});
|
||||
}
|
||||
if (this.options.inline === false) {
|
||||
this.element.on({
|
||||
'focusout.colorpicker': $.proxy(this.hide, this)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.component !== false) {
|
||||
this.component.on({
|
||||
'click.colorpicker': $.proxy(this.show, this)
|
||||
});
|
||||
}
|
||||
|
||||
if ((this.input === false) && (this.component === false)) {
|
||||
this.element.on({
|
||||
'click.colorpicker': $.proxy(this.show, this)
|
||||
});
|
||||
}
|
||||
this.update();
|
||||
|
||||
$($.proxy(function() {
|
||||
this.element.trigger('create');
|
||||
}, this));
|
||||
};
|
||||
|
||||
Colorpicker.version = '2.0.0-beta';
|
||||
|
||||
Colorpicker.Color = Color;
|
||||
|
||||
Colorpicker.prototype = {
|
||||
constructor: Colorpicker,
|
||||
destroy: function() {
|
||||
this.picker.remove();
|
||||
this.element.removeData('colorpicker').off('.colorpicker');
|
||||
if (this.input !== false) {
|
||||
this.input.off('.colorpicker');
|
||||
}
|
||||
if (this.component !== false) {
|
||||
this.component.off('.colorpicker');
|
||||
}
|
||||
this.element.removeClass('colorpicker-element');
|
||||
this.element.trigger({
|
||||
type: 'destroy'
|
||||
});
|
||||
},
|
||||
reposition: function() {
|
||||
if (this.options.inline !== false) {
|
||||
return false;
|
||||
}
|
||||
var offset = this.component ? this.component.offset() : this.element.offset();
|
||||
this.picker.css({
|
||||
top: offset.top + (this.component ? this.component.outerHeight() : this.element.outerHeight()),
|
||||
left: offset.left
|
||||
});
|
||||
},
|
||||
show: function(e) {
|
||||
if (this.isDisabled()) {
|
||||
return false;
|
||||
}
|
||||
this.picker.addClass('colorpicker-visible').removeClass('colorpicker-hidden');
|
||||
this.reposition();
|
||||
$(window).on('resize.colorpicker', $.proxy(this.reposition, this));
|
||||
if (!this.hasInput() && e) {
|
||||
if (e.stopPropagation && e.preventDefault) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
if (this.options.inline === false) {
|
||||
$(window.document).on({
|
||||
'mousedown.colorpicker': $.proxy(this.hide, this)
|
||||
});
|
||||
}
|
||||
this.element.trigger({
|
||||
type: 'showPicker',
|
||||
color: this.color
|
||||
});
|
||||
},
|
||||
hide: function() {
|
||||
this.picker.addClass('colorpicker-hidden').removeClass('colorpicker-visible');
|
||||
$(window).off('resize.colorpicker', this.reposition);
|
||||
$(document).off({
|
||||
'mousedown.colorpicker': this.hide
|
||||
});
|
||||
this.update();
|
||||
this.element.trigger({
|
||||
type: 'hidePicker',
|
||||
color: this.color
|
||||
});
|
||||
},
|
||||
updateData: function(val) {
|
||||
val = val || this.color.toString(this.format);
|
||||
this.element.data('color', val);
|
||||
return val;
|
||||
},
|
||||
updateInput: function(val) {
|
||||
val = val || this.color.toString(this.format);
|
||||
if (this.input !== false) {
|
||||
this.input.prop('value', val);
|
||||
}
|
||||
return val;
|
||||
},
|
||||
updatePicker: function(val) {
|
||||
if (val !== undefined) {
|
||||
this.color = new Color(val);
|
||||
}
|
||||
var sl = (this.options.horizontal === false) ? this.options.sliders : this.options.slidersHorz;
|
||||
var icns = this.picker.find('i');
|
||||
if (icns.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (this.options.horizontal === false) {
|
||||
sl = this.options.sliders;
|
||||
icns.eq(1).css('top', sl.hue.maxTop * (1 - this.color.value.h)).end()
|
||||
.eq(2).css('top', sl.alpha.maxTop * (1 - this.color.value.a));
|
||||
} else {
|
||||
sl = this.options.slidersHorz;
|
||||
icns.eq(1).css('left', sl.hue.maxLeft * (1 - this.color.value.h)).end()
|
||||
.eq(2).css('left', sl.alpha.maxLeft * (1 - this.color.value.a));
|
||||
}
|
||||
icns.eq(0).css({
|
||||
'top': sl.saturation.maxTop - this.color.value.b * sl.saturation.maxTop,
|
||||
'left': this.color.value.s * sl.saturation.maxLeft
|
||||
});
|
||||
this.picker.find('.colorpicker-saturation').css('backgroundColor', this.color.toHex(this.color.value.h, 1, 1, 1));
|
||||
this.picker.find('.colorpicker-alpha').css('backgroundColor', this.color.toHex());
|
||||
this.picker.find('.colorpicker-color, .colorpicker-color div').css('backgroundColor', this.color.toString(this.format));
|
||||
return val;
|
||||
},
|
||||
updateComponent: function(val) {
|
||||
val = val || this.color.toString(this.format);
|
||||
if (this.component !== false) {
|
||||
var icn = this.component.find('i').eq(0);
|
||||
if (icn.length > 0) {
|
||||
icn.css({
|
||||
'backgroundColor': val
|
||||
});
|
||||
} else {
|
||||
this.component.css({
|
||||
'backgroundColor': val
|
||||
});
|
||||
}
|
||||
}
|
||||
return val;
|
||||
},
|
||||
update: function(force) {
|
||||
var val = this.updateComponent();
|
||||
if ((this.getValue(false) !== false) || (force === true)) {
|
||||
// Update input/data only if the current value is not blank
|
||||
this.updateInput(val);
|
||||
this.updateData(val);
|
||||
}
|
||||
this.updatePicker();
|
||||
return val;
|
||||
|
||||
},
|
||||
setValue: function(val) { // set color manually
|
||||
this.color = new Color(val);
|
||||
this.update();
|
||||
this.element.trigger({
|
||||
type: 'changeColor',
|
||||
color: this.color,
|
||||
value: val
|
||||
});
|
||||
},
|
||||
getValue: function(defaultValue) {
|
||||
defaultValue = (defaultValue === undefined) ? '#000000' : defaultValue;
|
||||
var val;
|
||||
if (this.hasInput()) {
|
||||
val = this.input.val();
|
||||
} else {
|
||||
val = this.element.data('color');
|
||||
}
|
||||
if ((val === undefined) || (val === '') || (val === null)) {
|
||||
// if not defined or empty, return default
|
||||
val = defaultValue;
|
||||
}
|
||||
return val;
|
||||
},
|
||||
hasInput: function() {
|
||||
return (this.input !== false);
|
||||
},
|
||||
isDisabled: function() {
|
||||
if (this.hasInput()) {
|
||||
return (this.input.prop('disabled') === true);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
disable: function() {
|
||||
if (this.hasInput()) {
|
||||
this.input.prop('disabled', true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
enable: function() {
|
||||
if (this.hasInput()) {
|
||||
this.input.prop('disabled', false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
currentSlider: null,
|
||||
mousePointer: {
|
||||
left: 0,
|
||||
top: 0
|
||||
},
|
||||
mousedown: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
var target = $(e.target);
|
||||
|
||||
//detect the slider and set the limits and callbacks
|
||||
var zone = target.closest('div');
|
||||
var sl = this.options.horizontal ? this.options.slidersHorz : this.options.sliders;
|
||||
if (!zone.is('.colorpicker')) {
|
||||
if (zone.is('.colorpicker-saturation')) {
|
||||
this.currentSlider = $.extend({}, sl.saturation);
|
||||
} else if (zone.is('.colorpicker-hue')) {
|
||||
this.currentSlider = $.extend({}, sl.hue);
|
||||
} else if (zone.is('.colorpicker-alpha')) {
|
||||
this.currentSlider = $.extend({}, sl.alpha);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
var offset = zone.offset();
|
||||
//reference to guide's style
|
||||
this.currentSlider.guide = zone.find('i')[0].style;
|
||||
this.currentSlider.left = e.pageX - offset.left;
|
||||
this.currentSlider.top = e.pageY - offset.top;
|
||||
this.mousePointer = {
|
||||
left: e.pageX,
|
||||
top: e.pageY
|
||||
};
|
||||
//trigger mousemove to move the guide to the current position
|
||||
$(document).on({
|
||||
'mousemove.colorpicker': $.proxy(this.mousemove, this),
|
||||
'mouseup.colorpicker': $.proxy(this.mouseup, this)
|
||||
}).trigger('mousemove');
|
||||
}
|
||||
return false;
|
||||
},
|
||||
mousemove: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var left = Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
this.currentSlider.maxLeft,
|
||||
this.currentSlider.left + ((e.pageX || this.mousePointer.left) - this.mousePointer.left)
|
||||
)
|
||||
);
|
||||
var top = Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
this.currentSlider.maxTop,
|
||||
this.currentSlider.top + ((e.pageY || this.mousePointer.top) - this.mousePointer.top)
|
||||
)
|
||||
);
|
||||
this.currentSlider.guide.left = left + 'px';
|
||||
this.currentSlider.guide.top = top + 'px';
|
||||
if (this.currentSlider.callLeft) {
|
||||
this.color[this.currentSlider.callLeft].call(this.color, left / 100);
|
||||
}
|
||||
if (this.currentSlider.callTop) {
|
||||
this.color[this.currentSlider.callTop].call(this.color, top / 100);
|
||||
}
|
||||
this.update(true);
|
||||
|
||||
this.element.trigger({
|
||||
type: 'changeColor',
|
||||
color: this.color
|
||||
});
|
||||
return false;
|
||||
},
|
||||
mouseup: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
$(document).off({
|
||||
'mousemove.colorpicker': this.mousemove,
|
||||
'mouseup.colorpicker': this.mouseup
|
||||
});
|
||||
return false;
|
||||
},
|
||||
keyup: function(e) {
|
||||
if ((e.keyCode === 38)) {
|
||||
if (this.color.value.a < 1) {
|
||||
this.color.value.a = Math.round((this.color.value.a + 0.01) * 100) / 100;
|
||||
}
|
||||
this.update(true);
|
||||
} else if ((e.keyCode === 40)) {
|
||||
if (this.color.value.a > 0) {
|
||||
this.color.value.a = Math.round((this.color.value.a - 0.01) * 100) / 100;
|
||||
}
|
||||
this.update(true);
|
||||
} else {
|
||||
var val = this.input.val();
|
||||
this.color = new Color(val);
|
||||
if (this.getValue(false) !== false) {
|
||||
this.updateData();
|
||||
this.updateComponent();
|
||||
this.updatePicker();
|
||||
}
|
||||
}
|
||||
this.element.trigger({
|
||||
type: 'changeColor',
|
||||
color: this.color,
|
||||
value: val
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.colorpicker = Colorpicker;
|
||||
|
||||
$.fn.colorpicker = function(option) {
|
||||
var pickerArgs = arguments;
|
||||
|
||||
return this.each(function() {
|
||||
var $this = $(this),
|
||||
inst = $this.data('colorpicker'),
|
||||
options = ((typeof option === 'object') ? option : {});
|
||||
if ((!inst) && (typeof option !== 'string')) {
|
||||
$this.data('colorpicker', new Colorpicker(this, options));
|
||||
} else {
|
||||
if (typeof option === 'string') {
|
||||
inst[option].apply(inst, Array.prototype.slice.call(pickerArgs, 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.colorpicker.constructor = Colorpicker;
|
||||
|
||||
})(window.jQuery);
|
1
wise-webapp/src/main/webapp/bootstrap/js/bootstrap-colorpicker.min.js
vendored
Normal file
1
wise-webapp/src/main/webapp/bootstrap/js/bootstrap-colorpicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,3 +1,4 @@
|
||||
@import "../bootstrap/css/bootstrap-colorpicker.min.css";
|
||||
@import "../bootstrap/css/bootstrap.min.css";
|
||||
@import "pageHeaders.css";
|
||||
|
||||
@ -13,6 +14,20 @@
|
||||
@base-color: #111;
|
||||
|
||||
/* ----------------------------- General -------------------------------- */
|
||||
.nav-pills li {
|
||||
position: relative;
|
||||
width: 90%;
|
||||
}
|
||||
.nav-pills {
|
||||
width: 108%;
|
||||
}
|
||||
.active {
|
||||
position: relative;
|
||||
left: 8px;
|
||||
}
|
||||
.colorpicker {
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
#mindmapListContainer {
|
||||
background: #FFFFFF;
|
||||
@ -112,6 +127,113 @@ input#selectAll {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------------------------- Label --------------------------------- */
|
||||
|
||||
.labelColor {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
left: 3px;
|
||||
top: 2px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color: black;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.colorInput {
|
||||
border-radius: 4px !important;
|
||||
border: 1px solid #ccc !important;
|
||||
}
|
||||
|
||||
.labelIcon {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.labelName {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
left: 7px;
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.labelNameList {
|
||||
max-width: 79px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.labelTag {
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
padding: 2px 0px 0px 2px;
|
||||
position: relative;
|
||||
margin-right: 3px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.closeLabel {
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.listSeparator {
|
||||
height: 1px;
|
||||
background-color: #d5d3d4;
|
||||
}
|
||||
|
||||
.closeTag {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tableTag {
|
||||
padding:0px;
|
||||
margin-bottom: 0px;
|
||||
margin-right: 5px;
|
||||
float: right;
|
||||
position: relative;
|
||||
top: 3px;
|
||||
}
|
||||
|
||||
table.tableTag td {
|
||||
border-radius: 1px;
|
||||
padding-left: 4px;
|
||||
padding-right: 3px;
|
||||
padding-top :0px;
|
||||
padding-bottom: 0px;
|
||||
color: #ffffff;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.closeTag:hover {
|
||||
background-color: #ffffff !important;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* ---------------------------- Scrollbar for list filter --------------------------------- */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
direction:rtl;
|
||||
text-align: left;
|
||||
position: relative;
|
||||
left: 10px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
border-radius: 10px;
|
||||
background-color: #eaeaea;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 10px;
|
||||
background-color: #c6c6c6;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #08c;
|
||||
}
|
||||
|
||||
/* ---------------------------- Sorting --------------------------------- */
|
||||
|
||||
.sorting_asc {
|
||||
|
@ -1,3 +1,5 @@
|
||||
/*--------------------------------------------- Common actions --------------------------------------------------**/
|
||||
|
||||
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
|
||||
if (typeof sNewSource != 'undefined' && sNewSource != null) {
|
||||
oSettings.sAjaxSource = sNewSource;
|
||||
@ -39,18 +41,8 @@ $.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallbac
|
||||
};
|
||||
|
||||
jQuery.fn.dataTableExt.selectAllMaps = function () {
|
||||
var total = $('.select input:checkbox[id!="selectAll"]').size();
|
||||
var selected = $('.select input:checked[id!="selectAll"]').size();
|
||||
if (selected < total) {
|
||||
$('.select input:!checked[id!="selectAll"]').each(function () {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('.select input:!checked[id!="selectAll"]').each(function () {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
}
|
||||
var bool = $("input:checkbox[id='selectAll']").prop('checked');
|
||||
$("input:checkbox[id!='selectAll']").prop('checked', bool);
|
||||
updateStatusToolbar();
|
||||
};
|
||||
|
||||
@ -86,14 +78,14 @@ jQuery.fn.dialogForm = function (options) {
|
||||
|
||||
// Clear form values ...
|
||||
if (options.clearForm == undefined || options.clearForm) {
|
||||
$("#" + containerId).find('input').attr('value', '');
|
||||
$("#" + containerId).find('input[name!="color"]').val('');
|
||||
}
|
||||
|
||||
// Clear button "Saving..." state ...
|
||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||
acceptBtn.button('reset');
|
||||
|
||||
acceptBtn.click(function () {
|
||||
acceptBtn.unbind('click').click( function (event) {
|
||||
var formData = {};
|
||||
$('#' + containerId + ' input').each(function (index, elem) {
|
||||
formData[elem.name] = elem.value;
|
||||
@ -101,8 +93,8 @@ jQuery.fn.dialogForm = function (options) {
|
||||
|
||||
// Success actions ...
|
||||
var onSuccess = function (jqXHR, textStatus, data) {
|
||||
var resourceId = jqXHR ? jqXHR.getResponseHeader("ResourceId") : undefined;
|
||||
if (options.redirect) {
|
||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||
var redirectUrl = options.redirect;
|
||||
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
||||
|
||||
@ -111,7 +103,7 @@ jQuery.fn.dialogForm = function (options) {
|
||||
window.open(baseUrl + redirectUrl, '_self');
|
||||
|
||||
} else if (options.postUpdate) {
|
||||
options.postUpdate(formData);
|
||||
options.postUpdate(formData, resourceId);
|
||||
}
|
||||
dialogElem.modal('hide');
|
||||
};
|
||||
@ -169,7 +161,18 @@ jQuery.fn.dialogForm = function (options) {
|
||||
this.modal('hide');
|
||||
}.bind(this));
|
||||
|
||||
// Register enter input to submit...
|
||||
$("input").keypress(function(event) {
|
||||
if (event.which == 13) {
|
||||
event.preventDefault();
|
||||
acceptBtn.trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
// Open the modal dialog ...
|
||||
this.on('shown.bs.modal', function() {
|
||||
$(this).find('input:first').focus();
|
||||
});
|
||||
this.modal();
|
||||
|
||||
};
|
||||
@ -204,7 +207,6 @@ function updateStatusToolbar() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update toolbar events ...
|
||||
function updateStarred(spanElem) {
|
||||
$(spanElem).removeClass('starredOff');
|
||||
@ -258,6 +260,13 @@ function callbackOnTableInit() {
|
||||
updateStatusToolbar();
|
||||
}
|
||||
|
||||
// Register time update functions ....
|
||||
setTimeout(function () {
|
||||
jQuery("abbr.timeago").timeago()
|
||||
}, 50000);
|
||||
|
||||
/*--------------------------------------------- Button actions --------------------------------------------------**/
|
||||
|
||||
$(function () {
|
||||
// Creation buttons actions ...
|
||||
$("#newBtn").click(
|
||||
@ -266,8 +275,48 @@ $(function () {
|
||||
redirect: "c/maps/{header.resourceId}/edit",
|
||||
url: "c/restful/maps"
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$(document).on('click', '#createLabelBtn',
|
||||
function () {
|
||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||
$("#new-folder-dialog-modal").dialogForm({
|
||||
url: "c/restful/labels",
|
||||
postUpdate: function(data, id) {
|
||||
createLabelItem(data, id);
|
||||
if (mapIds.length > 0) {
|
||||
linkLabelToMindmap(mapIds, {id: id, title: data.title, color: data.color});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$("#addLabelButton").click( function () {
|
||||
var labels;
|
||||
fetchLabels({
|
||||
postUpdate: function(data) {
|
||||
labels = data.labels;
|
||||
}
|
||||
});
|
||||
|
||||
if (labels) {
|
||||
prepareLabelList(labels);
|
||||
$('.chooseLabel').one('click' ,
|
||||
function () {
|
||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||
if (mapIds.length > 0) {
|
||||
var labelId = $(this).attr('value');
|
||||
var labelName = $(this).text();
|
||||
var labelColor = $(this).attr('color');
|
||||
linkLabelToMindmap(mapIds, {id: labelId, title: labelName, color: labelColor});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$("#duplicateBtn").click(function () {
|
||||
// Map to be cloned ...
|
||||
var tableElem = $('#mindmapListTable');
|
||||
@ -388,7 +437,11 @@ $(function () {
|
||||
}
|
||||
};
|
||||
|
||||
$('#foldersContainer li').click(function (event) {
|
||||
$(document).on('click', '#foldersContainer li', function (event) {
|
||||
if (!$(this).is($('#foldersContainer .active'))) {
|
||||
$('#foldersContainer .active').animate({left: '-=8px'}, 'fast');
|
||||
}
|
||||
|
||||
// Deselect previous option ...
|
||||
$('#foldersContainer li').removeClass('active');
|
||||
$('#foldersContainer i').removeClass('glyphicon-white');
|
||||
@ -398,16 +451,188 @@ $(function () {
|
||||
$(this).addClass('active');
|
||||
$('#foldersContainer .active i').addClass('glyphicon-white');
|
||||
|
||||
$('input:checkbox').prop('checked', false);
|
||||
// Reload the table data ...
|
||||
dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$(document).on('click', "#deleteLabelBtn", function() {
|
||||
var me = $(this);
|
||||
$("#delete-label-dialog-modal").dialogForm({
|
||||
url: "c/restful/labels/" + me.attr('labelid'),
|
||||
type: 'DELETE',
|
||||
postUpdate: function() {
|
||||
var dataTable = $('#mindmapListTable').dataTable();
|
||||
//remove the selected tag...
|
||||
$("#foldersContainer li.active").remove();
|
||||
$("#foldersContainer li:first").addClass("active");
|
||||
$('#foldersContainer .active i').addClass('icon-white');
|
||||
$("#foldersContainer li:first").animate({left: '+=8px'}, 'fast');
|
||||
dataTable.fnReloadAjax("c/restful/maps/?q=all", callbackOnTableInit, true);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$(document).on('click', ".closeTag", function() {
|
||||
var me = $(this);
|
||||
var mindmapId = me.parents("td").find("a").attr("value");
|
||||
var data = {
|
||||
id: me.attr("value"),
|
||||
title: me.attr("name"),
|
||||
color: me.css('background-color')
|
||||
};
|
||||
jQuery.ajax("c/restful/labels/maps/" + mindmapId, {
|
||||
async:false,
|
||||
dataType:'json',
|
||||
data:JSON.stringify(data),
|
||||
type:'DELETE',
|
||||
contentType:"application/json; charset=utf-8",
|
||||
success: function() {
|
||||
var tag = me.closest("table");
|
||||
$(tag).fadeOut('fast', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// add labels to filter list...
|
||||
$("#foldersContainer li").fadeIn('fast');
|
||||
fetchLabels({
|
||||
postUpdate: function(data) {
|
||||
var labels = data.labels;
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
createLabelItem(labels[i], null)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//setting max heigth to ul filters...
|
||||
var maxHeight = $("#map-table").height() - 20;
|
||||
$("#foldersContainer ul").css('overflow-y', 'scrollbar');
|
||||
$("#foldersContainer ul").css('overflow-x', 'hidden');
|
||||
$("#foldersContainer ul").height(maxHeight);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
// Register time update functions ....
|
||||
setTimeout(function () {
|
||||
jQuery("abbr.timeago").timeago()
|
||||
}, 50000);
|
||||
/*--------------------------------------------- Label actions --------------------------------------------------**/
|
||||
function createLabelItem(data, id) {
|
||||
var labelId = data.id || id;
|
||||
var labelItem = $("<li data-filter=\"" + data.title + "\">");
|
||||
labelItem.append(
|
||||
"<a href=\"#\"> " +
|
||||
"<i class=\"glyphicon glyphicon-tag labelIcon\"></i>" +
|
||||
"<div class='labelColor' style='background: " + data.color + "'></div>" +
|
||||
"<div class='labelName labelNameList'>" + data.title + "</div>" +
|
||||
"<button id='deleteLabelBtn' class='close closeLabel' labelid=\""+ labelId +"\">x</button>" +
|
||||
"</a>"
|
||||
);
|
||||
labelItem.hide().appendTo($("#foldersContainer").find("ul"));
|
||||
labelItem.fadeIn('fast');
|
||||
}
|
||||
|
||||
function labelTagsAsHtml(labels) {
|
||||
var result = "";
|
||||
for (var i = 0; i<labels.length; i++) {
|
||||
var label = labels[i];
|
||||
result +=
|
||||
"<table class='tableTag'>" +
|
||||
"<tbody><tr>" +
|
||||
"<td style='cursor: default; background-color:"+ label.color +"'>" +
|
||||
"<div class='labelTag' >" +
|
||||
label.title +
|
||||
'</div>' +
|
||||
"</td>" +
|
||||
//"<td style='padding: 0; background-color: #d8d4d4'></td>" +
|
||||
"<td class='closeTag' style='background-color:" + label.color +"' name='" + label.title +"'value='" + label.id + "' >" +
|
||||
"<span style='top: -1px;position: relative;font-size: 11px' title='delete label'>x</span>"+
|
||||
"</td>" +
|
||||
"</tr></tbody>" +
|
||||
"</table>"
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function fetchLabels(options) {
|
||||
jQuery.ajax("c/restful/labels/", {
|
||||
async:false,
|
||||
dataType:'json',
|
||||
type:'GET',
|
||||
success:function (data) {
|
||||
if (options.postUpdate) {
|
||||
options.postUpdate(data)
|
||||
}
|
||||
},
|
||||
error:function (jqXHR, textStatus, errorThrown) {
|
||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function tagMindmaps(label) {
|
||||
//tag selected mindmaps...
|
||||
var rows = $('#mindmapListTable').dataTableExt.getSelectedRows();
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = $(rows[i]);
|
||||
if (row.find(".labelTag:contains('" + label.title + "')").length == 0) {
|
||||
var tag = $(labelTagsAsHtml([label]));
|
||||
tag.hide().appendTo(row.find('.mindmapName').parent());
|
||||
tag.fadeIn('fast');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function prepareLabelList(labels) {
|
||||
var labelList = $("#labelList");
|
||||
var defaultValue = labelList.find("li[id=\"createLabelBtn\"]");
|
||||
|
||||
//clear dropdown...
|
||||
labelList.find('li').remove();
|
||||
|
||||
//append items to dropdown
|
||||
$.each(labels, function(index, value) {
|
||||
labelList.append(
|
||||
$('<li class="chooseLabel"></li>').attr('value', value.id).attr('color', value.color)
|
||||
.append(
|
||||
'<a href="#" onclick="return false">' +
|
||||
"<div class='labelColor' style='background: " + value.color + "'></div>" +
|
||||
"<div class='labelName'>" + value.title + "</div>" +
|
||||
'</a>')
|
||||
);
|
||||
});
|
||||
|
||||
//add the defaultValue
|
||||
labelList.append('<li><div class="listSeparator"></div></li>')
|
||||
labelList.append(defaultValue);
|
||||
}
|
||||
|
||||
function linkLabelToMindmap(mapIds, label) {
|
||||
var onSuccess = function () {
|
||||
tagMindmaps(label);
|
||||
};
|
||||
jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
|
||||
type: 'POST',
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify({
|
||||
id: label.id,
|
||||
title: label.title,
|
||||
color: label.color
|
||||
}),
|
||||
statusCode: {
|
||||
200: onSuccess
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//animations...
|
||||
$(document).on('click', '#foldersContainer li[class!="nav-header"]', function (event) {
|
||||
if ($(this).attr('class') != 'active') {
|
||||
$(this).animate({left: '+=8px'}, 'fast');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
<script type="text/javascript" language="javascript" src="js/jquery-2.1.0.min.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap-colorpicker.js"></script>
|
||||
|
||||
<script src="js/less.js" type="text/javascript"></script>
|
||||
|
||||
<!--jQuery DataTables-->
|
||||
@ -52,11 +54,11 @@
|
||||
},
|
||||
{
|
||||
sTitle: "<spring:message code="NAME"/>",
|
||||
sWidth: "270px",
|
||||
sWidth:"430px",
|
||||
bUseRendered: false,
|
||||
mDataProp: "title",
|
||||
fnRender: function (obj) {
|
||||
return '<a href="c/maps/' + obj.aData.id + '/edit">' + $('<span></span>').text(obj.aData.title).html() + '</a>';
|
||||
return '<a class="mindmapName" value="'+ obj.aData.id +'" href="c/maps/' + obj.aData.id + '/edit">' + $('<span></span>').text(obj.aData.title).html() + '</a>' + labelTagsAsHtml(obj.aData.labels);
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -88,10 +90,13 @@
|
||||
bStateSave: true
|
||||
});
|
||||
|
||||
$('#colorGroup').colorpicker();
|
||||
|
||||
// Customize search action ...
|
||||
$('#mindmapListTable_filter').appendTo("#tableActions");
|
||||
$('#mindmapListTable_filter input').addClass('input-small search-query form-control');
|
||||
$('#mindmapListTable_filter input').attr('placeholder', 'Search');
|
||||
var input = $('#mindmapListTable_filter input');
|
||||
input.addClass('input-small search-query form-control');
|
||||
input.attr('placeholder', 'Search');
|
||||
$("#mindmapListTable_info").appendTo("#pageInfo");
|
||||
|
||||
// Re-arrange pagination actions ...
|
||||
@ -100,9 +105,11 @@
|
||||
$('#mindmapListTable_length select').attr("style", "width:60px;");
|
||||
|
||||
|
||||
$('input:checkbox[id="selectAll"]').click(function () {
|
||||
$("#mindmapListTable").dataTableExt.selectAllMaps();
|
||||
});
|
||||
$('input:checkbox[id="selectAll"]').click(
|
||||
function () {
|
||||
$("#mindmapListTable").dataTableExt.selectAllMaps();
|
||||
}
|
||||
);
|
||||
|
||||
// Hack for changing the pagination buttons ...
|
||||
$('#nPageBtn').click(function () {
|
||||
@ -115,400 +122,491 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<jsp:include page="header.jsp">
|
||||
<jsp:param name="removeSignin" value="false"/>
|
||||
<jsp:param name="showLogout" value="true"/>
|
||||
</jsp:include>
|
||||
<jsp:include page="header.jsp">
|
||||
<jsp:param name="removeSignin" value="false"/>
|
||||
<jsp:param name="showLogout" value="true"/>
|
||||
</jsp:include>
|
||||
|
||||
<div class="container">
|
||||
<div class="row hide" id="messagesPanel" style="margin-top: 20px">
|
||||
<div class="alert alert-danger alert-block fade in col-md-8 col-md-offset-2">
|
||||
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
|
||||
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2" id="foldersContainer">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li data-filter="all" class="active"><a href="#"><i
|
||||
class="glyphicon glyphicon-inbox glyphicon-white"></i>
|
||||
<spring:message
|
||||
code="ALL_MAPS"/></a></li>
|
||||
<li data-filter="my_maps"><a href="#"><i class="glyphicon glyphicon-user"></i> <spring:message
|
||||
code="MY_MAPS"/></a>
|
||||
</li>
|
||||
<li data-filter="shared_with_me"><a href="#"><i class="glyphicon glyphicon-share"></i> <spring:message
|
||||
code="SHARED_WITH_ME"/></a></li>
|
||||
<li data-filter="starred"><a href="#"><i class="glyphicon glyphicon-star"></i> <spring:message
|
||||
code="STARRED"/></a></li>
|
||||
<li data-filter="public"><a href="#"><i class="glyphicon glyphicon-globe"></i> <spring:message
|
||||
code="PUBLIC_MAPS"/></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="container">
|
||||
<div class="row hide" id="messagesPanel" style="margin-top: 20px">
|
||||
<div class="alert alert-danger alert-block fade in col-md-8 col-md-offset-2">
|
||||
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
|
||||
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="buttonsToolbar btn-toolbar ${requestScope['google.ads.enabled']?'col-md-9':'col-md-10'}">
|
||||
<div id="tableActions">
|
||||
<div id="pageInfo"></div>
|
||||
<div class="btn-group" id="pageButtons">
|
||||
<button class="btn" id="pPageBtn"><strong><</strong></button>
|
||||
<button class="btn" id="nPageBtn"><strong>></strong></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button id="newBtn" class="btn btn-primary"><i class="glyphicon glyphicon-file glyphicon-white"></i>
|
||||
<spring:message
|
||||
code="NEW"/></button>
|
||||
<button id="importBtn" class="btn btn-primary"><i
|
||||
class="glyphicon glyphicon-upload glyphicon-white"></i>
|
||||
<spring:message code="IMPORT"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group act-multiple" id="deleteBtn" style="display:none">
|
||||
<button class="btn btn-primary"><i class="glyphicon glyphicon-trash glyphicon-white"></i>
|
||||
<spring:message
|
||||
code="DELETE"/></button>
|
||||
</div>
|
||||
|
||||
<div id="infoBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-primary"><i class="glyphicon glyphicon-exclamation-sign glyphicon-white"></i>
|
||||
<spring:message
|
||||
code="INFO"/></button>
|
||||
</div>
|
||||
|
||||
<div id="actionsBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="glyphicon glyphicon-asterisk glyphicon-white"></i> <spring:message code="MORE"/>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li id="duplicateBtn"><a href="#" onclick="return false"><i
|
||||
class="glyphicon glyphicon-plus-sign"></i>
|
||||
<spring:message code="DUPLICATE"/></a></li>
|
||||
<li id="renameBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-edit"></i>
|
||||
<spring:message
|
||||
code="RENAME"/></a></li>
|
||||
<li id="publishBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-globe"></i>
|
||||
<spring:message code="PUBLISH"/></a>
|
||||
<div class="row">
|
||||
<div class="col-md-2" id="foldersContainer">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li data-filter="all" class="active" style="display: none">
|
||||
<a href="#"><i class="glyphicon glyphicon-inbox glyphicon-white"></i>
|
||||
<spring:message code="ALL_MAPS"/>
|
||||
</a></li>
|
||||
<li data-filter="my_maps" style="display: none">
|
||||
<a href="#"><i class="glyphicon glyphicon-user"></i>
|
||||
<spring:message code="MY_MAPS"/>
|
||||
</a>
|
||||
</li>
|
||||
<li id="shareBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-share"></i>
|
||||
<spring:message
|
||||
code="SHARE"/></a></li>
|
||||
<li id="exportBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-download"></i>
|
||||
<spring:message
|
||||
code="EXPORT"/></a>
|
||||
<li data-filter="shared_with_me" style="display: none">
|
||||
<a href="#"><i class="glyphicon glyphicon-share"></i>
|
||||
<spring:message code="SHARED_WITH_ME"/>
|
||||
</a>
|
||||
</li>
|
||||
<li id="printBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-print"></i>
|
||||
<spring:message
|
||||
code="PRINT"/></a></li>
|
||||
<li id="historyBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-time"></i>
|
||||
<spring:message
|
||||
code="HISTORY"/></a>
|
||||
<li data-filter="starred" style="display: none">
|
||||
<a href="#"><i class="glyphicon glyphicon-star"></i>
|
||||
<spring:message code="STARRED"/>
|
||||
</a>
|
||||
</li>
|
||||
<li data-filter="public" style="display: none">
|
||||
<a href="#"><i class="glyphicon glyphicon-globe"></i>
|
||||
<spring:message code="PUBLIC_MAPS"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="map-table">
|
||||
<table class="table table-hover" id="mindmapListTable"></table>
|
||||
</div>
|
||||
<div id="tableFooter" class="form-inline"></div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-1" style="padding-top:25px">
|
||||
<c:if test="${requestScope['google.ads.enabled']}">
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = "ca-pub-7564778578019285";
|
||||
/* WiseMapping Mindmap List */
|
||||
google_ad_slot = "4071968444";
|
||||
google_ad_width = 120;
|
||||
google_ad_height = 600;
|
||||
//-->
|
||||
</script>
|
||||
<div style="margin-top:5px;">
|
||||
<script type="text/javascript"
|
||||
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
<div class="buttonsToolbar btn-toolbar ${requestScope['google.ads.enabled']?'col-md-9':'col-md-10'}">
|
||||
<div id="tableActions">
|
||||
<div id="pageInfo"></div>
|
||||
<div class="btn-group" id="pageButtons">
|
||||
<button class="btn" id="pPageBtn"><strong><</strong></button>
|
||||
<button class="btn" id="nPageBtn"><strong>></strong></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button id="newBtn" class="btn btn-primary">
|
||||
<i class="glyphicon glyphicon-file glyphicon-white"></i>
|
||||
<spring:message code="NEW"/>
|
||||
</button>
|
||||
<button id="importBtn" class="btn btn-primary">
|
||||
<i class="glyphicon glyphicon-upload glyphicon-white"></i>
|
||||
<spring:message code="IMPORT"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button id='addLabelButton' class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="glyphicon glyphicon-tag glyphicon-white"></i>
|
||||
<spring:message code="LABEL"/>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul id="labelList" class="dropdown-menu">
|
||||
<li id="createLabelBtn">
|
||||
<a href="#" onclick="return false">
|
||||
<i class="glyphicon glyphicon-plus"></i>
|
||||
<spring:message code="CREATE"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="btn-group act-multiple" id="deleteBtn" style="display:none">
|
||||
<button class="btn btn-primary">
|
||||
<i class="glyphicon glyphicon-trash glyphicon-white"></i>
|
||||
<spring:message code="DELETE"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="infoBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-primary"><i class="glyphicon glyphicon-exclamation-sign glyphicon-white"></i>
|
||||
<spring:message code="INFO"/></button>
|
||||
</div>
|
||||
|
||||
<div id="actionsBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="glyphicon glyphicon-asterisk glyphicon-white"></i> <spring:message code="MORE"/>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li id="duplicateBtn"><a href="#" onclick="return false"><i
|
||||
class="glyphicon glyphicon-plus-sign"></i>
|
||||
<spring:message code="DUPLICATE"/></a></li>
|
||||
<li id="renameBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-edit"></i>
|
||||
<spring:message
|
||||
code="RENAME"/></a></li>
|
||||
<li id="publishBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-globe"></i>
|
||||
<spring:message code="PUBLISH"/></a>
|
||||
</li>
|
||||
<li id="shareBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-share"></i>
|
||||
<spring:message
|
||||
code="SHARE"/></a></li>
|
||||
<li id="exportBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-download"></i>
|
||||
<spring:message
|
||||
code="EXPORT"/></a>
|
||||
</li>
|
||||
<li id="printBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-print"></i>
|
||||
<spring:message
|
||||
code="PRINT"/></a></li>
|
||||
<li id="historyBtn"><a href="#" onclick="return false"><i class="glyphicon glyphicon-time"></i>
|
||||
<spring:message
|
||||
code="HISTORY"/></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="map-table">
|
||||
<table class="table table-hover" id="mindmapListTable"></table>
|
||||
</div>
|
||||
<div id="tableFooter" class="form-inline"></div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-1" style="padding-top:25px">
|
||||
<c:if test="${requestScope['google.ads.enabled']}">
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = "ca-pub-7564778578019285";
|
||||
/* WiseMapping Mindmap List */
|
||||
google_ad_slot = "4071968444";
|
||||
google_ad_width = 120;
|
||||
google_ad_height = 600;
|
||||
//-->
|
||||
</script>
|
||||
</div>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
<jsp:include page="footer.jsp"/>
|
||||
</div>
|
||||
|
||||
<div id="dialogsContainer">
|
||||
<!-- New map dialog -->
|
||||
<div id="new-dialog-modal" title="<spring:message code="ADD_NEW_MAP"/>" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="NEW_MAP_MSG"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="newTitle"><spring:message code="NAME"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" name="title" id="newTitle" type="text" required="required"
|
||||
placeholder="<spring:message code="MAP_NAME_HINT"/>" autofocus="autofocus"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="newDec"><spring:message
|
||||
code="DESCRIPTION"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" name="description" id="newDec" type="text"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/>"><spring:message
|
||||
code="CREATE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
<div style="margin-top:5px;">
|
||||
<script type="text/javascript"
|
||||
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
</script>
|
||||
</div>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
<jsp:include page="footer.jsp"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Duplicate map dialog -->
|
||||
<div id="duplicate-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div id="dialogsContainer">
|
||||
<!-- New map dialog -->
|
||||
<div id="new-dialog-modal" title="<spring:message code="ADD_NEW_MAP"/>" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3 id="dupDialogTitle"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-md-3 control-label"><spring:message code="NAME"/>: </label>
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="NEW_MAP_MSG"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="newTitle"><spring:message code="NAME"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="title" id="title" type="text" required="required"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" autofocus="autofocus"
|
||||
class="form-control" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description" class="col-md-3 control-label"><spring:message
|
||||
code="DESCRIPTION"/>: </label>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" name="title" id="newTitle" type="text" required="required"
|
||||
placeholder="<spring:message code="MAP_NAME_HINT"/>" autofocus="autofocus"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="newDec"><spring:message
|
||||
code="DESCRIPTION"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="description" id="description" type="text"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" class="form-control"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message code="DUPLICATE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rename map dialog -->
|
||||
<div id="rename-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3 id="renameDialogTitle"><spring:message code="RENAME"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="renTitle" class="col-md-3 control-label"><spring:message code="NAME"/>: </label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="title" id="renTitle" required="required" autofocus="autofocus"
|
||||
class="form-control" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="renDescription" class="col-md-3 control-label"><spring:message
|
||||
code="DESCRIPTION"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="description" class="form-control" id="renDescription" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message
|
||||
code="RENAME"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete map dialog -->
|
||||
<div id="delete-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="DELETE_MINDMAP"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-block">
|
||||
<h4 class="alert-heading"><spring:message code="WARNING"/>!</h4><spring:message
|
||||
code="DELETE_MAPS_WARNING"/>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" name="description" id="newDec" type="text"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/>"><spring:message
|
||||
code="CREATE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/> ..."><spring:message
|
||||
code="DELETE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
|
||||
<!-- New label dialog -->
|
||||
<div id="new-folder-dialog-modal" title="<spring:message code="ADD_NEW_LABEL"/>" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="NEW_LABEL_MSG"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="newLabelTitle"><spring:message code="NAME"/>:</label>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" name="title" id="newLabelTitle" type="text" required="required"
|
||||
placeholder="<spring:message code="LABEL_NAME_HINT"/>" autofocus="autofocus" maxlength="30"/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="colorGroup" class="form-group">
|
||||
<label class="col-md-3 control-label" for="colorChooser"><spring:message code="COLOR"/>:</label>
|
||||
<div class="col-md-1">
|
||||
<input class="form-control" name="color" id="colorChooser" style="display: none" type="text" required="required" value="#000000"/>
|
||||
<span class="input-group-addon colorInput"><i></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/>"><spring:message
|
||||
code="CREATE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info map dialog -->
|
||||
<div id="info-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="INFO"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Duplicate map dialog -->
|
||||
<div id="duplicate-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CLOSE"/></button>
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3 id="dupDialogTitle"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-md-3 control-label"><spring:message code="NAME"/>: </label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="title" id="title" type="text" required="required"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" autofocus="autofocus"
|
||||
class="form-control" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description" class="col-md-3 control-label"><spring:message
|
||||
code="DESCRIPTION"/>: </label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="description" id="description" type="text"
|
||||
placeholder="<spring:message code="MAP_DESCRIPTION_HINT"/>" class="form-control"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message code="DUPLICATE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Publish Dialog Config -->
|
||||
<div id="publish-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="PUBLISH"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Rename map dialog -->
|
||||
<div id="rename-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3 id="renameDialogTitle"><spring:message code="RENAME"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="errorMessage"></div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="renTitle" class="col-md-3 control-label"><spring:message code="NAME"/>: </label>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>...">
|
||||
<spring:message code="ACCEPT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
<div class="col-md-8">
|
||||
<input name="title" id="renTitle" required="required" autofocus="autofocus"
|
||||
class="form-control" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="renDescription" class="col-md-3 control-label"><spring:message
|
||||
code="DESCRIPTION"/>:</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input name="description" class="form-control" id="renDescription" maxlength="255"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message
|
||||
code="RENAME"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Export Dialog Config -->
|
||||
<div id="export-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="EXPORT"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Exporting..."><spring:message
|
||||
code="EXPORT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
<!-- Delete map dialog -->
|
||||
<div id="delete-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="DELETE_MINDMAP"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-block alert-warning">
|
||||
<h4 class="alert-heading"><spring:message code="WARNING"/>!</h4><spring:message
|
||||
code="DELETE_MAPS_WARNING"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/> ..."><spring:message
|
||||
code="DELETE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import Dialog Config -->
|
||||
<div id="import-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="IMPORT"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="IMPORTING"/>"><spring:message
|
||||
code="IMPORT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
<!-- Delete label dialog -->
|
||||
<div id="delete-label-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="DELETE"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-block alert-warning">
|
||||
<h4 class="alert-heading"><spring:message code="WARNING"/>!</h4><spring:message code="DELETE_LABELS_WARNING"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="SAVING"/> ..."><spring:message
|
||||
code="DELETE"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Share Dialog Config -->
|
||||
<div id="share-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="SHARE"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Info map dialog -->
|
||||
<div id="info-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="INFO"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message code="ACCEPT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CLOSE"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- History Dialog Config -->
|
||||
<div id="history-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="HISTORY"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Publish Dialog Config -->
|
||||
<div id="publish-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="PUBLISH"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CLOSE"/></button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>...">
|
||||
<spring:message code="ACCEPT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Export Dialog Config -->
|
||||
<div id="export-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="EXPORT"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Exporting..."><spring:message
|
||||
code="EXPORT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import Dialog Config -->
|
||||
<div id="import-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="IMPORT"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message
|
||||
code="IMPORTING"/>"><spring:message
|
||||
code="IMPORT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Share Dialog Config -->
|
||||
<div id="share-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="SHARE"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="<spring:message code="SAVING"/>">
|
||||
<spring:message code="ACCEPT"/></button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CANCEL"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- History Dialog Config -->
|
||||
<div id="history-dialog-modal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3><spring:message code="HISTORY"/></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-cancel" data-dismiss="modal"><spring:message code="CLOSE"/></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -20,38 +20,29 @@ package com.wisemapping.test.rest;
|
||||
|
||||
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.ADMIN_CREDENTIALS;
|
||||
import static com.wisemapping.test.rest.RestHelper.BASE_REST_URL;
|
||||
import static com.wisemapping.test.rest.RestHelper.HOST_PORT;
|
||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||
import static com.wisemapping.test.rest.RestHelper.createTemplate;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
||||
@Test
|
||||
public class RestAccountITCase {
|
||||
|
||||
@NonNls
|
||||
private static final String HOST_PORT = "http://localhost:8080";
|
||||
private static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||
private static final String ADMIN_CREDENTIALS = "admin@wisemapping.org" + ":" + "admin";
|
||||
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void deleteUser(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate adminTemplate = createTemplate(ADMIN_CREDENTIALS);
|
||||
@ -115,30 +106,6 @@ public class RestAccountITCase {
|
||||
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
||||
}
|
||||
|
||||
private HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||
acceptableMediaTypes.add(mediaType);
|
||||
|
||||
final HttpHeaders result = new HttpHeaders();
|
||||
result.setAccept(acceptableMediaTypes);
|
||||
result.setContentType(mediaType);
|
||||
return result;
|
||||
}
|
||||
|
||||
private RestTemplate createTemplate(@NotNull final String authorisation) {
|
||||
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
||||
@Override
|
||||
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
||||
super.prepareConnection(connection, httpMethod);
|
||||
|
||||
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
||||
}
|
||||
|
||||
};
|
||||
return new RestTemplate(s);
|
||||
}
|
||||
|
||||
private RestUser createDummyUser() {
|
||||
final RestUser restUser = new RestUser();
|
||||
final String username = "foo-to-delete" + System.nanoTime();
|
||||
@ -150,9 +117,4 @@ public class RestAccountITCase {
|
||||
return restUser;
|
||||
}
|
||||
|
||||
|
||||
@DataProvider(name = "ContentType-Provider-Function")
|
||||
public Object[][] contentTypes() {
|
||||
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
|
||||
}
|
||||
}
|
||||
|
@ -20,37 +20,34 @@ package com.wisemapping.test.rest;
|
||||
|
||||
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.BASE_REST_URL;
|
||||
import static com.wisemapping.test.rest.RestHelper.HOST_PORT;
|
||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||
import static com.wisemapping.test.rest.RestHelper.createTemplate;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Test
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public class RestAdminITCase {
|
||||
|
||||
@NonNls
|
||||
private static final String HOST_PORT = "http://localhost:8080";
|
||||
private static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||
String authorisation = "admin@wisemapping.org" + ":" + "admin";
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void changePassword(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate templateRest = createTemplate();
|
||||
final RestTemplate templateRest = createTemplate(authorisation);
|
||||
|
||||
// Fill user data ...
|
||||
final RestUser restUser = createDummyUser();
|
||||
@ -68,10 +65,10 @@ public class RestAdminITCase {
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void deleteUser(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate templateRest = createTemplate();
|
||||
final RestTemplate templateRest = createTemplate(authorisation);
|
||||
|
||||
final RestUser restUser = createDummyUser();
|
||||
|
||||
@ -97,7 +94,7 @@ public class RestAdminITCase {
|
||||
|
||||
// Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate templateRest = createTemplate();
|
||||
final RestTemplate templateRest = createTemplate(authorisation);
|
||||
|
||||
// Fill user data ...
|
||||
final RestUser restUser = createDummyUser();
|
||||
@ -116,7 +113,7 @@ public class RestAdminITCase {
|
||||
return restUser.getEmail();
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void createUser(final @NotNull MediaType mediaType) {
|
||||
this.createNewUser(mediaType);
|
||||
}
|
||||
@ -140,32 +137,6 @@ public class RestAdminITCase {
|
||||
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
||||
}
|
||||
|
||||
private HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||
acceptableMediaTypes.add(mediaType);
|
||||
|
||||
final HttpHeaders result = new HttpHeaders();
|
||||
result.setAccept(acceptableMediaTypes);
|
||||
result.setContentType(mediaType);
|
||||
return result;
|
||||
}
|
||||
|
||||
private RestTemplate createTemplate() {
|
||||
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
||||
@Override
|
||||
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
||||
super.prepareConnection(connection, httpMethod);
|
||||
|
||||
//Basic Authentication for Police API
|
||||
String authorisation = "admin@wisemapping.org" + ":" + "admin";
|
||||
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
||||
}
|
||||
|
||||
};
|
||||
return new RestTemplate(s);
|
||||
}
|
||||
|
||||
private RestUser createDummyUser() {
|
||||
final RestUser restUser = new RestUser();
|
||||
final String username = "foo-to-delete" + System.nanoTime();
|
||||
@ -177,9 +148,4 @@ public class RestAdminITCase {
|
||||
return restUser;
|
||||
}
|
||||
|
||||
|
||||
@DataProvider(name = "ContentType-Provider-Function")
|
||||
public Object[][] contentTypes() {
|
||||
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.wisemapping.test.rest;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RestHelper {
|
||||
|
||||
public static final String HOST_PORT = "http://localhost:8080";
|
||||
public static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||
public static final String ADMIN_CREDENTIALS = "admin@wisemapping.org" + ":" + "admin";
|
||||
public static final String COLOR = "#000000";
|
||||
|
||||
static HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||
acceptableMediaTypes.add(mediaType);
|
||||
|
||||
final HttpHeaders result = new HttpHeaders();
|
||||
result.setAccept(acceptableMediaTypes);
|
||||
result.setContentType(mediaType);
|
||||
return result;
|
||||
}
|
||||
|
||||
static RestTemplate createTemplate(@NotNull final String authorisation) {
|
||||
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
||||
@Override
|
||||
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
||||
super.prepareConnection(connection, httpMethod);
|
||||
|
||||
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
||||
}
|
||||
|
||||
};
|
||||
return new RestTemplate(s);
|
||||
}
|
||||
|
||||
@DataProvider(name = "ContentType-Provider-Function")
|
||||
static Object[][] contentTypes() {
|
||||
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.wisemapping.test.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.BASE_REST_URL;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.AssertJUnit.fail;
|
||||
|
||||
@Test
|
||||
public class RestLabelITCase {
|
||||
|
||||
private String userEmail;
|
||||
private static final String COLOR = "#000000";
|
||||
|
||||
@BeforeClass
|
||||
void createUser() {
|
||||
|
||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||
userEmail = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void createLabel(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = RestHelper.createHeaders(mediaType);
|
||||
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
||||
|
||||
// Create a new label
|
||||
final String title1 = "Label 1 - " + mediaType.toString();
|
||||
addNewLabel(requestHeaders, template, title1, COLOR);
|
||||
|
||||
// Create a new label
|
||||
final String title2 = "Label 2 - " + mediaType.toString();
|
||||
addNewLabel(requestHeaders, template, title2, COLOR);
|
||||
|
||||
// Check that the label has been created ...
|
||||
final RestLabelList restLabelList = getLabels(requestHeaders, template);
|
||||
|
||||
// Validate that the two labels are there ...
|
||||
final List<RestLabel> labels = restLabelList.getLabels();
|
||||
|
||||
boolean found1 = false;
|
||||
boolean found2 = false;
|
||||
for (RestLabel label : labels) {
|
||||
if (title1.equals(label.getTitle())) {
|
||||
found1 = true;
|
||||
}
|
||||
if (title2.equals(label.getTitle())) {
|
||||
found2 = true;
|
||||
}
|
||||
}
|
||||
assertTrue(found1 && found2, "Labels could not be found");
|
||||
|
||||
}
|
||||
|
||||
static RestLabelList getLabels(HttpHeaders requestHeaders, RestTemplate template) {
|
||||
final HttpEntity findLabelEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestLabelList> response = template.exchange(BASE_REST_URL + "/labels", HttpMethod.GET, findLabelEntity, RestLabelList.class);
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void createLabelWithoutRequiredField(final @NotNull MediaType mediaType) throws IOException, WiseMappingException {
|
||||
final HttpHeaders requestHeaders = RestHelper.createHeaders(mediaType);
|
||||
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
||||
|
||||
try {
|
||||
addNewLabel(requestHeaders, template, null, COLOR);
|
||||
fail("Wrong response");
|
||||
} catch (HttpClientErrorException e) {
|
||||
final String responseBodyAsString = e.getResponseBodyAsString();
|
||||
assertTrue (responseBodyAsString.contains("Required field cannot be left blank"));
|
||||
}
|
||||
|
||||
try {
|
||||
addNewLabel(requestHeaders, template, "title12345", null);
|
||||
fail("Wrong response");
|
||||
} catch (HttpClientErrorException e) {
|
||||
final String responseBodyAsString = e.getResponseBodyAsString();
|
||||
assert (responseBodyAsString.contains("Required field cannot be left blank"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void deleteLabel(final @NotNull MediaType mediaType) throws IOException, WiseMappingException {
|
||||
final HttpHeaders requestHeaders = RestHelper.createHeaders(mediaType);
|
||||
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
||||
|
||||
final String title = "title to delete";
|
||||
final URI resourceUri = addNewLabel(requestHeaders, template, title, COLOR);
|
||||
|
||||
// Now remove it ...
|
||||
template.delete(RestHelper.HOST_PORT + resourceUri.toString());
|
||||
final RestLabelList restLabelList = getLabels(requestHeaders, template);
|
||||
|
||||
for (RestLabel restLabel : restLabelList.getLabels()) {
|
||||
if (title.equals(restLabel.getTitle())) {
|
||||
Assert.fail("Label could not be removed:" + resourceUri);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static URI addNewLabel(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate template, @Nullable String title, @Nullable String color ) throws IOException, WiseMappingException {
|
||||
final RestLabel restLabel = new RestLabel();
|
||||
if (title != null) {
|
||||
restLabel.setTitle(title);
|
||||
}
|
||||
if (color != null) {
|
||||
restLabel.setColor(color);
|
||||
}
|
||||
|
||||
// Create a new label ...
|
||||
HttpEntity<RestLabel> createUserEntity = new HttpEntity<RestLabel>(restLabel, requestHeaders);
|
||||
return template.postForLocation(BASE_REST_URL + "/labels", createUserEntity);
|
||||
}
|
||||
}
|
@ -2,6 +2,10 @@ package com.wisemapping.test.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
@ -13,21 +17,21 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.BASE_REST_URL;
|
||||
import static com.wisemapping.test.rest.RestHelper.COLOR;
|
||||
import static com.wisemapping.test.rest.RestHelper.HOST_PORT;
|
||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||
import static com.wisemapping.test.rest.RestHelper.createTemplate;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
@ -36,20 +40,19 @@ import static org.testng.Assert.fail;
|
||||
public class RestMindmapITCase {
|
||||
|
||||
private String userEmail = "admin@wisemapping.com";
|
||||
private static final String HOST_PORT = "http://localhost:8080";
|
||||
private static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||
|
||||
@BeforeClass
|
||||
void createUser() {
|
||||
|
||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||
userEmail = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||
userEmail += ":" + "admin";
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void listMaps(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title1 = "List Maps 1 - " + mediaType.toString();
|
||||
@ -79,10 +82,10 @@ public class RestMindmapITCase {
|
||||
assertTrue(found1 && found2, "Map could not be found");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void deleteMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title1 = "Map to delete - " + mediaType.toString();
|
||||
@ -99,10 +102,10 @@ public class RestMindmapITCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void changeMapTitle(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(requestHeaders, template, "Map to change title - " + mediaType.toString());
|
||||
@ -118,10 +121,10 @@ public class RestMindmapITCase {
|
||||
assertEquals(newTitle, map.getTitle());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void validateMapsCreation(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title = "Map to Validate Creation - " + mediaType.toString();
|
||||
@ -145,10 +148,10 @@ public class RestMindmapITCase {
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void changeMapDescription(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(requestHeaders, template, "Map to change Description - " + mediaType.toString());
|
||||
@ -164,10 +167,10 @@ public class RestMindmapITCase {
|
||||
assertEquals(newDescription, map.getDescription());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void updateMapXml(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title = "Update XML sample " + mediaType.toString();
|
||||
@ -185,10 +188,10 @@ public class RestMindmapITCase {
|
||||
assertEquals(response.getXml(), newXmlContent);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void cloneMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title = "Map to clone sample " + mediaType.toString();
|
||||
@ -210,14 +213,14 @@ public class RestMindmapITCase {
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "ContentType-Provider-Function")
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void updateMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
if(MediaType.APPLICATION_XML==mediaType){
|
||||
throw new SkipException("Some research need to check why it;s falling.");
|
||||
}
|
||||
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate();
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title = "Update sample " + mediaType.toString();
|
||||
@ -241,6 +244,35 @@ public class RestMindmapITCase {
|
||||
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void addLabelToMindmap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a new label
|
||||
final String titleLabel = "Label 1 - " + mediaType.toString();
|
||||
final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
||||
|
||||
// Create a sample map ...
|
||||
final String mapTitle = "Maps 1 - " + mediaType.toString();
|
||||
final URI mindmapUri = addNewMap(requestHeaders, template, mapTitle);
|
||||
final String mapId = mindmapUri.getPath().replace("/service/maps/", "");
|
||||
|
||||
final RestLabel restLabel = new RestLabel();
|
||||
restLabel.setColor(COLOR);
|
||||
String labelId = labelUri.getPath().replace("/service/labels/", "");
|
||||
restLabel.setId(Integer.parseInt(labelId));
|
||||
restLabel.setTitle(titleLabel);
|
||||
|
||||
HttpEntity<RestLabel> labelEntity = new HttpEntity<>(restLabel, requestHeaders);
|
||||
template.postForLocation(BASE_REST_URL + "/labels/maps?ids=" + mapId, labelEntity);
|
||||
|
||||
// Load map again ..
|
||||
final RestMindmap withLabel = findMap(requestHeaders, template, mindmapUri);
|
||||
|
||||
// assertTrue(withLabel.getDelegated().getLabels().size() == 1);
|
||||
}
|
||||
|
||||
private RestMindmap findMap(HttpHeaders requestHeaders, RestTemplate template, URI resourceUri) {
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||
@ -265,32 +297,4 @@ public class RestMindmapITCase {
|
||||
return addNewMap(requestHeaders, template, title, null);
|
||||
}
|
||||
|
||||
private HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||
acceptableMediaTypes.add(mediaType);
|
||||
final HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.setAccept(acceptableMediaTypes);
|
||||
requestHeaders.setContentType(mediaType);
|
||||
return requestHeaders;
|
||||
}
|
||||
|
||||
private RestTemplate createTemplate() {
|
||||
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
||||
@Override
|
||||
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
||||
super.prepareConnection(connection, httpMethod);
|
||||
|
||||
//Basic Authentication for Police API
|
||||
String authorization = userEmail + ":" + "admin";
|
||||
byte[] encodedAuthorisation = Base64.encode(authorization.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
||||
}
|
||||
};
|
||||
return new RestTemplate(s);
|
||||
}
|
||||
|
||||
@DataProvider(name = "ContentType-Provider-Function")
|
||||
public Object[][] contentTypes() {
|
||||
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user