Skip to content

Commit

Permalink
Merge d81f1d7 into 8992412
Browse files Browse the repository at this point in the history
  • Loading branch information
souless94 committed Oct 31, 2018
2 parents 8992412 + d81f1d7 commit e95c1e6
Show file tree
Hide file tree
Showing 30 changed files with 209 additions and 329 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dependencies {
implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
implementation group: 'javax.activation', name: 'activation', version: '1.1.1'
implementation group: 'com.opencsv', name: 'opencsv' ,version: '4.3.2'
implementation group: 'org.jsoup', name: 'jsoup' ,version: '1.11.3'

testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.testfx', name: 'testfx-core', version: testFxVersion, {
Expand All @@ -83,7 +84,7 @@ dependencies {
}

shadowJar {
archiveName = 'addressbook.jar'
archiveName = 'nus Hangs.jar'

destinationDir = file("${buildDir}/jar/")
}
Expand Down Expand Up @@ -238,7 +239,7 @@ task deployOfflineDocs(type: Copy) {
}

task copyTimetablePage(type: Copy) {
from 'docs/Timetable.html'
from 'src/main/resources/view/Timetable.html'
into "${buildDir}/docs/html5"
}

Expand Down
47 changes: 24 additions & 23 deletions docs/Timetable.html → docs/onlineTimetable.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<html>
<head>
<meta charset="utf-8">
<title>Timetable</title>
<title>Dummy Search Page</title>
</head>
<body>
<input type="hidden" id="timetable" value="">

<p id="check"></p>
<script type="text/javascript">
function getJsonFromUrl() {
var query = location.search.substr(1);
var result = {};
query.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = decodeURIComponent(item[1]);
});
return result;
}
var matrixAsString =getJsonFromUrl().name;
var matrixAsString =document.getElementById("timetable").value;
if (matrixAsString == ""){
document.getElementById("check").innerHTML= "there seems to be an issue";
var m = null;
} else{
var matrixArray = matrixAsString.split(",");
var rows = 8;
var columns = 17;
Expand Down Expand Up @@ -51,29 +51,30 @@
counter+=1;
}
}
}
</script>
</head>
<body>
<table id="myTable" border=1>
</table>
<script>
//@@author souless94 -resued
// used code from 1BestCsharp blog in http://1bestcsharp.blogspot.com/2017/03/javascript-populate-html-table-from-array.html

table = document.getElementById("myTable");
for(var i = 0; i < m.length; i++)
{
if (m != null){
table = document.getElementById("myTable");
for(var i = 0; i < m.length; i++)
{
// create a new row
var newRow = table.insertRow(table.length);
for(var j = 0; j < m[i].length; j++)
{
var newRow = table.insertRow(table.length);
for(var j = 0; j < m[i].length; j++)
{
// create a new cell
var cell = newRow.insertCell(j);
var cell = newRow.insertCell(j);

// add value to the cell
// add value to the cell
cell.innerHTML = m[i][j];
}
}
}
}
}
//@@ author

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ public class AddTimetableCommand extends Command {
public static final String MESSAGE_ADD_TIMETABLE_SUCCESS = "timetable added successfully: %1$s";
public static final String MESSAGE_INVALID_TIMETABLE_SIZE =
"timetable to be added is wrong: \n"
+ "if format is horizontal,timetable should have in total rows: 8 , columns : 17 \n"
+ "if format is vertical,timetable should have in total rows: 17 , columns : 8 \n";

+ "timetable should have in total rows: 8 , columns : 17 \n";
private static final String timings = "correctTimings : \n"
+ "0800,0900,1000,1100 \n"
+ "1200,1300,1400,1500,1600 \n"
+ "1700,1800,1900,2000,2100,2200,2300 \n";
private static final String days = "correctDays: {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday";

public static final String MESSAGE_INVALID_TIMETABLE = "timetable to be added is wrong: \n"
+ "does not have correct timings or/and days present in first column or/and first row in the csv file \n"
+ "does not have correct timings in first row and correct days in first column in the csv file \n"
+ timings + "\n"
+ days + "\n";

Expand Down Expand Up @@ -78,7 +76,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
}
boolean doesFileExists = new File(filePath).exists();
if (doesFileExists) {
Timetable timetable = new Timetable(filePath, personToEdit.getFormat(),
Timetable timetable = new Timetable(filePath,
personToEdit.getTimetable().getTimetableDataString(), 2, null, null, null);
if (!timetable.isValid()) {
if (!timetable.isCorrectSize()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private Person createPersonWithNewTimetable(Person personToEdit) {
Address updatedAddress = personToEdit.getAddress();
Set<Tag> updatedTags = personToEdit.getTags();
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags,
null, null, null);
null, null);
}

@Override
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_FILE_LOCATION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand Down Expand Up @@ -46,7 +45,6 @@ public class EditCommand extends Command {
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_FORMAT + "ADDRESS] "
+ "[" + PREFIX_FILE_LOCATION + "ADDRESS] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
Expand Down Expand Up @@ -107,16 +105,15 @@ public static Person createEditedPerson(Person personToEdit,
Address updatedAddress = editPersonDescriptor.getAddress()
.orElse(personToEdit.getAddress());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());
String format = editPersonDescriptor.getFormat().orElse(personToEdit.getFormat());
String storedLocation = editPersonDescriptor.getStoredLocation()
.orElse(personToEdit.getStoredLocation());
String timetableString = personToEdit.getTimetable().getTimetableDataString();

UniqueList<Group> uniqueGroupList = new UniqueList<>();
uniqueGroupList.setElements(personToEdit.getGroups());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags, uniqueGroupList,
format, storedLocation, timetableString);
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags,
uniqueGroupList, storedLocation, timetableString);
}

@Override
Expand Down Expand Up @@ -147,7 +144,6 @@ public static class EditPersonDescriptor {
private Phone phone;
private Email email;
private Address address;
private String format;
private String storedLocation;
private Set<Tag> tags;
private List<Group> groupList;
Expand All @@ -163,7 +159,6 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setFormat(toCopy.format);
setStoredLocation(toCopy.storedLocation);
setTags(toCopy.tags);
setGroupList(toCopy.groupList);
Expand All @@ -175,7 +170,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
*/
public boolean isAnyFieldEdited() {
return CollectionUtil
.isAnyNonNull(name, phone, email, address, tags, format, storedLocation);
.isAnyNonNull(name, phone, email, address, tags, storedLocation);
}

public void setStoredLocation(String storedLocation) {
Expand All @@ -186,14 +181,6 @@ public Optional<String> getStoredLocation() {
return Optional.ofNullable(storedLocation);
}

public void setFormat(String format) {
this.format = format;
}

public Optional<String> getFormat() {
return Optional.ofNullable(format);
}

public void setName(Name name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
requireNonNull(model);
Person personToEdit = CommandUtil.retrievePersonFromIndex(model, index);
String filePath = personToEdit.getStoredLocation();
Timetable timetable = new Timetable(filePath, personToEdit.getFormat(),
Timetable timetable = new Timetable(filePath,
personToEdit.getTimetable().getTimetableDataString(), 3, day, timing, details);
Person updatedPerson = createUpdatedPerson(personToEdit, timetable, filePath);
model.update(personToEdit, updatedPerson);
Expand All @@ -89,12 +89,11 @@ public static Person createUpdatedPerson(Person personToEdit, Timetable timetabl
Email updatedEmail = personToEdit.getEmail();
Address updatedAddress = personToEdit.getAddress();
Set<Tag> updatedTags = personToEdit.getTags();
String format = personToEdit.getFormat();
String storedLocation = filePath;
String timetableString = timetable.getTimetableDataString();

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags,
format, storedLocation, timetableString);
storedLocation, timetableString);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public AddCommand parse(String args) throws ParseException {
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Person person = new Person(name, phone, email, address, tagList, "default", "default",
Person person = new Person(name, phone, email, address, tagList, null,
null);

return new AddCommand(person);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class CliSyntax {

public static final Prefix PREFIX_STORED_LOCATION = new Prefix("sl/");
public static final Prefix PREFIX_FILE_LOCATION = new Prefix("fl/");
public static final Prefix PREFIX_FORMAT = new Prefix("f/");
public static final Prefix PREFIX_DESCRIPTION = new Prefix("d/");

public static final Prefix PREFIX_DAY = new Prefix("day/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STORED_LOCATION;
Expand Down Expand Up @@ -37,7 +36,7 @@ public EditCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer
.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG,
PREFIX_FORMAT, PREFIX_STORED_LOCATION);
PREFIX_STORED_LOCATION);

Index index;

Expand Down Expand Up @@ -65,10 +64,6 @@ public EditCommand parse(String args) throws ParseException {
editPersonDescriptor
.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_FORMAT).isPresent()) {
editPersonDescriptor
.setFormat(ParserUtil.parseFormat(argMultimap.getValue(PREFIX_FORMAT).get()));
}
if (argMultimap.getValue(PREFIX_STORED_LOCATION).isPresent()) {
editPersonDescriptor
.setStoredLocation(
Expand Down
34 changes: 4 additions & 30 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,6 @@ public static String parseLocation(String location) throws ParseException {
return trimmedLocation;
}

/**
* Parses a {@code String fileName} into an {@code String fileName}. Leading and trailing
* whitespaces will be trimmed.
*
* @throws ParseException if the given {@code fileName} is invalid.
*/
public static String parseFilename(String fileName) throws ParseException {
requireNonNull(fileName);
return fileName;
}

/**
* Parses a {@code String format} into an {@code String format}. Leading and trailing
* whitespaces will be trimmed.
*
* @throws ParseException if the given {@code format} is invalid.
*/
public static String parseFormat(String format) throws ParseException {
requireNonNull(format);
if ("horizontal".equals(format) || "vertical".equals(format)) {
return format;
} else {
throw new ParseException(Messages.MESSAGE_INVALID_TIMETABLE_FORMAT);
}
}

/**
* Parses a {@code String day} into an {@code String day}. Leading and trailing whitespaces will
* be trimmed. checks if day is any of the days in a week.
Expand All @@ -214,7 +188,7 @@ public static String parseFormat(String format) throws ParseException {
public static String parseDay(String day) throws ParseException {
requireNonNull(day);
String trimmedDay = day.trim();
String[] validDays = new TimetableData("horizontal", null, null, 1, null, null, null)
String[] validDays = new TimetableData(null, null, 1, null, null, null)
.getDaysInLowerCase();
if (ArrayUtils.contains(validDays, trimmedDay.toLowerCase())) {
return trimmedDay;
Expand All @@ -232,7 +206,7 @@ public static String parseDay(String day) throws ParseException {
public static String parseTiming(String timing) throws ParseException {
requireNonNull(timing);
String trimmedTiming = timing.trim();
String[] validTiming = new TimetableData("horizontal", null, null, 1, null, null, null)
String[] validTiming = new TimetableData(null, null, 1, null, null, null)
.getTimings();
if (ArrayUtils.contains(validTiming, trimmedTiming)) {
return trimmedTiming;
Expand Down Expand Up @@ -262,10 +236,10 @@ public static String parseDetails(String details) {
public static void checkBothDayAndTiming(String day, String timing) throws ParseException {

String trimmedDay = day.trim();
String[] validDays = new TimetableData("horizontal", null, null, 1, null, null, null)
String[] validDays = new TimetableData(null, null, 1, null, null, null)
.getDaysInLowerCase();
String trimmedTiming = timing.trim();
String[] validTiming = new TimetableData("horizontal", null, null, 1, null, null, null)
String[] validTiming = new TimetableData(null, null, 1, null, null, null)
.getTimings();
if (!ArrayUtils.contains(validDays, trimmedDay.toLowerCase())
&& !ArrayUtils.contains(validTiming, trimmedTiming)) {
Expand Down
Loading

0 comments on commit e95c1e6

Please sign in to comment.