Skip to content

Commit

Permalink
Merge a86aa33 into 776dac7
Browse files Browse the repository at this point in the history
  • Loading branch information
souless94 committed Oct 30, 2018
2 parents 776dac7 + a86aa33 commit 66fac31
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matrix:

script: >-
./config/travis/run-checks.sh &&
travis_retry ./gradlew clean checkstyleMain checkstyleTest headless allTests coverage coveralls asciidoctor
travis_retry ./gradlew clean checkstyleMain checkstyleTest headless allTests coverage coveralls asciidoctor copyTimetablePage
deploy:
skip_cleanup: true
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ task deployOfflineDocs(type: Copy) {
}
}

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



deployOfflineDocs.dependsOn asciidoctor
processResources.dependsOn deployOfflineDocs
Expand Down
81 changes: 81 additions & 0 deletions docs/Timetable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Timetable</title>
<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 matrixArray = matrixAsString.split(",");
var rows = 8;
var columns = 17;
if (matrixArray[0] == "vertical"){
//means vertical
rows=17;
columns=8;
}
var counter =0;
//@@author souless94 -reused
// used code from marchen in https://stackoverflow.com/questions/39242313/how-to-create-nxn-matrix-array-in-javascript
function matrix(m, n) {
var result = [];
for(var i = 0; i < m; i++) {
result.push(new Array(n).fill(0));
}
return result;
}
//@@ author
var m= matrix(rows,columns);
//@@author souless94 -reused from w3resources
// https://www.w3resource.com/javascript-exercises/javascript-string-exercise-28.php
function hex_to_ascii(str1){
var hex = str1.toString();
var str = '';
for (var n = 0; n < hex.length; n += 2) {
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
}
return str;
}
//@@author
for (var i =0;i <rows; i++){
for(var j=0 ; j < columns ;j++){
m[i][j] = hex_to_ascii(matrixArray[counter]);
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++)
{
// create a new row
var newRow = table.insertRow(table.length);
for(var j = 0; j < m[i].length; j++)
{
// create a new cell
var cell = newRow.insertCell(j);

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

</script>
</body>
</html>
28 changes: 19 additions & 9 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,20 @@ Clears all entries from the address book. +
Format: `clear`

== Timetable(Wen Kai)

=== Adding a timetable: `add_timetable`
add a timetable from the stored folder in NUS Hangs or a file location +
Format: `add_timetable INDEX [fl/FILE_LOCATION] `
user to download timetable template first using download_timetable INDEX and changing csv at the location +
add details of a timetable csv file to the person specified by `INDEX` from the stored folder of the person specified by `INDEX` if no file location is present. +
Adds details of a timetable csv file to the person specified by the `INDEX` from file location if file location is present. +
Will not be able to add if timetable is not present in the stored location of person specified by `INDEX`. +
Existing values will be overwritten by the input values. +
Reload page by clicking on another person and then click again +
Or right click and select the reload page option.

Format: `add_timetable INDEX [fl/FILE_LOCATION]`

****
* Excel will delete leading zeros of timetable csv file by default.
* Add the timetable at the specified `INDEX`.
* The index refers to the index number shown in the displayed person list.
* The index *must be a positive integer* 1, 2, 3, ...
Expand All @@ -366,7 +375,8 @@ Examples:
* `add_timetable 1 fl/C:\Users\timetable\timetable.csv `

=== editing a timetable: `edit_timetable`
edit a timetable timeslot from the person from index specified +
Edits a timetable timeslot of the timetable from the person specified by the `INDEX`. +
days are days of a week. And timings are in 24h format from 0800 to 2300. Existing values will be overwritten by the input details.
Format: `add_timetable INDEX day/DAY timing/TIMING [m/DETAILS] `

****
Expand All @@ -385,7 +395,7 @@ Examples:

=== Download timetable : `download_timetable`

Download a timetable in the System as a csv file in the format of the person.+
Download a timetable from the person specified by the `INDEX` to the stored folder from the person specified by the `INDEX` as a csv file. Will not download if there is a file with same filename as the filename of the timetable from the person specified by the `INDEX`. +
Format: `download_timetable INDEX `

****
Expand All @@ -396,12 +406,12 @@ Format: `download_timetable INDEX `

Examples:

* `download_timetable 1 ` +
* `download_timetable 1` +

=== Deleting a timetable : `delete_timetable`

Delete a timetable in the system by index +
Format: `delete_timetable INDEX p/password`
delete csv file of the timetable from stored location from the person specified by the `INDEX` and adds a default timetable to the person specified by the `INDEX`.Resets the timetable of the person if there is no timetable in the stored location from the person specified by the `INDEX`. +
Format: `delete_timetable INDEX`

****
* Deletes the timetable at the specified `INDEX`.
Expand All @@ -412,10 +422,10 @@ Format: `delete_timetable INDEX p/password`
Examples:

* `list_timetable` +
`delete_timetable 2 p/password` +
`delete_timetable 2` +
Deletes the 2nd timetable in the address book.
* `find_timetable Betsy` +
`delete_timetable 1 p/password` +
`delete_timetable 1` +
Deletes the 1st timetable in the results of the `find_timetable` command.

== Groups (Melodies)
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,
"default", null, null);
null, null, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DownloadTimetableCommand extends Command {
+ "Parameters : INDEX (must be a positive integer) "
+ "Example: " + COMMAND_WORD + " 1 ";

public static final String MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS = "timetable downloaded successfully";
public static final String MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS = "timetable downloaded successfully to : ";
public static final String MESSAGE_TIMETABLE_IS_PRESENT =
"there is a csv file with same name as your timetable filename";
private final Index index;
Expand Down Expand Up @@ -61,7 +61,9 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
timetable.downloadTimetableAsCsv();
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
model.commitAddressBook();
return new CommandResult(String.format(MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS));
return new CommandResult(
String.format(MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS)
+ personToDownloadTimetable.getStoredLocation());
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static java.util.Objects.requireNonNull;
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 @@ -41,6 +43,8 @@ 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 "
+ PREFIX_PHONE + "91234567 "
Expand Down Expand Up @@ -157,7 +161,8 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, tags);
return CollectionUtil
.isAnyNonNull(name, phone, email, address, tags, format, storedLocation);
}

public void setStoredLocation(String storedLocation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public EditCommand parse(String args) throws ParseException {
}
if (argMultimap.getValue(PREFIX_FORMAT).isPresent()) {
editPersonDescriptor
.setFormat(argMultimap.getValue(PREFIX_FORMAT).get());
.setFormat(ParserUtil.parseFormat(argMultimap.getValue(PREFIX_FORMAT).get()));
}
if (argMultimap.getValue(PREFIX_STORED_LOCATION).isPresent()) {
editPersonDescriptor
.setStoredLocation(argMultimap.getValue(PREFIX_STORED_LOCATION).get());
.setStoredLocation(
ParserUtil.parseLocation(argMultimap.getValue(PREFIX_STORED_LOCATION).get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG))
.ifPresent(editPersonDescriptor::setTags);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tag
if (!directory.exists()) {
directory.mkdirs();
}
this.storedLocation = location + "/" + String.valueOf(hashCode()) + " timetable.csv";
this.storedLocation =
location.replace("\\", "/")
+ "/" + String.valueOf(hashCode())
+ " timetable.csv";
} else {
this.storedLocation = storedLocation.replace("\\", "/");
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label email;
@FXML
private Label storedLocation;
@FXML
private FlowPane tags;

public PersonCard(Person person, int displayedIndex) {
Expand All @@ -47,6 +49,7 @@ public PersonCard(Person person, int displayedIndex) {
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
storedLocation.setText(person.getStoredLocation());
person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="storedLocation" styleClass="cell_small_label" text="\$storedLocation" />
</VBox>
</GridPane>
</HBox>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void downloadTimetableSuccess() {
DownloadTimetableCommand downloadTimetableCommand = new DownloadTimetableCommand(
INDEX_FIRST);
String expectedMessage = String
.format(DownloadTimetableCommand.MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS);
.format(DownloadTimetableCommand.MESSAGE_DOWNLOAD_TIMETABLE_SUCCESS
+ personToDownloadTimetable.getStoredLocation());
Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
new UserPrefs());
expectedModel.update(model.getFilteredPersonList().get(0), personToDownloadTimetable);
Expand Down

0 comments on commit 66fac31

Please sign in to comment.