diff --git a/.expo/packager-info.json b/.expo/packager-info.json new file mode 100644 index 0000000..24e8ec3 --- /dev/null +++ b/.expo/packager-info.json @@ -0,0 +1,5 @@ +{ + "expoServerPort": null, + "packagerPort": null, + "packagerPid": null +} \ No newline at end of file diff --git a/.expo/settings.json b/.expo/settings.json new file mode 100644 index 0000000..5eee78b --- /dev/null +++ b/.expo/settings.json @@ -0,0 +1,9 @@ +{ + "hostType": "tunnel", + "lanType": "ip", + "dev": true, + "strict": false, + "minify": false, + "urlType": "exp", + "urlRandomness": null +} \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 191d05b..17afb0f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -137,6 +137,7 @@ dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules + compile project(':realm') } // Run this once to be able to run the application with BUCK diff --git a/android/app/src/main/java/com/organizer/MainApplication.java b/android/app/src/main/java/com/organizer/MainApplication.java index ecfb6ac..878c00f 100644 --- a/android/app/src/main/java/com/organizer/MainApplication.java +++ b/android/app/src/main/java/com/organizer/MainApplication.java @@ -8,6 +8,8 @@ import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; +import io.realm.react.RealmReactPackage; + import java.util.Arrays; import java.util.List; @@ -22,7 +24,8 @@ public class MainApplication extends Application implements ReactApplication { @Override protected List getPackages() { return Arrays.asList( - new MainReactPackage() + new MainReactPackage(), + new RealmReactPackage() ); } }; diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..b5166da Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..dbdc05d --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/android/keystores/BUCK b/android/keystores/BUCK new file mode 100644 index 0000000..88e4c31 --- /dev/null +++ b/android/keystores/BUCK @@ -0,0 +1,8 @@ +keystore( + name = "debug", + properties = "debug.keystore.properties", + store = "debug.keystore", + visibility = [ + "PUBLIC", + ], +) diff --git a/android/settings.gradle b/android/settings.gradle index 4952239..fa6f9f7 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = 'Organizer' include ':app' +include ':realm' +project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android') \ No newline at end of file diff --git a/components/DefaultHeader.js b/components/DefaultHeader.js index 385a37a..7493f13 100644 --- a/components/DefaultHeader.js +++ b/components/DefaultHeader.js @@ -1,5 +1,5 @@ import React, {Component} from "react"; -import {Body, Button, Container, Content, H3, Header, Icon, Left, Right, Title} from "native-base"; +import {Body, Button, Container, Content, H3, Header, Icon, Left, Right, Title, Text} from "native-base"; export default class DefaultHeader extends Component { @@ -21,7 +21,11 @@ export default class DefaultHeader extends Component { {this.props.title} - + + + ) diff --git a/ios/Organizer.xcodeproj/project.pbxproj b/ios/Organizer.xcodeproj/project.pbxproj index b4ecb25..25c16fe 100644 --- a/ios/Organizer.xcodeproj/project.pbxproj +++ b/ios/Organizer.xcodeproj/project.pbxproj @@ -1,3 +1,4 @@ +// diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..c98b6e0 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/model/Exam.js b/model/Exam.js index 2a26c71..a693a4d 100644 --- a/model/Exam.js +++ b/model/Exam.js @@ -100,7 +100,16 @@ export default class Exam { lesson = undefined; - + schema = { + name: "Exam", + properties: { + id: {type: "int", indexed: true, optional: true}, + date: {type: "date", indexed: true}, + startPeriod: {type: "int"}, + endPeriod: {type: "int"}, + lesson: {type: "Lesson"} + } + } diff --git a/model/Lesson.js b/model/Lesson.js index c0abce7..75c1a0c 100644 --- a/model/Lesson.js +++ b/model/Lesson.js @@ -34,13 +34,6 @@ export default class Lesson { constructor() { - - - - - - - } /** @@ -115,13 +108,18 @@ export default class Lesson { */ room = undefined; - - - - - - - + schema = { + name: "Lesson", + properties: { + weekday: {type: "int", indexed: true}, + period: {type: "int", indexed: true}, + course: {type: "string", indexed: true}, + subject: {type: "Subject"}, + teacher: {type: "Teacher"}, + additionalInformation: {type: "string"}, + room: {type: "string"} + } + } } diff --git a/model/ReplacementLesson.js b/model/ReplacementLesson.js index a81cd15..1efde6f 100644 --- a/model/ReplacementLesson.js +++ b/model/ReplacementLesson.js @@ -14,7 +14,8 @@ import ApiClient from '../ApiClient'; import Lesson from './Lesson'; - +import React, {Component} from 'react'; +import {ListItem, Left, Body, Text, Right, Container} from 'native-base'; @@ -24,7 +25,7 @@ import Lesson from './Lesson'; * @module model/ReplacementLesson * @version 1.0.0 */ -export default class ReplacementLesson { +export default class ReplacementLesson extends Component { /** * Constructs a new ReplacementLesson. * @alias module:model/ReplacementLesson @@ -32,14 +33,7 @@ export default class ReplacementLesson { */ constructor() { - - - - - - - - + super() } /** @@ -90,8 +84,39 @@ export default class ReplacementLesson { */ replacementLesson = undefined; + schema = { + name: "ReplacementLesson", + properties: { + id: {type: "int", indexed: true, optional: true}, + date: {type: "date", indexed: true}, + lesson: {type: "Lesson"}, + replacementLesson: {type: "Lesson"} + } + } + + render() { + if (this.replacementLesson === undefined) { + this.replacementLesson = this.lesson; + } + if (this.lesson === undefined) { + console.log(this); + } + return ( + + {this.lesson.period}. + + {this.lesson.subject.name} + {this.lesson.teacher.name} + + + {this.replacementLesson.subject.name} + {this.replacementLesson.teacher.name} + + + ) + } diff --git a/model/Subject.js b/model/Subject.js index d40661e..6720458 100644 --- a/model/Subject.js +++ b/model/Subject.js @@ -77,7 +77,14 @@ export default class Subject { name = undefined; - + schema = { + name: "Subject", + primaryKey: "abbreviation", + properties: { + abbreviation: {type: "string"}, + name: {type: "string"} + } + } diff --git a/model/Teacher.js b/model/Teacher.js index ad26ff8..bd5c689 100644 --- a/model/Teacher.js +++ b/model/Teacher.js @@ -80,7 +80,14 @@ export default class Teacher { - + schema = { + name: "Teacher", + primaryKey: "identifier", + properties: { + identifier: {type: "string"}, + name: {type: "string"} + } + } diff --git a/package.json b/package.json index 53d17a6..e7b78a3 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "expect.js": "~0.3.1", "jest-expo": "~19.0.0", "mocha": "~2.3.4", + "react-devtools": "^2.5.0", "react-test-renderer": "16.0.0-alpha.12", "sinon": "1.17.3" }, @@ -28,13 +29,14 @@ "@exponent/vector-icons": "^4.0.0", "babel": "^6.23.0", "babel-cli": "^6.24.1", - "native-base": "^2.3.1", "querystring": "^0.2.0", + "native-base": "^2.3.1", "react": "16.0.0-alpha.12", "react-native": "^0.46.1", + "react-navigation": "^1.0.0-beta.11", "react-native-cli": "^2.0.1", "react-native-vector-icons": "^4.3.0", - "react-navigation": "^1.0.0-beta.11", + "realm": "^1.11.1", "superagent": "3.5.2" } } diff --git a/tabs/Stundenliste.js b/tabs/Stundenliste.js index e3f171a..3f2a77c 100644 --- a/tabs/Stundenliste.js +++ b/tabs/Stundenliste.js @@ -1,6 +1,6 @@ import React, {Component} from 'react'; -import {StyleSheet} from 'react-native'; -import {Body, Left, List, ListItem, Separator, Text} from 'native-base'; +import {StyleSheet, SectionList, Text} from 'react-native'; +import ReplacementLesson from "../model/ReplacementLesson"; export default class Stundenliste extends Component { constructor(props) { @@ -9,19 +9,20 @@ export default class Stundenliste extends Component { } render() { return ( - - - {item.lesson.period}. - - {item.lesson.subject.name} - {item.lesson.teacher.name} - + { + console.log(item, "item") + if(item instanceof ReplacementLesson) { - - }> + item.render() + }else { + console.log("NO REPLACEMENT LESSON ;C") + return ReplacementLesson.constructFromObject(item).render(); + } + }} + renderSectionHeader={({section}) => {section.title}}> - + ); } @@ -33,5 +34,14 @@ var styles = StyleSheet.create({ borderRadius: 15, width: 30, backgroundColor: 'green' + }, + sectionHeader: { + paddingTop: 2, + paddingLeft: 10, + paddingRight: 10, + paddingBottom: 2, + fontSize: 14, + fontWeight: 'bold', + backgroundColor: 'rgba(247,247,247,1.0)', } }); \ No newline at end of file diff --git a/tabs/Vertretungsplan.js b/tabs/Vertretungsplan.js index 239e6f1..c5d1b2b 100644 --- a/tabs/Vertretungsplan.js +++ b/tabs/Vertretungsplan.js @@ -4,34 +4,36 @@ import Stundenliste from './Stundenliste'; import DefaultHeader from "../components/DefaultHeader"; import NoResultsFound from "../pages/NoResultsFound"; import ReplacementLesson from "../model/ReplacementLesson"; +import ReplacementLessonsApi from "../api/ReplacementLessonsApi"; +import ApiClient from "../ApiClient"; export default class Vertretungsplan extends Component { constructor(props) { super(props); this.state = { - replacementLessons: [ - ReplacementLesson.constructFromObject({ - id: 2, - date: "2017-08-22", - lesson: {teacher: {name: "Szabo"}, period: 1, subject: {name: "Informatik"}} - }), - ReplacementLesson.constructFromObject({ - id: 4, - date: "2017-08-22", - lesson: {teacher: {name: "Szabo"}, period: 2, subject: {name: "Informatik"}} - }), - ReplacementLesson.constructFromObject({ - id: 3, - date: "2017-08-23", - lesson: {teacher: {name: "Szabo"}, period: 2, subject: {name: "Informatik"}} - }) - ] - } + replacementLessons: [] + }; + api = new ApiClient(); + api.authentications.passwordAuth.username = "de" + api.authentications.passwordAuth.password = "de" + this.rla = new ReplacementLessonsApi(api); + vplan = this + this.rla.findReplacementLessons((s, lessons, pure) =>{ + console.log(lessons, "lessons"); + console.log(s, "s"); + console.log(pure, "pure") + vplan.setState({replacementLessons: lessons}) + } ) + } + + refreshData() { + alert("HEY!"); } + render() { return ( - + {this.renderTabsForLessons(this.state.replacementLessons)} ); @@ -42,15 +44,22 @@ export default class Vertretungsplan extends Component { * @param {ReplacementLesson[]} lessons */ renderTabsForLessons(lessons) { + //Grouping by date and course + rawTabs = this._groupByDateAndCourse(lessons); + + //Bringing grouped things into machine-readable format tabsByDate = {}; - lessons.forEach((lesson) => { - console.log(lesson); - if (!(lesson.date.toLocaleDateString() in tabsByDate)) { - tabsByDate[lesson.date.toLocaleDateString()] = [] - } - tabsByDate[lesson.date.toLocaleDateString()].push(lesson) - }); - console.log(tabsByDate); + for(date in rawTabs) { + tabItems = []; + content = rawTabs[date]; + content.forEach(function (value, course) { + console.log(course, "c"); + console.log(value, "con"); + tabItems.push({title: course, data: value}) + }); + tabsByDate[new Date(date).toLocaleDateString()] = tabItems; + } + console.log(tabsByDate, "tabs"); tabs = Object.keys(tabsByDate).map(value => ); if (tabsByDate.length == 0) { @@ -59,4 +68,26 @@ export default class Vertretungsplan extends Component { console.log(tabs); return {tabs} } + + _groupByDateAndCourse(lessons) { + groupedByDate = _.mapValues(_.groupBy(lessons, 'date'), + clist => clist.map(car => _.omit(car, 'date'))); + function groupBy(list, keyGetter) { + const map = new Map(); + list.forEach((item) => { + const key = keyGetter(item); + const collection = map.get(key); + if (!collection) { + map.set(key, [item]); + } else { + collection.push(item); + } + }); + return map; + } + Object.keys(groupedByDate).map(function (key, index) { + groupedByDate[key] = groupBy(groupedByDate[key], replacementLesson => replacementLesson.lesson.course) + }); + return groupedByDate + } } \ No newline at end of file