Fakultas Ilmu Komputer UI

Commit c0d5650c authored by sirinbaisa's avatar sirinbaisa
Browse files

Merge branch 'UserStory2' of https://gitlab.com/PPL2017csui/PPLA1 into UserStory2

# Conflicts:
#	assets/js/components/VacancyList.jsx
parents 381b61a5 f86c1bbb
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory } from 'react-router';
import { Segment, Modal, Button, Icon, Image as ImageComponent, Item, TextArea, Forms } from 'semantic-ui-react';
import { Router, Route, browserHistory, Redirect } from 'react-router';
import { Segment } from 'semantic-ui-react';
import Dashboard from './Dashboard';
import Login from './Login';
import VacancyPage from './VacancyPage';
import CompanyRegister from './CompanyRegister';
import Server from './lib/Server';
// import Register from './CompanyRegister'
import Pane from './components/Pane';
import Tabs from './components/Tabs';
import ModalAlert from './components/ModalAlert';
export const Profile = () => (
<Segment>
......@@ -17,21 +15,33 @@ export const Profile = () => (
</Segment>
);
export const App = () => (
<Router history={browserHistory}>
<Route path="/login" component={Login} />
<Route path="/register" component={CompanyRegister} />
{/*<Route path="/register" component={Register} />*/}
<Route component={Dashboard}>
<Route path="/" component={Profile} />
<Route path="profile" component={Profile} />
<Route path="lowongan" component={VacancyPage} />
<Route path="users" component={Profile} />
</Route>
</Router>
);
const paragraph = <ImageComponent src="http://semantic-ui.com/images/wireframe/short-paragraph.png" />;
const imageWireFrame = <Item.Image size="small" src="http://semantic-ui.com/images/wireframe/image.png" />;
export default class App extends React.Component {
constructor(props) {
super(props);
/* istanbul ignore next */
this.handleAuth = this.handleAuth.bind(this);
}
handleAuth = (nextState, replace) => (
Server.isLoggedIn() || replace({ pathname: '/login' })
);
render = () => (
<Router history={browserHistory}>
<Route path="/login" component={Login} />
<Route path="/register" component={CompanyRegister} />
<Route component={Dashboard} onEnter={this.handleAuth}>
<Route path="/" component={Profile} />
<Route path="profile" component={Profile} />
<Route path="lowongan" component={VacancyPage} />
<Route path="users" component={Profile} />
</Route>
<Redirect from="*" to="/login" />
</Router>
);
}
ReactDOM.render(<App />, document.getElementById('react-app'));
import React from 'react';
import { Segment, Input, Menu } from 'semantic-ui-react'
import Tabs from './components/Tabs';
import Pane from './components/Pane';
import VacancyList from './components/VacancyList';
import Server from './lib/Server';
export default class VacancyPage extends React.Component {
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = { email: '', password: '', errorFlag: false };
this.state = {
email: '',
password: '',
errorFlag: false,
vacancies: [],
};
this.handleItemClick = this.handleItemClick.bind(this);
}
handleItemClick = (e, { name }) => this.setState({ activeItem: name });
// fetchVacancies(url) {
// console.log("maho");
// Server.get(url).then((data) => {
// this.setState({ vacancies: data });
// }, () => {
// });
// }
render() {
const data = [{ data1: 'Software Enggineer' }, { data1: 'System Analyst' }];
const {activeItem} = this.state;
return (<div>
<Tabs selected={0}>
<Pane label="Semua Lowongan">
<VacancyList vacancies={data} />
</Pane>
<Pane label="Lamaran saya">
<div>This is my tab 2 contents!</div>
</Pane>
</Tabs>
</div>
<Tabs selected={0}>
<Pane label="Semua Lowongan" >
<VacancyList url="/vacancies/" />
</Pane>
<Pane label="Lamaran saya" >
<VacancyList url="/b" />
</Pane>
<Pane label="Lamaran Ditandai" >
<VacancyList url="/c" />
</Pane>
</Tabs>
</div>
);
};
}
}
......@@ -4,7 +4,7 @@ export default class Pane extends React.Component {
static displayName = 'Pane';
static propTypes = {
children: React.PropTypes.element.isRequired,
children: React.PropTypes.any.isRequired,
};
render = () => (
......
......@@ -38,7 +38,7 @@ export default class Tabs extends React.Component {
const activeClass = (this.state.selected === index ? 'active' : '');
return (
<li key={index}>
<a className={activeClass} onClick={this.handleClick.bind(this, index)}>
<a className={activeClass} href="#" onClick={this.handleClick.bind(this, index)}>
{child.props.label}
</a>
</li>
......
import React from 'react';
import { Item } from 'semantic-ui-react';
import Lowongan from './Lowongan';
import Server from '../lib/Server';
export default class VacancyList extends React.Component {
static propTypes = {
vacancies: React.PropTypes.array.isRequired,
url: React.PropTypes.string.isRequired,
};
constructor(props) {
super(props);
this.state = { vacancies: [] };
console.log(Server.isLoggedIn());
Server.get(this.props.url).then((data) => {
console.log(data);
this.setState({ vacancies: data });
}, () => {
});
this.generateVacancies = this.generateVacancies.bind(this);
}
generateVacancies() {
return this.props.vacancies.map((vacancy) =>
return this.state.vacancies.map((vacancy, index) =>
<Lowongan key={vacancy.id} data={vacancy} />,
);
}
render = () => (
<Item.Group relaxed>
{/*<Item.Group relaxed>*/}
render = () => {
return (
<Item.Group relaxed>
{/*<Item.Group relaxed>*/}
{ this.generateVacancies() }
{/*</Item.Group>*/}
</Item.Group>
)
{/*</Item.Group>*/}
</Item.Group>
);
}
}
\ No newline at end of file
......@@ -7,8 +7,8 @@ export default class Server {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i += 1) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (`${name}`)) {
if (cookie.substring(0, name.length) === (`${name}`)) {
// Does this cookie string begin with the name we want?
/* istanbul ignore next */
return decodeURIComponent(cookie.substring(name.length + 1));
}
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-28 07:00
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('core', '0002_auto_20170328_1131'),
]
operations = [
migrations.AddField(
model_name='vacancy',
name='created',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='vacancy',
name='name',
field=models.CharField(default=django.utils.timezone.now, max_length=100),
preserve_default=False,
),
migrations.AddField(
model_name='vacancy',
name='updated',
field=models.DateTimeField(auto_now=True),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-28 07:17
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0003_auto_20170328_1400'),
]
operations = [
migrations.RenameField(
model_name='company',
old_name='alamat',
new_name='address',
),
]
......@@ -69,7 +69,7 @@ class Company(models.Model):
description = models.TextField()
verified = models.BooleanField(default=False)
logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True)
alamat = models.CharField(max_length=1000, blank=True, null=True)
address = models.CharField(max_length=1000, blank=True, null=True)
@property
def name(self):
......
......@@ -9,3 +9,6 @@ class Vacancy(models.Model):
open_time = models.DateTimeField()
description = models.TextField(blank=True)
close_time = models.DateTimeField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100, null=False)
......@@ -35,7 +35,7 @@ router.register(r'login', LoginViewSet)
router.register(r'vacancies', VacancyViewSet)
router.register(r'students/(?P<student_id>\d+)/bookmarked-vacancies', BookmarkedVacancyByStudentViewSet,
base_name='bookmarked-vacancy-list')
router.register(r'students/(?P<student_id>\d+)/applications', ApplicationViewSet,
router.register(r'students/(?P<student_id>\d+)/applied-vacancies', ApplicationViewSet,
base_name='applications')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment