Compare commits
No commits in common. "develop" and "v2" have entirely different histories.
|
@ -1,4 +0,0 @@
|
|||
/client/node_modules
|
||||
/build
|
||||
/data
|
||||
/server/vendor
|
|
@ -1,4 +1,4 @@
|
|||
[*.{js,ts,tsx,json}]
|
||||
[*.{ts,tsx,js,jsx}]
|
||||
charset = utf-8
|
||||
indent_size = 2
|
||||
indent_style = space
|
|
@ -0,0 +1,7 @@
|
|||
DEBUG=true
|
||||
OIDC_CLIENT_ID=guesstimate
|
||||
OIDC_CLIENT_SECRET=guesstimate
|
||||
OIDC_POST_LOGOUT_REDIRECT_URL=http://localhost:8081/logout/redirect
|
||||
HTTP_COOKIE_AUTHENTICATION_KEY=cL87ucJJSGt7XSjRuQe7GDb2qna8ijfQ
|
||||
HTTP_COOKIE_ENCRYPTION_KEY=cL87ucJJSGt7XSjRuQe7GDb2qna8ijfQ
|
||||
DATABASE_DSN="host=localhost user=guesstimate database=guesstimate password=guesstimate port=5432 sslmode=disable"
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
|
||||
CLIENT_DIR="${DIR}/../client"
|
||||
|
||||
export NODE_PATH="${CLIENT_DIR}/node_modules"
|
||||
export PATH="${PATH}:${NODE_PATH}/.bin"
|
||||
|
||||
function lint_commit_message {
|
||||
local commit_message_file="$1"
|
||||
( cat "$commit_message_file" | commitlint )
|
||||
}
|
||||
|
||||
function main {
|
||||
local commit_message_file="$1"
|
||||
lint_commit_message "$commit_message_file"
|
||||
}
|
||||
|
||||
main $@
|
|
@ -1,8 +1,5 @@
|
|||
/client/node_modules
|
||||
/client/dist
|
||||
*.log
|
||||
/.vscode
|
||||
/server/bin
|
||||
/server/data
|
||||
/server/vendor
|
||||
/vendor
|
||||
/data
|
||||
/bin
|
||||
/.env
|
||||
/release
|
41
Dockerfile
|
@ -1,41 +0,0 @@
|
|||
FROM golang:1.19 AS build
|
||||
|
||||
ARG HTTP_PROXY=
|
||||
ARG HTTPS_PROXY=
|
||||
ARG http_proxy=
|
||||
ARG https_proxy=
|
||||
ARG NODE_MAJOR=16
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential git bash curl ca-certificates gnupg
|
||||
|
||||
RUN echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600' > /etc/apt/preferences.d/nodesource \
|
||||
&& mkdir -p /etc/apt/keyrings \
|
||||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
||||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y nodejs
|
||||
|
||||
COPY . /src
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN make deps \
|
||||
&& make ARCH_TARGETS=amd64 release
|
||||
|
||||
FROM busybox
|
||||
|
||||
COPY --from=build /src/release/server-linux-amd64 /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY misc/dokku/CHECKS /client/CHECKS
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
VOLUME /data
|
||||
|
||||
ENV GUESSTIMATE_HTTP_ADDRESS=:80
|
||||
ENV GUESSTIMATE_HTTP_PUBLIC_DIR=/app/public
|
||||
ENV GUESSTIMATE_DATA_PATH=/data/guesstimate.db
|
||||
|
||||
CMD ["/app/bin/server", "-config", "config.yml"]
|
661
LICENCE
|
@ -1,661 +0,0 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
73
Makefile
|
@ -1,34 +1,61 @@
|
|||
DOKKU_URL := dokku@dev.lookingfora.name:guesstimate
|
||||
SHELL := /bin/bash
|
||||
|
||||
watch:
|
||||
modd
|
||||
build: build-server
|
||||
|
||||
deps:
|
||||
cd client && npm ci
|
||||
docker:
|
||||
docker-compose build
|
||||
|
||||
build: clean build-server build-client
|
||||
|
||||
build-client:
|
||||
cd client && npm run build
|
||||
generate:
|
||||
go generate ./...
|
||||
|
||||
build-server:
|
||||
cd server && CGO_ENABLED=0 go build -v -o bin/server ./cmd/server
|
||||
CGO_ENABLED=0 go build -v -o ./bin/server ./cmd/server
|
||||
|
||||
clean:
|
||||
rm -rf client/dist server/bin release
|
||||
deps: generate
|
||||
cd client && npm install
|
||||
go get ./...
|
||||
|
||||
dokku-build:
|
||||
docker build \
|
||||
-t guesstimate-dokku:latest \
|
||||
.
|
||||
client-dist:
|
||||
cd client && NODE_ENV=production npm run build
|
||||
|
||||
dokku-run:
|
||||
docker run -it --rm -p 8080:80 guesstimate-dokku:latest
|
||||
up: docker
|
||||
docker-compose up
|
||||
|
||||
dokku-deploy:
|
||||
$(if $(shell git config remote.dokku.url),, git remote add dokku $(DOKKU_URL))
|
||||
git push -f dokku $(shell git rev-parse HEAD):refs/heads/master
|
||||
watch:
|
||||
go run github.com/cortesi/modd/cmd/modd
|
||||
|
||||
down:
|
||||
docker-compose down -v --remove-orphans
|
||||
|
||||
db-shell:
|
||||
docker-compose exec postgres psql -Uguesstimate
|
||||
|
||||
migrate: build-server
|
||||
( set -o allexport && source .env && set +o allexport && bin/server -workdir "./cmd/server" -config ../../data/config.yml -migrate $(MIGRATE) )
|
||||
|
||||
migrate-latest:
|
||||
$(MAKE) MIGRATE=latest migrate
|
||||
|
||||
migrate-up:
|
||||
$(MAKE) MIGRATE=up migrate
|
||||
|
||||
migrate-down:
|
||||
$(MAKE) MIGRATE=down migrate
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
|
||||
hydra-shell:
|
||||
docker-compose exec hydra /bin/sh
|
||||
|
||||
.PHONY: release
|
||||
release: clean
|
||||
@misc/script/release.sh
|
||||
release:
|
||||
./misc/script/release
|
||||
|
||||
install-git-hooks:
|
||||
git config core.hooksPath .githooks
|
||||
|
||||
clean:
|
||||
rm -rf client/node_modules bin data .env internal/graph/generated internal/graph/server.go
|
||||
rm -rf vendor
|
||||
go clean -modcache
|
72
README.md
|
@ -3,40 +3,60 @@ Application de création collaborative d’estimations de temps/coût pour la r
|
|||
|
||||
[Voir l'instance de démonstration](https://guesstimate.dev.lookingfora.name/)
|
||||
|
||||
## Démarrer à partir des sources
|
||||
## Démarrage
|
||||
|
||||
### Dépendances
|
||||
### Avec les sources
|
||||
|
||||
- [Go >= 1.13](https://golang.org/)
|
||||
- [GNU Make](https://fr.wikipedia.org/wiki/GNU_Make)
|
||||
- [NVM](https://github.com/nvm-sh/nvm)
|
||||
- Git
|
||||
- NodeJS/NPM
|
||||
|
||||
### Étapes
|
||||
#### Dépendances
|
||||
|
||||
1. Cloner le projet avec Git
|
||||
- docker
|
||||
- docker-compose
|
||||
- nodejs avec npm/yarn
|
||||
|
||||
```
|
||||
git clone https://forge.cadoles.com/wpetit/guesstimate.git
|
||||
```
|
||||
#### Procédure
|
||||
|
||||
2. Se positionner dans le répertoire du projet
|
||||
```bash
|
||||
make clean # On s'assure d'avoir un environnement propre
|
||||
make deps # Installer les dépendances
|
||||
make install-git-hooks # Installation des hooks Git du projet
|
||||
make up # Démarrer l'environnement docker-compose (hydra, hydra-passwordless et fake-smtp)
|
||||
# Dans un second terminal
|
||||
make watch # Suivre les modifications et compiler à la volée le backend et frontend
|
||||
```
|
||||
|
||||
```
|
||||
cd guesstimate
|
||||
```
|
||||
|
||||
3. Générer une version de distribution
|
||||
Les services suivants devraient être disponibles après démarrage de l'environnement:
|
||||
|
||||
```
|
||||
nvm use
|
||||
make deps
|
||||
make release
|
||||
```
|
||||
|Service|Type|Accès|Description|
|
||||
|-------|----|-----|-----------|
|
||||
|Application React|HTTP (UI)|http://localhost:8080/|Page d'accueil de l'application React (serveur Webpack)|
|
||||
|Interface Web GraphQL|HTTP (UI)|http://localhost:8081/api/v1/playground|Interface Web de développement de l'API GraphQL (mode debug uniquement, nécessite d'être authentifié)|
|
||||
|Serveur GraphQL|HTTP (GraphQL)|http://localhost:8081/api/v1/graphql (POST)|Point d'entrée de l'API GraphQL|
|
||||
|Serveur Hydra|HTTP (ReST)|http://localhost:4444|Point d'entrée pour l'API OAuth2 d'[Hydra](https://www.ory.sh/hydra/docs/)|
|
||||
|Serveur Hydra Passwordless|HTTP|http://localhost:3000|Point d'entrée pour la ["Login/Consent App"](https://www.ory.sh/hydra/docs/implementing-consent) [hydra-passwordless](https://forge.cadoles.com/wpetit/hydra-passwordless)|
|
||||
|Serveur FakeSMTP|HTTP|http://localhost:8082|Interface web du serveur [FakeSMTP](https://forge.cadoles.com/wpetit/fake-smtp)
|
||||
|Serveur PostgreSQL|TCP/IP (PostgreSQL)|`127.0.0.1:5432`|Port de connexion à la base de données PostgreSQL de développement|
|
||||
|
||||
Les archives pour les différentes OS/architectures seront générées dans le répertoire `release`.
|
||||
#### Fichiers/répertoires notables
|
||||
|
||||
|Chemin|Description|
|
||||
|------------------|-----------|
|
||||
|`docker-compose.yml`|Configuration de l'environnement Docker Compose|
|
||||
|`client/src`|Sources du frontend ([React](https://reactjs.org))|
|
||||
|
||||
#### Commandes utiles
|
||||
|
||||
|Commande|Description|
|
||||
|--------|-----------|
|
||||
|`make up`|Démarrer l'environnement Docker Compose, `Ctrl+C` pour le stopper.|
|
||||
|`make down`|Stopper et supprimer l'environnement Docker Compose.|
|
||||
|`make watch`|Suerveiller les sources et recompiler à la volée le client/server.|
|
||||
|`make db-shell`|Ouvrir une console `psql` sur la base de données de développement.|
|
||||
|`make hydra-shell`|Ouvrir un shell interactif dans le conteneur Hydra. (`hydra --help` pour voir les commandes disponibles pour l'administration)|
|
||||
|`make migrate-latest`|Migrer la base de données à la dernière version disponible du schéma.|
|
||||
|`make migrate-down`|Migrer la base de données à la version précédente du schéma.|
|
||||
|`make migrate-up`|Migrer la base de données à la version suivante du schéma.|
|
||||
|`make clean`|Nettoyer l'environnement.|
|
||||
|
||||
## Licence
|
||||
|
||||
[AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.txt)
|
||||
AGPL-3.0
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
/node_modules
|
||||
/dist
|
|
@ -1,47 +1,73 @@
|
|||
{
|
||||
"name": "guesstimate",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"@types/bs58": "^4.0.1",
|
||||
"@types/json-merge-patch": "0.0.4",
|
||||
"@types/react-router-dom": "^5.1.5",
|
||||
"bs58": "^4.0.1",
|
||||
"bulma": "^0.9.4",
|
||||
"bulma-switch": "^2.0.0",
|
||||
"json-merge-patch": "^0.2.3",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-redux": "^7.2.0",
|
||||
"react-router": "^5.2.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"redux-saga": "^1.1.3",
|
||||
"style-loader": "^1.1.4",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@teamsupercell/typings-for-css-modules-loader": "^2.1.1",
|
||||
"@types/react": "^16.9.34",
|
||||
"css-loader": "^3.5.2",
|
||||
"fork-ts-checker-webpack-plugin": "^4.1.3",
|
||||
"html-webpack-plugin": "^4.2.0",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"resolve-url-loader": "^3.1.1",
|
||||
"ts-loader": "^7.0.1",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"webpack-dev-server": "^3.11.0"
|
||||
},
|
||||
"description": "Guesstimate",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "NODE_ENV=development webpack-dev-server --watch",
|
||||
"build": "webpack --progress --profile",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"server": "webpack-dev-server"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@forge.cadoles.com:4242/wpetit/guesstimate.git"
|
||||
"url": "git+https://forge.cadoles.com/Cadoles/daddy.git"
|
||||
},
|
||||
"author": "William Petit <wpetit@cadoles.com>",
|
||||
"license": "AGPL-3.0"
|
||||
"license": "AGPL-3.0",
|
||||
"bugs": {
|
||||
"url": "https://forge.cadoles.com/Cadoles/daddy/issues"
|
||||
},
|
||||
"homepage": "https://forge.cadoles.com/Cadoles/daddy#readme",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-runtime": "^7.7.4",
|
||||
"@babel/preset-env": "^7.7.1",
|
||||
"@babel/preset-react": "^7.7.4",
|
||||
"@commitlint/cli": "^9.1.2",
|
||||
"@commitlint/config-conventional": "^9.1.1",
|
||||
"@fortawesome/fontawesome-free": "^5.11.2",
|
||||
"@teamsupercell/typings-for-css-modules-loader": "^2.2.1",
|
||||
"@types/node": "^13.13.4",
|
||||
"@types/react-dom": "^16.9.7",
|
||||
"@types/react-redux": "^7.1.7",
|
||||
"@types/react-router-dom": "^5.1.5",
|
||||
"@types/uuid": "^7.0.3",
|
||||
"babel-loader": "^8.0.6",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"copy-webpack-plugin": "^6.0.2",
|
||||
"css-loader": "^1.0.1",
|
||||
"extract-loader": "^3.1.0",
|
||||
"file-loader": "^2.0.0",
|
||||
"html-loader": "^0.5.5",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"mini-css-extract-plugin": "^0.4.4",
|
||||
"node-sass": "^4.14.0",
|
||||
"redux-logger": "^3.0.6",
|
||||
"resolve-url-loader": "^3.0.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"ts-loader": "^7.0.2",
|
||||
"webpack": "^4.25.0",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.0.2",
|
||||
"@types/qs": "^6.9.3",
|
||||
"bulma": "^0.9.0",
|
||||
"bulma-switch": "^2.0.0",
|
||||
"graphql": "^15.3.0",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-redux": "^7.1.3",
|
||||
"react-router": "^5.1.2",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"redux": "^4.0.4",
|
||||
"redux-saga": "^1.1.3",
|
||||
"styled-components": "^4.4.1",
|
||||
"subscriptions-transport-ws": "^0.9.17",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 626 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 8.8 KiB |
|
@ -0,0 +1,60 @@
|
|||
import React, { FunctionComponent, useState, useEffect } from 'react';
|
||||
import { BrowserRouter, Route, Redirect, Switch } from "react-router-dom";
|
||||
import { HomePage } from './HomePage/HomePage';
|
||||
import { ProfilePage } from './ProfilePage/ProfilePage';
|
||||
import { DashboardPage } from './DashboardPage/DashboardPage';
|
||||
import { PrivateRoute } from './PrivateRoute';
|
||||
import { useLoggedIn, LoggedInContext, getSavedLoggedIn, saveLoggedIn } from '../hooks/useLoggedIn';
|
||||
import { useUserProfile } from '../gql/queries/user';
|
||||
import { ProjectPage } from './ProjectPage/ProjectPage';
|
||||
import { createClient } from '../util/apollo';
|
||||
import { ApolloProvider } from '@apollo/client';
|
||||
|
||||
export interface AppProps {
|
||||
|
||||
}
|
||||
|
||||
export const App: FunctionComponent<AppProps> = () => {
|
||||
const [ loggedIn, setLoggedIn ] = useState(getSavedLoggedIn());
|
||||
|
||||
const client = createClient((loggedIn) => {
|
||||
setLoggedIn(loggedIn);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
saveLoggedIn(loggedIn);
|
||||
}, [loggedIn]);
|
||||
|
||||
return (
|
||||
<ApolloProvider client={client}>
|
||||
<LoggedInContext.Provider value={loggedIn}>
|
||||
<UserSessionCheck setLoggedIn={setLoggedIn} />
|
||||
<BrowserRouter>
|
||||
<Switch>
|
||||
<Route path="/" exact component={HomePage} />
|
||||
<PrivateRoute path="/profile" exact component={ProfilePage} />
|
||||
<PrivateRoute path="/dashboard" exact component={DashboardPage} />
|
||||
<PrivateRoute path="/projects/:id" exact component={ProjectPage} />
|
||||
<Route component={() => <Redirect to="/" />} />
|
||||
</Switch>
|
||||
</BrowserRouter>
|
||||
</LoggedInContext.Provider>
|
||||
</ApolloProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
interface UserSessionCheckProps {
|
||||
setLoggedIn: (boolean) => void
|
||||
}
|
||||
|
||||
const UserSessionCheck: FunctionComponent<UserSessionCheckProps> = ({ setLoggedIn }) => {
|
||||
const { user, loading } = useUserProfile();
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
setLoggedIn(user.id !== '');
|
||||
}, [user]);
|
||||
|
||||
return null;
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
import React from 'react';
|
||||
import { ProjectPanel } from './ProjectPanel';
|
||||
import { ProjectModelPanel } from './ProjectModelPanel';
|
||||
|
||||
export function Dashboard() {
|
||||
return (
|
||||
<div className="columns">
|
||||
<div className="column is-4">
|
||||
<ProjectPanel />
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
<ProjectModelPanel />
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import React from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { Dashboard } from './Dashboard';
|
||||
import { useUserProfile } from '../../gql/queries/user';
|
||||
|
||||
export function DashboardPage() {
|
||||
const { user } = useUserProfile();
|
||||
return (
|
||||
<Page title="Tableau de bord">
|
||||
<section className="mt-5">
|
||||
<div className="container is-fluid">
|
||||
<h2 className="subtitle is-size-3">Bonjour <span>{user.name !== '' ? user.name : ' utilisateur mystère'}</span> ! Sur quel projet souhaitez vous travailler aujourd'hui ?</h2>
|
||||
<Dashboard />
|
||||
</div>
|
||||
</section>
|
||||
</Page>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
import React, { FunctionComponent, useState, useEffect } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { WithLoader } from "../WithLoader";
|
||||
|
||||
export interface Item {
|
||||
id: string|number
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
export interface TabDefinition {
|
||||
label: string
|
||||
itemFilter?: (item: Item) => boolean
|
||||
}
|
||||
|
||||
|
||||
export interface ItemPanelProps {
|
||||
className?: string
|
||||
itemIconClassName?: string
|
||||
title?: string
|
||||
newItemUrl: string
|
||||
isLoading?: boolean
|
||||
items: Item[]
|
||||
tabs?: TabDefinition[],
|
||||
itemKey: (item: Item, index: number) => string|number
|
||||
itemLabel: (item: Item, index: number) => string
|
||||
itemUrl: (item: Item, index: number) => string
|
||||
}
|
||||
|
||||
export const ItemPanel: FunctionComponent<ItemPanelProps> = (props) => {
|
||||
const {
|
||||
title, className, newItemUrl,
|
||||
itemKey, itemLabel,
|
||||
itemIconClassName, itemUrl
|
||||
} = props;
|
||||
|
||||
const [ state, setState ] = useState({ selectedTab: 0, filteredItems: [] });
|
||||
|
||||
const filterItemsForTab = (tab: TabDefinition, items: Item[]) => {
|
||||
const itemFilter = tab && typeof tab.itemFilter === 'function' ? tab.itemFilter : () => true;
|
||||
return items.filter(itemFilter);
|
||||
};
|
||||
|
||||
const selectTab = (tabIndex: number) => {
|
||||
setState(state => {
|
||||
const { tabs, items } = props;
|
||||
const newTab = Array.isArray(tabs) && tabs.length > 0 ? tabs[tabIndex] : null;
|
||||
return {
|
||||
...state,
|
||||
selectedTab: tabIndex,
|
||||
filteredItems: filterItemsForTab(newTab, items)
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setState(state => {
|
||||
const { tabs, items } = props;
|
||||
const newTab = Array.isArray(tabs) && tabs.length > 0 ? tabs[state.selectedTab] : null;
|
||||
return {
|
||||
...state,
|
||||
filteredItems: filterItemsForTab(newTab, items),
|
||||
}
|
||||
});
|
||||
}, [props.items, props.tabs]);
|
||||
|
||||
const itemElements = state.filteredItems.map((item: Item, i: number) => {
|
||||
return (
|
||||
<Link to={itemUrl(item, i)} key={`item-${itemKey(item, i)}`} className="panel-block">
|
||||
<span className="panel-icon">
|
||||
<i className={itemIconClassName} aria-hidden="true"></i>
|
||||
</span>
|
||||
{itemLabel(item, i)}
|
||||
</Link>
|
||||
);
|
||||
});
|
||||
|
||||
const tabs = props.tabs || [];
|
||||
|
||||
return (
|
||||
<nav className={`panel ${className}`}>
|
||||
<div className="level is-mobile panel-heading mb-0">
|
||||
<div className="level-left">
|
||||
<p className="level-item">{title}</p>
|
||||
</div>
|
||||
<div className="level-right">
|
||||
<Link to={newItemUrl} className="button level-item is-outlined is-info is-inverted">
|
||||
<i className="icon fa fa-plus"></i>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="panel-block">
|
||||
<p className="control has-icons-left">
|
||||
<input className="input" type="text" placeholder="Filtrer..." />
|
||||
<span className="icon is-left">
|
||||
<i className="fas fa-search" aria-hidden="true"></i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<p className="panel-tabs">
|
||||
{
|
||||
tabs.map((tab, i) => {
|
||||
return (
|
||||
<a key={`workgroup-tab-${i}`}
|
||||
onClick={selectTab.bind(null, i)}
|
||||
className={i === state.selectedTab ? 'is-active' : ''}>
|
||||
{tab.label}
|
||||
</a>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
{
|
||||
itemElements.length > 0 ?
|
||||
itemElements :
|
||||
<a className="panel-block has-text-centered is-block">
|
||||
<em>Aucun élément pour l'instant.</em>
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
)
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { ItemPanel } from "./ItemPanel";
|
||||
import { useProjects } from "../../gql/queries/project";
|
||||
|
||||
export interface ProjectModelPanelProps {
|
||||
|
||||
}
|
||||
|
||||
export const ProjectModelPanel: FunctionComponent<ProjectModelPanelProps> = () => {
|
||||
return (
|
||||
<ItemPanel
|
||||
title="Mes modèles de projet"
|
||||
className="is-info"
|
||||
newItemUrl="/models/new"
|
||||
items={[]}
|
||||
itemKey={(item) => { return item.id }}
|
||||
itemLabel={(item) => { return `${item.id}` }}
|
||||
itemUrl={(item) => { return `/models/${item.id}` }}
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { ItemPanel } from "./ItemPanel";
|
||||
import { useProjects } from "../../gql/queries/project";
|
||||
|
||||
export interface ProjectPanelProps {
|
||||
|
||||
}
|
||||
|
||||
export const ProjectPanel: FunctionComponent<ProjectPanelProps> = () => {
|
||||
const { projects } = useProjects({
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
return (
|
||||
<ItemPanel
|
||||
title="Mes projets"
|
||||
className="is-primary"
|
||||
newItemUrl="/projects/new"
|
||||
items={projects}
|
||||
itemIconClassName="fa fa-file"
|
||||
itemKey={(item) => { return item.id }}
|
||||
itemLabel={(item) => { return `#${item.id} - ${item.title ? item.title : 'Projet sans nom'}` }}
|
||||
itemUrl={(item) => { return `/projects/${item.id}` }}
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -17,26 +17,23 @@ const EditableText: FunctionComponent<EditableTextProps> = ({ onChange, value, r
|
|||
const [ internalValue, setInternalValue ] = useState(value);
|
||||
const [ editMode, setEditMode ] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (internalValue === value) return;
|
||||
if (onChange) onChange(internalValue);
|
||||
}, [internalValue]);
|
||||
|
||||
useEffect(() => {
|
||||
setInternalValue(value);
|
||||
}, [value])
|
||||
|
||||
const onEditIconClick = () => {
|
||||
setEditMode(true);
|
||||
setEditMode(true);
|
||||
};
|
||||
|
||||
const onValidateButtonClick = () => {
|
||||
setEditMode(false);
|
||||
setEditMode(false);
|
||||
if (internalValue === value) return;
|
||||
if (onChange) onChange(internalValue);
|
||||
}
|
||||
|
||||
const onValueChange = (evt: ChangeEvent) => {
|
||||
const currentTarget = evt.currentTarget as HTMLInputElement;
|
||||
setInternalValue(currentTarget.value);
|
||||
const currentTarget = evt.currentTarget as HTMLInputElement;
|
||||
setInternalValue(currentTarget.value);
|
||||
};
|
||||
|
||||
return (
|
|
@ -1,13 +1,13 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
declare namespace StyleModuleCssNamespace {
|
||||
export interface IStyleModuleCss {
|
||||
editIcon: string;
|
||||
editableText: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
declare const StyleModuleCssModule: StyleModuleCssNamespace.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
locals: StyleModuleCssNamespace.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -1,8 +1,8 @@
|
|||
import ProjectTimeUnit from "./project-time-unit";
|
||||
import { getRoundUpEstimations } from "../models/params";
|
||||
import { Project } from "../models/project";
|
||||
import ProjectTimeUnit from "./ProjectTimeUnit";
|
||||
import { getRoundUpEstimations } from "../types/params";
|
||||
import { Project } from "../types/project";
|
||||
import React, { Fragment,FunctionComponent } from "react";
|
||||
import { Estimation } from "../hooks/use-project-estimations";
|
||||
import { Estimation } from "../hooks/useProjectEstimations";
|
||||
|
||||
export interface EstimationRangeProps {
|
||||
project: Project,
|
|
@ -0,0 +1,23 @@
|
|||
import React, { useEffect } from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { useUserProfile } from '../../gql/queries/user';
|
||||
import { WelcomeContent } from './WelcomeContent';
|
||||
import { useHistory } from 'react-router';
|
||||
import { useLoggedIn } from '../../hooks/useLoggedIn';
|
||||
|
||||
export function HomePage() {
|
||||
const loggedIn = useLoggedIn();
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
if (loggedIn) history.push('/dashboard');
|
||||
}, [loggedIn]);
|
||||
|
||||
return (
|
||||
<Page title="Accueil">
|
||||
<section className="mt-5">
|
||||
<WelcomeContent />
|
||||
</section>
|
||||
</Page>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
import React, { FunctionComponent, Fragment } from "react";
|
||||
|
||||
export interface WelcomeContentProps {
|
||||
|
||||
}
|
||||
|
||||
export const WelcomeContent: FunctionComponent<WelcomeContentProps> = () => {
|
||||
return (
|
||||
<Fragment>
|
||||
<section className="hero is-normal is-light is-bold">
|
||||
<div className="hero-body has-text-centered">
|
||||
<div className="container">
|
||||
<h1 className="title">
|
||||
Bienvenue sur Guesstimate !
|
||||
</h1>
|
||||
<h2 className="subtitle">
|
||||
La solution pour réaliser simplement des estimations de temps pour vos projets.
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div className="box cta">
|
||||
<p className="has-text-centered">
|
||||
<span className="tag is-info">Attention</span> Le service est actuellement en alpha. L'accès est restreint aux adresses autorisées.
|
||||
</p>
|
||||
</div>
|
||||
<section className="container mt-5">
|
||||
<div className="columns">
|
||||
<div className="column is-4">
|
||||
<div className="card is-shady">
|
||||
<div className="card-image has-text-centered">
|
||||
<i className="fa fa-at mt-5" style={{fontSize: '8rem'}}></i>
|
||||
</div>
|
||||
<div className="card-content">
|
||||
<div className="content">
|
||||
<h4>Une adresse courriel et c'est parti !</h4>
|
||||
<p>Pas de création de compte, pas de mot de passe à retenir. Entrez votre adresse courriel et commencez directement à travailler !</p>
|
||||
{/* <p><a href="#">En savoir plus</a></p> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
<div className="card is-shady">
|
||||
<div className="card-image has-text-centered">
|
||||
<i className="fa fa-edit mt-5" style={{fontSize: '8rem'}}></i>
|
||||
</div>
|
||||
<div className="card-content">
|
||||
<div className="content">
|
||||
<h4>Un méthode simple et efficace.</h4>
|
||||
<p>Découpez votre projet en tâches, faites l'estimation de temps <b>optimiste</b>, <b>probable</b> et <b>pessimiste</b> et obtenez en temps réel vos estimations de temps/financières avec leurs indices de confiance.</p>
|
||||
{/* <p><a href="#">En savoir plus</a></p> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
<div className="card is-shady">
|
||||
<div className="card-image has-text-centered">
|
||||
<i className="fa fa-users mt-5" style={{fontSize: '8rem'}}></i>
|
||||
</div>
|
||||
<div className="card-content">
|
||||
<div className="content">
|
||||
<h4>Partagez simplement vos estimations.</h4>
|
||||
<p>Une adresse courriel et votre estimation est partagée ! Le niveau d'accès (lecture seule, écriture, vue partielle...) peut être défini pour chaque partage.</p>
|
||||
{/* <p><a href="#">En savoir plus</a></p> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
import React, { PropsWithChildren } from 'react';
|
||||
|
||||
export interface ModalProps {
|
||||
active: boolean
|
||||
showCloseButton?: boolean
|
||||
onClose?: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
||||
}
|
||||
|
||||
export class Modal extends React.PureComponent<PropsWithChildren<ModalProps>> {
|
||||
render() {
|
||||
const { children, active, showCloseButton, onClose } = this.props;
|
||||
return (
|
||||
<div className={`modal ${active ? 'is-active': ''}`}>
|
||||
<div className="modal-background"></div>
|
||||
<div className="modal-content">
|
||||
{children}
|
||||
</div>
|
||||
{
|
||||
showCloseButton ?
|
||||
<button onClick={onClose} className="modal-close is-large" aria-label="close"></button> :
|
||||
null
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
import React, { Fragment, useState } from 'react';
|
||||
import { Config } from '../config';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useUserProfile } from '../gql/queries/user';
|
||||
import { WithLoader } from './WithLoader';
|
||||
import { useLoggedIn } from '../hooks/useLoggedIn';
|
||||
|
||||
export function Navbar() {
|
||||
const loggedIn = useLoggedIn();
|
||||
const [ isActive, setActive ] = useState(false);
|
||||
|
||||
const toggleMenu = () => {
|
||||
setActive(active => !active);
|
||||
};
|
||||
|
||||
return (
|
||||
<nav className="navbar is-fixed-top" role="navigation" aria-label="main navigation">
|
||||
<div className="container is-fluid">
|
||||
<div className="navbar-brand">
|
||||
<Link className="navbar-item" to={loggedIn ? '/dashboard' : '/'}>
|
||||
<h1 className="is-size-4">
|
||||
<i className="fa fa-stopwatch mr-1"></i>
|
||||
<span className="has-text-dark">Guessti</span><span className="has-text-grey">Mate</span>
|
||||
</h1>
|
||||
</Link>
|
||||
<a role="button"
|
||||
className={`navbar-burger ${isActive ? 'is-active' : ''}`}
|
||||
onClick={toggleMenu}
|
||||
aria-label="menu"
|
||||
aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div className={`navbar-menu ${isActive ? 'is-active' : ''}`}>
|
||||
<div className="navbar-end">
|
||||
<div className="navbar-item">
|
||||
<div className="buttons">
|
||||
{
|
||||
loggedIn ?
|
||||
<Fragment>
|
||||
<Link to="/profile" className="button">
|
||||
<span className="icon">
|
||||
<i className="fas fa-user"></i>
|
||||
</span>
|
||||
</Link>
|
||||
<a className="button" href={Config.logoutURL}>
|
||||
<span className="icon">
|
||||
<i className="fas fa-sign-out-alt"></i>
|
||||
</span>
|
||||
</a>
|
||||
</Fragment> :
|
||||
<a className="button is-primary" href={Config.loginURL}>
|
||||
<span className="icon">
|
||||
<i className="fas fa-sign-in-alt"></i>
|
||||
</span>
|
||||
<span>Se connecter</span>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
import React from 'react';
|
||||
import { Navbar } from './Navbar';
|
||||
|
||||
export interface PageProps {
|
||||
title?: string
|
||||
}
|
||||
|
||||
export class Page extends React.PureComponent<PageProps> {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Navbar />
|
||||
{this.props.children}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.updateTitle();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.updateTitle();
|
||||
}
|
||||
|
||||
updateTitle() {
|
||||
const { title } = this.props;
|
||||
if (title !== undefined) window.document.title = title + ' - Guesstimate';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import React, { FunctionComponent, Component, ReactType } from "react"
|
||||
import { Route, Redirect, RouteProps } from "react-router"
|
||||
import { useLoggedIn } from "../hooks/useLoggedIn";
|
||||
|
||||
export interface PrivateRouteProps extends RouteProps {
|
||||
}
|
||||
|
||||
export const PrivateRoute: FunctionComponent<PrivateRouteProps> = ({component: Component, ...rest}) => {
|
||||
const loggedIn = useLoggedIn();
|
||||
return (
|
||||
<Route
|
||||
{...rest}
|
||||
render={(props) => loggedIn === true
|
||||
? <Component {...props} />
|
||||
: <Redirect to={{pathname: '/', state: {from: props.location}}} />}
|
||||
/>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import React from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { UserForm } from '../UserForm';
|
||||
import { User } from '../../types/user';
|
||||
import { useUserProfile } from '../../gql/queries/user';
|
||||
import { useUpdateUserMutation } from '../../gql/mutations/user';
|
||||
import { WithLoader } from '../WithLoader';
|
||||
|
||||
export function ProfilePage() {
|
||||
const { user, loading } = useUserProfile();
|
||||
const [ updateUser, updateUserMutation ] = useUpdateUserMutation();
|
||||
const isLoading = updateUserMutation.loading || loading;
|
||||
|
||||
const onUserChange = (updatedUser: User) => {
|
||||
if (user.name !== updatedUser.name) {
|
||||
updateUser({ variables: {id: user.id, changes: { name: updatedUser.name }}});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Page title="Mon profil">
|
||||
<div className="container is-fluid">
|
||||
<section className="section">
|
||||
<div className="columns">
|
||||
<div className="column is-6 is-offset-3">
|
||||
<div className="box">
|
||||
<h2 className="is-size-2 subtitle">Mon profil</h2>
|
||||
<WithLoader loading={isLoading || !user}>
|
||||
{
|
||||
<UserForm onChange={onUserChange} user={user} />
|
||||
}
|
||||
</WithLoader>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import React, { FunctionComponent, Fragment } from "react";
|
||||
import { Project } from "../../types/project";
|
||||
import TaskTable from "./TasksTable";
|
||||
import { TimePreview } from "./TimePreview";
|
||||
import FinancialPreview from "./FinancialPreview";
|
||||
import { addTask, updateTaskEstimation, removeTask, updateTaskLabel, ProjectReducerActions } from "../../hooks/useProjectReducer";
|
||||
import { Task, TaskID, EstimationConfidence } from "../../types/task";
|
||||
import RepartitionPreview from "./RepartitionPreview";
|
||||
import { getHideFinancialPreviewOnPrint } from "../../types/params";
|
||||
|
||||
export interface EstimationTabProps {
|
||||
project: Project
|
||||
dispatch: (action: ProjectReducerActions) => void
|
||||
}
|
||||
|
||||
const EstimationTab: FunctionComponent<EstimationTabProps> = ({ project, dispatch }) => {
|
||||
const onTaskAdd = (task: Task) => {
|
||||
dispatch(addTask(task));
|
||||
};
|
||||
|
||||
const onTaskRemove = (id: number) => {
|
||||
dispatch(removeTask(id));
|
||||
}
|
||||
|
||||
const onTaskLabelUpdate = (id: number, label: string) => {
|
||||
dispatch(updateTaskLabel(id, label));
|
||||
}
|
||||
|
||||
const onEstimationChange = (id: number, confidence: EstimationConfidence, value: number) => {
|
||||
dispatch(updateTaskEstimation(id, confidence, value));
|
||||
};
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="columns">
|
||||
<div className="column is-9">
|
||||
<TaskTable
|
||||
project={project}
|
||||
onTaskAdd={onTaskAdd}
|
||||
onTaskRemove={onTaskRemove}
|
||||
onTaskLabelUpdate={onTaskLabelUpdate}
|
||||
onEstimationChange={onEstimationChange} />
|
||||
</div>
|
||||
<div className="column is-3">
|
||||
<TimePreview project={project} />
|
||||
<RepartitionPreview project={project} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="columns">
|
||||
<div className={`column ${getHideFinancialPreviewOnPrint(project) ? 'noPrint': ''}`}>
|
||||
<FinancialPreview project={project} />
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
Object.keys(project.tasks).length <= 20 ?
|
||||
<div className="message noPrint">
|
||||
<div className="message-body">
|
||||
<p><strong>⚠️ Attention</strong></p>
|
||||
<p>Votre projet ne contient pas assez de tâches pour que les niveaux de confiance soient fiables. Un minimum de 20 tâches est conseillé pour obtenir une estimation pertinente.</p>
|
||||
</div>
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
<hr />
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default EstimationTab;
|
|
@ -1,5 +1,5 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Project } from "../../models/project";
|
||||
import { Project } from "../../types/project";
|
||||
|
||||
export interface ExportTabProps {
|
||||
project: Project
|
|
@ -1,10 +1,9 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Project } from "../../models/project";
|
||||
import { useProjectEstimations } from "../../hooks/use-project-estimations";
|
||||
import { getCurrency, defaults, getTaskCategoryCost, getRoundUpEstimations } from "../../models/params";
|
||||
import { getMinMaxCosts, Cost } from "../../util/stat";
|
||||
import { Project, getMinMaxCosts, Cost } from "../../types/project";
|
||||
import { useProjectEstimations } from "../../hooks/useProjectEstimations";
|
||||
import { getCurrency, defaults, getTaskCategoryCost, getRoundUpEstimations } from "../../types/params";
|
||||
import * as style from './style.module.css';
|
||||
import ProjectTimeUnit from "../../components/project-time-unit";
|
||||
import ProjectTimeUnit from "../ProjectTimeUnit";
|
||||
|
||||
export interface FinancialPreviewProps {
|
||||
project: Project
|
||||
|
@ -21,7 +20,7 @@ const FinancialPreview: FunctionComponent<FinancialPreviewProps> = ({ project })
|
|||
<tr>
|
||||
<th colSpan={2}>
|
||||
<span>Prévisionnel financier</span><br />
|
||||
<span className="is-size-7 has-text-weight-normal">confiance >= 99.7%</span>
|
||||
<span className="is-size-7 has-text-weight-normal">confiance >= 99.7%</span>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -65,7 +64,7 @@ export const CostDetails:FunctionComponent<CostDetailsProps> = ({ project, cost,
|
|||
<tbody>
|
||||
{
|
||||
Object.keys(cost.details).map(taskCategoryId => {
|
||||
const taskCategory = project.params.taskCategories[taskCategoryId];
|
||||
const taskCategory = project.taskCategories[parseInt(taskCategoryId)];
|
||||
const details = cost.details[taskCategoryId];
|
||||
return (
|
||||
<tr key={`task-category-cost-${taskCategory.id}`}>
|
|
@ -1,10 +1,9 @@
|
|||
import React, { FunctionComponent, Fragment, useState, ChangeEvent, MouseEvent } from "react";
|
||||
import { Project } from "../../models/project";
|
||||
import { ProjectReducerActions, updateParam } from "../../hooks/use-project-reducer";
|
||||
import { getRoundUpEstimations, getCurrency, getTimeUnit, getHideFinancialPreviewOnPrint } from "../../models/params";
|
||||
import TaskCategoriesTable from "./task-categories-table";
|
||||
import { Project } from "../../types/project";
|
||||
import { ProjectReducerActions, updateParam } from "../../hooks/useProjectReducer";
|
||||
import { getRoundUpEstimations, getCurrency, getTimeUnit, getHideFinancialPreviewOnPrint } from "../../types/params";
|
||||
import TaskCategoriesTable from "./TaskCategorieTable";
|
||||
import { useHistory } from "react-router";
|
||||
import { getProjectStorageKey } from "../../util/storage";
|
||||
|
||||
export interface ParamsTabProps {
|
||||
project: Project
|
||||
|
@ -48,9 +47,7 @@ const ParamsTab: FunctionComponent<ParamsTabProps> = ({ project, dispatch }) =>
|
|||
};
|
||||
|
||||
const onDeleteProjectClick = (evt: MouseEvent) => {
|
||||
const projectStorageKey = getProjectStorageKey(project.id);
|
||||
window.localStorage.removeItem(projectStorageKey);
|
||||
history.push('/');
|
||||
// TODO
|
||||
};
|
||||
|
||||
return (
|
|
@ -0,0 +1,75 @@
|
|||
import React, { FunctionComponent, useEffect } from "react";
|
||||
import style from "./style.module.css";
|
||||
import { newProject, Project } from "../../types/project";
|
||||
import { useProjectReducer, updateProjectTitle, resetProject } from "../../hooks/useProjectReducer";
|
||||
import EditableText from "../EditableText/EditableText";
|
||||
import Tabs from "../../components/Tabs/Tabs";
|
||||
import EstimationTab from "./EstimationTab";
|
||||
import ParamsTab from "./ParamsTab";
|
||||
import ExportTab from "./ExportTab";
|
||||
import { useParams, useHistory } from "react-router";
|
||||
import { Page } from "../Page";
|
||||
import { useProjects } from "../../gql/queries/project";
|
||||
|
||||
export interface ProjectProps {
|
||||
projectId: string
|
||||
}
|
||||
|
||||
export const ProjectPage: FunctionComponent<ProjectProps> = () => {
|
||||
const { id } = useParams();
|
||||
const isNew = id === 'new';
|
||||
const projectId = isNew ? undefined : parseInt(id);
|
||||
const { projects } = useProjects({ variables: { filter: {ids: projectId !== undefined ? [projectId] : undefined} }});
|
||||
const [ project, dispatch ] = useProjectReducer(newProject(projectId));
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
history.push(`/projects/${project.id}`);
|
||||
}, [project.id])
|
||||
|
||||
useEffect(() => {
|
||||
if (isNew || projects.length === 0) return;
|
||||
dispatch(resetProject(projects[0]));
|
||||
}, [projects.length]);
|
||||
|
||||
const onProjectTitleChange = (projectTitle: string) => {
|
||||
if (project.title === projectTitle) return;
|
||||
dispatch(updateProjectTitle(projectTitle));
|
||||
};
|
||||
|
||||
return (
|
||||
<Page title="Projet">
|
||||
<div className="container is-fluid">
|
||||
<div className="columns">
|
||||
<div className="column mt-3 is-10">
|
||||
<EditableText
|
||||
editIconClass="is-size-4"
|
||||
render={(value) => (<h2 className="is-size-3">{value}</h2>)}
|
||||
onChange={onProjectTitleChange}
|
||||
value={project.title ? project.title : "Projet sans nom"}
|
||||
/>
|
||||
<div className={`box mt-3 ${style.tabContainer}`}>
|
||||
<Tabs items={[
|
||||
{
|
||||
label: 'Estimation',
|
||||
icon: 'fa fa-clipboard',
|
||||
render: () => <EstimationTab project={project} dispatch={dispatch} />
|
||||
},
|
||||
{
|
||||
label: 'Options avancées',
|
||||
icon: 'fa fa-sliders-h',
|
||||
render: () => <ParamsTab project={project} dispatch={dispatch} />
|
||||
},
|
||||
{
|
||||
label: 'Exporter',
|
||||
icon: 'fa fa-file-export',
|
||||
render: () => <ExportTab project={project} />
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Project, getTaskCategoriesMeanRepartition } from "../../types/project";
|
||||
|
||||
export interface RepartitionPreviewProps {
|
||||
project: Project
|
||||
}
|
||||
|
||||
const RepartitionPreview: FunctionComponent<RepartitionPreviewProps> = ({ project }) => {
|
||||
const repartition = getTaskCategoriesMeanRepartition(project);
|
||||
return (
|
||||
<div className="table-container">
|
||||
<table className="table is-bordered is-striped is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colSpan={2}>Répartition moyenne</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Catégorie</th>
|
||||
<th>Temps (en %)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
Object.values(project.taskCategories).map(tc => {
|
||||
let percent = (repartition[tc.id] * 100).toFixed(0);
|
||||
return (
|
||||
<tr key={`task-category-${tc.id}`}>
|
||||
<td>{tc.label}</td>
|
||||
<td>{percent} %</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default RepartitionPreview;
|
|
@ -1,10 +1,10 @@
|
|||
import React, { FunctionComponent, useState, MouseEvent, ChangeEvent } from "react";
|
||||
import { Project } from "../../models/project";
|
||||
import { Project } from "../../types/project";
|
||||
import style from './style.module.css';
|
||||
import { ProjectReducerActions, updateTaskCategoryCost, updateTaskCategoryLabel, removeTaskCategory, addTaskCategory } from "../../hooks/use-project-reducer";
|
||||
import EditableText from "../../components/editable-text";
|
||||
import { TaskCategoryID, createTaskCategory } from "../../models/task";
|
||||
import { getCurrency, getTaskCategoryCost } from "../../models/params";
|
||||
import { ProjectReducerActions, updateTaskCategoryCost, updateTaskCategoryLabel, removeTaskCategory, addTaskCategory } from "../../hooks/useProjectReducer";
|
||||
import EditableText from "../EditableText/EditableText";
|
||||
import { TaskCategoryID, createTaskCategory } from "../../types/task";
|
||||
import { getCurrency, getTaskCategoryCost } from "../../types/params";
|
||||
|
||||
export interface TaskCategoriesTableProps {
|
||||
project: Project
|
||||
|
@ -55,7 +55,7 @@ const TaskCategoriesTable: FunctionComponent<TaskCategoriesTableProps> = ({ proj
|
|||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
Object.values(project.params.taskCategories).map(tc => {
|
||||
Object.values(project.taskCategories).map(tc => {
|
||||
return (
|
||||
<tr key={`task-category-${tc.id}`}>
|
||||
<td>
|
|
@ -0,0 +1,203 @@
|
|||
import React, { FunctionComponent, useState, useEffect, ChangeEvent, MouseEvent } from "react";
|
||||
import style from "./style.module.css";
|
||||
import { Project } from "../../types/project";
|
||||
import { newTask, Task, TaskID, EstimationConfidence } from "../../types/task";
|
||||
import EditableText from "../EditableText/EditableText";
|
||||
import { usePrintMediaQuery } from "../../hooks/useMediaQuery";
|
||||
import ProjectTimeUnit from "../ProjectTimeUnit";
|
||||
|
||||
export interface TaskTableProps {
|
||||
project: Project
|
||||
onTaskAdd: (task: Task) => void
|
||||
onTaskRemove: (taskId: number) => void
|
||||
onEstimationChange: (taskId: number, confidence: EstimationConfidence, value: number) => void
|
||||
onTaskLabelUpdate: (taskId: number, label: string) => void
|
||||
}
|
||||
|
||||
export type EstimationTotals = { [confidence in EstimationConfidence]: number }
|
||||
|
||||
const TaskTable: FunctionComponent<TaskTableProps> = ({ project, onTaskAdd, onEstimationChange, onTaskRemove, onTaskLabelUpdate }) => {
|
||||
const [ task, setTask ] = useState(newTask("", null));
|
||||
const [ totals, setTotals ] = useState({
|
||||
[EstimationConfidence.Optimistic]: 0,
|
||||
[EstimationConfidence.Likely]: 0,
|
||||
[EstimationConfidence.Pessimistic]: 0,
|
||||
} as EstimationTotals);
|
||||
|
||||
useEffect(() => {
|
||||
if (project.taskCategories.length === 0) return;
|
||||
setTask({...task, category: project.taskCategories[0]});
|
||||
}, [project.taskCategories]);
|
||||
|
||||
const isPrint = usePrintMediaQuery();
|
||||
|
||||
useEffect(() => {
|
||||
let optimistic = 0;
|
||||
let likely = 0;
|
||||
let pessimistic = 0;
|
||||
|
||||
project.tasks.forEach(t => {
|
||||
optimistic += t.estimations.optimistic;
|
||||
likely += t.estimations.likely;
|
||||
pessimistic += t.estimations.pessimistic;
|
||||
});
|
||||
|
||||
setTotals({ optimistic, likely, pessimistic });
|
||||
}, [project.tasks]);
|
||||
|
||||
const onNewTaskLabelChange = (evt: ChangeEvent) => {
|
||||
const value = (evt.currentTarget as HTMLInputElement).value;
|
||||
setTask({...task, label: value});
|
||||
};
|
||||
|
||||
const onNewTaskCategoryChange = (evt: ChangeEvent) => {
|
||||
const value = (evt.currentTarget as HTMLInputElement).value;
|
||||
const taskCategoryId = parseInt(value);
|
||||
const category = project.taskCategories.find(tc => tc.id === taskCategoryId);
|
||||
setTask({...task, category });
|
||||
};
|
||||
|
||||
const onTaskLabelChange = (taskId: number, value: string) => {
|
||||
onTaskLabelUpdate(taskId, value);
|
||||
};
|
||||
|
||||
const onAddTaskClick = (evt: MouseEvent) => {
|
||||
onTaskAdd(task);
|
||||
setTask(newTask("", project.taskCategories[0]));
|
||||
};
|
||||
|
||||
const onTaskRemoveClick = (taskId: number, evt: MouseEvent) => {
|
||||
onTaskRemove(taskId);
|
||||
};
|
||||
|
||||
const withEstimationChange = (confidence: EstimationConfidence, taskId: number, evt: ChangeEvent) => {
|
||||
const textValue = (evt.currentTarget as HTMLInputElement).value;
|
||||
const value = parseFloat(textValue);
|
||||
onEstimationChange(taskId, confidence, value);
|
||||
};
|
||||
|
||||
const onOptimisticChange = withEstimationChange.bind(null, EstimationConfidence.Optimistic);
|
||||
const onLikelyChange = withEstimationChange.bind(null, EstimationConfidence.Likely);
|
||||
const onPessimisticChange = withEstimationChange.bind(null, EstimationConfidence.Pessimistic);
|
||||
|
||||
return (
|
||||
<div className="table-container">
|
||||
<table className={`table is-bordered is-striped is-hoverable is-fullwidth ${style.middleTable}`}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className={`${style.noBorder} noPrint`} rowSpan={2}></th>
|
||||
<th className={style.mainColumn} rowSpan={2}>Tâche</th>
|
||||
<th rowSpan={2}>Catégorie</th>
|
||||
<th colSpan={3}>Estimation (en <ProjectTimeUnit project={project} />)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Optimiste</th>
|
||||
<th>Probable</th>
|
||||
<th>Pessimiste</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
project.tasks.map((t,i) => {
|
||||
const category = project.taskCategories.find(tc => tc.id === t.category.id);
|
||||
const categoryLabel = category ? category.label : '???';
|
||||
return (
|
||||
<tr key={`tasks-${t.id}-${i}`}>
|
||||
<td className={`is-narrow noPrint`}>
|
||||
<button
|
||||
onClick={onTaskRemoveClick.bind(null, t.id)}
|
||||
className="button is-danger is-small is-outlined">
|
||||
🗑️
|
||||
</button>
|
||||
</td>
|
||||
<td className={style.mainColumn}>
|
||||
<EditableText
|
||||
render={(value) => (<span>{value}</span>)}
|
||||
onChange={onTaskLabelChange.bind(null, t.id)}
|
||||
value={t.label} />
|
||||
</td>
|
||||
<td>{ categoryLabel }</td>
|
||||
<td>
|
||||
{
|
||||
isPrint ?
|
||||
<span>{t.estimations.optimistic}</span> :
|
||||
<input className="input" type="number" value={t.estimations.optimistic}
|
||||
min={0}
|
||||
onChange={onOptimisticChange.bind(null, t.id)} />
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{
|
||||
isPrint ?
|
||||
<span>{t.estimations.likely}</span> :
|
||||
<input className="input" type="number" value={t.estimations.likely}
|
||||
min={0}
|
||||
onChange={onLikelyChange.bind(null, t.id)} />
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{
|
||||
isPrint ?
|
||||
<span>{t.estimations.pessimistic}</span> :
|
||||
<input className="input" type="number" value={t.estimations.pessimistic}
|
||||
min={0}
|
||||
onChange={onPessimisticChange.bind(null, t.id)} />
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
Object.keys(project.tasks).length === 0 ?
|
||||
<tr>
|
||||
<td className={`${style.noBorder} noPrint`}></td>
|
||||
<td className={style.noTasks} colSpan={5}>Aucune tâche pour l'instant.</td>
|
||||
</tr> :
|
||||
null
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td className={`${style.noBorder} noPrint`}></td>
|
||||
<td colSpan={2} className={isPrint ? style.noBorder : ''}>
|
||||
<div className="field has-addons noPrint">
|
||||
<p className="control is-expanded">
|
||||
<input className="input" type="text" placeholder="Nouvelle tâche"
|
||||
value={task.label} onChange={onNewTaskLabelChange} />
|
||||
</p>
|
||||
<p className="control">
|
||||
<span className="select">
|
||||
<select onChange={onNewTaskCategoryChange} value={task.category ? task.category.id : -1}>
|
||||
{
|
||||
Object.values(project.taskCategories).map(tc => {
|
||||
return (
|
||||
<option key={`task-category-${tc.id}`} value={tc.id}>{tc.label}</option>
|
||||
);
|
||||
})
|
||||
}
|
||||
</select>
|
||||
</span>
|
||||
</p>
|
||||
<p className="control">
|
||||
<a className="button is-primary" onClick={onAddTaskClick}>
|
||||
Ajouter
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<th colSpan={3}>Total</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colSpan={isPrint ? 2 : 3} className={style.noBorder}></td>
|
||||
<td>{totals.optimistic} <ProjectTimeUnit project={project} /></td>
|
||||
<td>{totals.likely} <ProjectTimeUnit project={project} /></td>
|
||||
<td>{totals.pessimistic} <ProjectTimeUnit project={project} /></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TaskTable;
|
|
@ -0,0 +1,48 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Project } from "../../types/project";
|
||||
import { useProjectEstimations } from "../../hooks/useProjectEstimations";
|
||||
import EstimationRange from "../EstimationRange";
|
||||
|
||||
export interface TimePreviewProps {
|
||||
project: Project
|
||||
}
|
||||
|
||||
export const TimePreview: FunctionComponent<TimePreviewProps> = ({ project }) => {
|
||||
const estimations = useProjectEstimations(project);
|
||||
return (
|
||||
<div className="table-container">
|
||||
<table className="table is-bordered is-striped is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colSpan={2}>Prévisionnel temps</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th className="is-narrow">Confiance</th>
|
||||
<th>Estimation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="is-narrow">>= 99.7%</td>
|
||||
<td><EstimationRange project={project} estimation={estimations.p99} /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="is-narrow">>= 90%</td>
|
||||
<td><EstimationRange project={project} estimation={estimations.p90} /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="is-narrow">>= 68%</td>
|
||||
<td><EstimationRange project={project} estimation={estimations.p68} /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot className="noPrint">
|
||||
<tr>
|
||||
<td colSpan={2}>
|
||||
<a className="is-small is-pulled-right" href="https://en.wikipedia.org/wiki/Three-point_estimation" target="_blank">❓ Estimation à 3 points</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
declare namespace StyleModuleCssNamespace {
|
||||
export interface IStyleModuleCss {
|
||||
estimation: string;
|
||||
mainColumn: string;
|
||||
|
@ -9,9 +9,9 @@ declare namespace StyleModuleCssModule {
|
|||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
declare const StyleModuleCssModule: StyleModuleCssNamespace.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
locals: StyleModuleCssNamespace.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -1,6 +1,6 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Project } from "../models/project";
|
||||
import { getTimeUnit } from "../models/params";
|
||||
import { Project } from "../types/project";
|
||||
import { getTimeUnit } from "../types/params";
|
||||
|
||||
export interface ProjectTimeUnitProps {
|
||||
project: Project
|
|
@ -23,7 +23,7 @@ const Tabs: FunctionComponent<TabsProps> = ({ items, ...props }) => {
|
|||
|
||||
return (
|
||||
<div className={`${style.tabs} ${props.class}`}>
|
||||
<div className="tabs">
|
||||
<div className="tabs is-boxed">
|
||||
<ul className={`noPrint`}>
|
||||
{
|
||||
items.map((tabItem, tabIndex) => (
|
||||
|
@ -31,8 +31,8 @@ const Tabs: FunctionComponent<TabsProps> = ({ items, ...props }) => {
|
|||
onClick={onTabClick.bind(null, tabIndex)}
|
||||
className={`${selectedTabIndex === tabIndex ? 'is-active' : ''}`}>
|
||||
<a>
|
||||
<span className="icon is-small">{tabItem.icon}</span>
|
||||
{tabItem.label}
|
||||
<span className={`icon is-small`}><i className={`${tabItem.icon}`}></i></span>
|
||||
<span>{tabItem.label}</span>
|
||||
</a>
|
||||
</li>
|
||||
))
|
|
@ -1,13 +1,13 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
declare namespace StyleModuleCssNamespace {
|
||||
export interface IStyleModuleCss {
|
||||
tabContent: string;
|
||||
tabs: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
declare const StyleModuleCssModule: StyleModuleCssNamespace.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
locals: StyleModuleCssNamespace.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -0,0 +1,93 @@
|
|||
import React, { useState, ChangeEvent, useEffect } from 'react';
|
||||
import { User } from '../types/user';
|
||||
|
||||
export interface UserFormProps {
|
||||
user: User
|
||||
onChange?: (user: User) => void
|
||||
}
|
||||
|
||||
export function UserForm({ user, onChange }: UserFormProps) {
|
||||
const [ state, setState ] = useState({
|
||||
changed: false,
|
||||
user: {
|
||||
id: user && user.id ? user.id : '',
|
||||
name: user && user.name ? user.name : '',
|
||||
email: user && user.email ? user.email : '',
|
||||
createdAt: user && user.createdAt ? user.createdAt : null,
|
||||
connectedAt: user && user.connectedAt ? user.connectedAt : null,
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setState({
|
||||
changed: false,
|
||||
user: {
|
||||
id: user && user.id ? user.id : '',
|
||||
name: user && user.name ? user.name : '',
|
||||
email: user && user.email ? user.email : '',
|
||||
createdAt: user && user.createdAt ? user.createdAt : null,
|
||||
connectedAt: user && user.connectedAt ? user.connectedAt : null,
|
||||
}
|
||||
});
|
||||
}, [user]);
|
||||
|
||||
const onSaveClick = () => {
|
||||
if (!state.changed) return;
|
||||
if (typeof onChange !== 'function') return;
|
||||
onChange(state.user);
|
||||
setState(state => {
|
||||
return {
|
||||
...state,
|
||||
changed: false,
|
||||
};
|
||||
})
|
||||
};
|
||||
|
||||
const onUserAttrChange = function(attrName: string, evt: ChangeEvent<HTMLInputElement>) {
|
||||
const value = evt.currentTarget.value;
|
||||
setState(state => {
|
||||
return {
|
||||
...state,
|
||||
changed: true,
|
||||
user: {
|
||||
...state.user,
|
||||
[attrName]: value,
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="form">
|
||||
<div className="field">
|
||||
<label className="label">Nom d'utilisateur</label>
|
||||
<div className="control">
|
||||
<input type="text" className="input" value={state.user.name}
|
||||
onChange={onUserAttrChange.bind(null, "name")} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="label">Adresse courriel</label>
|
||||
<div className="control">
|
||||
<p className="input is-static">{state.user.email}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="label">Date de dernière connexion</label>
|
||||
<div className="control">
|
||||
<p className="input is-static">{state.user.connectedAt}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="label">Date de création</label>
|
||||
<div className="control">
|
||||
<p className="input is-static">{state.user.createdAt}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="buttons is-right">
|
||||
<button disabled={!state.changed}
|
||||
className="button is-primary" onClick={onSaveClick}>Enregistrer</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import React, { Fragment, PropsWithChildren, FunctionComponent } from 'react';
|
||||
|
||||
export interface WithLoaderProps {
|
||||
loading?: boolean|boolean[]
|
||||
}
|
||||
|
||||
export const WithLoader: FunctionComponent<WithLoaderProps> = ({ loading, children }) => {
|
||||
const isLoading = Array.isArray(loading) ? loading.some(l => l) : loading;
|
||||
return (
|
||||
<Fragment>
|
||||
{
|
||||
isLoading ?
|
||||
<div>Chargement</div> :
|
||||
children
|
||||
}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
||||
|
||||
import Home from "../routes/home/index";
|
||||
import Project from "../routes/project/index";
|
||||
import NotFound from '../routes/notfound/index';
|
||||
import Header from "./header/index";
|
||||
import Footer from "./footer";
|
||||
|
||||
const App: FunctionComponent = () => {
|
||||
return (
|
||||
<div id="app">
|
||||
<Header class="noPrint" />
|
||||
<Router>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home} />
|
||||
<Route exact path="/p/:projectId" component={Project} />
|
||||
<Route component={NotFound} />
|
||||
</Switch>
|
||||
</Router>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
|
@ -1,29 +0,0 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import style from "./style.module.css";
|
||||
import { formatDate } from "../../util/date";
|
||||
|
||||
declare var __BUILD__: any;
|
||||
|
||||
export interface FooterProps {
|
||||
class?: string
|
||||
}
|
||||
|
||||
const Footer: FunctionComponent<FooterProps> = ({ ...props}) => {
|
||||
return (
|
||||
<div className={`container ${style.footer} ${props.class ? props.class : ''}`}>
|
||||
<div className="columns">
|
||||
<div className="column is-4 is-offset-8">
|
||||
<p className="has-text-right is-size-7">
|
||||
Propulsé par <a className="has-text-primary" href="https://forge.cadoles.com/wpetit/guesstimate">Guesstimate</a> et publié sous licence <a className="has-text-primary" href="https://www.gnu.org/licenses/agpl-3.0.txt">AGPL-3.0</a>.
|
||||
</p>
|
||||
<p className="has-text-right is-size-7">
|
||||
Réf.: {__BUILD__.gitRef ? __BUILD__.gitRef : '??'} |
|
||||
Date de construction: {__BUILD__.buildDate ? formatDate(__BUILD__.buildDate) : '??'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
|
@ -1,3 +0,0 @@
|
|||
.footer {
|
||||
display: inherit;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
export interface IStyleModuleCss {
|
||||
footer: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -1,31 +0,0 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import style from "./style.module.css";
|
||||
|
||||
export interface HeaderProps {
|
||||
class?: string
|
||||
}
|
||||
|
||||
const Header: FunctionComponent<HeaderProps> = ({ ...props}) => {
|
||||
return (
|
||||
<div className={`container ${style.header} ${props.class ? props.class : ''}`}>
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<nav className="navbar" role="navigation" aria-label="main navigation">
|
||||
<div className="navbar-brand">
|
||||
<a className="navbar-item" href="/">
|
||||
<h1 className="title is-size-4">⏱️ Guesstimate</h1>
|
||||
</a>
|
||||
<a role="button" className="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
|
@ -1,3 +0,0 @@
|
|||
.header {
|
||||
display: inherit;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
export interface IStyleModuleCss {
|
||||
header: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -0,0 +1,15 @@
|
|||
export const Config = {
|
||||
loginURL: get<string>("loginURL", "http://localhost:8081/login"),
|
||||
logoutURL: get<string>("logoutURL", "http://localhost:8081/logout"),
|
||||
graphQLEndpoint: get<string>("graphQLEndpoint", "http://localhost:8081/api/v1/graphql"),
|
||||
subscriptionEndpoint: get<string>("subscriptionEndpoint", "ws://localhost:8081/api/v1/graphql"),
|
||||
};
|
||||
|
||||
function get<T>(key: string, defaultValue: T):T {
|
||||
const config = window['__CONFIG__'] || {};
|
||||
if (config && config.hasOwnProperty(key)) {
|
||||
return config[key] as T;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
declare module "*.svg" {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client';
|
||||
import { Config } from '../config';
|
||||
import { WebSocketLink } from "@apollo/client/link/ws";
|
||||
import { RetryLink } from "@apollo/client/link/retry";
|
||||
import { SubscriptionClient } from "subscriptions-transport-ws";
|
||||
|
||||
const subscriptionClient = new SubscriptionClient(Config.subscriptionEndpoint, {
|
||||
reconnect: true,
|
||||
});
|
||||
|
||||
const link = new RetryLink({attempts: {max: 2}}).split(
|
||||
(operation) => operation.operationName === 'subscription',
|
||||
new WebSocketLink(subscriptionClient),
|
||||
new HttpLink({ uri: Config.graphQLEndpoint, credentials: 'include' })
|
||||
);
|
||||
|
||||
export const client = new ApolloClient<any>({
|
||||
cache: new InMemoryCache(),
|
||||
link: link,
|
||||
});
|
|
@ -0,0 +1,55 @@
|
|||
import { gql } from '@apollo/client';
|
||||
|
||||
export const FRAGMENT_FULL_TASK = gql`
|
||||
fragment FullTask on Task {
|
||||
id
|
||||
label
|
||||
category {
|
||||
id
|
||||
label
|
||||
}
|
||||
estimations {
|
||||
optimistic
|
||||
likely
|
||||
pessimistic
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const FRAGMENT_FULL_PROJECT_PARAMS = gql`
|
||||
fragment FullProjectParams on ProjectParams {
|
||||
timeUnit {
|
||||
label
|
||||
acronym
|
||||
}
|
||||
currency
|
||||
hideFinancialPreviewOnPrint
|
||||
}
|
||||
`;
|
||||
|
||||
export const FRAGMENT_FULL_TASK_CATEGORY = gql`
|
||||
fragment FullTaskCategory on TaskCategory {
|
||||
id
|
||||
label
|
||||
costPerTimeUnit
|
||||
}
|
||||
`;
|
||||
|
||||
export const FRAGMENT_FULL_PROJECT = gql`
|
||||
fragment FullProject on Project {
|
||||
id
|
||||
title
|
||||
taskCategories {
|
||||
...FullTaskCategory
|
||||
}
|
||||
tasks {
|
||||
...FullTask
|
||||
}
|
||||
params {
|
||||
...FullProjectParams
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_TASK}
|
||||
${FRAGMENT_FULL_PROJECT_PARAMS}
|
||||
${FRAGMENT_FULL_TASK_CATEGORY}
|
||||
`
|
|
@ -0,0 +1,120 @@
|
|||
import { gql, useMutation, PureQueryOptions } from '@apollo/client';
|
||||
import { FRAGMENT_FULL_PROJECT, FRAGMENT_FULL_TASK, FRAGMENT_FULL_PROJECT_PARAMS, FRAGMENT_FULL_TASK_CATEGORY } from '../fragments/project';
|
||||
import { QUERY_PROJECTS } from '../queries/project';
|
||||
|
||||
export const MUTATION_CREATE_PROJECT = gql`
|
||||
mutation createProject($changes: CreateProjectChanges!) {
|
||||
createProject(changes: $changes) {
|
||||
...FullProject
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_PROJECT}
|
||||
`;
|
||||
|
||||
export function useProjectCreateMutation() {
|
||||
return useMutation(MUTATION_CREATE_PROJECT);
|
||||
}
|
||||
|
||||
export const MUTATION_UPDATE_PROJECT_TITLE = gql`
|
||||
mutation updateProjectTitle($projectId: ID!, $title: String!) {
|
||||
updateProjectTitle(projectId: $projectId, title: $title) {
|
||||
...FullProject
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_PROJECT}
|
||||
`;
|
||||
|
||||
export function useUpdateProjectTitleMutation() {
|
||||
return useMutation(MUTATION_UPDATE_PROJECT_TITLE, {
|
||||
refetchQueries: ({ variables }: PureQueryOptions) => {
|
||||
return [
|
||||
{ query: QUERY_PROJECTS, variables: { filters: { ids: [ variables.projectId ] } }},
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const MUTATION_ADD_PROJECT_TASK = gql`
|
||||
mutation addProjectTask($projectId: ID!, $changes: ProjectTaskChanges!) {
|
||||
addProjectTask(projectId: $projectId, changes: $changes) {
|
||||
...FullTask
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_TASK}
|
||||
`;
|
||||
|
||||
export function useAddProjectTaskMutation() {
|
||||
return useMutation(MUTATION_ADD_PROJECT_TASK);
|
||||
}
|
||||
|
||||
export const MUTATION_UPDATE_PROJECT_TASK = gql`
|
||||
mutation updateProjectTask($projectId: ID!, $taskId: ID!, $changes: ProjectTaskChanges!) {
|
||||
updateProjectTask(projectId: $projectId, taskId: $taskId, changes: $changes) {
|
||||
...FullTask
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_TASK}
|
||||
`;
|
||||
|
||||
export function useUpdateProjectTaskMutation() {
|
||||
return useMutation(MUTATION_UPDATE_PROJECT_TASK);
|
||||
}
|
||||
|
||||
export const MUTATION_REMOVE_PROJECT_TASK = gql`
|
||||
mutation removeProjectTask($projectId: ID!, $taskId: ID!) {
|
||||
removeProjectTask(projectId: $projectId, taskId: $taskId)
|
||||
}
|
||||
`;
|
||||
|
||||
export function useRemoveProjectTaskMutation() {
|
||||
return useMutation(MUTATION_REMOVE_PROJECT_TASK);
|
||||
}
|
||||
|
||||
export const MUTATION_UPDATE_PROJECT_PARAMS = gql`
|
||||
mutation updateProjectParams($projectId: ID!, $changes: ProjectParamsChanges!) {
|
||||
updateProjectParams(projectId: $projectId, changes: $changes) {
|
||||
...FullProjectParams
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_PROJECT_PARAMS}
|
||||
`;
|
||||
|
||||
export function useUpdateProjectParamsMutation() {
|
||||
return useMutation(MUTATION_UPDATE_PROJECT_PARAMS);
|
||||
}
|
||||
|
||||
export const MUTATION_ADD_PROJECT_TASK_CATEGORY = gql`
|
||||
mutation addProjectTaskCategory($projectId: ID!, $changes: ProjectTaskCategoryChanges!) {
|
||||
addProjectTaskCategory(projectId: $projectId, changes: $changes) {
|
||||
...FullTaskCategory
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_TASK_CATEGORY}
|
||||
`;
|
||||
|
||||
export function useAddProjectTaskCategoryMutation() {
|
||||
return useMutation(MUTATION_ADD_PROJECT_TASK_CATEGORY);
|
||||
}
|
||||
|
||||
export const MUTATION_UPDATE_PROJECT_TASK_CATEGORY = gql`
|
||||
mutation updateProjectTaskCategory($projectId: ID!, $taskCategoryId: ID!, $changes: ProjectTaskCategoryChanges!) {
|
||||
updateProjectTaskCategory(projectId: $projectId, taskCategoryId: $taskCategoryId, changes: $changes) {
|
||||
...FullTaskCategory
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_TASK_CATEGORY}
|
||||
`;
|
||||
|
||||
export function useUpdateProjectTaskCategoryMutation() {
|
||||
return useMutation(MUTATION_UPDATE_PROJECT_TASK_CATEGORY);
|
||||
}
|
||||
|
||||
export const MUTATION_REMOVE_PROJECT_TASK_CATEGORY = gql`
|
||||
mutation removeProjectTaskCategory($projectId: ID!, $taskCategoryId: ID!) {
|
||||
removeProjectTaskCategory(projectId: $projectId, taskCategoryId: $taskCategoryId)
|
||||
}
|
||||
`;
|
||||
|
||||
export function useRemoveProjectTaskCategoryMutation() {
|
||||
return useMutation(MUTATION_REMOVE_PROJECT_TASK_CATEGORY);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { gql, useMutation } from '@apollo/client';
|
||||
|
||||
export const MUTATION_UPDATE_USER = gql`
|
||||
mutation updateUser($id: ID!, $changes: UserChanges!) {
|
||||
updateUser(id: $id, changes: $changes) {
|
||||
id,
|
||||
name,
|
||||
createdAt,
|
||||
connectedAt,
|
||||
}
|
||||
}`;
|
||||
|
||||
export function useUpdateUserMutation() {
|
||||
return useMutation(MUTATION_UPDATE_USER);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { useQuery, DocumentNode, QueryHookOptions } from "@apollo/client";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
export function useGraphQLData<T, A = any, R = Record<string, any>>(q: DocumentNode, key: string, defaultValue: T, options: QueryHookOptions<A, R> = {}) {
|
||||
const query = useQuery(q, options);
|
||||
const [ data, setData ] = useState<T>(defaultValue);
|
||||
useEffect(() => {
|
||||
setData(query.data ? query.data[key] as T : defaultValue);
|
||||
}, [query.loading, query.data]);
|
||||
return { data, loading: query.loading, error: query.error };
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||
import { useGraphQLData } from './helper';
|
||||
import { Project } from '../../types/project';
|
||||
import { FRAGMENT_FULL_PROJECT } from '../fragments/project';
|
||||
|
||||
export const QUERY_PROJECTS = gql`
|
||||
query projects($filter: ProjectsFilter) {
|
||||
projects(filter: $filter) {
|
||||
...FullProject
|
||||
}
|
||||
}
|
||||
${FRAGMENT_FULL_PROJECT}`;
|
||||
|
||||
export function useProjectsQuery() {
|
||||
return useQuery(QUERY_PROJECTS);
|
||||
}
|
||||
|
||||
export function useProjects<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||
const { data, loading, error } = useGraphQLData<Project[]>(
|
||||
QUERY_PROJECTS, 'projects', [], options
|
||||
);
|
||||
return { projects: data, loading, error };
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
import { gql, useQuery } from '@apollo/client';
|
||||
import { User } from '../../types/user';
|
||||
import { useGraphQLData } from './helper';
|
||||
|
||||
export const QUERY_CURRENT_USER = gql`
|
||||
query userProfile {
|
||||
currentUser {
|
||||
id,
|
||||
name,
|
||||
email,
|
||||
createdAt,
|
||||
connectedAt
|
||||
}
|
||||
}`;
|
||||
|
||||
export function useUserProfileQuery() {
|
||||
return useQuery(QUERY_CURRENT_USER);
|
||||
}
|
||||
|
||||
export function useUserProfile() {
|
||||
const { data, loading, error } = useGraphQLData<User>(
|
||||
QUERY_CURRENT_USER, 'currentUser', {id: '', email: ''}
|
||||
);
|
||||
return { user: data, loading, error };
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import { useMemo, useState } from "react";
|
||||
|
||||
export default function useDebounce(func: Function, delay: number) {
|
||||
const [id, setId] = useState<number|null>(null)
|
||||
return useMemo(
|
||||
(...args) => {
|
||||
if (id) {
|
||||
clearTimeout(id)
|
||||
} else {
|
||||
setId(
|
||||
window.setTimeout(() => {
|
||||
setId(null)
|
||||
func(...args)
|
||||
}, delay)
|
||||
)
|
||||
}
|
||||
}, [func]
|
||||
)
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
import { useState } from "react";
|
||||
|
||||
export function useLocalStorage<T>(key: string, initialValue: T) {
|
||||
// State to store our value
|
||||
// Pass initial state function to useState so logic is only executed once
|
||||
const [storedValue, setStoredValue] = useState(() => {
|
||||
try {
|
||||
// Get from local storage by key
|
||||
const item = window.localStorage.getItem(key);
|
||||
// Parse stored json or if none return initialValue
|
||||
return item ? JSON.parse(item) : initialValue;
|
||||
} catch (error) {
|
||||
// If error also return initialValue
|
||||
console.error(error);
|
||||
return initialValue;
|
||||
}
|
||||
});
|
||||
|
||||
// Return a wrapped version of useState's setter function that ...
|
||||
// ... persists the new value to localStorage.
|
||||
const setValue = (value: T) => {
|
||||
try {
|
||||
// Allow value to be a function so we have same API as useState
|
||||
const valueToStore =
|
||||
value instanceof Function ? value(storedValue) : value;
|
||||
// Save state
|
||||
setStoredValue(valueToStore);
|
||||
// Save to local storage
|
||||
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
||||
} catch (error) {
|
||||
// A more advanced implementation would handle the error case
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return [storedValue, setValue];
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import { useEffect, useRef } from "react";
|
||||
|
||||
export function usePrevious<T>(value: T): T|undefined {
|
||||
const ref = useRef<T>();
|
||||
|
||||
useEffect(() => {
|
||||
ref.current = value;
|
||||
}, [value]);
|
||||
|
||||
return ref.current as T|undefined;
|
||||
}
|
|
@ -1,383 +0,0 @@
|
|||
import { Project, sanitize } from "../models/project";
|
||||
import { Task, TaskID, EstimationConfidence, TaskCategoryID, TaskCategory } from "../models/task";
|
||||
import { useReducer } from "react";
|
||||
import { generate as diff } from "json-merge-patch";
|
||||
import { applyPatch } from "../util/patch";
|
||||
|
||||
|
||||
export interface Action {
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ProjectReducerActions =
|
||||
AddTask |
|
||||
RemoveTask |
|
||||
UpdateTaskEstimation |
|
||||
UpdateProjectLabel |
|
||||
UpdateTaskLabel |
|
||||
UpdateParam |
|
||||
UpdateTaskCategoryLabel |
|
||||
UpdateTaskCategoryCost |
|
||||
AddTaskCategory |
|
||||
RemoveTaskCategory |
|
||||
PatchProject
|
||||
|
||||
export function useProjectReducer(project: Project) {
|
||||
return useReducer(projectReducer, project);
|
||||
}
|
||||
|
||||
export function projectReducer(project: Project, action: ProjectReducerActions): Project {
|
||||
console.log('action', action);
|
||||
switch(action.type) {
|
||||
case ADD_TASK:
|
||||
return handleAddTask(project, action as AddTask);
|
||||
|
||||
case REMOVE_TASK:
|
||||
return handleRemoveTask(project, action as RemoveTask);
|
||||
|
||||
case UPDATE_TASK_ESTIMATION:
|
||||
return handleUpdateTaskEstimation(project, action as UpdateTaskEstimation);
|
||||
|
||||
case UPDATE_PROJECT_LABEL:
|
||||
return handleUpdateProjectLabel(project, action as UpdateProjectLabel);
|
||||
|
||||
case UPDATE_TASK_LABEL:
|
||||
return handleUpdateTaskLabel(project, action as UpdateTaskLabel);
|
||||
|
||||
case MOVE_TASK:
|
||||
return handleMoveTask(project, action as MoveTask);
|
||||
|
||||
case UPDATE_PARAM:
|
||||
return handleUpdateParam(project, action as UpdateParam);
|
||||
|
||||
case ADD_TASK_CATEGORY:
|
||||
return handleAddTaskCategory(project, action as AddTaskCategory);
|
||||
|
||||
case REMOVE_TASK_CATEGORY:
|
||||
return handleRemoveTaskCategory(project, action as RemoveTaskCategory);
|
||||
|
||||
case UPDATE_TASK_CATEGORY_LABEL:
|
||||
return handleUpdateTaskCategoryLabel(project, action as UpdateTaskCategoryLabel);
|
||||
|
||||
case UPDATE_TASK_CATEGORY_COST:
|
||||
return handleUpdateTaskCategoryCost(project, action as UpdateTaskCategoryCost);
|
||||
|
||||
case PATCH_PROJECT:
|
||||
return handlePatchProject(project, action as PatchProject);
|
||||
}
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
export interface AddTask extends Action {
|
||||
task: Task
|
||||
}
|
||||
|
||||
export const ADD_TASK = "ADD_TASK";
|
||||
|
||||
export function addTask(task: Task): AddTask {
|
||||
return { type: ADD_TASK, task };
|
||||
}
|
||||
|
||||
export function handleAddTask(project: Project, action: AddTask): Project {
|
||||
const task = { ...action.task };
|
||||
return {
|
||||
...project,
|
||||
tasks: {
|
||||
...project.tasks,
|
||||
[task.id]: task,
|
||||
},
|
||||
ordering: [
|
||||
...project.ordering,
|
||||
task.id
|
||||
],
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface RemoveTask extends Action {
|
||||
id: TaskID
|
||||
}
|
||||
|
||||
export const REMOVE_TASK = "REMOVE_TASK";
|
||||
|
||||
export function removeTask(id: TaskID): RemoveTask {
|
||||
return { type: REMOVE_TASK, id };
|
||||
}
|
||||
|
||||
export function handleRemoveTask(project: Project, action: RemoveTask): Project {
|
||||
const tasks = { ...project.tasks };
|
||||
delete tasks[action.id];
|
||||
|
||||
const ordering = [ ...(project.ordering ?? []) ]
|
||||
const taskIndex = ordering.findIndex(taskId => taskId === action.id)
|
||||
if (taskIndex !== -1) {
|
||||
ordering.splice(taskIndex, 1)
|
||||
}
|
||||
|
||||
return {
|
||||
...project,
|
||||
tasks,
|
||||
ordering,
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskEstimation extends Action {
|
||||
id: TaskID
|
||||
confidence: string
|
||||
value: number
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_ESTIMATION = "UPDATE_TASK_ESTIMATION";
|
||||
|
||||
export function updateTaskEstimation(id: TaskID, confidence: EstimationConfidence, value: number): UpdateTaskEstimation {
|
||||
return { type: UPDATE_TASK_ESTIMATION, id, confidence, value };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskEstimation(project: Project, action: UpdateTaskEstimation): Project {
|
||||
const estimations = {
|
||||
...project.tasks[action.id].estimations,
|
||||
[action.confidence]: action.value
|
||||
};
|
||||
|
||||
return {
|
||||
...project,
|
||||
tasks: {
|
||||
...project.tasks,
|
||||
[action.id]: {
|
||||
...project.tasks[action.id],
|
||||
estimations: estimations,
|
||||
},
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface UpdateProjectLabel extends Action {
|
||||
label: string
|
||||
}
|
||||
|
||||
export const UPDATE_PROJECT_LABEL = "UPDATE_PROJECT_LABEL";
|
||||
|
||||
export function updateProjectLabel(label: string): UpdateProjectLabel {
|
||||
return { type: UPDATE_PROJECT_LABEL, label };
|
||||
}
|
||||
|
||||
export function handleUpdateProjectLabel(project: Project, action: UpdateProjectLabel): Project {
|
||||
return {
|
||||
...project,
|
||||
label: action.label,
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskLabel extends Action {
|
||||
id: TaskID
|
||||
label: string
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_LABEL = "UPDATE_TASK_LABEL";
|
||||
|
||||
export function updateTaskLabel(id: TaskID, label: string): UpdateTaskLabel {
|
||||
return { type: UPDATE_TASK_LABEL, id, label };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskLabel(project: Project, action: UpdateTaskLabel): Project {
|
||||
return {
|
||||
...project,
|
||||
tasks: {
|
||||
...project.tasks,
|
||||
[action.id]: {
|
||||
...project.tasks[action.id],
|
||||
label: action.label,
|
||||
}
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export const MOVE_TASK = "MOVE_TASK";
|
||||
|
||||
export interface MoveTask extends Action {
|
||||
id: TaskID
|
||||
move: number
|
||||
}
|
||||
|
||||
export function moveTask(id: TaskID, move: number): MoveTask {
|
||||
return { type: MOVE_TASK, id, move };
|
||||
}
|
||||
|
||||
export function handleMoveTask(project: Project, action: MoveTask): Project {
|
||||
let ordering = [
|
||||
...(project.ordering ?? []),
|
||||
]
|
||||
|
||||
if (ordering.length === 0) {
|
||||
ordering = Object.keys(project.tasks)
|
||||
}
|
||||
|
||||
const taskIndex = ordering.findIndex(taskId => action.id === taskId)
|
||||
|
||||
if (taskIndex+action.move < 0 || taskIndex+action.move > ordering.length-1 ) {
|
||||
return project
|
||||
}
|
||||
|
||||
ordering.splice(taskIndex, 1)
|
||||
ordering.splice(taskIndex+action.move, 0, action.id)
|
||||
|
||||
return {
|
||||
...project,
|
||||
ordering,
|
||||
updatedAt: new Date(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface UpdateParam extends Action {
|
||||
name: string
|
||||
value: any
|
||||
}
|
||||
|
||||
export const UPDATE_PARAM = "UPDATE_PARAM";
|
||||
|
||||
export function updateParam(name: string, value: any): UpdateParam {
|
||||
return { type: UPDATE_PARAM, name, value };
|
||||
}
|
||||
|
||||
export function handleUpdateParam(project: Project, action: UpdateParam): Project {
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
[action.name]: action.value,
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskCategoryLabel extends Action {
|
||||
categoryId: TaskCategoryID
|
||||
label: string
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_CATEGORY_LABEL = "UPDATE_TASK_CATEGORY_LABEL";
|
||||
|
||||
export function updateTaskCategoryLabel(categoryId: TaskCategoryID, label: string): UpdateTaskCategoryLabel {
|
||||
return { type: UPDATE_TASK_CATEGORY_LABEL, categoryId, label };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskCategoryLabel(project: Project, action: UpdateTaskCategoryLabel): Project {
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
taskCategories: {
|
||||
...project.params.taskCategories,
|
||||
[action.categoryId]: {
|
||||
...project.params.taskCategories[action.categoryId],
|
||||
label: action.label
|
||||
},
|
||||
}
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskCategoryCost extends Action {
|
||||
categoryId: TaskCategoryID
|
||||
costPerTimeUnit: number
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_CATEGORY_COST = "UPDATE_TASK_CATEGORY_COST";
|
||||
|
||||
export function updateTaskCategoryCost(categoryId: TaskCategoryID, costPerTimeUnit: number): UpdateTaskCategoryCost {
|
||||
return { type: UPDATE_TASK_CATEGORY_COST, categoryId, costPerTimeUnit };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskCategoryCost(project: Project, action: UpdateTaskCategoryCost): Project {
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
taskCategories: {
|
||||
...project.params.taskCategories,
|
||||
[action.categoryId]: {
|
||||
...project.params.taskCategories[action.categoryId],
|
||||
costPerTimeUnit: action.costPerTimeUnit
|
||||
},
|
||||
}
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export const ADD_TASK_CATEGORY = "ADD_TASK_CATEGORY";
|
||||
|
||||
export interface AddTaskCategory extends Action {
|
||||
taskCategory: TaskCategory
|
||||
}
|
||||
|
||||
export function addTaskCategory(taskCategory: TaskCategory): AddTaskCategory {
|
||||
return { type: ADD_TASK_CATEGORY, taskCategory };
|
||||
}
|
||||
|
||||
export function handleAddTaskCategory(project: Project, action: AddTaskCategory): Project {
|
||||
const taskCategory = { ...action.taskCategory };
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
taskCategories: {
|
||||
...project.params.taskCategories,
|
||||
[taskCategory.id]: taskCategory,
|
||||
}
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface RemoveTaskCategory extends Action {
|
||||
taskCategoryId: TaskCategoryID
|
||||
}
|
||||
|
||||
export const REMOVE_TASK_CATEGORY = "REMOVE_TASK_CATEGORY";
|
||||
|
||||
export function removeTaskCategory(taskCategoryId: TaskCategoryID): RemoveTaskCategory {
|
||||
return { type: REMOVE_TASK_CATEGORY, taskCategoryId };
|
||||
}
|
||||
|
||||
export function handleRemoveTaskCategory(project: Project, action: RemoveTaskCategory): Project {
|
||||
const taskCategories = { ...project.params.taskCategories };
|
||||
delete taskCategories[action.taskCategoryId];
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
taskCategories
|
||||
},
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
export interface PatchProject extends Action {
|
||||
from: Project
|
||||
}
|
||||
|
||||
export const PATCH_PROJECT = "PATCH_PROJECT";
|
||||
|
||||
export function patchProject(from: Project): PatchProject {
|
||||
return { type: PATCH_PROJECT, from };
|
||||
}
|
||||
|
||||
export function handlePatchProject(project: Project, action: PatchProject): Project {
|
||||
const p = diff(project, action.from);
|
||||
console.log('patch to apply', p);
|
||||
if (!p) return project;
|
||||
const patched: Project = applyPatch(project, p) as Project
|
||||
|
||||
sanitize(patched)
|
||||
|
||||
return patched;
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
import { Project } from "../models/project";
|
||||
import { useEffect, useState } from "react";
|
||||
import { generate as diff } from "json-merge-patch";
|
||||
|
||||
export interface ServerSyncOptions {
|
||||
projectURL: string
|
||||
refreshInterval: number
|
||||
}
|
||||
|
||||
export const defaultOptions = {
|
||||
refreshInterval: 5000,
|
||||
projectURL: `//${window.location.host}/api/v1/projects`,
|
||||
}
|
||||
|
||||
export function useServerSync(project: Project, applyServerUpdate: (project: Project) => void, options: ServerSyncOptions = defaultOptions) {
|
||||
options = Object.assign({}, defaultOptions, options);
|
||||
|
||||
const [ serverState, setServerState ] = useState({
|
||||
version: 0,
|
||||
project: project,
|
||||
});
|
||||
|
||||
console.log('server state', serverState);
|
||||
|
||||
const handleAPIResponse = (res: Response) => {
|
||||
// If the project does not yet exist, create it
|
||||
if (res.status === 404) {
|
||||
return createProject(project, options)
|
||||
.then(res => res.json())
|
||||
.then(result => {
|
||||
setServerState({ version: result.version, project });
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
// In case of conflict, notify of new server version
|
||||
if (res.status === 409) {
|
||||
console.log("server conflict detected");
|
||||
return res.json().then((result: any) => {
|
||||
console.log('received response', result);
|
||||
applyServerUpdate(result.project);
|
||||
setServerState({ version: result.version, project: result.project });
|
||||
});
|
||||
}
|
||||
|
||||
// If the server version is not modified, do nothing
|
||||
if (res.status === 304) {
|
||||
console.log("no modification on server");
|
||||
return;
|
||||
}
|
||||
|
||||
return res.json().then((result: any) => {
|
||||
console.log('received response', result);
|
||||
applyServerUpdate(result.project);
|
||||
setServerState({ version: result.version, project: result.project });
|
||||
});
|
||||
};
|
||||
|
||||
// Force refresh periodically
|
||||
useEffect(() => {
|
||||
const intervalId = window.setInterval(() => {
|
||||
console.time("server-sync");
|
||||
refreshProject(project, serverState.version, options).then(handleAPIResponse)
|
||||
.then(() => {
|
||||
console.timeEnd("server-sync");
|
||||
});
|
||||
}, options.refreshInterval);
|
||||
return () => clearInterval(intervalId);
|
||||
}, [serverState]);
|
||||
|
||||
// Send delayed update
|
||||
useEffect(() => {
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
const patch = diff(serverState.project, project);
|
||||
if (!patch) return;
|
||||
patchProject(project, patch, serverState.version, options).then(handleAPIResponse);
|
||||
}, 5000);
|
||||
return () => clearTimeout(timeoutId);
|
||||
}, [project, serverState]);
|
||||
|
||||
}
|
||||
|
||||
function refreshProject(project: Project, version: number, options: ServerSyncOptions): Promise<Response> {
|
||||
return fetch(`${options.projectURL}/${project.id}?version=${version}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
function createProject(project: Project, options: ServerSyncOptions): Promise<Response> {
|
||||
return fetch(`${options.projectURL}/${project.id}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ project })
|
||||
});
|
||||
}
|
||||
|
||||
function patchProject(project: Project, patch: Object, version: number, options: ServerSyncOptions): Promise<any> {
|
||||
return fetch(`${options.projectURL}/${project.id}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ version, patch })
|
||||
});
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
import { Project, sanitize } from "../models/project";
|
||||
import { useState } from "react";
|
||||
import { ProjectStorageKeyPrefix } from "../util/storage";
|
||||
|
||||
export function loadStoredProjects(): Project[] {
|
||||
const projects: Project[] = [];
|
||||
|
||||
Object.keys(window.localStorage).forEach(key => {
|
||||
if (key.startsWith(ProjectStorageKeyPrefix)) {
|
||||
try {
|
||||
const data = window.localStorage.getItem(key);
|
||||
if (data) {
|
||||
const project: Project = JSON.parse(data);
|
||||
|
||||
sanitize(project)
|
||||
|
||||
projects.push(project);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return projects
|
||||
}
|
||||
|
||||
export function useStoredProjectList(): [Project[], () => void] {
|
||||
const [projects, setProjects] = useState(() => {
|
||||
return loadStoredProjects();
|
||||
});
|
||||
|
||||
const refresh = () => {
|
||||
setProjects(loadStoredProjects());
|
||||
};
|
||||
|
||||
return [projects, refresh];
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
import { useEffect } from "react"
|
||||
|
||||
export const useTitle = (title: string) => {
|
||||
useEffect(() => {
|
||||
window.document.title = `⏱️ | ${title}`
|
||||
}, [title])
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import React, { useContext, useEffect } from "react";
|
||||
|
||||
const LOGGED_IN_KEY = 'loggedIn';
|
||||
|
||||
export const LoggedInContext = React.createContext(getSavedLoggedIn());
|
||||
|
||||
export const useLoggedIn = () => {
|
||||
return useContext(LoggedInContext);
|
||||
};
|
||||
|
||||
export function saveLoggedIn(loggedIn: boolean) {
|
||||
window.sessionStorage.setItem(LOGGED_IN_KEY, JSON.stringify(loggedIn));
|
||||
}
|
||||
|
||||
export function getSavedLoggedIn(): boolean {
|
||||
try {
|
||||
const loggedIn = JSON.parse(window.sessionStorage.getItem(LOGGED_IN_KEY));
|
||||
return !!loggedIn;
|
||||
} catch(err) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
import { Project } from "../models/project";
|
||||
import { Project, getProjectWeightedMean, getProjectStandardDeviation } from "../types/project";
|
||||
import { useState, useEffect } from "react";
|
||||
import { getProjectWeightedMean, getProjectStandardDeviation } from "../util/stat";
|
||||
|
||||
export interface Estimation {
|
||||
e: number
|
|
@ -0,0 +1,272 @@
|
|||
import { all, select, takeLatest, put, delay } from "redux-saga/effects";
|
||||
import { client } from '../gql/client';
|
||||
import {
|
||||
MUTATION_CREATE_PROJECT, MUTATION_UPDATE_PROJECT_TITLE,
|
||||
MUTATION_ADD_PROJECT_TASK, MUTATION_REMOVE_PROJECT_TASK,
|
||||
MUTATION_UPDATE_PROJECT_TASK, MUTATION_UPDATE_PROJECT_PARAMS,
|
||||
MUTATION_ADD_PROJECT_TASK_CATEGORY,
|
||||
MUTATION_UPDATE_PROJECT_TASK_CATEGORY,
|
||||
MUTATION_REMOVE_PROJECT_TASK_CATEGORY
|
||||
} from "../gql/mutations/project";
|
||||
import {
|
||||
UPDATE_PROJECT_TITLE, resetProject,
|
||||
ADD_TASK, taskSaved, AddTask,
|
||||
taskRemoved, RemoveTask, REMOVE_TASK,
|
||||
UPDATE_TASK_ESTIMATION, UpdateTaskEstimation,
|
||||
UpdateTaskLabel, UPDATE_TASK_LABEL, UpdateParam,
|
||||
paramsSaved, UPDATE_PARAM, AddTaskCategory,
|
||||
ADD_TASK_CATEGORY, taskCategorySaved, UpdateTaskCategoryLabel, UPDATE_TASK_CATEGORY_LABEL, UPDATE_TASK_CATEGORY_COST, updateTaskCategoryCost, UpdateTaskCategoryCost, RemoveTaskCategory, taskCategoryRemoved, REMOVE_TASK_CATEGORY, backendError
|
||||
} from "./useProjectReducer";
|
||||
import { Project } from "../types/project";
|
||||
|
||||
export function* rootSaga() {
|
||||
yield all([
|
||||
createProjectSaga(),
|
||||
takeLatest(UPDATE_PROJECT_TITLE, updateProjectTitleSaga),
|
||||
takeLatest(UPDATE_TASK_ESTIMATION, updateTaskEstimationSaga),
|
||||
takeLatest(UPDATE_TASK_LABEL, updateTaskLabelSaga),
|
||||
takeLatest(UPDATE_PARAM, updateProjectParamsSaga),
|
||||
takeLatest(ADD_TASK, addTaskSaga),
|
||||
takeLatest(REMOVE_TASK, removeTaskSaga),
|
||||
takeLatest(ADD_TASK_CATEGORY, addProjectTaskCategorySaga),
|
||||
takeLatest(UPDATE_TASK_CATEGORY_LABEL, updateProjectTaskCategoryLabelSaga),
|
||||
takeLatest(UPDATE_TASK_CATEGORY_COST, updateProjectTaskCategoryCostSaga),
|
||||
takeLatest(REMOVE_TASK_CATEGORY, removeProjectTaskCategorySaga),
|
||||
]);
|
||||
}
|
||||
|
||||
export function* updateProjectTitleSaga() {
|
||||
let project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_TITLE,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
title: project.title,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function* createProjectSaga() {
|
||||
const project: Project = yield select();
|
||||
|
||||
if (project.id !== undefined) return;
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_CREATE_PROJECT,
|
||||
variables: {
|
||||
changes: {
|
||||
title: project.title,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(resetProject(data.createProject));
|
||||
|
||||
return yield select();
|
||||
}
|
||||
|
||||
export function* addTaskSaga({ task }: AddTask) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_ADD_PROJECT_TASK,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
changes: {
|
||||
label: task.label,
|
||||
categoryId: task.category ? task.category.id : -1,
|
||||
estimations: {
|
||||
optimistic: task.estimations.optimistic,
|
||||
likely: task.estimations.likely,
|
||||
pessimistic: task.estimations.pessimistic,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskSaved({ ...task, ...data.addProjectTask }));
|
||||
}
|
||||
|
||||
export function* removeTaskSaga({ id }: RemoveTask) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
yield client.mutate({
|
||||
mutation: MUTATION_REMOVE_PROJECT_TASK,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskId: id,
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskRemoved(id));
|
||||
}
|
||||
|
||||
export function* updateTaskEstimationSaga({ id, confidence, value }: UpdateTaskEstimation) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_TASK,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskId: id,
|
||||
changes: {
|
||||
estimations: {
|
||||
[confidence]: value,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskSaved({ ...data.updateProjectTask }));
|
||||
}
|
||||
|
||||
export function* updateTaskLabelSaga({ id, label }: UpdateTaskLabel) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_TASK,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskId: id,
|
||||
changes: {
|
||||
label,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskSaved({ ...data.updateProjectTask }));
|
||||
}
|
||||
|
||||
export function* updateProjectParamsSaga({ name, value }: UpdateParam) {
|
||||
yield delay(500);
|
||||
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
delete value.__typename;
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_PARAMS,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
changes: {
|
||||
[name]: value,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(paramsSaved({ ...data.updateProjectParams }));
|
||||
}
|
||||
|
||||
export function* addProjectTaskCategorySaga({ taskCategory }: AddTaskCategory) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_ADD_PROJECT_TASK_CATEGORY,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
changes: {
|
||||
label: taskCategory.label,
|
||||
costPerTimeUnit: taskCategory.costPerTimeUnit,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskCategorySaved({ ...data.addProjectTaskCategory }));
|
||||
}
|
||||
|
||||
export function* updateProjectTaskCategoryLabelSaga({ categoryId, label }: UpdateTaskCategoryLabel) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_TASK_CATEGORY,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskCategoryId: categoryId,
|
||||
changes: {
|
||||
label,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskCategorySaved({ ...data.updateProjectTaskCategory }));
|
||||
}
|
||||
|
||||
export function* updateProjectTaskCategoryCostSaga({ categoryId, costPerTimeUnit }: UpdateTaskCategoryCost) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
const { data } = yield client.mutate({
|
||||
mutation: MUTATION_UPDATE_PROJECT_TASK_CATEGORY,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskCategoryId: categoryId,
|
||||
changes: {
|
||||
costPerTimeUnit,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield put(taskCategorySaved({ ...data.updateProjectTaskCategory }));
|
||||
}
|
||||
|
||||
export function* removeProjectTaskCategorySaga({ taskCategoryId }: RemoveTaskCategory) {
|
||||
let project: Project = yield select();
|
||||
|
||||
if (project.id === undefined) {
|
||||
project = yield createProjectSaga();
|
||||
}
|
||||
|
||||
try {
|
||||
yield client.mutate({
|
||||
mutation: MUTATION_REMOVE_PROJECT_TASK_CATEGORY,
|
||||
variables: {
|
||||
projectId: project.id,
|
||||
taskCategoryId,
|
||||
}
|
||||
});
|
||||
} catch(err) {
|
||||
yield put(backendError(err));
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
yield put(taskCategoryRemoved(taskCategoryId));
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
import { Project } from "../types/project";
|
||||
import { Task, TaskID, EstimationConfidence, TaskCategoryID, TaskCategory } from "../types/task";
|
||||
import { useReducerAndSaga } from "./useReducerAndSaga";
|
||||
import { rootSaga } from "./useProjectReducer.sagas";
|
||||
import { uuid } from "../util/uuid";
|
||||
import { Params } from "../types/params";
|
||||
|
||||
export interface ProjectState extends Project {
|
||||
lastBackendError: Error
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ProjectReducerActions =
|
||||
AddTask |
|
||||
TaskSaved |
|
||||
RemoveTask |
|
||||
TaskRemoved |
|
||||
UpdateTaskEstimation |
|
||||
UpdateProjectTitle |
|
||||
UpdateTaskLabel |
|
||||
UpdateParam |
|
||||
ParamsSaved |
|
||||
UpdateTaskCategoryLabel |
|
||||
UpdateTaskCategoryCost |
|
||||
AddTaskCategory |
|
||||
RemoveTaskCategory |
|
||||
TaskCategoryRemoved |
|
||||
TaskCategorySaved |
|
||||
ResetProject |
|
||||
BackendError
|
||||
|
||||
export function useProjectReducer(project: Project) {
|
||||
return useReducerAndSaga<ProjectState>(projectReducer, project, rootSaga);
|
||||
}
|
||||
|
||||
export function projectReducer(project: ProjectState, action: ProjectReducerActions): ProjectState {
|
||||
console.log(action.type, action);
|
||||
|
||||
switch(action.type) {
|
||||
case TASK_SAVED:
|
||||
return handleTaskSaved(project, action as TaskSaved);
|
||||
|
||||
case TASK_REMOVED:
|
||||
return handleTaskRemoved(project, action as RemoveTask);
|
||||
|
||||
case UPDATE_TASK_ESTIMATION:
|
||||
return handleUpdateTaskEstimation(project, action as UpdateTaskEstimation);
|
||||
|
||||
case UPDATE_PROJECT_TITLE:
|
||||
return handleUpdateProjectTitle(project, action as UpdateProjectTitle);
|
||||
|
||||
case UPDATE_TASK_LABEL:
|
||||
return handleUpdateTaskLabel(project, action as UpdateTaskLabel);
|
||||
|
||||
case UPDATE_PARAM:
|
||||
return handleUpdateParam(project, action as UpdateParam);
|
||||
|
||||
case PARAMS_SAVED:
|
||||
return handleParamsSaved(project, action as ParamsSaved);
|
||||
|
||||
case TASK_CATEGORY_SAVED:
|
||||
return handleTaskCategorySaved(project, action as TaskCategorySaved);
|
||||
|
||||
case TASK_CATEGORY_REMOVED:
|
||||
return handleTaskCategoryRemoved(project, action as TaskCategoryRemoved);
|
||||
|
||||
case RESET_PROJECT:
|
||||
return handleResetProject(project, action as ResetProject);
|
||||
|
||||
case BACKEND_ERROR:
|
||||
return handleBackendError(project, action as BackendError);
|
||||
|
||||
}
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
export interface AddTask extends Action {
|
||||
task: Task
|
||||
}
|
||||
|
||||
export const ADD_TASK = "ADD_TASK";
|
||||
|
||||
export function addTask(task: Task): AddTask {
|
||||
return { type: ADD_TASK, task };
|
||||
}
|
||||
|
||||
export interface TaskAdded extends Action {
|
||||
task: Task
|
||||
}
|
||||
|
||||
export const TASK_SAVED = "TASK_SAVED";
|
||||
|
||||
export interface TaskSaved extends Action {
|
||||
task: Task
|
||||
}
|
||||
|
||||
export function taskSaved(task: Task): TaskSaved {
|
||||
return { type: TASK_SAVED, task };
|
||||
}
|
||||
|
||||
export function handleTaskSaved(project: ProjectState, action: TaskSaved): ProjectState {
|
||||
const taskIndex = project.tasks.findIndex(t => t.id === action.task.id);
|
||||
const tasks = [ ...project.tasks ];
|
||||
if (taskIndex === -1) {
|
||||
tasks.push({ ...action.task });
|
||||
} else {
|
||||
tasks[taskIndex] = { ...tasks[taskIndex], ...action.task };
|
||||
}
|
||||
return {
|
||||
...project,
|
||||
tasks
|
||||
};
|
||||
}
|
||||
|
||||
export interface RemoveTask extends Action {
|
||||
id: number
|
||||
}
|
||||
|
||||
export const REMOVE_TASK = "REMOVE_TASK";
|
||||
|
||||
export function removeTask(id: number): RemoveTask {
|
||||
return { type: REMOVE_TASK, id };
|
||||
}
|
||||
|
||||
export interface TaskRemoved extends Action {
|
||||
id: number
|
||||
}
|
||||
|
||||
export const TASK_REMOVED = "TASK_REMOVED";
|
||||
|
||||
export function taskRemoved(id: number): TaskRemoved {
|
||||
return { type: TASK_REMOVED, id };
|
||||
}
|
||||
|
||||
|
||||
export function handleTaskRemoved(project: ProjectState, action: TaskRemoved): ProjectState {
|
||||
const tasks = [...project.tasks];
|
||||
const taskIndex = project.tasks.findIndex(t => t.id === action.id);
|
||||
if (taskIndex === -1) return project;
|
||||
tasks.splice(taskIndex, 1);
|
||||
return {
|
||||
...project,
|
||||
tasks
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskEstimation extends Action {
|
||||
id: number
|
||||
confidence: string
|
||||
value: number
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_ESTIMATION = "UPDATE_TASK_ESTIMATION";
|
||||
|
||||
export function updateTaskEstimation(id: number, confidence: EstimationConfidence, value: number): UpdateTaskEstimation {
|
||||
return { type: UPDATE_TASK_ESTIMATION, id, confidence, value };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskEstimation(project: ProjectState, action: UpdateTaskEstimation): ProjectState {
|
||||
const tasks = [...project.tasks];
|
||||
const taskIndex = project.tasks.findIndex(t => t.id === action.id);
|
||||
if (taskIndex === -1) return project;
|
||||
|
||||
const estimations = {
|
||||
...project.tasks[taskIndex].estimations,
|
||||
[action.confidence]: action.value
|
||||
};
|
||||
|
||||
project.tasks[taskIndex] = { ...project.tasks[taskIndex], estimations };
|
||||
|
||||
return {
|
||||
...project,
|
||||
tasks
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface UpdateProjectTitle extends Action {
|
||||
title: string
|
||||
}
|
||||
|
||||
export const UPDATE_PROJECT_TITLE = "UPDATE_PROJECT_TITLE";
|
||||
|
||||
export function updateProjectTitle(title: string): UpdateProjectTitle {
|
||||
return { type: UPDATE_PROJECT_TITLE, title };
|
||||
}
|
||||
|
||||
export function handleUpdateProjectTitle(project: ProjectState, action: UpdateProjectTitle): ProjectState {
|
||||
return {
|
||||
...project,
|
||||
title: action.title
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskLabel extends Action {
|
||||
id: number
|
||||
label: string
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_LABEL = "UPDATE_TASK_LABEL";
|
||||
|
||||
export function updateTaskLabel(id: number, label: string): UpdateTaskLabel {
|
||||
return { type: UPDATE_TASK_LABEL, id, label };
|
||||
}
|
||||
|
||||
export function handleUpdateTaskLabel(project: ProjectState, action: UpdateTaskLabel): ProjectState {
|
||||
const tasks = [...project.tasks];
|
||||
const taskIndex = project.tasks.findIndex(t => t.id === action.id);
|
||||
if (taskIndex === -1) return project;
|
||||
|
||||
tasks[taskIndex] = { ...tasks[taskIndex], label: action.label };
|
||||
|
||||
return {
|
||||
...project,
|
||||
tasks
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateParam extends Action {
|
||||
name: string
|
||||
value: any
|
||||
}
|
||||
|
||||
export const UPDATE_PARAM = "UPDATE_PARAM";
|
||||
|
||||
export function updateParam(name: string, value: any): UpdateParam {
|
||||
return { type: UPDATE_PARAM, name, value };
|
||||
}
|
||||
|
||||
export function handleUpdateParam(project: ProjectState, action: UpdateParam): ProjectState {
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...project.params,
|
||||
[action.name]: action.value,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface ParamsSaved extends Action {
|
||||
params: Params
|
||||
}
|
||||
|
||||
export const PARAMS_SAVED = "PARAMS_SAVED";
|
||||
|
||||
export function paramsSaved(params: Params): ParamsSaved {
|
||||
return { type: PARAMS_SAVED, params };
|
||||
}
|
||||
|
||||
function handleParamsSaved(project: ProjectState, action: ParamsSaved): ProjectState {
|
||||
return {
|
||||
...project,
|
||||
params: {
|
||||
...action.params
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface TaskCategorySaved extends Action {
|
||||
taskCategory: TaskCategory
|
||||
}
|
||||
|
||||
export const TASK_CATEGORY_SAVED = "TASK_CATEGORY_SAVED";
|
||||
|
||||
export function taskCategorySaved(taskCategory: TaskCategory): TaskCategorySaved {
|
||||
return { type: TASK_CATEGORY_SAVED, taskCategory };
|
||||
}
|
||||
|
||||
export function handleTaskCategorySaved(project: ProjectState, action: TaskCategorySaved): ProjectState {
|
||||
const taskCategories = [...project.taskCategories];
|
||||
const taskCategoryIndex = taskCategories.findIndex(tc => tc.id === action.taskCategory.id);
|
||||
|
||||
if (taskCategoryIndex === -1) {
|
||||
taskCategories.push({ ...action.taskCategory });
|
||||
} else {
|
||||
taskCategories[taskCategoryIndex] = { ...action.taskCategory };
|
||||
}
|
||||
|
||||
return {
|
||||
...project,
|
||||
taskCategories
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateTaskCategoryLabel extends Action {
|
||||
categoryId: TaskCategoryID
|
||||
label: string
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_CATEGORY_LABEL = "UPDATE_TASK_CATEGORY_LABEL";
|
||||
|
||||
export function updateTaskCategoryLabel(categoryId: TaskCategoryID, label: string): UpdateTaskCategoryLabel {
|
||||
return { type: UPDATE_TASK_CATEGORY_LABEL, categoryId, label };
|
||||
}
|
||||
|
||||
export interface UpdateTaskCategoryCost extends Action {
|
||||
categoryId: TaskCategoryID
|
||||
costPerTimeUnit: number
|
||||
}
|
||||
|
||||
export const UPDATE_TASK_CATEGORY_COST = "UPDATE_TASK_CATEGORY_COST";
|
||||
|
||||
export function updateTaskCategoryCost(categoryId: TaskCategoryID, costPerTimeUnit: number): UpdateTaskCategoryCost {
|
||||
return { type: UPDATE_TASK_CATEGORY_COST, categoryId, costPerTimeUnit };
|
||||
}
|
||||
|
||||
export const ADD_TASK_CATEGORY = "ADD_TASK_CATEGORY";
|
||||
|
||||
export interface AddTaskCategory extends Action {
|
||||
taskCategory: TaskCategory
|
||||
}
|
||||
|
||||
export function addTaskCategory(taskCategory: TaskCategory): AddTaskCategory {
|
||||
return { type: ADD_TASK_CATEGORY, taskCategory };
|
||||
}
|
||||
|
||||
export interface RemoveTaskCategory extends Action {
|
||||
taskCategoryId: TaskCategoryID
|
||||
}
|
||||
|
||||
export const REMOVE_TASK_CATEGORY = "REMOVE_TASK_CATEGORY";
|
||||
|
||||
export function removeTaskCategory(taskCategoryId: TaskCategoryID): RemoveTaskCategory {
|
||||
return { type: REMOVE_TASK_CATEGORY, taskCategoryId };
|
||||
}
|
||||
|
||||
export interface TaskCategoryRemoved extends Action {
|
||||
id: number
|
||||
}
|
||||
|
||||
export const TASK_CATEGORY_REMOVED = "TASK_CATEGORY_REMOVED";
|
||||
|
||||
export function taskCategoryRemoved(id: number): TaskCategoryRemoved {
|
||||
return { type: TASK_CATEGORY_REMOVED, id };
|
||||
}
|
||||
|
||||
export function handleTaskCategoryRemoved(project: ProjectState, action: TaskCategoryRemoved): ProjectState {
|
||||
const taskCategories = [...project.taskCategories];
|
||||
const taskCategoryIndex = project.taskCategories.findIndex(tc => tc.id === action.id);
|
||||
if (taskCategoryIndex === -1) return project;
|
||||
taskCategories.splice(taskCategoryIndex, 1);
|
||||
return {
|
||||
...project,
|
||||
taskCategories
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface ResetProject extends Action {
|
||||
project: Project
|
||||
}
|
||||
|
||||
export const RESET_PROJECT = "RESET_PROJECT";
|
||||
|
||||
export function resetProject(project: Project): ResetProject {
|
||||
const newProject = JSON.parse(JSON.stringify(project));
|
||||
|
||||
newProject.tasks.forEach(t => {
|
||||
if (!t.localId) t.localId = uuid();
|
||||
});
|
||||
|
||||
newProject.taskCategories.forEach(tc => {
|
||||
if (!tc.localId) tc.localId = uuid();
|
||||
});
|
||||
|
||||
return { type: RESET_PROJECT, project: newProject };
|
||||
}
|
||||
|
||||
export function handleResetProject(project: ProjectState, action: ResetProject): ProjectState {
|
||||
return {
|
||||
...project,
|
||||
...action.project,
|
||||
};
|
||||
}
|
||||
|
||||
export interface BackendError extends Action {
|
||||
err: Error
|
||||
}
|
||||
|
||||
export const BACKEND_ERROR = "BACKEND_ERROR";
|
||||
|
||||
export function backendError(err: Error): BackendError {
|
||||
return { type: BACKEND_ERROR, err };
|
||||
}
|
||||
|
||||
export function handleBackendError(project: ProjectState, action: BackendError): ProjectState {
|
||||
return {
|
||||
...project,
|
||||
lastBackendError: action.err,
|
||||
};
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import { useReducer, useRef, useMemo, useCallback, useEffect } from "react"
|
||||
import { runSaga, stdChannel } from 'redux-saga'
|
||||
|
||||
export function useReducerAndSaga<T>(reducer: React.Reducer<any, any>, initialState, rootSaga): [T, (a: any) => void] {
|
||||
const [state, reactDispatch] = useReducer(reducer, initialState)
|
||||
|
||||
const env = useRef(state)
|
||||
env.current = state
|
||||
|
||||
const channel = useMemo(() => stdChannel(), [])
|
||||
const dispatch = useCallback((a) => {
|
||||
setImmediate(channel.put, a)
|
||||
reactDispatch(a)
|
||||
}, [])
|
||||
|
||||
const getState = useCallback(() => env.current, [])
|
||||
|
||||
useEffect(() => {
|
||||
const task = runSaga({ channel, dispatch, getState }, rootSaga)
|
||||
return () => task.cancel()
|
||||
}, [])
|
||||
|
||||
return [state, dispatch]
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export enum Direction {
|
||||
ASC = 1,
|
||||
DESC = -1
|
||||
}
|
||||
|
||||
export function useKeySort<T>(items: T[], key: string, direction: Direction = Direction.ASC): T[] {
|
||||
const predicate = useCallback((a: any, b: any) => {
|
||||
if (!a.hasOwnProperty(key)) return -direction;
|
||||
if (!b.hasOwnProperty(key)) return direction;
|
||||
if (a[key] > b[key]) return direction;
|
||||
if (a[key] < b[key]) return -direction;
|
||||
return 0
|
||||
}, [key, direction])
|
||||
|
||||
return useSort(items, predicate)
|
||||
}
|
||||
|
||||
export function useSort<T>(items: T[], predicate: (a:T, b:T) => number): T[] {
|
||||
const [ sorted, setSorted ] = useState(items);
|
||||
useEffect(() => {
|
||||
const sorted = [ ...items ]
|
||||
|
||||
sorted.sort(predicate)
|
||||
|
||||
setSorted(sorted)
|
||||
}, [items, predicate])
|
||||
|
||||
return sorted
|
||||
}
|
|
@ -1,14 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en" class="has-navbar-fixed-top">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>Guesstimate</title>
|
||||
<% for (var css in htmlWebpackPlugin.files.css) { %>
|
||||
<link href="<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
|
||||
<link href="/<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
|
||||
<% } %>
|
||||
<% if (htmlWebpackPlugin.files.favicon) { %>
|
||||
<link rel="shortcut icon" href="/<%= htmlWebpackPlugin.files.favicon%>">
|
||||
<% } %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<div id="app" class="is-fullheight"></div>
|
||||
<script src="/config.js"></script>
|
||||
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
|
||||
<script type="text/javascript" src="/<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
|
||||
<% } %>
|
||||
</body>
|
||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||
import "./style/index.css";
|
||||
import "bulma/css/bulma.css";
|
||||
import "bulma-switch/dist/css/bulma-switch.min.css";
|
||||
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import App from "./components/app";
|
||||
|
||||
render(
|
||||
React.createElement(App, {}, null),
|
||||
document.getElementById('app')
|
||||
);
|
|
@ -0,0 +1,18 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { App } from './components/App';
|
||||
|
||||
import "./style/index.css";
|
||||
import "bulma/css/bulma.css";
|
||||
import "bulma-switch/dist/css/bulma-switch.min.css";
|
||||
|
||||
import '@fortawesome/fontawesome-free/js/fontawesome'
|
||||
import '@fortawesome/fontawesome-free/js/solid'
|
||||
import '@fortawesome/fontawesome-free/js/regular'
|
||||
import '@fortawesome/fontawesome-free/js/brands'
|
||||
import './resources/favicon.png';
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('app')
|
||||
);
|
|
@ -1,51 +0,0 @@
|
|||
import { Task, TaskID } from './task';
|
||||
import { Params, defaults } from "./params";
|
||||
import { uuidV4 } from "../util/uuid";
|
||||
|
||||
export type ProjectID = string;
|
||||
|
||||
export interface Project {
|
||||
id: ProjectID
|
||||
label: string
|
||||
description: string
|
||||
tasks: Tasks
|
||||
params: Params
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
ordering: TaskID[]
|
||||
}
|
||||
|
||||
export interface Tasks {
|
||||
[id: string]: Task
|
||||
}
|
||||
|
||||
export function newProject(id?: string): Project {
|
||||
return {
|
||||
id: id ? id : uuidV4(),
|
||||
label: "",
|
||||
description: "",
|
||||
tasks: {},
|
||||
params: {
|
||||
...defaults
|
||||
},
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
ordering: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function sanitize(project: Project): Project {
|
||||
if (!Array.isArray(project.ordering)) {
|
||||
project.ordering = Object.keys(project.tasks)
|
||||
}
|
||||
|
||||
if (typeof project.updatedAt === 'string') {
|
||||
project.updatedAt = new Date(project.updatedAt)
|
||||
}
|
||||
|
||||
if (typeof project.createdAt === 'string') {
|
||||
project.createdAt = new Date(project.createdAt)
|
||||
}
|
||||
|
||||
return project
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
// Use this file to customize client configuration.
|
||||
// See frontend/src/config.ts for more informations.
|
||||
window['__CONFIG__'] = {};
|
After Width: | Height: | Size: 888 B |
|
@ -0,0 +1 @@
|
|||
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="stopwatch" class="svg-inline--fa fa-stopwatch fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M432 304c0 114.9-93.1 208-208 208S16 418.9 16 304c0-104 76.3-190.2 176-205.5V64h-28c-6.6 0-12-5.4-12-12V12c0-6.6 5.4-12 12-12h120c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-28v34.5c37.5 5.8 71.7 21.6 99.7 44.6l27.5-27.5c4.7-4.7 12.3-4.7 17 0l28.3 28.3c4.7 4.7 4.7 12.3 0 17l-29.4 29.4-.6.6C419.7 223.3 432 262.2 432 304zm-176 36V188.5c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12V340c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"></path></svg>
|
After Width: | Height: | Size: 660 B |
|
@ -0,0 +1,148 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="256px"
|
||||
height="256px"
|
||||
viewBox="0 0 256 256"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="daddysvg.svg"
|
||||
inkscape:export-filename="/home/benjamin/Images/daddysvg.svg.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14">
|
||||
<defs
|
||||
id="defs3785">
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect11307"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="1"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect11303"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="1"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect11299"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="1"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<inkscape:path-effect
|
||||
effect="bspline"
|
||||
id="path-effect11297"
|
||||
is_visible="true"
|
||||
weight="33.333333"
|
||||
steps="2"
|
||||
helper_size="0"
|
||||
apply_no_weight="true"
|
||||
apply_with_weight="true"
|
||||
only_selected="false" />
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect4672"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="1"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<inkscape:path-effect
|
||||
effect="bspline"
|
||||
id="path-effect4670"
|
||||
is_visible="true"
|
||||
weight="33.333333"
|
||||
steps="2"
|
||||
helper_size="0"
|
||||
apply_no_weight="true"
|
||||
apply_with_weight="true"
|
||||
only_selected="false" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="47.812546"
|
||||
inkscape:cy="121.69356"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1865"
|
||||
inkscape:window-height="1029"
|
||||
inkscape:window-x="55"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:grid-bbox="true">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid11360" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata3788">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="fill:#058eff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
|
||||
d="m 32.583136,21.416152 c 0.432923,-0.183441 1.65138,1.815536 3.85459,5.558711 1.876009,3.187273 5.638052,9.780818 10.540554,14.926476 4.902145,5.186689 12.7877,10.329902 22.509118,11.171913 5.287649,0.501505 10.82326,0.01212 16.981963,-1.006244 6.160916,-1.036929 12.451394,-2.633697 19.096969,-4.720546 5.92081,-1.862873 11.96851,-4.083209 18.09205,-6.704773 4.70577,-2.01913 9.47684,-4.242646 13.98868,-6.84685 2.78157,-1.651835 5.40309,-3.206 7.1713,-5.122172 0.72442,-1.142891 1.45398,-1.672372 1.05724,-1.417617 0.32165,0.358747 -0.21409,0.06426 -0.74301,-0.731311 -1.10708,-1.096321 -2.77281,-2.009494 -4.71571,-3.103565 0,0 -2e-5,-8e-6 -2e-5,-8e-6 -5.02038,-2.724381 -10.68908,-5.025077 -16.52146,-7.931398 -2.71668,-1.344975 -5.54564,-2.85375 -8.31782,-4.709758 0,0 -2e-5,-10e-6 -2e-5,-10e-6 -2.15905,-1.3673133 -4.52019,-3.2751851 -6.52692,-6.0493324 -1.61911,-2.4211048 -2.44027,-5.21000004 -2.40705,-8.0392852 0,0 0,-2.59e-5 0,-2.59e-5 0.09,-2.7949565 0.69429,-5.2119617 1.41807,-7.2341845 0.42972,-1.302744 0.886,-2.553107 1.33877,-3.764434 1.25978,-3.370408 2.45493,-6.346665 2.94174,-9.192843 0.88436,-4.684509 0.5051,-9.593748 -1.02641,-13.97674 -1.81489,-5.355405 -5.58765,-10.060675 -10.09284,-13.565898 -6.185708,-4.82811 -13.850872,-7.899477 -21.424861,-10.19356 -7.846124,-2.284214 -15.31769,-3.712304 -22.49963,-3.291965 0,0 -10e-6,4e-6 -10e-6,4e-6 -4.941703,0.320675 -9.556379,1.724903 -12.759349,4.515646 -3.340828,2.680913 -5.806968,6.910841 -8.090315,11.031815 -6.254309,11.724587 -9.740983,22.044246 -10.398302,32.001908 -0.845296,10.957356 2.454185,22.2768522 4.090997,27.981816 1.895369,6.606141 3.015663,10.171026 2.441687,10.414234 -0.439344,0.186161 -2.566206,-2.934783 -5.446076,-9.308474 -2.557029,-5.6591822 -6.989301,-16.7224702 -7.020222,-29.295099 0.07855,-11.034421 3.227368,-22.756907 9.435014,-35.331317 2.142237,-4.508984 5.001492,-9.589461 9.535428,-13.760978 4.883182,-4.244584 11.147908,-6.571491 17.615613,-7.025057 10e-7,5e-6 1.6e-5,-10e-7 1.6e-5,-10e-7 8.592767,-0.650065 17.191925,0.693474 25.668062,3.084144 8.282922,2.247398 17.023837,5.688766 24.741208,11.430798 5.91486,4.416957 10.85903,10.581991 13.55164,18.017862 2.14173,6.040892 2.69157,12.662434 1.49516,19.106381 -0.80091,4.041083 -2.14135,7.582602 -3.37362,10.870104 -0.44272,1.1811067 -0.86613,2.3161062 -1.24092,3.4206913 -0.51854,1.6952301 -0.95487,3.091231 -0.91259,4.1877256 0,0 0,7.6e-6 0,7.6e-6 -0.0118,0.8349371 0.21925,1.7074536 0.6526,2.28958094 0.66465,1.13442943 2.14357,2.18347446 3.86618,3.44382626 0,0 2e-5,8.3e-6 2e-5,8.3e-6 2.17771,1.4948012 4.63292,2.8070937 7.18494,4.1111063 5.3624,2.7221697 11.13485,5.1455167 16.74875,8.2559417 0,0 2e-5,8e-6 2e-5,8e-6 2.13483,1.143298 4.46579,2.583477 6.67927,4.65126 1.80636,1.426501 3.29256,4.006836 3.65258,7.555011 -0.34386,3.964935 -2.0161,6.713128 -3.85914,8.18127 -3.01783,2.949299 -6.35207,4.9621 -9.36964,6.570362 -5.03606,2.76332 -10.17639,5.028534 -15.13018,6.999205 -6.47792,2.583408 -12.87124,4.723785 -19.12085,6.469439 -7.00088,1.959402 -13.740645,3.397556 -20.366513,4.235038 -6.575016,0.84831 -12.824726,1.051204 -18.888844,0.183956 C 56.987331,58.018531 48.354967,51.422103 43.313256,45.056121 38.316131,38.685001 35.474015,31.775565 34.132073,28.055142 32.633631,23.900835 32.212485,21.573206 32.583136,21.416152 Z"
|
||||
id="path4668"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:path-effect="#path-effect4670;#path-effect4672"
|
||||
inkscape:original-d="m 30,18.5 c 8.834333,17.665667 17.667667,35.332333 26.5,53 C 90.50177,58.998717 124.501,46.499 158.5,34 155.33445,29.165838 152.16767,24.332333 149,19.5 133.33512,13.999275 117.66767,8.4989999 102,2.9999999 108.66791,-4.6679494 115.33433,-12.334333 122,-20 c -2.83194,-12.832552 -5.66567,-25.667667 -8.5,-38.5 -21.497755,-5.667339 -42.999,-11.334334 -64.5,-17 -5.499176,7.49924 -10.999,14.999 -16.5,22.5 -4.499676,12.000804 -8.999,23.999 -13.5,36 3.668035,11.8335217 7.334333,23.6656665 11,35.5 z"
|
||||
transform="matrix(0,-1.3691421,1.8997251,0,140.89907,239.44713)" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 8.1 KiB |
|
@ -1,111 +0,0 @@
|
|||
import React, { FunctionComponent, MouseEvent, useCallback, useEffect, useState } from "react";
|
||||
import style from "./style.module.css";
|
||||
import { useHistory } from 'react-router';
|
||||
import { base58UUID } from '../../util/uuid';
|
||||
import { useStoredProjectList } from "../../hooks/use-stored-project-list";
|
||||
import { formatDate } from "../../util/date";
|
||||
import { Direction, useKeySort, useSort } from "../../hooks/useSort";
|
||||
import { useTitle } from "../../hooks/use-title";
|
||||
|
||||
const Home: FunctionComponent = () => {
|
||||
useTitle('Accueil')
|
||||
|
||||
const [projects] = useStoredProjectList()
|
||||
const [sortingKey, setSortingKey] = useState('updatedAt')
|
||||
const [sortingDirection, setSortingDirection] = useState<Direction>(Direction.DESC)
|
||||
const sortedProjects = useKeySort(projects, sortingKey, sortingDirection)
|
||||
const history = useHistory()
|
||||
|
||||
const openNewProject = () => {
|
||||
const uuid = base58UUID()
|
||||
history.push(`/p/${uuid}`)
|
||||
};
|
||||
|
||||
const openProject = useCallback((evt: MouseEvent<HTMLTableRowElement>) => {
|
||||
const projectId = evt.currentTarget.dataset.projectId;
|
||||
history.push(`/p/${projectId}`)
|
||||
}, [])
|
||||
|
||||
const sortBy = useCallback((evt: MouseEvent<HTMLTableCellElement>) => {
|
||||
const key = evt.currentTarget.dataset.sortKey
|
||||
if (!key) return
|
||||
|
||||
if (sortingKey !== key) {
|
||||
setSortingKey(key)
|
||||
return
|
||||
}
|
||||
|
||||
setSortingDirection(sortingDirection => -sortingDirection)
|
||||
}, [sortingKey, sortingDirection])
|
||||
|
||||
return (
|
||||
<div className={`container ${style.home}`}>
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<div className="buttons is-right">
|
||||
<button className="button is-primary is-medium"
|
||||
onClick={openNewProject}>
|
||||
<strong>+</strong> Nouveau projet
|
||||
</button>
|
||||
</div>
|
||||
<div className="box">
|
||||
<div className="table-container">
|
||||
<table className="table is-fullwidth is-hoverable">
|
||||
<thead>
|
||||
<tr className="is-size-5">
|
||||
<TableHeader onClick={sortBy} label="Projet" isCurrentSortingKey={sortingKey === 'label'} sortingDirection={sortingDirection} sortingKey="label" />
|
||||
<TableHeader onClick={sortBy} label="Mis à jour le" isCurrentSortingKey={sortingKey === 'updatedAt'} sortingDirection={sortingDirection} sortingKey="updatedAt" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
sortedProjects.map(p => (
|
||||
<tr
|
||||
key={`project-${p.id}`}
|
||||
data-project-id={p.id}
|
||||
onClick={openProject}
|
||||
className="is-clickable">
|
||||
<td>
|
||||
<span className="mr-3">🗒️</span>
|
||||
{p.label ? p.label : "Projet sans nom"}
|
||||
</td>
|
||||
<td>
|
||||
{p.updatedAt ? formatDate(p.updatedAt) : "--"}
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
}
|
||||
{
|
||||
projects.length === 0 ?
|
||||
<tr className={style.noProjects}>
|
||||
<td colSpan={2}>
|
||||
Aucun project pour l'instant.
|
||||
</td>
|
||||
</tr> :
|
||||
null
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface TableHeaderProps {
|
||||
onClick?: React.MouseEventHandler<HTMLTableCellElement>
|
||||
sortingKey: string
|
||||
isCurrentSortingKey: boolean
|
||||
sortingDirection: Direction
|
||||
label: string
|
||||
}
|
||||
|
||||
const TableHeader: FunctionComponent<TableHeaderProps> = ({ onClick, isCurrentSortingKey, sortingKey, label, sortingDirection }) => {
|
||||
return (
|
||||
<th className="is-clickable" onClick={onClick} data-sort-key={sortingKey}>{label}<span className={`ml-1 ${!isCurrentSortingKey ? 'is-hidden' : ''}`}>{sortingDirection === Direction.ASC ? '↑' : '↓'}</span></th>
|
||||
)
|
||||
}
|
||||
|
||||
export default Home;
|
|
@ -1,9 +0,0 @@
|
|||
.home {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.noProjects {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
export interface IStyleModuleCss {
|
||||
home: string;
|
||||
noProjects: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -1,18 +0,0 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
import { Link } from 'react-router-dom';
|
||||
import style from "./style.module.css";
|
||||
import { useTitle } from "../../hooks/use-title";
|
||||
|
||||
const NotFound: FunctionComponent = () => {
|
||||
useTitle("Page non trouvée")
|
||||
|
||||
return (
|
||||
<div className={style.notFound}>
|
||||
<h1>Erreur 404</h1>
|
||||
<p>Cette page n'existe pas</p>
|
||||
<Link to="/"><h4>Retour à la page d'accueil</h4></Link>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotFound;
|
|
@ -1,3 +0,0 @@
|
|||
.notFound {
|
||||
display: inherit;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
declare namespace StyleModuleCssModule {
|
||||
export interface IStyleModuleCss {
|
||||
notFound: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const StyleModuleCssModule: StyleModuleCssModule.IStyleModuleCss & {
|
||||
/** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
|
||||
locals: StyleModuleCssModule.IStyleModuleCss;
|
||||
};
|
||||
|
||||
export = StyleModuleCssModule;
|
|
@ -1,74 +0,0 @@
|
|||
import React, { FunctionComponent, Fragment, useCallback } from "react";
|
||||
import { Project } from "../../models/project";
|
||||
import TaskTable from "./tasks-table";
|
||||
import TimePreview from "./time-preview";
|
||||
import FinancialPreview from "./financial-preview";
|
||||
import { addTask, updateTaskEstimation, removeTask, updateTaskLabel, ProjectReducerActions, moveTask } from "../../hooks/use-project-reducer";
|
||||
import { Task, TaskID, EstimationConfidence } from "../../models/task";
|
||||
import RepartitionPreview from "./repartition-preview";
|
||||
import { getHideFinancialPreviewOnPrint } from "../../models/params";
|
||||
|
||||
export interface EstimationTabProps {
|
||||
project: Project
|
||||
dispatch: (action: ProjectReducerActions) => void
|
||||
}
|
||||
|
||||
const EstimationTab: FunctionComponent<EstimationTabProps> = ({ project, dispatch }) => {
|
||||
const onTaskAdd = (task: Task) => {
|
||||
dispatch(addTask(task));
|
||||
};
|
||||
|
||||
const onTaskRemove = (taskId: TaskID) => {
|
||||
dispatch(removeTask(taskId));
|
||||
}
|
||||
|
||||
const onTaskLabelUpdate = (taskId: TaskID, label: string) => {
|
||||
dispatch(updateTaskLabel(taskId, label));
|
||||
}
|
||||
|
||||
const onEstimationChange = (taskId: TaskID, confidence: EstimationConfidence, value: number) => {
|
||||
dispatch(updateTaskEstimation(taskId, confidence, value));
|
||||
};
|
||||
|
||||
const onTaskMove = useCallback((taskId: TaskID, move: number) => {
|
||||
dispatch(moveTask(taskId, move))
|
||||
}, [dispatch])
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="columns">
|
||||
<div className="column is-9">
|
||||
<TaskTable
|
||||
project={project}
|
||||
onTaskMove={onTaskMove}
|
||||
onTaskAdd={onTaskAdd}
|
||||
onTaskRemove={onTaskRemove}
|
||||
onTaskLabelUpdate={onTaskLabelUpdate}
|
||||
onEstimationChange={onEstimationChange} />
|
||||
</div>
|
||||
<div className="column is-3">
|
||||
<TimePreview project={project} />
|
||||
<RepartitionPreview project={project} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="columns">
|
||||
<div className={`column ${getHideFinancialPreviewOnPrint(project) ? 'noPrint' : ''}`}>
|
||||
<FinancialPreview project={project} />
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
Object.keys(project.tasks).length <= 20 ?
|
||||
<div className="message noPrint">
|
||||
<div className="message-body">
|
||||
<p><strong>⚠️ Attention</strong></p>
|
||||
<p>Votre projet ne contient pas assez de tâches pour que les niveaux de confiance soient fiables. Un minimum de 20 tâches est conseillé pour obtenir une estimation pertinente.</p>
|
||||
</div>
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
<hr />
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default EstimationTab;
|
|
@ -1,73 +0,0 @@
|
|||
import React, { FunctionComponent, useEffect } from "react";
|
||||
import style from "./style.module.css";
|
||||
import { newProject, Project, sanitize } from "../../models/project";
|
||||
import { useProjectReducer, updateProjectLabel, patchProject } from "../../hooks/use-project-reducer";
|
||||
import { getProjectStorageKey } from "../../util/storage";
|
||||
import { useLocalStorage } from "../../hooks/use-local-storage";
|
||||
import EditableText from "../../components/editable-text";
|
||||
import Tabs from "../../components/tabs";
|
||||
import EstimationTab from "./estimation-tab";
|
||||
import ParamsTab from "./params-tab";
|
||||
import ExportTab from "./export-tab";
|
||||
import { useServerSync } from "../../hooks/use-server-sync";
|
||||
import { RouteChildrenProps, RouteProps, useParams } from "react-router";
|
||||
import { useTitle } from "../../hooks/use-title";
|
||||
|
||||
export interface ProjectProps {
|
||||
projectId: string
|
||||
}
|
||||
|
||||
const Project: FunctionComponent<ProjectProps> = () => {
|
||||
const { projectId } = useParams<{ projectId: string }>();
|
||||
const projectStorageKey = getProjectStorageKey(projectId);
|
||||
const [ storedProject, storeProject ] = useLocalStorage(projectStorageKey, newProject(projectId));
|
||||
const [ project, dispatch ] = useProjectReducer(sanitize(storedProject));
|
||||
|
||||
useServerSync(project, (project: Project) => {
|
||||
sanitize(project)
|
||||
dispatch(patchProject(project));
|
||||
});
|
||||
|
||||
const onProjectLabelChange = (projectLabel: string) => {
|
||||
dispatch(updateProjectLabel(projectLabel));
|
||||
};
|
||||
|
||||
// Save project in local storage on change
|
||||
useEffect(()=> {
|
||||
storeProject(project);
|
||||
}, [project]);
|
||||
|
||||
useTitle(project.label ? project.label : "Projet sans nom")
|
||||
|
||||
return (
|
||||
<div className={`container ${style.estimation}`}>
|
||||
<EditableText
|
||||
editIconClass="is-size-4"
|
||||
render={(value) => (<h2 className="is-size-3">{value}</h2>)}
|
||||
onChange={onProjectLabelChange}
|
||||
value={project.label ? project.label : "Projet sans nom"}
|
||||
/>
|
||||
<div className={style.tabContainer}>
|
||||
<Tabs items={[
|
||||
{
|
||||
label: 'Estimation',
|
||||
icon: '📋',
|
||||
render: () => <EstimationTab project={project} dispatch={dispatch} />
|
||||
},
|
||||
{
|
||||
label: 'Options avancées',
|
||||
icon: '⚙️',
|
||||
render: () => <ParamsTab project={project} dispatch={dispatch} />
|
||||
},
|
||||
{
|
||||
label: 'Exporter',
|
||||
icon: '↗️',
|
||||
render: () => <ExportTab project={project} />
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Project;
|