Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

License server #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
packages/server/node_modules
packages/app/node_modules
packages/license-server
.git
3 changes: 2 additions & 1 deletion packages/app/src/collections/SettingsCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export class SettingsCollection {
if (!this.db) {
this.db = low(new LocalStorage('connection'));
}
this.db.defaults({ settings: { url: window.location.host } }).write();
const url = process.env.NODE_ENV === 'production' ? window.location.host : `${window.location.hostname}:3001`;
this.db.defaults({ settings: { url } }).write();
return this.db;
}

Expand Down
37 changes: 34 additions & 3 deletions packages/app/src/components/Booking/BookingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ interface States {
statisticForDate: t.Statistic;
statisticForWeek: t.Statistic;
statisticForMonth: t.Statistic;
statisticErrors: readonly GraphQLError[];
hoursSpentForMonthPerDay: t.HoursPerDay[];
yearSaldo: string;
timestamps: t.Timestamp[];
timestampError?: string | null;
complainsErrors: GraphQLError[];
timestampErrors: readonly GraphQLError[];
complainsErrors: readonly GraphQLError[];
complains: t.Complain[];
listOfLeaves: t.Leave[];
publicHolidays: t.PublicHoliday[];
Expand All @@ -55,10 +57,12 @@ export class BookingPage extends React.Component<Props, States> {
statisticForDate: initialStatisticState,
statisticForMonth: initialStatisticState,
statisticForWeek: initialStatisticState,
statisticErrors: [],
hoursSpentForMonthPerDay: [],
yearSaldo: '00:00',
timestamps: [],
timestampError: '',
timestampErrors: [],
complains: [],
complainsErrors: [],
listOfLeaves: [],
Expand Down Expand Up @@ -121,6 +125,11 @@ export class BookingPage extends React.Component<Props, States> {
yearSaldo: result.data.getYearSaldo
});
}
if (result.errors) {
this.setState({ statisticErrors: result.errors });
} else {
this.setState({ statisticErrors: [] });
}
});
}

Expand All @@ -140,6 +149,11 @@ export class BookingPage extends React.Component<Props, States> {
previousSelectedDate: result.data.getStatisticForWeek.selectedDate
});
}
if (result.errors) {
this.setState({ statisticErrors: result.errors });
} else {
this.setState({ statisticErrors: [] });
}
});
}

Expand All @@ -159,6 +173,11 @@ export class BookingPage extends React.Component<Props, States> {
previousSelectedDate: result.data.getStatisticForMonth.selectedDate
});
}
if (result.errors) {
this.setState({ statisticErrors: result.errors });
} else {
this.setState({ statisticErrors: [] });
}
});
}

Expand Down Expand Up @@ -191,16 +210,25 @@ export class BookingPage extends React.Component<Props, States> {
if (result.data) {
this.setState({
timestamps: result.data.updateTimestamps.timestamps,
timestampError: result.data.updateTimestamps.error
timestampError: result.data.updateTimestamps.error,
timestampErrors: []
});
}
if (result.errors) {
this.setState({ timestampErrors: result.errors });
}
});
}

updateComplains(userId: string, dateKey: string, complains: t.ComplainInput[]) {
return this.props.apollo.updateComplains(userId, dateKey, complains).then(result => {
if (result.data) {
this.setState({ complains: result.data.updateComplains });
this.setState({ complains: result.data.updateComplains, complainsErrors: [] });
}
if (result.errors) {
this.setState({ complainsErrors: result.errors });
} else {
this.setState({ complainsErrors: [] });
}
});
}
Expand All @@ -216,6 +244,7 @@ export class BookingPage extends React.Component<Props, States> {
this.setState({
timestamps: [],
timestampError: '',
timestampErrors: [],
complains: [],
complainsErrors: []
});
Expand Down Expand Up @@ -307,6 +336,7 @@ export class BookingPage extends React.Component<Props, States> {
statisticForDate={this.state.statisticForDate}
statisticForWeek={this.state.statisticForWeek}
statisticForMonth={this.state.statisticForMonth}
errors={this.state.statisticErrors}
/>
</Col>
<Col lg={5} xs={12} className="pt-3">
Expand Down Expand Up @@ -335,6 +365,7 @@ export class BookingPage extends React.Component<Props, States> {
selectedDate={this.state.selectedDate}
timestamps={this.state.timestamps}
timestampError={this.state.timestampError}
errors={this.state.timestampErrors}
onClose={this.handleBookingModalClose}
onUpdateTimestamps={this.updateTimestampsAndRefreshStatistics}
showData={this.state.showData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare let MOCKLOGIN: boolean;
interface Props {
selectedDate: moment.Moment;
complains: t.Complain[];
complainsErrors: GraphQLError[];
complainsErrors: readonly GraphQLError[];
onUpdateComplains: (complains: t.Complain[]) => void;
showData: boolean;
userRole: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/components/Booking/StatisticWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { GraphQLError } from 'graphql';
import { Card, CardBody, CardFooter, CardHeader, Table } from 'reactstrap';
import * as t from 'common/types';
import { GraphQLErrorMessage } from 'components/Error/GraphQLErrorMessage';

interface Props {
yearSaldo: string;
selectedUser: t.User;
statisticForDate: t.Statistic;
statisticForWeek: t.Statistic;
statisticForMonth: t.Statistic;
errors: readonly GraphQLError[];
}

export class StatisticWidget extends React.Component<Props, {}> {
Expand Down Expand Up @@ -125,6 +128,7 @@ export class StatisticWidget extends React.Component<Props, {}> {
>
{this.props.yearSaldo}
</b>
<GraphQLErrorMessage errors={this.props.errors} />
</CardFooter>
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ErrorMessage } from 'components/Error/ErrorMessage';
import * as moment from 'moment';
import * as React from 'react';
import { GraphQLError } from 'graphql';
import { FormattedMessage } from 'react-intl';
import { Button, Card, CardBody, CardFooter, CardHeader, Table } from 'reactstrap';
import * as t from 'common/types';
import { TimestampWidgetCreateModal } from './TimestampWidgetCreateModal';
import { TimestampWidgetItem } from './TimestampWidgetItem';
import { GraphQLErrorMessage } from 'components/Error/GraphQLErrorMessage';
declare let MOCKLOGIN: boolean;

interface Props {
Expand All @@ -16,6 +18,7 @@ interface Props {
showData: boolean;
timestampError?: string | null;
userRole: string;
errors: readonly GraphQLError[];
}

interface State {
Expand Down Expand Up @@ -109,6 +112,7 @@ export class TimestampWidget extends React.Component<Props, State> {
</Button>
)}
<ErrorMessage error={this.props.timestampError} />
<GraphQLErrorMessage errors={this.props.errors} />
</CardFooter>
</Card>
</div>
Expand Down
16 changes: 13 additions & 3 deletions packages/app/src/components/Evaluation/EvaluationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@ import * as React from 'react';
import { WrappedComponentProps, injectIntl } from 'react-intl';
import { RouteComponentProps } from 'react-router-dom';
import { Container } from 'reactstrap';
import { GraphQLError } from 'graphql';
import * as t from 'common/types';
import { EvaluationTable } from './EvaluationTable';
import { MonthAndYearPickerWidget } from './MonthAndYearPickerWidget';
import { GraphQLErrorMessage } from 'components/Error/GraphQLErrorMessage';

interface Props extends RouteComponentProps<{ userId: string }>, ApolloProps, WrappedComponentProps {}

interface State {
listOfEvaluation: t.Evaluation[];
selectedUser: t.User;
errors: readonly GraphQLError[];
}

export class EvaluationPage extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
listOfEvaluation: [],
selectedUser: initialUserState
selectedUser: initialUserState,
errors: []
};
}

Expand All @@ -46,11 +50,16 @@ export class EvaluationPage extends React.Component<Props, State> {
if (result.data) {
this.setState({ listOfEvaluation: result.data.getEvaluationForMonth });
}
if (result.errors) {
this.setState({ errors: result.errors });
} else {
this.setState({ errors: [] });
}
});
}

handleChange = (date: moment.Moment) => {
this.setState({ listOfEvaluation: [] });
this.setState({ listOfEvaluation: [], errors: [] });
const userId = this.props.match.params.userId;
this.getEvaluationForMonth(userId, moment(date).format(API_DATE));
};
Expand All @@ -67,7 +76,8 @@ export class EvaluationPage extends React.Component<Props, State> {
className="mt-3"
/>
)}
{!this.state.listOfEvaluation.length && <LoadingSpinner />}
{!!this.state.errors.length && <GraphQLErrorMessage errors={this.state.errors} />}
{!this.state.listOfEvaluation.length && !this.state.errors && <LoadingSpinner />}
</Container>
);
}
Expand Down
19 changes: 15 additions & 4 deletions packages/app/src/components/Evaluation/UserEvaluationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ import { LoadingSpinner } from 'components/Spinner/LoadingSpinner';
import { API_DATE } from 'common/constants';
import * as moment from 'moment';
import * as React from 'react';
import { GraphQLError } from 'graphql';
import { WrappedComponentProps, injectIntl } from 'react-intl';
import { RouteComponentProps } from 'react-router-dom';
import { Container } from 'reactstrap';
import * as t from 'common/types';
import { EvaluationTable } from './EvaluationTable';
import { MonthAndYearPickerWidget } from './MonthAndYearPickerWidget';
import { GraphQLErrorMessage } from 'components/Error/GraphQLErrorMessage';

interface Props extends RouteComponentProps<{}>, ApolloProps, WrappedComponentProps {}

interface State {
listOfUserEvaluation: t.UserEvaluation[];
errors: readonly GraphQLError[];
}

export class UserEvaluationPage extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
listOfUserEvaluation: []
listOfUserEvaluation: [],
errors: []
};
}

Expand All @@ -33,15 +37,21 @@ export class UserEvaluationPage extends React.Component<Props, State> {
if (result.data) {
this.setState({ listOfUserEvaluation: result.data.getEvaluationForUsers });
}

if (result.errors) {
this.setState({ errors: result.errors });
} else {
this.setState({ errors: [] });
}
});
}

componentWillUnmount() {
this.setState({ listOfUserEvaluation: [] });
this.setState({ listOfUserEvaluation: [], errors: [] });
}

handleChange = (date: moment.Moment) => {
this.setState({ listOfUserEvaluation: [] });
this.setState({ listOfUserEvaluation: [], errors: [] });
this.getEvaluationForUsers(moment(date).format(API_DATE));
};

Expand All @@ -61,7 +71,8 @@ export class UserEvaluationPage extends React.Component<Props, State> {
/>
);
})}
{!this.state.listOfUserEvaluation.length && <LoadingSpinner />}
{!!this.state.errors.length && <GraphQLErrorMessage errors={this.state.errors} />}
{!this.state.listOfUserEvaluation.length && !this.state.errors.length && <LoadingSpinner />}
</Container>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import { ApolloProps } from 'components/hoc/WithApollo';
import { MonthAndYearPicker } from 'components/TimePicker/MonthAndYearPicker.tsx';
import * as moment from 'moment';
import * as React from 'react';
import { GraphQLError } from 'graphql';
import { FormattedMessage } from 'react-intl';
import { Button, Card, CardBody, CardFooter, CardHeader, Table } from 'reactstrap';
import * as t from 'common/types';
import { PublicHolidayWidgetCreateModal } from './PublicHolidayWidgetCreateModal';
import { PublicHolidayWidgetItem } from './PublicHolidayWidgetItem';
import { GraphQLErrorMessage } from 'components/Error/GraphQLErrorMessage';

type Props = ApolloProps;

interface State {
isOpen: boolean;
year: string;
publicHolidays: t.PublicHoliday[];
errors: readonly GraphQLError[];
}

export class PublicHolidayWidget extends React.Component<Props, State> {
Expand All @@ -22,7 +25,8 @@ export class PublicHolidayWidget extends React.Component<Props, State> {
this.state = {
isOpen: false,
year: moment().format('YYYY'),
publicHolidays: []
publicHolidays: [],
errors: []
};
}

Expand All @@ -43,9 +47,13 @@ export class PublicHolidayWidget extends React.Component<Props, State> {
this.props.apollo.loadPublicHolidays(this.state.year).then(result => {
if (result.data) {
this.setState({
publicHolidays: result.data.loadPublicHolidays
publicHolidays: result.data.loadPublicHolidays,
errors: []
});
}
if (result.errors) {
this.setState({ errors: result.errors });
}
});
};

Expand All @@ -66,6 +74,11 @@ export class PublicHolidayWidget extends React.Component<Props, State> {
publicHolidays: result.data.deletePublicHoliday
});
}
if (result.errors) {
this.setState({ errors: result.errors });
} else {
this.setState({ errors: [] });
}
});
};

Expand All @@ -74,6 +87,11 @@ export class PublicHolidayWidget extends React.Component<Props, State> {
if (result.data) {
this.setState({ publicHolidays: result.data.createPublicHoliday });
}
if (result.errors) {
this.setState({ errors: result.errors });
} else {
this.setState({ errors: [] });
}
});
};

Expand Down Expand Up @@ -112,6 +130,7 @@ export class PublicHolidayWidget extends React.Component<Props, State> {
<Button onClick={this.loadPublicHolidays}>
<i className="fa fa-refresh" />
</Button>
<GraphQLErrorMessage errors={this.state.errors} />
</CardFooter>
<PublicHolidayWidgetCreateModal
onCreatePublicHoliday={this.createPublicHolidays}
Expand Down
Loading