Work is still in progress

workbench
Gitea 7 years ago
parent 9760376f0a
commit 43e1142419
  1. 5
      .expo/packager-info.json
  2. 9
      .expo/settings.json
  3. 1
      android/app/build.gradle
  4. 5
      android/app/src/main/java/com/organizer/MainApplication.java
  5. BIN
      android/gradle/wrapper/gradle-wrapper.jar
  6. 5
      android/gradle/wrapper/gradle-wrapper.properties
  7. 8
      android/keystores/BUCK
  8. 2
      android/settings.gradle
  9. 8
      components/DefaultHeader.js
  10. 1
      ios/Organizer.xcodeproj/project.pbxproj
  11. 9
      jsconfig.json
  12. 11
      model/Exam.js
  13. 26
      model/Lesson.js
  14. 45
      model/ReplacementLesson.js
  15. 9
      model/Subject.js
  16. 9
      model/Teacher.js
  17. 6
      package.json
  18. 36
      tabs/Stundenliste.js
  19. 85
      tabs/Vertretungsplan.js

@ -0,0 +1,5 @@
{
"expoServerPort": null,
"packagerPort": null,
"packagerPid": null
}

@ -0,0 +1,9 @@
{
"hostType": "tunnel",
"lanType": "ip",
"dev": true,
"strict": false,
"minify": false,
"urlType": "exp",
"urlRandomness": null
}

@ -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

@ -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<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
new MainReactPackage(),
new RealmReactPackage()
);
}
};

Binary file not shown.

@ -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

@ -0,0 +1,8 @@
keystore(
name = "debug",
properties = "debug.keystore.properties",
store = "debug.keystore",
visibility = [
"PUBLIC",
],
)

@ -1,3 +1,5 @@
rootProject.name = 'Organizer'
include ':app'
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')

@ -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 {
<Body>
<Title>{this.props.title}</Title>
</Body>
<Right/>
<Right>
<Button transparent onPress={this.props.refresh}>
<Icon name='refresh' />
</Button>
</Right>
</Header>
)

@ -1,3 +1,4 @@
//
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

@ -0,0 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}

@ -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"}
}
}

@ -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"}
}
}
}

@ -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 <code>ReplacementLesson</code>.
* @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 (
<ListItem icon>
<Left><Text>{this.lesson.period}.</Text></Left>
<Body>
<Text>{this.lesson.subject.name}</Text>
<Text note>{this.lesson.teacher.name}</Text>
</Body>
<Right>
<Text>{this.replacementLesson.subject.name}</Text>
<Text note>{this.replacementLesson.teacher.name}</Text>
</Right>
</ListItem>
)
}

@ -77,7 +77,14 @@ export default class Subject {
name = undefined;
schema = {
name: "Subject",
primaryKey: "abbreviation",
properties: {
abbreviation: {type: "string"},
name: {type: "string"}
}
}

@ -80,7 +80,14 @@ export default class Teacher {
schema = {
name: "Teacher",
primaryKey: "identifier",
properties: {
identifier: {type: "string"},
name: {type: "string"}
}
}

@ -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"
}
}

@ -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 (
<List dataArray={this.props.data}
renderRow={item =>
<ListItem icon>
<Left><Text>{item.lesson.period}.</Text></Left>
<Body>
<Text>{item.lesson.subject.name}</Text>
<Text note>{item.lesson.teacher.name}</Text>
</Body>
<SectionList sections={this.props.data}
renderItem={({item}) => {
console.log(item, "item")
if(item instanceof ReplacementLesson) {
</ListItem>
}>
item.render()
}else {
console.log("NO REPLACEMENT LESSON ;C")
return ReplacementLesson.constructFromObject(item).render();
}
}}
renderSectionHeader={({section}) => <Text style={styles.sectionHeader}>{section.title}</Text>}>
</List>
</SectionList>
);
}
@ -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)',
}
});

@ -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 (
<Container>
<DefaultHeader hasTabs title="Vertretungsplan" navigation={this.props.navigation}/>
<DefaultHeader hasTabs title="Vertretungsplan" navigation={this.props.navigation} refresh={this.refreshData()}/>
{this.renderTabsForLessons(this.state.replacementLessons)}
</Container>
);
@ -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 => <Tab heading={value}><Stundenliste
data={tabsByDate[value]}/></Tab>);
if (tabsByDate.length == 0) {
@ -59,4 +68,26 @@ export default class Vertretungsplan extends Component {
console.log(tabs);
return <Tabs>{tabs}</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
}
}
Loading…
Cancel
Save