rename folders
@@ -0,0 +1,18 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# For the full list of supported browsers by the Angular framework, please see:
|
||||
# https://angular.io/guide/browser-support
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
last 1 Chrome version
|
||||
last 1 Firefox version
|
||||
last 2 Edge major versions
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
Firefox ESR
|
||||
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
|
||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,49 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
# Only exists if Bazel was run
|
||||
/bazel-out
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events*.json
|
||||
speed-measure-plugin*.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.angular/cache
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.vscode
|
||||
@@ -0,0 +1,661 @@
|
||||
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/>.
|
||||
@@ -0,0 +1,3 @@
|
||||
# buntspecht frontend
|
||||
|
||||
Frontend of buntspecht created with Angular Framework.
|
||||
@@ -0,0 +1,132 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"buntspecht-frontent": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "scss"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist/buntspecht",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"assets": [
|
||||
"src/.htaccess",
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/manifest.webmanifest"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": [],
|
||||
"serviceWorker": true,
|
||||
"ngswConfigPath": "ngsw-config.json",
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": true,
|
||||
"optimization": false,
|
||||
"namedChunks": true,
|
||||
"allowedCommonJsDependencies": [
|
||||
"moment"
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"namedChunks": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumError": "5mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb",
|
||||
"maximumError": "10kb"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": ""
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"buildTarget": "buntspecht-frontent:build",
|
||||
"port": 4201
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "buntspecht-frontent:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "buntspecht-frontent:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"karmaConfig": "karma.conf.js",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/manifest.webmanifest"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "e2e/protractor.conf.js",
|
||||
"devServerTarget": "buntspecht-frontent:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "buntspecht-frontent:serve:production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// @ts-check
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
|
||||
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./src/**/*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
browserName: 'chrome'
|
||||
},
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {}
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.json')
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displayStacktrace: StacktraceOption.PRETTY
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
import { AppPage } from './app.po';
|
||||
import { browser, logging } from 'protractor';
|
||||
|
||||
describe('workspace-project App', () => {
|
||||
let page: AppPage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new AppPage();
|
||||
});
|
||||
|
||||
it('should display welcome message', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getTitleText()).toEqual('buntspecht-frontent app is running!');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Assert that there are no errors emitted from the browser
|
||||
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||
expect(logs).not.toContain(jasmine.objectContaining({
|
||||
level: logging.Level.SEVERE,
|
||||
} as logging.Entry));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
navigateTo(): Promise<unknown> {
|
||||
return browser.get(browser.baseUrl) as Promise<unknown>;
|
||||
}
|
||||
|
||||
getTitleText(): Promise<string> {
|
||||
return element(by.css('app-root .content span')).getText() as Promise<string>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/e2e",
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"jasminewd2",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, './coverage/buntspecht-frontent'),
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false,
|
||||
restartOnFileChange: true
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||
"index": "/index.html",
|
||||
"appData": {
|
||||
"version": "1.5.5"
|
||||
},
|
||||
"assetGroups": [
|
||||
{
|
||||
"name": "app",
|
||||
"installMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/favicon.ico",
|
||||
"/index.html",
|
||||
"/manifest.webmanifest",
|
||||
"/*.css",
|
||||
"/*.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "assets",
|
||||
"installMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/assets/**",
|
||||
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"dataGroups": [
|
||||
{
|
||||
"name": "api",
|
||||
"urls": [
|
||||
"/api"
|
||||
],
|
||||
"cacheConfig": {
|
||||
"maxSize": 0,
|
||||
"maxAge": "0u",
|
||||
"strategy": "freshness"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "buntspecht-web",
|
||||
"version": "0.4.1",
|
||||
"license": "AGPL3",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^18.2.7",
|
||||
"@angular/cdk": "^18.2.7",
|
||||
"@angular/common": "^18.2.7",
|
||||
"@angular/compiler": "^18.2.7",
|
||||
"@angular/core": "^18.2.7",
|
||||
"@angular/forms": "^18.2.7",
|
||||
"@angular/material": "^18.2.7",
|
||||
"@angular/material-moment-adapter": "^18.2.7",
|
||||
"@angular/platform-browser": "^18.2.7",
|
||||
"@angular/platform-browser-dynamic": "^18.2.7",
|
||||
"@angular/router": "^18.2.7",
|
||||
"@angular/service-worker": "^18.2.7",
|
||||
"moment": "^2.30.1",
|
||||
"rxjs": "~7.8.1",
|
||||
"tslib": "^2.7.0",
|
||||
"zone.js": "~0.14.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^18.2.7",
|
||||
"@angular/cli": "^18.2.7",
|
||||
"@angular/compiler-cli": "^18.2.7",
|
||||
"@angular/localize": "^18.2.7",
|
||||
"@types/jasmine": "^5.1.4",
|
||||
"jasmine-core": "~5.3.0",
|
||||
"karma": "^6.4.4",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.1",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "^2.1.0",
|
||||
"typescript": "~5.5.4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
|
||||
RewriteCond %{REQUEST_URI} !^/api/.*$
|
||||
RewriteRule ^ - [L]
|
||||
|
||||
RewriteRule ^ /index.html [L]
|
||||
@@ -0,0 +1,44 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AnonymousGuard, AuthAdminGuard, AuthenticatedGuard } from './auth/auth.guard';
|
||||
import { PageLogin } from './pages/login/login.page';
|
||||
import { PageNotFound } from './pages/notfound/notfound.page';
|
||||
import { PageProfile } from './pages/profile/profile.page';
|
||||
|
||||
import { PageManagement } from './pages/management/management.page';
|
||||
import { PagePassword } from './pages/password/password.page';
|
||||
import { PageTurnover } from './pages/turnover/turnover.page';
|
||||
import { PageTurnoversManage } from './pages/turnovers/manage/manage.page';
|
||||
import { PageTurnovers } from './pages/turnovers/turnovers.page';
|
||||
import { PageUnavailable } from './pages/unavailable/unavailable.page';
|
||||
import { PageUserCreate } from './pages/users/create/users.create.page';
|
||||
import { PageUsers } from './pages/users/users.page';
|
||||
import { UiMain } from './ui/main/main.ui';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: 'login', component: PageLogin, canActivate: [AnonymousGuard] },
|
||||
{
|
||||
path: '', component: UiMain, children: [
|
||||
{ path: '', component: PageTurnovers, canActivate: [AuthenticatedGuard] },
|
||||
{ path: 'password', component: PagePassword, canActivate: [AuthenticatedGuard] },
|
||||
{ path: 'profile', component: PageProfile, canActivate: [AuthenticatedGuard] },
|
||||
{ path: 'create', component: PageTurnover, canActivate: [AuthenticatedGuard] },
|
||||
{ path: 't/:id', component: PageTurnover, canActivate: [AuthenticatedGuard] },
|
||||
{ path: 't', component: PageTurnoversManage, canActivate: [AuthAdminGuard] },
|
||||
{ path: 'm', component: PageManagement, canActivate: [AuthAdminGuard] },
|
||||
{ path: 'u', component: PageUsers, canActivate: [AuthAdminGuard] },
|
||||
{ path: 'user', component: PageUserCreate, canActivate: [AuthAdminGuard] },
|
||||
{ path: 'u/:username', component: PageProfile, canActivate: [AuthAdminGuard] },
|
||||
{ path: 'unavailable', component: PageUnavailable },
|
||||
{ path: '**', component: PageNotFound, pathMatch: 'full', canActivate: [AuthenticatedGuard] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload' })],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
@@ -0,0 +1 @@
|
||||
<router-outlet></router-outlet>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { I18nService } from './services/i18n.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html'
|
||||
})
|
||||
|
||||
export class AppComponent {
|
||||
|
||||
constructor(private i18n: I18nService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
window.document.title = this.i18n.get('buntspecht', []);
|
||||
|
||||
if (localStorage.getItem("buntspecht.darkTheme") == "true") {
|
||||
window.document.body.classList.add("dark-theme");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { HTTP_INTERCEPTORS, HttpHandler, HttpInterceptor, HttpRequest, provideHttpClient } from '@angular/common/http';
|
||||
import { APP_INITIALIZER, Injectable, NgModule } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MAT_DATE_LOCALE } from '@angular/material/core';
|
||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import * as moment from 'moment';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { MaterialModule } from './material/material.module';
|
||||
|
||||
import { AutofocusDirective } from './material/autofocus';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { PageLogin } from './pages/login/login.page';
|
||||
import { PageNotFound } from './pages/notfound/notfound.page';
|
||||
import { PageProfile } from './pages/profile/profile.page';
|
||||
import { PageUnavailable } from './pages/unavailable/unavailable.page';
|
||||
import { UiMain } from './ui/main/main.ui';
|
||||
import { I18nEmptyPipe, I18nPipe } from './utils/i18n.pipe';
|
||||
import { MomentPipe } from './utils/moment.pipe';
|
||||
|
||||
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
||||
import { ServiceWorkerModule } from '@angular/service-worker';
|
||||
import { environment } from '../environments/environment';
|
||||
import { PageManagement } from './pages/management/management.page';
|
||||
import { PagePassword } from './pages/password/password.page';
|
||||
import { PageTurnover } from './pages/turnover/turnover.page';
|
||||
import { PageTurnoversManage } from './pages/turnovers/manage/manage.page';
|
||||
import { PageTurnovers } from './pages/turnovers/turnovers.page';
|
||||
import { PageUserCreate } from './pages/users/create/users.create.page';
|
||||
import { PageUsers } from './pages/users/users.page';
|
||||
import { I18nPaginatorIntl, I18nService } from './services/i18n.service';
|
||||
import { ConfirmDialog } from './ui/confirm/confirm.component';
|
||||
import { UiTurnovers } from './ui/turnovers/turnovers.ui';
|
||||
|
||||
|
||||
export function fetchI18n(i18n: I18nService) {
|
||||
return () => i18n.fetch();
|
||||
}
|
||||
|
||||
|
||||
export function setMaterialDate(i18n: I18nService) {
|
||||
let locale = i18n.getLocale();
|
||||
|
||||
if (locale == 'de-informal') {
|
||||
locale = 'de';
|
||||
}
|
||||
|
||||
moment.locale(locale);
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class XhrInterceptor implements HttpInterceptor {
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
||||
const xhr = req.clone({
|
||||
headers: req.headers.set('X-Requested-With', 'XMLHttpRequest').set('Content-Type', 'application/json;charset=UTF-8'), withCredentials: true
|
||||
});
|
||||
return next.handle(xhr);
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AutofocusDirective,
|
||||
I18nPipe,
|
||||
I18nEmptyPipe,
|
||||
MomentPipe,
|
||||
AppComponent,
|
||||
PageTurnovers,
|
||||
PageTurnoversManage,
|
||||
PageTurnover,
|
||||
PageLogin,
|
||||
PageManagement,
|
||||
PageNotFound,
|
||||
PagePassword,
|
||||
PageProfile,
|
||||
PageUnavailable,
|
||||
PageUsers,
|
||||
PageUserCreate,
|
||||
UiMain,
|
||||
UiTurnovers,
|
||||
ConfirmDialog
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
BrowserAnimationsModule,
|
||||
MaterialModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerWhenStable:30000' }),
|
||||
],
|
||||
exports: [MaterialModule],
|
||||
providers: [
|
||||
provideHttpClient(),
|
||||
{ provide: APP_INITIALIZER, useFactory: fetchI18n, deps: [I18nService], multi: true },
|
||||
{ provide: MAT_DATE_LOCALE, useFactory: setMaterialDate, deps: [I18nService], multi: true },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: XhrInterceptor, multi: true },
|
||||
DatePipe,
|
||||
{
|
||||
provide: MatPaginatorIntl, useFactory: (i18n: I18nService) => {
|
||||
const service = new I18nPaginatorIntl();
|
||||
service.injectI18n(i18n)
|
||||
return service;
|
||||
}, deps: [I18nService]
|
||||
},
|
||||
{
|
||||
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
|
||||
useValue: {
|
||||
subscriptSizing: 'dynamic'
|
||||
}
|
||||
}],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { RequestError } from '../services/requesterror';
|
||||
import { UserService } from '../services/user.service';
|
||||
import { I18nService } from '../services/i18n.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthUpdateGuard implements CanActivate {
|
||||
constructor(private authService: AuthService) { }
|
||||
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
this.authService.getAuth().catch(function (error) { });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
constructor(private authService: AuthService, private router: Router) { }
|
||||
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
const that = this;
|
||||
return this.authService.getAuth().then(response => {
|
||||
return true;
|
||||
}).catch(function (error) {
|
||||
if (error instanceof RequestError && (error as RequestError).getResponse().status == 401) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + encodeURIComponent(state.url)), { skipLocationChange: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthenticatedGuard implements CanActivate {
|
||||
constructor(private authService: AuthService, private userService: UserService, private i18nService: I18nService, private router: Router) { }
|
||||
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
const that = this;
|
||||
return this.authService.getAuth().then((data: any) => {
|
||||
this.userService.get().subscribe({
|
||||
next: (user: any) => {
|
||||
let updateLocale = false;
|
||||
let updateTheme = false;
|
||||
let darktheme = 'false';
|
||||
|
||||
if (user.darkTheme) {
|
||||
darktheme = 'true';
|
||||
}
|
||||
|
||||
if (darktheme != localStorage.getItem("buntspecht.darkTheme")) {
|
||||
localStorage.setItem("buntspecht.darkTheme", darktheme);
|
||||
updateTheme = true;
|
||||
}
|
||||
|
||||
if (this.i18nService.locales.indexOf(user.locale) != -1 && localStorage.getItem("buntspecht.locale") != user.locale) {
|
||||
if (this.i18nService.locale != user.locale) {
|
||||
localStorage.setItem("buntspecht.locale", user.locale);
|
||||
updateLocale = true;
|
||||
}
|
||||
}
|
||||
if (updateLocale || updateTheme) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}).catch(function (error) {
|
||||
if (error instanceof RequestError && (error as RequestError).getResponse().status == 401) {
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/login?target=' + encodeURIComponent(state.url)));
|
||||
}
|
||||
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + encodeURIComponent(state.url)), { skipLocationChange: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthAdminGuard implements CanActivate {
|
||||
constructor(private authService: AuthService, private router: Router) { }
|
||||
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
const that = this;
|
||||
return this.authService.getAuth().then(data => {
|
||||
if (data.authorities && data.authorities.find((role) => role.authority == 'ROLE_ADMIN') != undefined) {
|
||||
return true;
|
||||
}
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/not-found'), { skipLocationChange: true });
|
||||
}).catch(function (error) {
|
||||
if (error instanceof RequestError && (error as RequestError).getResponse().status == 401) {
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/login?target=' + encodeURIComponent(state.url)));
|
||||
}
|
||||
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/not-found'), { skipLocationChange: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AnonymousGuard implements CanActivate {
|
||||
constructor(private authService: AuthService, private router: Router) { }
|
||||
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
const that = this;
|
||||
return this.authService.getAuth().then((data: any) => {
|
||||
this.router.navigateByUrl('/');
|
||||
return false;
|
||||
}).catch(function (error) {
|
||||
if (error instanceof RequestError && (error as RequestError).getResponse().status == 401) {
|
||||
return true;
|
||||
}
|
||||
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + encodeURIComponent(state.url)), { replaceUrl: true });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Directive, ElementRef, OnInit } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[matAutofocus]',
|
||||
})
|
||||
export class AutofocusDirective implements OnInit {
|
||||
|
||||
constructor(private element: ElementRef) { }
|
||||
|
||||
ngOnInit() {
|
||||
setTimeout(() => {
|
||||
this.element.nativeElement.focus();
|
||||
this.element.nativeElement.scrollIntoView();
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
// Material Form Controls
|
||||
import {MatAutocompleteModule} from '@angular/material/autocomplete';
|
||||
import {MatCheckboxModule} from '@angular/material/checkbox';
|
||||
import {MatDatepickerModule} from '@angular/material/datepicker';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {MatRadioModule} from '@angular/material/radio';
|
||||
import {MatSelectModule} from '@angular/material/select';
|
||||
import {MatSliderModule} from '@angular/material/slider';
|
||||
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
||||
// Material Navigation
|
||||
import {MatMenuModule} from '@angular/material/menu';
|
||||
import {MatSidenavModule} from '@angular/material/sidenav';
|
||||
import {MatToolbarModule} from '@angular/material/toolbar';
|
||||
// Material Layout
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatDividerModule} from '@angular/material/divider';
|
||||
import {MatExpansionModule} from '@angular/material/expansion';
|
||||
import {MatGridListModule} from '@angular/material/grid-list';
|
||||
import {MatListModule} from '@angular/material/list';
|
||||
import {MatStepperModule} from '@angular/material/stepper';
|
||||
import {MatTabsModule} from '@angular/material/tabs';
|
||||
import {MatTreeModule} from '@angular/material/tree';
|
||||
// Material Buttons & Indicators
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatButtonToggleModule} from '@angular/material/button-toggle';
|
||||
import {MatBadgeModule} from '@angular/material/badge';
|
||||
import {MatChipsModule} from '@angular/material/chips';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
||||
import {MatProgressBarModule} from '@angular/material/progress-bar';
|
||||
import {MatRippleModule} from '@angular/material/core';
|
||||
// Material Popups & Modals
|
||||
import {MatBottomSheetModule} from '@angular/material/bottom-sheet';
|
||||
import {MatDialogModule} from '@angular/material/dialog';
|
||||
import {MatSnackBarModule} from '@angular/material/snack-bar';
|
||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||
// Material Data tables
|
||||
import {MatPaginatorModule} from '@angular/material/paginator';
|
||||
import {MatSortModule} from '@angular/material/sort';
|
||||
import {MatTableModule} from '@angular/material/table';
|
||||
import {MatMomentDateModule} from '@angular/material-moment-adapter';
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatAutocompleteModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatRadioModule,
|
||||
MatSelectModule,
|
||||
MatSliderModule,
|
||||
MatSlideToggleModule,
|
||||
MatMenuModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule,
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatExpansionModule,
|
||||
MatGridListModule,
|
||||
MatListModule,
|
||||
MatStepperModule,
|
||||
MatTabsModule,
|
||||
MatTreeModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatBadgeModule,
|
||||
MatChipsModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatProgressBarModule,
|
||||
MatRippleModule,
|
||||
MatBottomSheetModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatTooltipModule,
|
||||
MatPaginatorModule,
|
||||
MatSortModule,
|
||||
MatTableModule,
|
||||
MatMomentDateModule
|
||||
],
|
||||
exports: [
|
||||
MatAutocompleteModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatRadioModule,
|
||||
MatSelectModule,
|
||||
MatSliderModule,
|
||||
MatSlideToggleModule,
|
||||
MatMenuModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule,
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatExpansionModule,
|
||||
MatGridListModule,
|
||||
MatListModule,
|
||||
MatStepperModule,
|
||||
MatTabsModule,
|
||||
MatTreeModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatBadgeModule,
|
||||
MatChipsModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatProgressBarModule,
|
||||
MatRippleModule,
|
||||
MatBottomSheetModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatTooltipModule,
|
||||
MatPaginatorModule,
|
||||
MatSortModule,
|
||||
MatTableModule
|
||||
]
|
||||
})
|
||||
export class MaterialModule {}
|
||||
@@ -0,0 +1,54 @@
|
||||
<div class="container">
|
||||
<div class="flex column fill center middle">
|
||||
<form action="{{apiUrl}}/login" method="POST" #loginForm class="box">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<img class="logo" src="assets/images/banner.png">
|
||||
<h2>{{'login.internal' | i18n}}</h2>
|
||||
<mat-error *ngIf="loginInvalid">
|
||||
{{'login.invalid' | i18n}}
|
||||
</mat-error>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'login.username' | i18n}}</mat-label>
|
||||
<input id="username" name="username" matInput required matAutofocus [value]="username">
|
||||
<mat-error>
|
||||
{{'login.username.missing' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'login.password' | i18n}}</mat-label>
|
||||
<input id="password" name="password" matInput type="password" required>
|
||||
<mat-error>
|
||||
{{'login.password.invalid.hint' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-slide-toggle (change)="rememberMe.value = '' + $event.checked">
|
||||
{{'login.keepSession' | i18n}}
|
||||
</mat-slide-toggle>
|
||||
<input #rememberMe id="remember-me" name="remember-me" type="hidden">
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button type="submit" (click)="loginForm.submit()" mat-raised-button color="primary"
|
||||
[disabled]="loginForm.invalid"><mat-icon>open_in_new</mat-icon>{{'login' | i18n}}</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
|
||||
<mat-card *ngIf="externals && externals.length > 0" class="box">
|
||||
<mat-card-content>
|
||||
<h2>{{'login.external' | i18n}}</h2>
|
||||
<mat-error *ngIf="externalLoginInvalid">
|
||||
{{'login.external.invalid' | i18n}}
|
||||
</mat-error>
|
||||
</mat-card-content>
|
||||
<mat-card-actions class="flex wrap">
|
||||
<a class="external-login" (click)="externalLogin(client)" *ngFor="let client of externals"
|
||||
mat-raised-button color="accent">{{'login.external.client' | i18n:('login.provider.' + client.id |
|
||||
i18n)}}</a>
|
||||
<mat-slide-toggle [(ngModel)]="autologin">
|
||||
{{'login.autologin' | i18n}}
|
||||
</mat-slide-toggle>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,33 @@
|
||||
img.logo {
|
||||
width: 300px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
mat-form-field,
|
||||
mat-slide-toggle {
|
||||
display: block;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
a.external-login {
|
||||
margin: 20px 0;
|
||||
flex-basis: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.box {
|
||||
margin: 5px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'page-login',
|
||||
templateUrl: './login.page.html',
|
||||
styleUrls: ['./login.page.scss']
|
||||
})
|
||||
export class PageLogin implements OnInit {
|
||||
|
||||
@ViewChild('loginForm') loginForm: ElementRef;
|
||||
autologin: boolean = false;
|
||||
loginInvalid: boolean;
|
||||
externalLoginInvalid: boolean;
|
||||
apiUrl = environment.apiUrl;
|
||||
targetRoute: string;
|
||||
externals: any[];
|
||||
username: string = '';
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.route.queryParams.subscribe({
|
||||
next: (params) => {
|
||||
if (params['target']) {
|
||||
this.targetRoute = params['target'];
|
||||
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', replaceUrl: true });
|
||||
}
|
||||
if (params['error'] || params['error'] == '') {
|
||||
this.loginInvalid = true;
|
||||
this.router.navigate([], { queryParams: { error: null }, queryParamsHandling: 'merge', replaceUrl: true });
|
||||
}
|
||||
if (params['username']) {
|
||||
this.username = params['username'];
|
||||
this.router.navigate([], { queryParams: { username: null }, queryParamsHandling: 'merge', replaceUrl: true });
|
||||
}
|
||||
if (params['externalError'] || params['externalError'] == '') {
|
||||
this.externalLoginInvalid = true;
|
||||
this.router.navigate([], { queryParams: { externalError: null }, queryParamsHandling: 'merge', replaceUrl: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.authService.getExternal().subscribe({
|
||||
next: (data: any[]) => {
|
||||
this.externals = data;
|
||||
const autologinClient = localStorage.getItem("buntspecht.autologin");
|
||||
for (let client of this.externals) {
|
||||
if (client.id == autologinClient) {
|
||||
window.location.href = this.apiUrl + "/" + client.loginUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
if (this.targetRoute) {
|
||||
this.loginForm.nativeElement.action = this.loginForm.nativeElement.action + "?forward=" + window.location.origin + encodeURIComponent(this.targetRoute);
|
||||
}
|
||||
}
|
||||
|
||||
externalLogin(client: any): void {
|
||||
if (this.autologin) {
|
||||
localStorage.setItem("buntspecht.autologin", client.id);
|
||||
} else {
|
||||
localStorage.removeItem("buntspecht.autologin");
|
||||
}
|
||||
|
||||
window.location.href = this.apiUrl + "/" + client.loginUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<div class="flex column fill">
|
||||
@if (entries && entries.error) {
|
||||
<div class="flex column fill">
|
||||
<mat-card class="accent box">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ 'management.error.' + entries.error.status | i18n}}</mat-card-title>
|
||||
<mat-card-subtitle>{{'management.error' | i18n}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>
|
||||
{{ 'management.error.' + entries.error.status + '.text' | i18n}}
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="flex wrap filter-container">
|
||||
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'turnovers.filter' | i18n}}"
|
||||
[color]="filterOpen ? 'primary': 'accent'">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
</a>
|
||||
|
||||
@if (filterOpen) {
|
||||
<form class="flex wrap filter">
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'management.filter.dueDate' | i18n}}</mat-label>
|
||||
<mat-date-range-input [rangePicker]="picker">
|
||||
<input matStartDate placeholder="{{'turnovers.filter.dueDate.from' | i18n}}"
|
||||
[value]="entries && entries.filter && entries.filter.from"
|
||||
(dateChange)="setFilter('from', $event.value && $event.value.toISOString() || undefined)">
|
||||
<input matEndDate placeholder="{{'turnovers.filter.dueDate.to' | i18n}}"
|
||||
[value]="entries && entries.filter && entries.filter.to"
|
||||
(dateChange)="setFilter('to', $event.value && $event.value.endOf('day').toISOString() || undefined)">
|
||||
</mat-date-range-input>
|
||||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-date-range-picker #picker></mat-date-range-picker>
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'management.filter.username' | i18n}}</mat-label>
|
||||
<input type="text" matInput [matAutocomplete]="auto" [formControl]="usersFormControl"
|
||||
(change)="setInputFilter('username', $event.target)">
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="setFilter('username', $event.option.value)">
|
||||
@for (user of users | async; track user.username) {
|
||||
<mat-option [value]="user.username">{{user.username}}</mat-option>
|
||||
}
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
}
|
||||
<span class="spacer"></span>
|
||||
<a class="margin" mat-icon-button (click)="export()" title="{{'turnovers.export' | i18n}}" color="primary" [disabled]="!entries.total">
|
||||
<mat-icon>file_download</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (entries && entries.total == 0) {
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<p>{{'paginator.empty' | i18n}}</p>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
}
|
||||
|
||||
@if (entries && entries.total) {
|
||||
<div class="scroll-container">
|
||||
<table class="default-table" mat-table [dataSource]="entries.results || []" multiTemplateDataRows matSort
|
||||
(matSortChange)="applySort($event)" [matSortDisableClear]="true">
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header [disableClear]="false">
|
||||
{{'user.username' | i18n}}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let entry">
|
||||
<div class="flex middle">
|
||||
<a class="select-user"
|
||||
[ngClass]="{'selected': entries.filter && entries.filter.username == entry[0]}"
|
||||
(click)="selectUser(entry[0])">{{entry[0]}}</a>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="price">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>
|
||||
<span class="spacer"></span>
|
||||
<span>{{'turnover.price' | i18n}}</span>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let entry">
|
||||
<div class="flex">
|
||||
<span class="spacer"></span>
|
||||
<span>{{entry[1] | number: '1.2-2'}}</span>
|
||||
<span> {{'turnover.price.suffix' | i18n}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="timeInvestment">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>
|
||||
<span class="spacer"></span>
|
||||
<span>{{'turnover.timeInvestment' | i18n}}</span>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let entry">
|
||||
<div class="flex">
|
||||
<span class="spacer"></span>
|
||||
<span>{{entry[2] | number: '1.1-1'}}</span>
|
||||
<span> {{'turnover.timeInvestment.suffix' | i18n}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="menu">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let entry">
|
||||
@if (entries.filter && entries.filter.username == entry[0]) {
|
||||
<button mat-icon-button (click)="expanded = !expanded">
|
||||
@if (expanded) {
|
||||
<mat-icon>keyboard_arrow_up</mat-icon>
|
||||
} @else {
|
||||
<mat-icon>keyboard_arrow_down</mat-icon>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="expanded">
|
||||
<td mat-cell *matCellDef="let entry" [attr.colspan]="columns.length">
|
||||
@if (expanded && entries.total && entries.filter && entries.filter.username == entry[0]) {
|
||||
<ui-turnovers #uiTurnovers class="flex column fill" [turnovers]="turnovers" (page)="applyTurnoverPage($event)"
|
||||
[enableSort]="false"></ui-turnovers>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="columns; sticky: true"></tr>
|
||||
<tr class="entry" mat-row *matRowDef="let row; columns: columns;"></tr>
|
||||
|
||||
<tr class="expanded-row" [ngClass]="{'visible' : expanded}" mat-row
|
||||
*matRowDef="let row; columns: expanded ? ['expanded'] : []"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if (!entries.filter || !entries.filter.username) {
|
||||
<span class="spacer"></span>
|
||||
<div class="mat-mdc-paginator flex">
|
||||
<span class="spacer"></span>
|
||||
<mat-paginator [pageSizeOptions]="pageSizeOptions" [pageIndex]="entries.offset / entries.limit"
|
||||
[length]="entries.total" [pageSize]="entries.limit" (page)="applyPage($event)" showFirstLastButtons>
|
||||
</mat-paginator>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!entries || !entries.results && !entries.error) {
|
||||
<mat-progress-bar *ngIf="" mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
.filter-container {
|
||||
padding-left: 15px;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
.filter {
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&>* {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.expanded-row {
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
transition: height 500ms ease-in-out;
|
||||
|
||||
&.visible {
|
||||
visibility: visible;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
}
|
||||
|
||||
a.select-user {
|
||||
cursor: pointer;
|
||||
|
||||
&.selected {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { debounceTime, Observable, switchMap } from 'rxjs';
|
||||
import { I18nService } from 'src/app/services/i18n.service';
|
||||
import { TurnoverManagementService } from 'src/app/services/turnover.management.service';
|
||||
import { UserManagementService } from 'src/app/services/user.management.service';
|
||||
import { UiTurnovers } from 'src/app/ui/turnovers/turnovers.ui';
|
||||
|
||||
@Component({
|
||||
selector: 'ui-management',
|
||||
templateUrl: './management.page.html',
|
||||
styleUrls: ['./management.page.scss']
|
||||
})
|
||||
export class PageManagement implements OnInit {
|
||||
|
||||
@Input() entries: any;
|
||||
pageSizeOptions: number[] = [1, 2, 3, 4, 5, 10, 15, 30, 50, 100];
|
||||
sort: string = "username";
|
||||
descending: boolean = false;
|
||||
filterOpen: boolean = true;
|
||||
|
||||
columns: string[] = ['username', 'price', 'timeInvestment', 'menu'];
|
||||
expanded: boolean = false;
|
||||
|
||||
users: Observable<any>;
|
||||
usersFormControl = new FormControl();
|
||||
|
||||
@ViewChild('uiTurnovers') uiTurnovers: UiTurnovers;
|
||||
|
||||
turnovers: any;
|
||||
|
||||
constructor(
|
||||
private turnoverManagementService: TurnoverManagementService,
|
||||
private userManagementService: UserManagementService,
|
||||
private i18n: I18nService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.entries = {};
|
||||
this.turnovers = {};
|
||||
this.users = this.usersFormControl
|
||||
.valueChanges
|
||||
.pipe(
|
||||
debounceTime(300),
|
||||
switchMap(value => this.userManagementService.pick(value))
|
||||
);
|
||||
|
||||
this.route.queryParams.subscribe({
|
||||
next: (params) => {
|
||||
this.entries = { filter: {} };
|
||||
this.expanded = false;
|
||||
if (params['l']) {
|
||||
this.entries.limit = +params['l'];
|
||||
if (this.entries.limit < 1) {
|
||||
this.entries.limit = 1;
|
||||
}
|
||||
}
|
||||
if (params['o']) {
|
||||
this.entries.offset = +params['o'];
|
||||
if (this.entries.offset < 0) {
|
||||
this.entries.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params['s']) {
|
||||
this.sort = params['s'];
|
||||
}
|
||||
|
||||
if (params['a']) {
|
||||
this.descending = false;
|
||||
} else {
|
||||
this.descending = true;
|
||||
}
|
||||
|
||||
for (const param in params) {
|
||||
if (param != 'l' && param != 'o' && param != 's' && param != 'a') {
|
||||
this.entries.filter[param] = params[param];
|
||||
}
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
const filter = JSON.parse(JSON.stringify(this.entries.filter || {}));
|
||||
this.turnoverManagementService.overview(this.entries.limit || 15, this.entries.offset || 0, this.sort, this.descending, filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.entries = data;
|
||||
this.entries.filter = filter;
|
||||
if (filter.username) {
|
||||
this.applyUser(filter.username);
|
||||
}
|
||||
}, error: (error) => {
|
||||
this.entries = { error: error };
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
update() {
|
||||
const filter = JSON.parse(JSON.stringify(this.entries.filter || {}));
|
||||
|
||||
const params: Params = { l: null, o: null, s: null, a: null };
|
||||
|
||||
if ((this.entries.limit || 15) != 15) {
|
||||
params['l'] = this.entries.limit;
|
||||
}
|
||||
|
||||
if ((this.entries.offset || 0) != 0) {
|
||||
params['o'] = this.entries.offset;
|
||||
}
|
||||
|
||||
if (this.sort != 'username') {
|
||||
params['s'] = this.sort;
|
||||
}
|
||||
|
||||
if (!this.descending) {
|
||||
params['a'] = true;
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
for (const param in filter) {
|
||||
params[param] = filter[param] || null;
|
||||
}
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'replace'
|
||||
});
|
||||
}
|
||||
|
||||
applyPage(event: PageEvent) {
|
||||
this.entries.limit = event.pageSize;
|
||||
this.entries.offset = event.pageSize * event.pageIndex;
|
||||
this.update();
|
||||
}
|
||||
|
||||
applySort(event: Sort) {
|
||||
this.sort = event.direction ? event.active : 'username';
|
||||
this.descending = event.direction !== 'asc';
|
||||
this.update();
|
||||
}
|
||||
|
||||
setInputFilter(key: string, target: EventTarget) {
|
||||
this.setFilter(key, (target as HTMLInputElement).value);
|
||||
}
|
||||
|
||||
setFilter(key: string, value) {
|
||||
if (value != this.entries.filter[key]) {
|
||||
this.entries.filter[key] = value;
|
||||
this.entries.offset = 0;
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
selectUser(username: string) {
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: { username: this.entries.filter && this.entries.filter.username == username ? null : username },
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
}
|
||||
|
||||
applyUser(username: string) {
|
||||
this.usersFormControl.setValue(username);
|
||||
if (this.entries.total) {
|
||||
this.expanded = true;
|
||||
const filter = JSON.parse(JSON.stringify(this.entries.filter || {}));
|
||||
this.turnoverManagementService.fetch(this.turnovers.limit || 100, this.turnovers.offset || 0, 'dueDate', true, filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.turnovers = data;
|
||||
this.turnovers.filter = filter;
|
||||
}, error: (error) => {
|
||||
this.turnovers = { error: error };
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
applyTurnoverPage(event: PageEvent) {
|
||||
this.turnovers.limit = event.pageSize;
|
||||
this.turnovers.offset = event.pageSize * event.pageIndex;
|
||||
this.applyUser(this.usersFormControl.value);
|
||||
}
|
||||
|
||||
|
||||
export() {
|
||||
if (this.entries.total) {
|
||||
let rows = [[this.i18n.get('user.username'), this.i18n.get('turnover.price'), this.i18n.get('turnover.price.suffix')]];
|
||||
|
||||
this.entries.results.forEach(result => {
|
||||
rows[rows.length] = [result[0], result[1], [result[2]]]
|
||||
});
|
||||
|
||||
if (this.uiTurnovers) {
|
||||
rows.push(...this.uiTurnovers.getCsvRows());
|
||||
}
|
||||
|
||||
if (rows.length) {
|
||||
let csvContent = "data:text/csv;charset=utf-8,"
|
||||
+ rows.map(e => e.join(";")).join("\n");
|
||||
|
||||
var encodedUri = encodeURI(csvContent);
|
||||
var link = document.createElement("a");
|
||||
link.setAttribute("href", encodedUri);
|
||||
link.setAttribute("download", "export.csv");
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<div class="container">
|
||||
<div class="flex column fill center middle">
|
||||
<mat-card class="accent box">
|
||||
<mat-card-header>
|
||||
<mat-card-title>404</mat-card-title>
|
||||
<mat-card-subtitle>{{'not-found' | i18n}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>
|
||||
{{'not-found.text' | i18n}}
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
.box {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'page-notfound',
|
||||
templateUrl: './notfound.page.html',
|
||||
styleUrls: [ './notfound.page.scss' ]
|
||||
})
|
||||
export class PageNotFound {
|
||||
|
||||
constructor() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="flex column fill middle">
|
||||
<form [formGroup]="passwordForm" (ngSubmit)="setPassword()">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<mat-card-title>{{'password' | i18n}}</mat-card-title>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'password.old' | i18n}}</mat-label>
|
||||
<input matInput formControlName="old" type="password">
|
||||
<mat-error *ngFor="let error of passwordForm.get('old').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'password.new' | i18n}}</mat-label>
|
||||
<input matInput formControlName="password" type="password">
|
||||
<mat-error *ngFor="let error of passwordForm.get('password').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'password.repeat' | i18n}}</mat-label>
|
||||
<input matInput formControlName="password2" type="password">
|
||||
<mat-error *ngFor="let error of passwordForm.get('password2').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button type="submit" *ngIf="!working" mat-raised-button color="primary" [disabled]="passwordForm.invalid">
|
||||
{{'password.update' | i18n}}
|
||||
</button>
|
||||
<a *ngIf="passwordSuccess" mat-button color="primary">{{'password.success' | i18n}}</a>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
mat-form-field {
|
||||
display: block;
|
||||
margin: 20px 0 !important;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { AbstractControlOptions, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { UserService } from '../../services/user.service';
|
||||
import { MatchingValidator } from 'src/app/utils/matching.validator';
|
||||
|
||||
@Component({
|
||||
selector: 'page-password',
|
||||
templateUrl: './password.page.html',
|
||||
styleUrls: ['./password.page.scss']
|
||||
})
|
||||
export class PagePassword implements OnInit, OnDestroy {
|
||||
|
||||
auth: any;
|
||||
working: boolean = false;
|
||||
passwordSuccess: boolean = false;
|
||||
passwordForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private formBuilder: FormBuilder) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.passwordForm = this.formBuilder.group({
|
||||
old: ['', Validators.nullValidator],
|
||||
password: ['', Validators.nullValidator],
|
||||
password2: ['', Validators.nullValidator]
|
||||
}, {
|
||||
validator: MatchingValidator('password', 'password2')
|
||||
} as AbstractControlOptions);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
}
|
||||
|
||||
passwordHasError(controlName: string): boolean {
|
||||
return this.passwordForm.controls[controlName].errors != null;
|
||||
}
|
||||
|
||||
setPassword() {
|
||||
if (this.working) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.working = true;
|
||||
this.passwordSuccess = false;
|
||||
this.userService.setPassword(this.passwordForm.get('old').value, this.passwordForm.get('password').value, this.passwordForm.get('password2').value).subscribe({
|
||||
next: () => {
|
||||
this.working = false;
|
||||
this.passwordSuccess = true;
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 409) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.passwordForm.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<div class="flex column fill middle">
|
||||
<form [formGroup]="profileForm" (ngSubmit)="saveProfile()" *ngIf="user">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'profile.username' | i18n}}</mat-label>
|
||||
<input matInput formControlName="username" type="name">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'profile.name' | i18n}}</mat-label>
|
||||
<input matInput formControlName="name" type="name">
|
||||
<mat-error *ngIf="profileHasError('name')">
|
||||
{{'profile.name.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'profile.email' | i18n}}</mat-label>
|
||||
<input matInput formControlName="email" type="email">
|
||||
<mat-error *ngIf="profileHasError('email')">
|
||||
{{'profile.email.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'profile.about' | i18n}}</mat-label>
|
||||
<textarea matAutosize matAutosizeMinRows="3" matInput formControlName="about"></textarea>
|
||||
<mat-error>
|
||||
{{'profile.about.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
@if (admin) {
|
||||
<mat-slide-toggle class="margin" [checked]="isAdmin" (change)="isAdmin=$event.checked">
|
||||
{{'user.admin' | i18n}}
|
||||
</mat-slide-toggle>
|
||||
}
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button type="submit" *ngIf="!working" mat-raised-button color="primary" [disabled]="profileForm.invalid">
|
||||
{{'profile.update' | i18n}}
|
||||
</button>
|
||||
<a *ngIf="profileSuccess" mat-button color="primary">{{'profile.success' | i18n}}</a>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
|
||||
@if(admin) {
|
||||
<form [formGroup]="passwordForm" (ngSubmit)="setPassword()">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'password.new' | i18n}}</mat-label>
|
||||
<input matInput formControlName="password" type="password">
|
||||
<mat-error *ngFor="let error of passwordForm.get('password').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label>{{'password.repeat' | i18n}}</mat-label>
|
||||
<input matInput formControlName="password2" type="password">
|
||||
<mat-error *ngFor="let error of passwordForm.get('password2').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button type="submit" *ngIf="!working" mat-raised-button color="primary" [disabled]="passwordForm.invalid">
|
||||
{{'password.update' | i18n}}
|
||||
</button>
|
||||
<a *ngIf="passwordSuccess" mat-button color="primary">{{'password.success' | i18n}}</a>
|
||||
@if (admin && user && user.username) {
|
||||
<span class="spacer"></span>
|
||||
<a mat-raised-button color="warn" (click)="deleteUser()">
|
||||
<mat-icon>delete</mat-icon> {{'user.delete' | i18n}}
|
||||
</a>
|
||||
}
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
mat-form-field,
|
||||
mat-slide-toggle {
|
||||
display: block;
|
||||
margin: 20px 0 !important;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { AbstractControlOptions, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { UserService } from '../../services/user.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserManagementService } from 'src/app/services/user.management.service';
|
||||
import { MatchingValidator } from 'src/app/utils/matching.validator';
|
||||
import { ConfirmDialog } from 'src/app/ui/confirm/confirm.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'page-profile',
|
||||
templateUrl: './profile.page.html',
|
||||
styleUrls: ['./profile.page.scss']
|
||||
})
|
||||
export class PageProfile implements OnInit, OnDestroy {
|
||||
|
||||
auth: any;
|
||||
user: any;
|
||||
working: boolean = false;
|
||||
profileSuccess: boolean = false;
|
||||
profileForm: FormGroup;
|
||||
passwordSuccess: boolean = false;
|
||||
passwordForm: FormGroup;
|
||||
admin: boolean = false;
|
||||
isAdmin: boolean = false;
|
||||
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private userManagementService: UserManagementService,
|
||||
private formBuilder: FormBuilder,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.profileForm = this.formBuilder.group({
|
||||
username: [{ disabled: true }, Validators.nullValidator],
|
||||
email: ['', Validators.nullValidator],
|
||||
name: ['', Validators.nullValidator],
|
||||
about: ['', Validators.nullValidator]
|
||||
});
|
||||
|
||||
this.passwordForm = this.formBuilder.group({
|
||||
password: ['', Validators.nullValidator],
|
||||
password2: ['', Validators.nullValidator]
|
||||
}, {
|
||||
validator: MatchingValidator('password', 'password2')
|
||||
} as AbstractControlOptions);
|
||||
|
||||
this.profileForm.get('username').disable();
|
||||
|
||||
let userFetch = this.userService.get();
|
||||
if (this.route.snapshot.paramMap.has('username')) {
|
||||
this.admin = true;
|
||||
userFetch = this.userManagementService.get(this.route.snapshot.paramMap.get('username'));
|
||||
}
|
||||
|
||||
userFetch.subscribe({
|
||||
next: (user) => {
|
||||
this.user = user;
|
||||
this.isAdmin = this.user.roles && this.user.roles.indexOf('ROLE_ADMIN') != -1;
|
||||
this.profileForm.get('username').setValue(this.user.username);
|
||||
this.profileForm.get('name').setValue(this.user.name);
|
||||
this.profileForm.get('email').setValue(this.user.email);
|
||||
this.profileForm.get('about').setValue(this.user.about);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
}
|
||||
|
||||
profileHasError(controlName: string): boolean {
|
||||
return this.profileForm.controls[controlName].errors != null;
|
||||
}
|
||||
|
||||
saveProfile(): void {
|
||||
if (this.working) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.working = true;
|
||||
this.profileSuccess = false;
|
||||
|
||||
this.user.about = this.profileForm.get('about').value;
|
||||
this.user.email = this.profileForm.get('email').value;
|
||||
this.user.name = this.profileForm.get('name').value;
|
||||
|
||||
if (this.isAdmin && (!this.user.roles || this.user.roles.indexOf('ROLE_ADMIN') == -1)) {
|
||||
this.user.roles = this.user.roles || [];
|
||||
this.user.roles.push('ROLE_ADMIN');
|
||||
} else if (!this.isAdmin && this.user.roles && this.user.roles.indexOf('ROLE_ADMIN') != -1) {
|
||||
this.user.roles.splice(this.user.roles.indexOf('ROLE_ADMIN'), 1);
|
||||
}
|
||||
|
||||
const create = this.admin ? this.userManagementService.update(this.user) : this.userService.update(this.user);
|
||||
|
||||
create.subscribe({
|
||||
next: (data) => {
|
||||
this.user = data;
|
||||
this.isAdmin = this.user.roles && this.user.roles.indexOf('ROLE_ADMIN') != -1;
|
||||
this.working = false;
|
||||
this.profileSuccess = true;
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 422) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.profileForm.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
setPassword() {
|
||||
if (this.working) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.working = true;
|
||||
this.passwordSuccess = false;
|
||||
this.userManagementService.setPassword(this.user.username, this.passwordForm.get('password').value).subscribe({
|
||||
next: () => {
|
||||
this.working = false;
|
||||
this.passwordSuccess = true;
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 409) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.passwordForm.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
deleteUser() {
|
||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||
data: {
|
||||
'label': 'user.confirmDelete',
|
||||
'args': [this.user.username]
|
||||
}
|
||||
})
|
||||
|
||||
dialogRef.afterClosed().subscribe({
|
||||
next: (result) => {
|
||||
if (result) {
|
||||
this.userManagementService.deleteUser(this.user.username).subscribe({
|
||||
next: () => {
|
||||
this.router.navigateByUrl('/u');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<div class="flex column fill middle">
|
||||
@if (!turnover) {
|
||||
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
@if (turnover) {
|
||||
<form [formGroup]="form" (ngSubmit)="turnover.id ? update() : create()" #formDirective="ngForm">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<div class="flex space-between">
|
||||
<p>{{ (turnover.id ? 'turnover.edit' : 'turnover.info') | i18n}}</p>
|
||||
@if (turnover.created) {
|
||||
<span>{{(turnover.username == username ? 'turnover.created.label' : 'turnover.created.label.username') |
|
||||
i18n:(turnover.created | datef:'LLL' ):turnover.username}}</span>
|
||||
}
|
||||
</div>
|
||||
<mat-form-field [floatLabel]="'always'">
|
||||
<mat-label>{{'turnover.dueDate' | i18n}}</mat-label>
|
||||
<input matInput formControlName="dueDate" [matDatepicker]="picker"
|
||||
[placeholder]="(turnover.created || today) | datef:'L'">
|
||||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.customer' | i18n}}</mat-label>
|
||||
<input matInput formControlName="customer" type="text" [required]="true">
|
||||
<mat-error *ngIf="hasError('customer')">
|
||||
{{'turnover.customer.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.motif' | i18n}}</mat-label>
|
||||
<input matInput formControlName="motif" type="text" [required]="true">
|
||||
<mat-error *ngIf="hasError('motif')">
|
||||
{{'turnover.motif.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.price' | i18n}}</mat-label>
|
||||
<input matInput formControlName="price" type="number" min="0" step="0.01" [required]="true">
|
||||
<span matTextSuffix>{{'turnover.price.suffix' | i18n}}</span>
|
||||
<mat-error *ngIf="hasError('price')">
|
||||
{{'turnover.price.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.timeInvestment' | i18n}}</mat-label>
|
||||
<input matInput formControlName="timeInvestment" type="number" min="0" step="0.1">
|
||||
<span matTextSuffix>{{'turnover.timeInvestment.suffix' | i18n}}</span>
|
||||
<mat-error *ngIf="hasError('timeInvestment')">
|
||||
{{'turnover.timeInvestment.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.remark' | i18n}}</mat-label>
|
||||
<textarea matAutosize matAutosizeMinRows="3" matInput formControlName="remark"></textarea>
|
||||
<mat-error *ngIf="hasError('remark')">
|
||||
{{'turnover.remark.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'turnover.materialConsumption' | i18n}}</mat-label>
|
||||
<textarea matAutosize matAutosizeMinRows="3" matInput formControlName="materialConsumption"></textarea>
|
||||
<mat-error *ngIf="hasError('materialConsumption')">
|
||||
{{'turnover.materialConsumption.error' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions class="flex column">
|
||||
<div class="flex fill">
|
||||
@if (!working) {
|
||||
<button type="submit" mat-raised-button color="primary" [disabled]="form.invalid">
|
||||
{{(turnover.id ? 'turnover.update' : 'turnover.create') | i18n}}
|
||||
</button>
|
||||
}
|
||||
@if (success) {
|
||||
<a mat-button color="primary" disabled="true">{{'turnover.success' | i18n}}</a>
|
||||
}
|
||||
@if (admin && turnover.id) {
|
||||
<span class="spacer"></span>
|
||||
<a mat-raised-button color="warn" (click)="deleteTurnover()">
|
||||
<mat-icon>delete</mat-icon> {{'turnover.delete' | i18n}}
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
@if (turnover.updated && turnover.updated != turnover.created) {
|
||||
<div class="flex">
|
||||
<span class="margin">{{'turnover.updated.label' | i18n:(turnover.updated | datef:'LLL' )}}</span>
|
||||
</div>
|
||||
}
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
mat-form-field {
|
||||
display: block;
|
||||
margin: 20px 0 !important;
|
||||
}
|
||||
form {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
mat-card-actions .flex:first-child {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatDatepickerInputEvent } from '@angular/material/datepicker';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import moment, { Moment } from 'moment';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { TurnoverManagementService } from 'src/app/services/turnover.management.service';
|
||||
import { TurnoverService } from 'src/app/services/turnover.service';
|
||||
import { ConfirmDialog } from 'src/app/ui/confirm/confirm.component';
|
||||
|
||||
@Component({
|
||||
selector: 'page-turnover',
|
||||
templateUrl: './turnover.page.html',
|
||||
styleUrls: ['./turnover.page.scss']
|
||||
})
|
||||
export class PageTurnover implements OnInit {
|
||||
|
||||
id: number;
|
||||
turnover: any;
|
||||
notfound: boolean = false;
|
||||
working: boolean = false;
|
||||
success: boolean = false;
|
||||
form: FormGroup;
|
||||
username: string = "";
|
||||
admin: boolean = false;
|
||||
today: Moment = moment();
|
||||
|
||||
constructor(
|
||||
private turnoverService: TurnoverService,
|
||||
private turnoverManagementService: TurnoverManagementService,
|
||||
private authService: AuthService,
|
||||
private formBuilder: FormBuilder,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private snackBar: MatSnackBar,
|
||||
private dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.formBuilder.group({
|
||||
dueDate: ['', Validators.nullValidator],
|
||||
customer: ['', Validators.required],
|
||||
motif: ['', Validators.required],
|
||||
price: ['', Validators.required],
|
||||
timeInvestment: ['', Validators.nullValidator],
|
||||
remark: ['', Validators.nullValidator],
|
||||
materialConsumption: ['', Validators.nullValidator],
|
||||
});
|
||||
|
||||
this.id = this.route.snapshot.paramMap.get('id') && +this.route.snapshot.paramMap.get('id');
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
if (this.id) {
|
||||
let request = this.turnoverService.get(this.id);
|
||||
|
||||
this.authService.auth.subscribe({
|
||||
next: (auth) => {
|
||||
this.username = auth.username;
|
||||
this.admin = auth.authorities && auth.authorities.find((role) => role.authority == 'ROLE_ADMIN') != undefined;
|
||||
|
||||
if (this.admin) {
|
||||
request = this.turnoverManagementService.get(this.id);
|
||||
}
|
||||
|
||||
request.subscribe({
|
||||
next: (data) => {
|
||||
this.turnover = data;
|
||||
if (this.turnover.dueDate != this.turnover.created) {
|
||||
this.form.get("dueDate").setValue(this.turnover.dueDate);
|
||||
}
|
||||
this.form.get("customer").setValue(this.turnover.customer);
|
||||
this.form.get("motif").setValue(this.turnover.motif);
|
||||
this.form.get("price").setValue(this.turnover.price);
|
||||
this.form.get("timeInvestment").setValue(this.turnover.timeInvestment);
|
||||
this.form.get("remark").setValue(this.turnover.remark);
|
||||
this.form.get("materialConsumption").setValue(this.turnover.materialConsumption);
|
||||
|
||||
},
|
||||
error: (error) => {
|
||||
if (error.status == 404) {
|
||||
this.notfound = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
error: (error) => {
|
||||
this.username = ""
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
this.turnover = {};
|
||||
}
|
||||
}
|
||||
|
||||
hasError(controlName: string): boolean {
|
||||
return this.form.controls[controlName].errors != null;
|
||||
}
|
||||
|
||||
create(): void {
|
||||
if (this.working) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.working = true;
|
||||
|
||||
this.turnover.dueDate = this.form.get("dueDate").value;
|
||||
this.turnover.customer = this.form.get("customer").value;
|
||||
this.turnover.motif = this.form.get("motif").value;
|
||||
this.turnover.price = this.form.get("price").value;
|
||||
this.turnover.timeInvestment = this.form.get("timeInvestment").value;
|
||||
this.turnover.remark = this.form.get("remark").value;
|
||||
this.turnover.materialConsumption = this.form.get("materialConsumption").value;
|
||||
|
||||
this.turnoverService.create(this.turnover).subscribe({
|
||||
next: (data) => {
|
||||
this.router.navigateByUrl('/');
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 422) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.form.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
update(): void {
|
||||
if (this.working) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.working = true;
|
||||
this.turnover.dueDate = this.form.get("dueDate").value;
|
||||
this.turnover.customer = this.form.get("customer").value;
|
||||
this.turnover.motif = this.form.get("motif").value;
|
||||
this.turnover.price = this.form.get("price").value;
|
||||
this.turnover.timeInvestment = this.form.get("timeInvestment").value;
|
||||
this.turnover.remark = this.form.get("remark").value;
|
||||
this.turnover.materialConsumption = this.form.get("materialConsumption").value;
|
||||
|
||||
const request = this.admin ? this.turnoverManagementService.update(this.turnover) : this.turnoverService.update(this.turnover);
|
||||
|
||||
request.subscribe({
|
||||
next: (data) => {
|
||||
this.turnover = data;
|
||||
this.working = false;
|
||||
this.success = true;
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 403) {
|
||||
this.snackBar.open("Error");
|
||||
}
|
||||
if (error.status == 422) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.form.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteTurnover() {
|
||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||
data: {
|
||||
'label': 'turnover.confirmDelete',
|
||||
'args': [this.turnover.username]
|
||||
}
|
||||
})
|
||||
|
||||
dialogRef.afterClosed().subscribe({
|
||||
next: (result) => {
|
||||
if (result) {
|
||||
this.turnoverManagementService.delete(this.turnover.id).subscribe({
|
||||
next: () => {
|
||||
this.router.navigateByUrl('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<div class="flex column fill">
|
||||
<div class="flex wrap middle filter-container">
|
||||
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'turnovers.filter' | i18n}}"
|
||||
[color]="filterOpen ? 'primary': 'accent'">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
</a>
|
||||
|
||||
@if(filterOpen) {
|
||||
<form class="flex wrap filter">
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.dueDate' | i18n}}</mat-label>
|
||||
<mat-date-range-input [rangePicker]="picker">
|
||||
<input matStartDate placeholder="{{'turnovers.filter.dueDate.from' | i18n}}"
|
||||
[value]="turnovers && turnovers.filter && turnovers.filter.from"
|
||||
(dateChange)="setFilter('from', $event.value && $event.value.toISOString() || undefined)">
|
||||
<input matEndDate placeholder="{{'turnovers.filter.dueDate.to' | i18n}}"
|
||||
[value]="turnovers && turnovers.filter && turnovers.filter.to"
|
||||
(dateChange)="setFilter('to', $event.value && $event.value.endOf('day').toISOString() || undefined)">
|
||||
</mat-date-range-input>
|
||||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-date-range-picker #picker></mat-date-range-picker>
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.username' | i18n}}</mat-label>
|
||||
<input type="text" matInput [matAutocomplete]="auto" [formControl]="usersFormControl"
|
||||
[value]="turnovers && turnovers.filter && turnovers.filter.username || ''"
|
||||
(change)="setInputFilter('username', $event.target)">
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="setFilter('username', $event.option.value)">
|
||||
@for (user of users | async; track user.username) {
|
||||
<mat-option [value]="user.username">{{user.username}}</mat-option>
|
||||
}
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.customer' | i18n}}</mat-label>
|
||||
<input type="text" matInput [value]="turnovers && turnovers.filter && turnovers.filter.customer || ''"
|
||||
(input)="setInputFilter('customer', $event.target)">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.motif' | i18n}}</mat-label>
|
||||
<input type="text" matInput [value]="turnovers && turnovers.filter && turnovers.filter.motif || ''"
|
||||
(input)="setInputFilter('motif', $event.target)">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
}
|
||||
<span class="spacer"></span>
|
||||
<a class="margin" mat-icon-button (click)="export()" title="{{'turnovers.export' | i18n}}" color="primary" [disabled]="!turnovers.total">
|
||||
<mat-icon>file_download</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<ui-turnovers #uiTurnovers class="flex column grow" [turnovers]="turnovers" (page)="applyPage($event)"
|
||||
(sort)="applySort($event)" [username]="true"></ui-turnovers>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
.filter-container {
|
||||
padding-left: 15px;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
.filter {
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&>* {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui-turnovers {
|
||||
min-height: 0;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { debounceTime, Observable, switchMap } from 'rxjs';
|
||||
import { TurnoverManagementService } from 'src/app/services/turnover.management.service';
|
||||
import { UserManagementService } from 'src/app/services/user.management.service';
|
||||
import { UiTurnovers } from 'src/app/ui/turnovers/turnovers.ui';
|
||||
|
||||
@Component({
|
||||
selector: 'page-turnovers-manage',
|
||||
templateUrl: './manage.page.html',
|
||||
styleUrls: ['./manage.page.scss']
|
||||
})
|
||||
export class PageTurnoversManage implements OnInit {
|
||||
|
||||
turnovers: any;
|
||||
sort: string = "dueDate";
|
||||
descending: boolean = true;
|
||||
filterOpen: boolean = false;
|
||||
|
||||
users: Observable<any>;
|
||||
usersFormControl = new FormControl();
|
||||
|
||||
@ViewChild('uiTurnovers') uiTurnovers: UiTurnovers;
|
||||
|
||||
constructor(
|
||||
private turnoverManagementService: TurnoverManagementService,
|
||||
private userManagementService: UserManagementService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
) { }
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.turnovers = {};
|
||||
this.users = this.usersFormControl
|
||||
.valueChanges
|
||||
.pipe(
|
||||
debounceTime(300),
|
||||
switchMap(value => this.userManagementService.pick(value))
|
||||
);
|
||||
this.route.queryParams.subscribe({
|
||||
next: (params) => {
|
||||
this.turnovers = { filter: {} };
|
||||
if (params['l']) {
|
||||
this.turnovers.limit = +params['l'];
|
||||
if (this.turnovers.limit < 1) {
|
||||
this.turnovers.limit = 1;
|
||||
}
|
||||
}
|
||||
if (params['o']) {
|
||||
this.turnovers.offset = +params['o'];
|
||||
if (this.turnovers.offset < 0) {
|
||||
this.turnovers.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params['s']) {
|
||||
this.sort = params['s'];
|
||||
}
|
||||
|
||||
if (params['a']) {
|
||||
this.descending = false;
|
||||
} else {
|
||||
this.descending = true;
|
||||
}
|
||||
|
||||
for (const param in params) {
|
||||
if (param != 'l' && param != 'o' && param != 's' && param != 'a') {
|
||||
this.filterOpen = true;
|
||||
this.turnovers.filter[param] = params[param];
|
||||
if (param == 'username') {
|
||||
this.usersFormControl.setValue(params[param]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
const filter = JSON.parse(JSON.stringify(this.turnovers.filter || {}));
|
||||
this.turnoverManagementService.fetch(this.turnovers.limit || 15, this.turnovers.offset || 0, this.sort, this.descending, filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.turnovers = data;
|
||||
this.turnovers.filter = filter;
|
||||
}, error: (error) => {
|
||||
this.turnovers = { error: error };
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
update() {
|
||||
const filter = JSON.parse(JSON.stringify(this.turnovers.filter || {}));
|
||||
|
||||
const params: Params = { l: null, o: null, s: null, a: null };
|
||||
|
||||
if ((this.turnovers.limit || 15) != 15) {
|
||||
params['l'] = this.turnovers.limit;
|
||||
}
|
||||
|
||||
if ((this.turnovers.offset || 0) != 0) {
|
||||
params['o'] = this.turnovers.offset;
|
||||
}
|
||||
|
||||
if (this.sort != 'dueDate') {
|
||||
params['s'] = this.sort;
|
||||
}
|
||||
|
||||
if (!this.descending) {
|
||||
params['a'] = true;
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
for (const param in filter) {
|
||||
params[param] = filter[param] || null;
|
||||
}
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'replace'
|
||||
});
|
||||
}
|
||||
|
||||
applyPage(event: PageEvent) {
|
||||
this.turnovers.limit = event.pageSize;
|
||||
this.turnovers.offset = event.pageSize * event.pageIndex;
|
||||
this.update();
|
||||
}
|
||||
|
||||
applySort(event: Sort) {
|
||||
this.sort = event.direction ? event.active : 'dueDate';
|
||||
this.descending = event.direction !== 'asc';
|
||||
this.update();
|
||||
}
|
||||
|
||||
setInputFilter(key: string, target: EventTarget) {
|
||||
this.setFilter(key, (target as HTMLInputElement).value);
|
||||
}
|
||||
|
||||
setFilter(key: string, value) {
|
||||
if (value != this.turnovers.filter[key]) {
|
||||
this.turnovers.filter[key] = value;
|
||||
this.turnovers.offset = 0;
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
export() {
|
||||
let rows = this.uiTurnovers.getCsvRows();
|
||||
if (rows.length) {
|
||||
let csvContent = "data:text/csv;charset=utf-8,"
|
||||
+ rows.map(e => e.join(";")).join("\n");
|
||||
|
||||
var encodedUri = encodeURI(csvContent);
|
||||
var link = document.createElement("a");
|
||||
link.setAttribute("href", encodedUri);
|
||||
link.setAttribute("download", "export.csv");
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<div class="flex column fill">
|
||||
<div class="flex wrap filter-container">
|
||||
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'turnovers.filter' | i18n}}"
|
||||
[color]="filterOpen ? 'primary': 'accent'">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
</a>
|
||||
|
||||
@if (filterOpen) {
|
||||
<form class="flex wrap filter">
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.dueDate' | i18n}}</mat-label>
|
||||
<mat-date-range-input [rangePicker]="picker">
|
||||
<input matStartDate placeholder="{{'turnovers.filter.dueDate.from' | i18n}}"
|
||||
[value]="turnovers && turnovers.filter && turnovers.filter.from"
|
||||
(dateChange)="setFilter('from', $event.value && $event.value.toISOString() || undefined)">
|
||||
<input matEndDate placeholder="{{'turnovers.filter.dueDate.to' | i18n}}"
|
||||
[value]="turnovers && turnovers.filter && turnovers.filter.to"
|
||||
(dateChange)="setFilter('to', $event.value && $event.value.endOf('day').toISOString() || undefined)">
|
||||
</mat-date-range-input>
|
||||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-date-range-picker #picker></mat-date-range-picker>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.customer' | i18n}}</mat-label>
|
||||
<input type="text" matInput [value]="turnovers && turnovers.filter && turnovers.filter.customer || ''"
|
||||
(input)="setInputFilter('customer', $event.target)">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'turnovers.filter.motif' | i18n}}</mat-label>
|
||||
<input type="text" matInput [value]="turnovers && turnovers.filter && turnovers.filter.motif || ''"
|
||||
(input)="setInputFilter('motif', $event.target)">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
}
|
||||
<span class="spacer"></span>
|
||||
<a class="margin" mat-icon-button (click)="export()" title="{{'turnovers.export' | i18n}}" color="primary" [disabled]="!turnovers.total">
|
||||
<mat-icon>file_download</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<ui-turnovers #uiTurnovers class="flex column grow" [turnovers]="turnovers" [overview]="overview" (page)="applyPage($event)"
|
||||
(sort)="applySort($event)"></ui-turnovers>
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
.filter-container {
|
||||
padding-left: 15px;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
.filter {
|
||||
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&>* {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ui-turnovers {
|
||||
min-height: 0;
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { TurnoverService } from 'src/app/services/turnover.service';
|
||||
import { UiTurnovers } from 'src/app/ui/turnovers/turnovers.ui';
|
||||
|
||||
@Component({
|
||||
selector: 'page-turnovers',
|
||||
templateUrl: './turnovers.page.html',
|
||||
styleUrls: ['./turnovers.page.scss']
|
||||
})
|
||||
export class PageTurnovers implements OnInit {
|
||||
|
||||
turnovers: any;
|
||||
overview: any[];
|
||||
sort: string = "dueDate";
|
||||
descending: boolean = true;
|
||||
filterOpen: boolean = false;
|
||||
init: boolean = true;
|
||||
|
||||
@ViewChild('uiTurnovers') uiTurnovers: UiTurnovers;
|
||||
|
||||
constructor(
|
||||
private turnoverService: TurnoverService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.turnovers = {};
|
||||
this.route.queryParams.subscribe({
|
||||
next: (params) => {
|
||||
this.turnovers = { filter: {} };
|
||||
if (params['l']) {
|
||||
this.turnovers.limit = +params['l'];
|
||||
if (this.turnovers.limit < 1) {
|
||||
this.turnovers.limit = 1;
|
||||
}
|
||||
}
|
||||
if (params['o']) {
|
||||
this.turnovers.offset = +params['o'];
|
||||
if (this.turnovers.offset < 0) {
|
||||
this.turnovers.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params['s']) {
|
||||
this.sort = params['s'];
|
||||
}
|
||||
|
||||
if (params['a']) {
|
||||
this.descending = false;
|
||||
} else {
|
||||
this.descending = true;
|
||||
}
|
||||
|
||||
for (const param in params) {
|
||||
if (param != 'l' && param != 'o' && param != 's' && param != 'a') {
|
||||
this.filterOpen = true;
|
||||
this.turnovers.filter[param] = params[param];
|
||||
}
|
||||
}
|
||||
this.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
const filter = JSON.parse(JSON.stringify(this.turnovers.filter || {}));
|
||||
this.turnoverService.fetch(this.turnovers.limit || 15, this.turnovers.offset || 0, this.sort, this.descending, this.turnovers.filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.turnovers = data;
|
||||
this.turnovers.filter = filter;
|
||||
}, error: (error) => {
|
||||
this.turnovers = { error: error };
|
||||
}
|
||||
})
|
||||
|
||||
this.turnoverService.overview(this.turnovers.limit || 15, this.turnovers.offset || 0, this.sort, this.descending, this.turnovers.filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.overview = data;
|
||||
if (!this.overview) {
|
||||
this.overview = ['', 0, 0];
|
||||
}
|
||||
}, error: (error) => {
|
||||
this.turnovers = { error: error };
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
update() {
|
||||
const filter = JSON.parse(JSON.stringify(this.turnovers.filter || {}));
|
||||
|
||||
const params: Params = { l: null, o: null, s: null, a: null };
|
||||
|
||||
if ((this.turnovers.limit || 15) != 15) {
|
||||
params['l'] = this.turnovers.limit;
|
||||
}
|
||||
|
||||
if ((this.turnovers.offset || 0) != 0) {
|
||||
params['o'] = this.turnovers.offset;
|
||||
}
|
||||
|
||||
if (this.sort != 'dueDate') {
|
||||
params['s'] = this.sort;
|
||||
}
|
||||
|
||||
if (!this.descending) {
|
||||
params['a'] = true;
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
for (const param in filter) {
|
||||
params[param] = filter[param] || null;
|
||||
}
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'replace'
|
||||
});
|
||||
}
|
||||
|
||||
applyPage(event: PageEvent) {
|
||||
this.turnovers.limit = event.pageSize;
|
||||
this.turnovers.offset = event.pageSize * event.pageIndex;
|
||||
this.update();
|
||||
}
|
||||
|
||||
applySort(event: Sort) {
|
||||
this.sort = event.direction ? event.active : 'dueDate';
|
||||
this.descending = event.direction !== 'asc';
|
||||
this.update();
|
||||
}
|
||||
|
||||
setInputFilter(key: string, target: EventTarget) {
|
||||
this.setFilter(key, (target as HTMLInputElement).value);
|
||||
}
|
||||
|
||||
setFilter(key: string, value) {
|
||||
if (value != this.turnovers.filter[key]) {
|
||||
this.turnovers.filter[key] = value;
|
||||
this.turnovers.offset = 0;
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
export() {
|
||||
let rows = this.uiTurnovers.getCsvRows();
|
||||
if (rows.length) {
|
||||
let csvContent = "data:text/csv;charset=utf-8,"
|
||||
+ rows.map(e => e.join(";")).join("\n");
|
||||
|
||||
var encodedUri = encodeURI(csvContent);
|
||||
var link = document.createElement("a");
|
||||
link.setAttribute("href", encodedUri);
|
||||
link.setAttribute("download", "export.csv");
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="container">
|
||||
<div class="flex column fill center middle">
|
||||
<mat-card class="warn box">
|
||||
<mat-card-header>
|
||||
<mat-card-title>503</mat-card-title>
|
||||
<mat-card-subtitle>{{'service-unavailable' | i18n}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>
|
||||
{{'service-unavailable.text' | i18n}}
|
||||
</p>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<a mat-raised-button color="primary" (click)="retry()">
|
||||
{{'service-unavailable.retry' | i18n}}
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
.box {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Location } from '@angular/common'
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'page-unavailable',
|
||||
templateUrl: './unavailable.page.html',
|
||||
styleUrls: ['./unavailable.page.scss']
|
||||
})
|
||||
export class PageUnavailable implements OnInit {
|
||||
|
||||
targetRoute = '';
|
||||
|
||||
constructor(
|
||||
private location: Location,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParams.subscribe({
|
||||
next: (params) => {
|
||||
if (params['target']) {
|
||||
this.targetRoute = params['target'];
|
||||
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', skipLocationChange: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
retry() {
|
||||
if (!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") {
|
||||
this.location.back;
|
||||
} else {
|
||||
this.router.navigate([this.targetRoute]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<div class="flex column fill middle">
|
||||
<form [formGroup]="form" (ngSubmit)="createUser()" #formDirective="ngForm">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'profile.username' | i18n}}</mat-label>
|
||||
<input matInput formControlName="username" type="text" [required]="true">
|
||||
<mat-error *ngFor="let error of form.get('username').errors | keyvalue">
|
||||
{{'user.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'profile.name' | i18n}}</mat-label>
|
||||
<input matInput formControlName="name" type="text">
|
||||
<mat-error *ngFor="let error of form.get('name').errors | keyvalue">
|
||||
{{'user.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'profile.email' | i18n}}</mat-label>
|
||||
<input matInput formControlName="email" type="email">
|
||||
<mat-error *ngFor="let error of form.get('email').errors | keyvalue">
|
||||
{{'user.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'user.password' | i18n}}</mat-label>
|
||||
<input matInput formControlName="password" type="password">
|
||||
<mat-error *ngFor="let error of form.get('password').errors | keyvalue">
|
||||
{{'password.error.' + error.key | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-slide-toggle class="margin" (change)="isAdmin=$event.checked">
|
||||
{{'user.admin' | i18n}}
|
||||
</mat-slide-toggle>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
@if (!working) {
|
||||
<button type="submit" mat-raised-button color="primary"
|
||||
[disabled]="form.invalid"><mat-icon>person_add</mat-icon>{{'user.create' |
|
||||
i18n}}</button>
|
||||
}
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
mat-form-field {
|
||||
display: block;
|
||||
margin: 20px 0 !important;
|
||||
}
|
||||
form {
|
||||
margin: 5px;
|
||||
min-width: 390px;
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
max-width: 80%;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { UserManagementService } from 'src/app/services/user.management.service';
|
||||
|
||||
@Component({
|
||||
selector: 'page-user-create',
|
||||
templateUrl: './users.create.page.html',
|
||||
styleUrls: ['./users.create.page.scss']
|
||||
})
|
||||
export class PageUserCreate implements OnInit {
|
||||
|
||||
form: FormGroup;
|
||||
isAdmin: boolean = false;
|
||||
working: boolean = false;
|
||||
|
||||
constructor(
|
||||
private userManagementService: UserManagementService,
|
||||
private formBuilder: FormBuilder,
|
||||
private router: Router) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.formBuilder.group({
|
||||
username: ['', Validators.required],
|
||||
name: ['', Validators.nullValidator],
|
||||
email: ['', Validators.nullValidator],
|
||||
password: ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
createUser() {
|
||||
this.working = true;
|
||||
const user = {
|
||||
username: this.form.get("username").value,
|
||||
name: this.form.get("name").value,
|
||||
email: this.form.get("email").value,
|
||||
roles: this.isAdmin ? ['ROLE_ADMIN'] : []
|
||||
}
|
||||
|
||||
const request = this.form.get("username").disabled ? this.userManagementService.update(user) : this.userManagementService.create(user);
|
||||
|
||||
request.subscribe({
|
||||
next: (result: any) => {
|
||||
this.userManagementService.setPassword(result.username, this.form.get("password").value).subscribe({
|
||||
next: (result) => {
|
||||
this.working = false;
|
||||
this.router.navigateByUrl('/u');
|
||||
},
|
||||
error: (error) => {
|
||||
this.form.get("username").disable();
|
||||
|
||||
this.working = false;
|
||||
if (error.status == 409) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.form.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
this.working = false;
|
||||
if (error.status == 409) {
|
||||
let errors = {};
|
||||
for (let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
}
|
||||
|
||||
for (let code in errors) {
|
||||
this.form.get(code).setErrors(errors[code]);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<div class="flex column fill">
|
||||
@if (users && users.error) {
|
||||
<div class="flex column fill">
|
||||
<mat-card class="accent box">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ 'users.error.' + users.error.status | i18n}}</mat-card-title>
|
||||
<mat-card-subtitle>{{'users.error' | i18n}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>
|
||||
{{ 'users.error.' + users.error.status + '.text' | i18n}}
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="flex wrap filter-container">
|
||||
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'users.filter' | i18n}}"
|
||||
[color]="filterOpen ? 'primary': 'accent'">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
</a>
|
||||
|
||||
@if (filterOpen) {
|
||||
<form class="flex wrap filter">
|
||||
<mat-form-field class="margin">
|
||||
<mat-label>{{'users.filter.search' | i18n}}</mat-label>
|
||||
<input type="text" matInput [value]="users && users.filter && users.filter || ''"
|
||||
(input)="setFilter( $event.target)">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (users) {
|
||||
<div class="scroll-container">
|
||||
<table class="default-table" mat-table [dataSource]="users.results || []" matSort
|
||||
(matSortChange)="applySort($event)" [matSortDisableClear]="true">
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header [disableClear]="false">{{'user.username' |
|
||||
i18n}}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let user">
|
||||
<div class="flex middle">
|
||||
@if (user.roles && user.roles.indexOf('ROLE_ADMIN') != -1) {
|
||||
<mat-icon>admin_panel_settings</mat-icon>
|
||||
}
|
||||
{{user.username}}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{'profile.name' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let user">{{user.name}}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="email">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'profile.email' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let user">{{user.email}}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="about">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'profile.about' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let user">
|
||||
<span class="ellipsis" matTooltip="{{user.about}}">{{user.about}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="columns; sticky: true"></tr>
|
||||
<tr class="user" mat-row *matRowDef="let user; columns: columns;" [routerLink]="'/u/' + user.username">
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@if (users.total == 0) {
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<p>{{'paginator.empty' | i18n}}</p>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
}
|
||||
|
||||
<span class="spacer"></span>
|
||||
|
||||
<div class="mat-mdc-paginator flex wrap middle">
|
||||
<a class="margin" routerLink="/user" mat-raised-button color="primary">
|
||||
<mat-icon>person_add</mat-icon>
|
||||
<span class="hide-small">{{'user.create' | i18n}}</span>
|
||||
</a>
|
||||
<span class="spacer"></span>
|
||||
<mat-paginator [pageSizeOptions]="pageSizeOptions" [pageIndex]="users.offset / users.limit"
|
||||
[length]="users.total" [pageSize]="users.limit" (page)="applyPage($event)" showFirstLastButtons>
|
||||
</mat-paginator>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!users || !users.results && !users.error) {
|
||||
<mat-progress-bar *ngIf="" mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,32 @@
|
||||
.filter-container {
|
||||
padding-left: 15px;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
.filter {
|
||||
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&>* {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tr.user {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-mdc-paginator a.margin {
|
||||
margin: 15px;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Component, HostListener, Input, OnInit } from '@angular/core';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { UserManagementService } from 'src/app/services/user.management.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ui-users',
|
||||
templateUrl: './users.page.html',
|
||||
styleUrls: ['./users.page.scss']
|
||||
})
|
||||
export class PageUsers implements OnInit {
|
||||
|
||||
@Input() users: any;
|
||||
pageSizeOptions: number[] = [1, 2, 3, 4, 5, 10, 15, 30, 50, 100];
|
||||
sort: string = "username";
|
||||
descending: boolean = false;
|
||||
filterOpen: boolean = true;
|
||||
|
||||
columns: string[] = [];
|
||||
|
||||
username: string = "";
|
||||
|
||||
constructor(
|
||||
private userManagementService: UserManagementService,
|
||||
private authService: AuthService,
|
||||
private formBuilder: FormBuilder) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.users = {};
|
||||
this.update();
|
||||
this.applyResize(window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
|
||||
|
||||
this.authService.auth.subscribe({
|
||||
next: (auth) => {
|
||||
this.username = auth.username;
|
||||
},
|
||||
error: (error) => {
|
||||
this.username = ""
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event) {
|
||||
this.applyResize(event.target.innerWidth || event.target.documentElement.clientWidth || event.target.body.clientWidth)
|
||||
}
|
||||
|
||||
applyResize(width: number) {
|
||||
if (width < 992) {
|
||||
this.columns = ['username', 'name', 'email']
|
||||
} else {
|
||||
this.columns = ['username', 'name', 'email', 'about'];
|
||||
}
|
||||
}
|
||||
|
||||
update() {
|
||||
const filter = this.users.filter || "";
|
||||
this.userManagementService.fetch(this.users.limit || 15, this.users.offset || 0, this.sort, this.descending, filter).subscribe({
|
||||
next: (data: any) => {
|
||||
this.users = data;
|
||||
this.users.filter = filter;
|
||||
}, error: (error) => {
|
||||
this.users = { error: error };
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
applyPage(event: PageEvent) {
|
||||
this.users.limit = event.pageSize;
|
||||
this.users.offset = event.pageSize * event.pageIndex;
|
||||
this.update();
|
||||
}
|
||||
|
||||
applySort(event: Sort) {
|
||||
this.sort = event.direction ? event.active : 'username';
|
||||
this.descending = event.direction !== 'asc';
|
||||
this.update();
|
||||
}
|
||||
|
||||
setFilter(target: EventTarget) {
|
||||
const value = (target as HTMLInputElement).value;
|
||||
if (value != this.users.filter) {
|
||||
this.users.filter = value;
|
||||
this.users.offset = 0;
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { environment } from "src/environments/environment";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AbstractService {
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
fetch(path: string, limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||
let httpParams = new HttpParams();
|
||||
if (limit != undefined) {
|
||||
httpParams = httpParams.set("limit", "" + limit);
|
||||
}
|
||||
if (offset) {
|
||||
httpParams = httpParams.set("offset", "" + offset);
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
httpParams = httpParams.set("sort", "" + sort);
|
||||
}
|
||||
|
||||
if (descending) {
|
||||
httpParams = httpParams.set("descending", "" + descending);
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
for (const param in filter) {
|
||||
if (filter[param]) {
|
||||
httpParams = httpParams.set(param, "" + filter[param]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.http.get(environment.apiUrl + path, { params: httpParams });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ReplaySubject, of } from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
import { RequestError } from './requesterror';
|
||||
|
||||
import { environment } from './../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
|
||||
auth: ReplaySubject<any> = new ReplaySubject(undefined);
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
getAuth() {
|
||||
return this.authMe().toPromise().then((data: any) => {
|
||||
this.auth.next(data);
|
||||
return data;
|
||||
}, error => {
|
||||
throw new RequestError(error);
|
||||
});
|
||||
}
|
||||
|
||||
authMe() {
|
||||
return this.http.get(environment.apiUrl + "/auth");
|
||||
}
|
||||
|
||||
getExternal() {
|
||||
return this.http.get(environment.apiUrl + "/auth/external");
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this.http.post(environment.apiUrl + "/logout", {});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DebugService {
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
random() {
|
||||
return this.http.get(environment.apiUrl + "/debug/random");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class I18nService {
|
||||
|
||||
locale: string = "de-informal";
|
||||
locales: any[] = ["de-informal"];
|
||||
i18n: any;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
}
|
||||
|
||||
getLocales() {
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
getLocale() {
|
||||
return this.locale || 'de-informal';
|
||||
}
|
||||
|
||||
setLocale(locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
async fetch() {
|
||||
|
||||
let browserLocale = navigator.language;
|
||||
|
||||
if (browserLocale.indexOf("-") != -1) {
|
||||
browserLocale = browserLocale.split("-")[0];
|
||||
}
|
||||
|
||||
let locale = localStorage.getItem("buntspecht.locale") || browserLocale || this.locales[0];
|
||||
|
||||
if (locale == 'de') {
|
||||
locale = 'de-informal';
|
||||
}
|
||||
|
||||
if (this.locales.indexOf(locale) == -1) {
|
||||
locale = this.locales[0];
|
||||
}
|
||||
|
||||
this.setLocale(locale);
|
||||
this.i18n = await this.http.get("/assets/i18n/" + locale + ".json").toPromise();
|
||||
console.debug("fallback to default locale");
|
||||
|
||||
}
|
||||
|
||||
get(key, args: string[] = []): string {
|
||||
return this.getInternal(key, args, this.i18n, "", true);
|
||||
}
|
||||
|
||||
getEmpty(key, args: string[]): string {
|
||||
return this.getInternal(key, args, this.i18n, "", false);
|
||||
}
|
||||
|
||||
getInternal(key, args: string[], from, path, empty: boolean): string {
|
||||
key += '';
|
||||
if (!from) {
|
||||
return empty ? this.empty(key, args, path) : (key || "");
|
||||
} else if (from[key]) {
|
||||
if (typeof from[key] === 'object') {
|
||||
if (from[key]["."]) {
|
||||
return this.insertArguments(from[key]["."], args);
|
||||
}
|
||||
return empty ? this.empty(key, args, path) : (key || "");
|
||||
}
|
||||
return this.insertArguments(from[key], args);
|
||||
} else {
|
||||
let keys = key.split(".");
|
||||
if (from[keys[0]]) {
|
||||
key = keys.slice(1, keys.length).join(".");
|
||||
return this.getInternal(key, args, from[keys[0]], path + keys[0] + ".", empty)
|
||||
}
|
||||
}
|
||||
|
||||
return empty ? this.empty(key, args, path) : (key || "");
|
||||
}
|
||||
|
||||
empty(key, args: string[], path: string): string {
|
||||
return (path ? path + (path.endsWith(".") ? "" : ".") : "") + key + (args && args.length > 0 ? (" [" + args + "]") : "");
|
||||
}
|
||||
|
||||
insertArguments(label: string, args: string[]) {
|
||||
if (args) {
|
||||
for (let index in args) {
|
||||
label = label.replace(`{${index}}`, this.get(args[index], null));
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class I18nPaginatorIntl implements MatPaginatorIntl {
|
||||
|
||||
changes = new Subject<void>();
|
||||
|
||||
i18n: I18nService;
|
||||
|
||||
itemsPerPageLabel: string;
|
||||
nextPageLabel: string;
|
||||
previousPageLabel: string;
|
||||
firstPageLabel: string;
|
||||
lastPageLabel: string;
|
||||
|
||||
|
||||
injectI18n(i18n: I18nService) {
|
||||
this.i18n = i18n;
|
||||
|
||||
this.firstPageLabel = this.i18n.get('paginator.firstPage', []);
|
||||
this.itemsPerPageLabel = this.i18n.get('paginator.itemsPerPage', []);
|
||||
this.lastPageLabel = this.i18n.get('paginator.lastPage', []);
|
||||
|
||||
this.nextPageLabel = this.i18n.get('paginator.nextPage', []);
|
||||
this.previousPageLabel = this.i18n.get('paginator.previousPage', []);
|
||||
|
||||
}
|
||||
|
||||
|
||||
getRangeLabel(page: number, pageSize: number, length: number): string {
|
||||
if (length === 0) {
|
||||
return this.i18n.get('paginator.empty', []);
|
||||
}
|
||||
|
||||
const amountPages = Math.ceil(length / pageSize);
|
||||
return this.i18n.get('paginator.range', [page + 1 + "", amountPages + ""]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export class RequestError extends Error {
|
||||
|
||||
response: any;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response.message);
|
||||
this.response = response;
|
||||
// Set the prototype explicitly.
|
||||
Object.setPrototypeOf(this, RequestError.prototype);
|
||||
}
|
||||
|
||||
getResponse(): any {
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
import { AbstractService } from './abstract.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TurnoverManagementService {
|
||||
|
||||
constructor(private http: HttpClient, private abstractService: AbstractService) {
|
||||
}
|
||||
|
||||
fetch(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||
return this.abstractService.fetch("/turnovers/manage", limit, offset, sort, descending, filter);
|
||||
}
|
||||
|
||||
overview(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||
return this.abstractService.fetch("/turnovers/manage/overview", limit, offset, sort, descending, filter);
|
||||
}
|
||||
|
||||
get(id: number) {
|
||||
return this.http.get(environment.apiUrl + "/turnovers/manage/" + id);
|
||||
}
|
||||
|
||||
update(turnover: any) {
|
||||
return this.http.patch(environment.apiUrl + "/turnovers/manage", turnover);
|
||||
}
|
||||
|
||||
delete(id: number) {
|
||||
return this.http.delete(environment.apiUrl + "/turnovers/manage/" + id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
import { AbstractService } from './abstract.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TurnoverService {
|
||||
|
||||
constructor(private http: HttpClient, private abstractService: AbstractService) {
|
||||
}
|
||||
|
||||
fetch(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||
return this.abstractService.fetch("/turnovers", limit, offset, sort, descending, filter);
|
||||
}
|
||||
|
||||
overview(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||
return this.abstractService.fetch("/turnovers/overview", limit, offset, sort, descending, filter);
|
||||
}
|
||||
|
||||
get(id: number) {
|
||||
return this.http.get(environment.apiUrl + "/turnovers/" + id);
|
||||
}
|
||||
|
||||
create(turnover: any) {
|
||||
return this.http.post(environment.apiUrl + "/turnovers", turnover);
|
||||
}
|
||||
|
||||
update(turnover: any) {
|
||||
return this.http.patch(environment.apiUrl + "/turnovers", turnover);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
import { AbstractService } from './abstract.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserManagementService {
|
||||
|
||||
constructor(private http: HttpClient, private abstractService: AbstractService) {
|
||||
}
|
||||
|
||||
fetch(limit: number, offset: number, sort: string, descending: boolean, search: string = "") {
|
||||
return this.abstractService.fetch("/users/manage", limit, offset, sort, descending, { filter: search });
|
||||
}
|
||||
|
||||
pick(search: string) {
|
||||
return this.abstractService.fetch("/users/manage/pick", undefined, undefined, undefined, undefined, { filter: search });
|
||||
}
|
||||
|
||||
get(username: string) {
|
||||
return this.http.get(environment.apiUrl + "/users/manage/" + username);
|
||||
}
|
||||
|
||||
create(user: any) {
|
||||
return this.http.post(environment.apiUrl + "/users/manage", user);
|
||||
}
|
||||
|
||||
update(user: any) {
|
||||
return this.http.patch(environment.apiUrl + "/users/manage", user);
|
||||
}
|
||||
|
||||
setPassword(username: string, password: string) {
|
||||
return this.http.post(environment.apiUrl + "/users/manage/" + username + "/password", { password: password, password2: password });
|
||||
}
|
||||
|
||||
deleteUser(username: string) {
|
||||
return this.http.delete(environment.apiUrl + "/users/manage/" + username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
get() {
|
||||
return this.http.get(environment.apiUrl + "/users/user");
|
||||
}
|
||||
|
||||
update(user: any) {
|
||||
return this.http.patch(environment.apiUrl + "/users/user", user);
|
||||
}
|
||||
|
||||
setPassword(old: string, password: string, password2: string) {
|
||||
return this.http.post(environment.apiUrl + "/users/password", { old: old, password: password, password2: password2 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<mat-dialog-content>
|
||||
{{text}}
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<a mat-raised-button [mat-dialog-close]="true" color="accent" matAutofocus>{{'confirm' | i18n}}</a>
|
||||
<a mat-button [mat-dialog-close]="false">{{'cancel' | i18n}}</a>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,3 @@
|
||||
mat-form-field {
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import {Component, Inject} from '@angular/core';
|
||||
import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||||
import {I18nService} from '../../services/i18n.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'confirm.component.html',
|
||||
styleUrls: ['./confirm.component.scss']
|
||||
})
|
||||
export class ConfirmDialog {
|
||||
|
||||
|
||||
text;
|
||||
|
||||
constructor(private i18nService: I18nService,
|
||||
public dialogRef: MatDialogRef<ConfirmDialog>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||
this.text = data.empty ? i18nService.getEmpty(data.label, data.args) : i18nService.get(data.label, data.args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<mat-toolbar color="primary">
|
||||
@if (authenticated) {
|
||||
<a href="javascript:" mat-icon-button (click)="sidenav.toggle()">
|
||||
<mat-icon>menu</mat-icon>
|
||||
</a>
|
||||
}
|
||||
<a class="main" routerLink="/">
|
||||
<img class="logo margin" src="assets/images/logo.png">
|
||||
<span class="hide-small">{{'buntspecht' | i18n}}</span>
|
||||
</a>
|
||||
<span class="spacer"></span>
|
||||
@if (authenticated && isBiggerScreen) {
|
||||
<a class="margin" routerLink="/create" mat-raised-button color="accent">
|
||||
<mat-icon>edit</mat-icon>
|
||||
{{'turnover.create' | i18n}}
|
||||
</a>
|
||||
} @if (authenticated && !isBiggerScreen) {
|
||||
<a class="margin" routerLink="/create" mat-mini-fab color="accent">
|
||||
<mat-icon>edit</mat-icon>
|
||||
</a>
|
||||
}
|
||||
<ng-container>
|
||||
<button mat-button [matMenuTriggerFor]="menu">
|
||||
<mat-icon>settings</mat-icon>
|
||||
<mat-icon>arrow_drop_down</mat-icon>
|
||||
</button>
|
||||
<mat-menu #menu="matMenu">
|
||||
@if (authenticated) {
|
||||
<a mat-menu-item disabled>{{'profile.hello' | i18n:username}}</a>
|
||||
<mat-divider></mat-divider>
|
||||
}
|
||||
<ng-container *ngIf="locales.length > 1">
|
||||
<a *ngFor="let locale of locales" mat-menu-item (click)="setLocale(locale)">
|
||||
<mat-icon *ngIf="locale == currentLocale">done</mat-icon>{{'locale.' + locale + '.long' |
|
||||
i18n}}
|
||||
</a>
|
||||
</ng-container>
|
||||
<a mat-menu-item (click)="toggleDarkTheme()">
|
||||
<mat-slide-toggle [checked]="darkTheme">
|
||||
{{'darkTheme' | i18n}}
|
||||
</mat-slide-toggle>
|
||||
</a>
|
||||
<mat-divider></mat-divider>
|
||||
@if (authenticated) {
|
||||
<a routerLink="/profile" routerLinkActive="active" mat-menu-item>
|
||||
<mat-icon>tune</mat-icon> {{'profile' | i18n}}
|
||||
</a>
|
||||
<a routerLink="/password" routerLinkActive="active" mat-menu-item>
|
||||
<mat-icon>lock</mat-icon> {{'password' | i18n}}
|
||||
</a>
|
||||
<mat-divider></mat-divider>
|
||||
<a (click)="logout()" mat-menu-item>
|
||||
<mat-icon>exit_to_app</mat-icon> {{'logout' | i18n}}
|
||||
</a>
|
||||
}
|
||||
@if (!authenticated) {
|
||||
<a routerLink="/login" routerLinkActive="active" mat-menu-item>
|
||||
<mat-icon>login</mat-icon> {{'login' | i18n}}
|
||||
</a>
|
||||
}
|
||||
</mat-menu>
|
||||
</ng-container>
|
||||
</mat-toolbar>
|
||||
|
||||
<mat-sidenav-container>
|
||||
<mat-sidenav #sidenav [mode]="isBiggerScreen ? 'side' : 'over'" [opened]="opened" [autoFocus]="false"
|
||||
(click)="!isBiggerScreen && this.close()">
|
||||
@if (authenticated) {
|
||||
<mat-nav-list>
|
||||
<a routerLink="" routerLinkActive="active" mat-list-item (click)="!isBiggerScreen && this.close()">
|
||||
<mat-icon matListItemIcon>receipt</mat-icon>
|
||||
<span>{{(admin ? 'turnovers.mine' : 'turnovers') | i18n}}</span>
|
||||
</a>
|
||||
@if(admin) {
|
||||
<mat-divider></mat-divider>
|
||||
<a routerLink="m" routerLinkActive="active" mat-list-item (click)="!isBiggerScreen && this.close()">
|
||||
<mat-icon matListItemIcon>insert_chart_outlined</mat-icon>
|
||||
<span>{{'management' | i18n}}</span>
|
||||
</a>
|
||||
<a routerLink="t" routerLinkActive="active" mat-list-item (click)="!isBiggerScreen && this.close()">
|
||||
<mat-icon matListItemIcon>receipt_long</mat-icon>
|
||||
<span>{{'turnovers' | i18n}}</span>
|
||||
</a>
|
||||
<mat-divider></mat-divider>
|
||||
<a routerLink="u" routerLinkActive="active" mat-list-item (click)="!isBiggerScreen && this.close()">
|
||||
<mat-icon matListItemIcon>people</mat-icon>
|
||||
<span>{{'users' | i18n}}</span>
|
||||
</a>
|
||||
<span class="spacer"></span>
|
||||
}
|
||||
</mat-nav-list>
|
||||
}
|
||||
|
||||
<span class="spacer"></span>
|
||||
|
||||
|
||||
@if(debug) {
|
||||
<mat-nav-list>
|
||||
<a mat-list-item (click)="random()">Random Data</a>
|
||||
</mat-nav-list>
|
||||
}
|
||||
@if(admin) {
|
||||
}
|
||||
|
||||
</mat-sidenav>
|
||||
|
||||
<!-- Main content -->
|
||||
<mat-sidenav-content>
|
||||
<router-outlet></router-outlet>
|
||||
</mat-sidenav-content>
|
||||
</mat-sidenav-container>
|
||||
@@ -0,0 +1,15 @@
|
||||
mat-sidenav {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
a.main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
|
||||
img.logo {
|
||||
height: 40px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
import { Component, HostListener, ViewChild } from '@angular/core';
|
||||
import { DateAdapter } from '@angular/material/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { fromEvent } from 'rxjs';
|
||||
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
import { I18nService } from '../../services/i18n.service';
|
||||
import { UserService } from '../../services/user.service';
|
||||
|
||||
import { SwUpdate } from '@angular/service-worker';
|
||||
import packageJson from '../../../../package.json';
|
||||
import { MatSidenav } from '@angular/material/sidenav';
|
||||
import { DebugService } from 'src/app/services/debug.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ui-main',
|
||||
templateUrl: './main.ui.html',
|
||||
styleUrls: ['./main.ui.scss']
|
||||
})
|
||||
export class UiMain {
|
||||
|
||||
opened: boolean = true;
|
||||
darkTheme: boolean = false;
|
||||
title = 'buntspecht';
|
||||
currentLocale: String;
|
||||
datetimeformat: String;
|
||||
locales;
|
||||
authenticated: boolean = false;
|
||||
username: string = "";
|
||||
admin: boolean = false;
|
||||
debug: boolean = false;
|
||||
hasUpdate: boolean = false;
|
||||
isBiggerScreen: boolean = false;
|
||||
|
||||
touchThresh: number = 150;
|
||||
touchStartX: number;
|
||||
touchX: number;
|
||||
|
||||
version = packageJson.version;
|
||||
|
||||
@ViewChild('sidenav') sidenav: MatSidenav;
|
||||
|
||||
constructor(
|
||||
private i18n: I18nService,
|
||||
private authService: AuthService,
|
||||
private userService: UserService,
|
||||
private debugService: DebugService,
|
||||
private router: Router,
|
||||
private _adapter: DateAdapter<any>,
|
||||
private swUpdate: SwUpdate) {
|
||||
|
||||
this.swUpdate.versionUpdates.subscribe({
|
||||
next: (evt) => {
|
||||
if (evt.type == 'VERSION_READY') {
|
||||
this.hasUpdate = true;
|
||||
} else if (evt.type == 'VERSION_INSTALLATION_FAILED') {
|
||||
console.error(`Failed to install version '${evt.version.hash}': ${evt.error}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (this.swUpdate.isEnabled) {
|
||||
// check for PWA update every 30s
|
||||
setInterval(() => {
|
||||
this.swUpdate.checkForUpdate();
|
||||
}, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this.datetimeformat = this.i18n.get('format.datetime', []);
|
||||
this.currentLocale = this.i18n.getLocale();
|
||||
this.locales = this.i18n.getLocales();
|
||||
this.authService.auth.subscribe({
|
||||
next: (auth) => {
|
||||
this.authenticated = true;
|
||||
this.username = auth.username;
|
||||
this.admin = auth.authorities && auth.authorities.find((role) => role.authority == 'ROLE_ADMIN') != undefined;
|
||||
this.debug = auth.authorities && auth.authorities.find((role) => role.authority == 'ROLE_DEBUG') != undefined;
|
||||
},
|
||||
error: (error) => {
|
||||
this.authenticated = false;
|
||||
this.opened = false;
|
||||
}
|
||||
})
|
||||
|
||||
this._adapter.setLocale(this.currentLocale);
|
||||
|
||||
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
||||
if (width < 768) {
|
||||
this.opened = false;
|
||||
this.isBiggerScreen = false;
|
||||
} else {
|
||||
this.opened = true;
|
||||
this.isBiggerScreen = true;
|
||||
}
|
||||
|
||||
if (localStorage.getItem("buntspecht.darkTheme") == "true") {
|
||||
this.darkTheme = true;
|
||||
window.document.body.classList.add("dark-theme");
|
||||
}
|
||||
|
||||
this.touchEvents();
|
||||
}
|
||||
|
||||
setLocale(locale) {
|
||||
localStorage.setItem("buntspecht.locale", locale);
|
||||
|
||||
if (this.authenticated) {
|
||||
this.userService.get().subscribe({
|
||||
next: (user: any) => {
|
||||
user.locale = locale;
|
||||
this.userService.update(user).subscribe({
|
||||
next: () => {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.opened = false;
|
||||
this.sidenav.close();
|
||||
}
|
||||
|
||||
preventClose(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
toggleDarkTheme() {
|
||||
this.darkTheme = !this.darkTheme;
|
||||
|
||||
localStorage.setItem("buntspecht.darkTheme", this.darkTheme ? "true" : "false");
|
||||
|
||||
if (this.authenticated) {
|
||||
this.userService.get().subscribe({
|
||||
next: (user: any) => {
|
||||
user.darkTheme = this.darkTheme;
|
||||
this.userService.update(user).subscribe({
|
||||
next: () => {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
logout() {
|
||||
localStorage.removeItem("buntspecht.autologin");
|
||||
this.authService.logout().subscribe({
|
||||
next: () => {
|
||||
this.router.navigate([""]).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
openExternal(event, url, target = '_self') {
|
||||
window.open(url, target);
|
||||
this.preventClose(event);
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event) {
|
||||
if (event.target.innerWidth < 768) {
|
||||
this.opened = false;
|
||||
this.isBiggerScreen = false;
|
||||
} else {
|
||||
this.opened = true;
|
||||
this.isBiggerScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
touchEvents(): void {
|
||||
fromEvent(document, 'touchstart').subscribe({
|
||||
next: (event: TouchEvent) => {
|
||||
if (event.touches[0]) {
|
||||
this.touchStartX = event.touches[0].screenX;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
fromEvent(document, 'touchmove').subscribe({
|
||||
next: (event: TouchEvent) => {
|
||||
if (event.touches[0]) {
|
||||
this.touchX = event.touches[0].screenX;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
fromEvent(document, 'touchend').subscribe({
|
||||
next: () => {
|
||||
if (this.touchX != 0) {
|
||||
const touchDiff = this.touchStartX - this.touchX;
|
||||
this.touchStartX = 0;
|
||||
this.touchX = 0;
|
||||
if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.opened) {
|
||||
this.opened = true;
|
||||
} else if (touchDiff > 0 && touchDiff > this.touchThresh && this.opened) {
|
||||
this.opened = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateSw(force: boolean = false): void {
|
||||
if (this.hasUpdate || force) {
|
||||
if (this.swUpdate.isEnabled) {
|
||||
this.swUpdate.activateUpdate().then(() => {
|
||||
this.clearAndRefresh();
|
||||
});
|
||||
} else {
|
||||
this.clearAndRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearAndRefresh() {
|
||||
if ('caches' in window) {
|
||||
caches.keys()
|
||||
.then(function (keyList) {
|
||||
return Promise.all(keyList.map(function (key) {
|
||||
return caches.delete(key);
|
||||
}));
|
||||
})
|
||||
}
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
random() {
|
||||
this.debugService.random().subscribe({
|
||||
next: () => {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
@if (turnovers && turnovers.error) {
|
||||
<div class="flex column fill">
|
||||
<mat-card class="accent box">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ 'turnovers.error.' + turnovers.error.status | i18n}}</mat-card-title>
|
||||
<mat-card-subtitle>{{'turnovers.error' | i18n}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>
|
||||
{{ 'turnovers.error.' + turnovers.error.status + '.text' | i18n}}
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (turnovers) {
|
||||
|
||||
@if (turnovers.total == 0) {
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<p>{{'paginator.empty' | i18n}}</p>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
}
|
||||
|
||||
@if(turnovers.total) {
|
||||
<div class="scroll-container">
|
||||
<table class="default-table" mat-table [dataSource]="turnovers.results" matSort [matSortDisabled]="!enableSort"
|
||||
(matSortChange)="sort.emit($event)" [matSortDisableClear]="true">
|
||||
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{'turnover.username' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let turnover">{{turnover.username}}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="dueDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header [disableClear]="false">{{'turnover.dueDate' |
|
||||
i18n}}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.dueDate | datef:'LL'}}">
|
||||
<span class="nowrap">{{turnover.dueDate | datef:'L'}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="customer">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{'turnover.customer' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let turnover">{{turnover.customer}}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="motif">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'turnover.motif' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let turnover">
|
||||
<span class="ellipsis" matTooltip="{{turnover.motif}}">{{turnover.motif}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="price">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>
|
||||
<span class="spacer"></span>
|
||||
<span>{{'turnover.price' | i18n}}</span>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let turnover">
|
||||
<div class="flex">
|
||||
<span class="spacer"></span>
|
||||
<span>{{turnover.price | number: '1.2-2'}}</span>
|
||||
<span> {{'turnover.price.suffix' | i18n}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="timeInvestment">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>
|
||||
<span class="spacer"></span>
|
||||
<span>{{'turnover.timeInvestment' | i18n}}</span>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let turnover">
|
||||
@if (turnover.timeInvestment) {
|
||||
<div class="flex">
|
||||
<span class="spacer"></span>
|
||||
<span>{{turnover.timeInvestment | number: '1.1-1'}}</span>
|
||||
<span> {{'turnover.timeInvestment.suffix' | i18n}}</span>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="remark">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'turnover.remark' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let turnover">
|
||||
<span class="ellipsis" matTooltip="{{turnover.remark}}">{{turnover.remark}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="materialConsumption">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'turnover.materialConsumption' | i18n}}</th>
|
||||
<td mat-cell *matCellDef="let turnover">
|
||||
<span class="ellipsis"
|
||||
matTooltip="{{turnover.materialConsumption}}">{{turnover.materialConsumption}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="created">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{'turnover.created' |
|
||||
i18n}}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.created | datef:'LLLL'}}">
|
||||
<span class="nowrap">{{turnover.created | datef}}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="updated">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>
|
||||
<span class="spacer"></span>
|
||||
<span>{{'turnover.updated' | i18n}}</span>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.updated | datef:'LLLL'}}">
|
||||
<div class="flex">
|
||||
<span class="spacer"></span>
|
||||
@if(turnover.created != turnover.updated) {
|
||||
<span class="nowrap">{{turnover.updated | datef}}</span>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="columns; sticky: true"></tr>
|
||||
<tr class="turnover" [ngClass]="{'disabled': !linkTurnover}" (click)="select(turnover)" mat-row
|
||||
*matRowDef="let turnover; columns: columns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<span class="spacer"></span>
|
||||
|
||||
<div class="mat-mdc-paginator flex wrap">
|
||||
@if (overview && overview.length > 2) {
|
||||
<div class="overview flex middle">
|
||||
<span class="margin">{{'turnover.price.total' | i18n:(overview[1] | number: '1.2-2')}}</span> <span
|
||||
class="margin">{{'turnover.timeInvestment.total' | i18n:(overview[2] | number: '1.1-1')}}</span>
|
||||
</div>
|
||||
}
|
||||
<span class="spacer"></span>
|
||||
<mat-paginator [pageSizeOptions]="pageSizeOptions" [pageIndex]="turnovers.offset / turnovers.limit"
|
||||
[length]="turnovers.total" [pageSize]="turnovers.limit" (page)="page.emit($event)" showFirstLastButtons>
|
||||
</mat-paginator>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!turnovers || !turnovers.results && !turnovers.error) {
|
||||
<mat-progress-bar *ngIf="" mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
tr.turnover {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-column-created {
|
||||
@media screen and (min-width: 992px) {
|
||||
min-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
.overview {
|
||||
margin: 5px;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { Component, EventEmitter, HostListener, Input, OnInit, Output } from '@angular/core';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { Router } from '@angular/router';
|
||||
import moment from 'moment';
|
||||
import { I18nService } from 'src/app/services/i18n.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ui-turnovers',
|
||||
templateUrl: './turnovers.ui.html',
|
||||
styleUrls: ['./turnovers.ui.scss']
|
||||
})
|
||||
export class UiTurnovers implements OnInit {
|
||||
|
||||
@Input() turnovers: any;
|
||||
@Input() overview: any[];
|
||||
@Input() showFilter: boolean = true;
|
||||
@Input() linkTurnover: boolean = true;
|
||||
@Input() username: boolean = false;
|
||||
@Input() enableSort: boolean = true;
|
||||
@Output() page: EventEmitter<PageEvent> = new EventEmitter<PageEvent>();
|
||||
@Output() sort: EventEmitter<Sort> = new EventEmitter<Sort>();
|
||||
|
||||
pageSizeOptions: number[] = [1, 2, 3, 4, 5, 10, 15, 30, 50, 100];
|
||||
|
||||
columns: string[] = [];
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private i18n: I18nService
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.applyResize(window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event) {
|
||||
this.applyResize(event.target.innerWidth || event.target.documentElement.clientWidth || event.target.body.clientWidth)
|
||||
}
|
||||
|
||||
applyResize(width: number) {
|
||||
if (width < 992) {
|
||||
this.columns = ['customer', 'price', 'motif'];
|
||||
} else {
|
||||
this.columns = ['customer', 'motif', 'price', 'timeInvestment', 'remark', 'materialConsumption', 'created', 'updated'];
|
||||
}
|
||||
if (this.username) {
|
||||
this.columns.unshift('username');
|
||||
}
|
||||
this.columns.unshift('dueDate');
|
||||
}
|
||||
|
||||
select(row: any) {
|
||||
this.router.navigateByUrl('/t/' + row.id);
|
||||
}
|
||||
|
||||
getCsvRows(): any[] {
|
||||
if (this.turnovers.total) {
|
||||
let rows = [[
|
||||
this.i18n.get('turnover.dueDate'),
|
||||
this.i18n.get('turnover.customer'),
|
||||
this.i18n.get('turnover.motif'),
|
||||
this.i18n.get('turnover.price'),
|
||||
this.i18n.get('turnover.timeInvestment'),
|
||||
this.i18n.get('turnover.remark'),
|
||||
this.i18n.get('turnover.materialConsumption'),
|
||||
this.i18n.get('turnover.created'),
|
||||
this.i18n.get('turnover.updated')]];
|
||||
|
||||
if (this.username) {
|
||||
rows[0].unshift(
|
||||
this.i18n.get('turnover.username'));
|
||||
}
|
||||
|
||||
this.turnovers.results.forEach(turnover => {
|
||||
rows[rows.length] = [
|
||||
moment(turnover.dueDate).format('L'),
|
||||
turnover.customer,
|
||||
turnover.motif,
|
||||
turnover.price.toFixed(2),
|
||||
turnover.timeInvestment.toFixed(1),
|
||||
turnover.remark,
|
||||
turnover.materialConsumption,
|
||||
moment(turnover.created).format(this.i18n.get('turnovers.export.dateformat')),
|
||||
moment(turnover.updated).format(this.i18n.get('turnovers.export.dateformat'))
|
||||
]
|
||||
if (this.username) {
|
||||
rows[rows.length - 1].unshift(turnover.username);
|
||||
}
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
|
||||
import { I18nService } from './../services/i18n.service';
|
||||
|
||||
@Pipe({
|
||||
name: 'i18n'
|
||||
})
|
||||
export class I18nPipe implements PipeTransform {
|
||||
|
||||
|
||||
constructor(private i18n: I18nService) {
|
||||
}
|
||||
|
||||
transform(value: String, ...args: any[]): String {
|
||||
return this.i18n.get(value, args);
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
name: 'i18nEmpty'
|
||||
})
|
||||
export class I18nEmptyPipe implements PipeTransform {
|
||||
|
||||
constructor(private i18n: I18nService) {
|
||||
}
|
||||
|
||||
transform(value: String, ...args: any[]): String {
|
||||
return this.i18n.getEmpty(value, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { FormGroup } from '@angular/forms';
|
||||
|
||||
export function MatchingValidator(passwordName: string, password2Name: string) {
|
||||
|
||||
return (formGroup: FormGroup) => {
|
||||
|
||||
const password = formGroup.controls[passwordName];
|
||||
const password2 = formGroup.controls[password2Name];
|
||||
|
||||
if (password2.errors && !password2.errors.NOT_MATCH) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.value !== password2.value) {
|
||||
password2.setErrors({ NOT_MATCH: true });
|
||||
} else {
|
||||
password2.setErrors(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Pipe({ name: 'datef' })
|
||||
export class MomentPipe implements PipeTransform {
|
||||
transform(value: Date | moment.Moment, dateFormat: string | undefined = undefined): any {
|
||||
if (!dateFormat) {
|
||||
return moment(value).fromNow();
|
||||
}
|
||||
|
||||
return moment(value).format(dateFormat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
{
|
||||
"buntspecht": {
|
||||
".": "Buntspecht"
|
||||
},
|
||||
"cancel": "Abbrechen",
|
||||
"confirm": "Bestätigen",
|
||||
"darkTheme": "Dunkles Thema",
|
||||
"locale": {
|
||||
"de-informal": {
|
||||
"long": "Deutsch",
|
||||
"short": "DE"
|
||||
},
|
||||
"en": {
|
||||
"long": "English",
|
||||
"short": "EN"
|
||||
}
|
||||
},
|
||||
"login": {
|
||||
".": "Login",
|
||||
"autologin": "Automatisch einloggen",
|
||||
"external": {
|
||||
".": "Login",
|
||||
"client": "mit {0} einloggen",
|
||||
"invalid": "Login fehlgeschlagen"
|
||||
},
|
||||
"internal": "Login",
|
||||
"invalid": "Falscher Username oder Password",
|
||||
"keepSession": "eingeloggt bleiben",
|
||||
"password": "Passwort",
|
||||
"username": "Username"
|
||||
},
|
||||
"logout": "Logout",
|
||||
"management": {
|
||||
".": "Verwaltung",
|
||||
"filter": {
|
||||
"created": {
|
||||
".": "Erstellt",
|
||||
"from": "von",
|
||||
"to": "bis"
|
||||
},
|
||||
"dueDate": {
|
||||
".": "Zeitraum",
|
||||
"from": "von",
|
||||
"to": "bis"
|
||||
},
|
||||
"username": "User auswählen"
|
||||
}
|
||||
},
|
||||
"not-found": {
|
||||
".": "Nicht gefunden",
|
||||
"text": "Seite nicht gefunden"
|
||||
},
|
||||
"paginator": {
|
||||
"empty": "Keine Ergebnisse",
|
||||
"firstPage": "Erste Seite",
|
||||
"itemsPerPage": "Einträge pro Seite:",
|
||||
"lastPage": "Letzte Seite",
|
||||
"nextPage": "Nächste Seite",
|
||||
"previousPage": "Vorherige Seite",
|
||||
"range": "Seite {0} von {1}"
|
||||
},
|
||||
"password": {
|
||||
".": "Passwort ändern",
|
||||
"error": {
|
||||
"ILLEGAL_WHITESPACE": "Bitte keine Leerzeichen verwenden.",
|
||||
"INSUFFICIENT_DIGIT": "Bitte mindestens eine Zahl eingeben.",
|
||||
"INSUFFICIENT_LOWERCASE": "Bitte mindestens einen Kleinbuchstaben eingeben.",
|
||||
"INSUFFICIENT_SPECIAL": "Bitte mindestens ein Sonderzeichen eingeben.",
|
||||
"INSUFFICIENT_UPPERCASE": "Bitte mindestens einen Großbuchstaben eingeben.",
|
||||
"NOT_MATCH": "Passwörter stimmen nicht überein.",
|
||||
"TOO_SHORT": "Bitte ein längeres Passwort wählen.",
|
||||
"UNAUTHORIZED": "Falsches Passwort"
|
||||
},
|
||||
"old": "Altes Password",
|
||||
"new": "Neues Password",
|
||||
"repeat": "Neues Password wiederholen",
|
||||
"success": "Erfolgreich gespeichert",
|
||||
"update": "Aktualisieren"
|
||||
},
|
||||
"profile": {
|
||||
".": "Profil",
|
||||
"about": "Über",
|
||||
"darkTheme": "Dunkles Thema",
|
||||
"email": "E-Mail Adresse",
|
||||
"hello": "Hallo {0}",
|
||||
"name": "Voller Name",
|
||||
"success": "Erfolgreich gespeichert",
|
||||
"update": "Aktualisieren",
|
||||
"username": "Username"
|
||||
},
|
||||
"service-unavailable": {
|
||||
".": "Dienst nicht erreichbar",
|
||||
"retry": "Seite neu laden",
|
||||
"support": "Support",
|
||||
"text": "Zurzeit scheint der Dienst nicht erreichbar zu sein. Wenn diese Meldung länger besteht, melde dich beim Support!"
|
||||
},
|
||||
"turnover": {
|
||||
".": "Buchung",
|
||||
"confirmDelete": "Möchtest du diese Buchung von '{0}' wirklich löschen?",
|
||||
"create": "Buchung erstellen",
|
||||
"created": {
|
||||
".": "Erstellt",
|
||||
"label": {
|
||||
".": "Erstellt am {0}",
|
||||
"username": "Erstellt am {0} von {1}"
|
||||
}
|
||||
},
|
||||
"customer": {
|
||||
".": "Kunde",
|
||||
"error": "Angabe von Kunde erforderlich"
|
||||
},
|
||||
"dueDate": {
|
||||
".": "Fälligkeitsdatum",
|
||||
"label": {
|
||||
".": "Fällig am {0}"
|
||||
}
|
||||
},
|
||||
"delete": "Löschen",
|
||||
"edit": "Buchung bearbeiten",
|
||||
"info": "Neue Buchung erstellen",
|
||||
"materialConsumption": "Materialverbrauch",
|
||||
"motif": {
|
||||
".": "Motiv",
|
||||
"error": "Angabe von Motiv erforderlich"
|
||||
},
|
||||
"price": {
|
||||
".": "Preis",
|
||||
"error": "Angabe des Preises erforderlich",
|
||||
"suffix": "€",
|
||||
"total": "Umsatz: {0} €"
|
||||
},
|
||||
"remark": "Bemerkungen",
|
||||
"success": "Erfolgreich gespeichert",
|
||||
"timeInvestment": {
|
||||
".": "Zeiteinsatz",
|
||||
"suffix": "Std.",
|
||||
"total": "Zeiteinsatz: {0} Std."
|
||||
},
|
||||
"update": "Aktualisieren",
|
||||
"updated": {
|
||||
".": "Aktualisiert",
|
||||
"label": "Zuletzt aktualisiert am {0}"
|
||||
},
|
||||
"username": "User"
|
||||
},
|
||||
"turnovers": {
|
||||
".": "Buchungen",
|
||||
"export": {
|
||||
".": "Als CSV exportieren",
|
||||
"dateformat": "DD.MM.YYYY-HH:mm"
|
||||
},
|
||||
"filter": {
|
||||
".": "Filter",
|
||||
"created": {
|
||||
".": "Erstellt",
|
||||
"from": "von",
|
||||
"to": "bis"
|
||||
},
|
||||
"dueDate": {
|
||||
".": "Zeitraum",
|
||||
"from": "von",
|
||||
"to": "bis"
|
||||
},
|
||||
"customer": "Kunde durchsuchen",
|
||||
"motif": "Motiv durchsuchen",
|
||||
"username": "User auswählen"
|
||||
},
|
||||
"mine": "Eigene Buchungen"
|
||||
},
|
||||
"updateSw": "Update?",
|
||||
"user": {
|
||||
"admin": "Administrator",
|
||||
"confirmDelete": "Möchtest du den User '{0}' wirklich löschen? ALLE Buchungen dieses Users werden ebenfalls gelöscht!",
|
||||
"create": "Neuen User erstellen",
|
||||
"delete": "User löschen",
|
||||
"error": {
|
||||
"ALREADY_EXISTS": "User existiert bereits"
|
||||
},
|
||||
"manage": "Verwalten",
|
||||
"password": "Passwort",
|
||||
"username": "User"
|
||||
},
|
||||
"users": {
|
||||
".": "User verwalten",
|
||||
"filter": {
|
||||
".": "Filter",
|
||||
"search": "Nach Username filtern"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 359 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 786 KiB |
|
After Width: | Height: | Size: 666 KiB |
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl : 'https://buntspecht.8lh.de/api'
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
// apiUrl : 'http://localhost:8080/api',
|
||||
apiUrl : 'https://buntspecht.dev.lh8.de/api',
|
||||
};
|
||||
|
||||
/*
|
||||
* For easier debugging in development mode, you can import the following file
|
||||
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||
*
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
|
||||
|
After Width: | Height: | Size: 948 B |
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Buntspecht</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="assets/icons/favicon.png">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "buntspecht",
|
||||
"short_name": "buntspecht",
|
||||
"theme_color": "#1976d2",
|
||||
"background_color": "#fafafa",
|
||||
"display": "standalone",
|
||||
"scope": "./",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "assets/icons/icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
import '@angular/localize/init';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import 'zone.js'; // Included with Angular CLI.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
// Custom Theming for Angular Material
|
||||
@use '@angular/material' as mat;
|
||||
// For more information: https://material.angular.io/guide/theming
|
||||
// Plus imports for other components in your app.
|
||||
|
||||
// Include the common styles for Angular Material. We include this here so that you only
|
||||
// have to load a single css file for Angular Material in your app.
|
||||
// Be sure that you only ever include this mixin once!
|
||||
@include mat.core();
|
||||
|
||||
@import './variables.scss';
|
||||
|
||||
// Include theme styles for core and each component used in your app.
|
||||
// Alternatively, you can import and @include the theme mixins for each component
|
||||
// that you are using.
|
||||
@include mat.all-component-themes($light-theme);
|
||||
|
||||
.dark-theme {
|
||||
@include mat.all-component-colors($dark-theme);
|
||||
}
|
||||
|
||||
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
/* fallback */
|
||||
@font-face {
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(assets/fonts/material_icons.woff2) format('woff2');
|
||||
}
|
||||
|
||||
a {
|
||||
color: $primary;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
font-family: 'Material Icons';
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
word-wrap: normal;
|
||||
direction: ltr;
|
||||
-moz-font-feature-settings: 'liga';
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
|
||||
}
|
||||
|
||||
app-root,
|
||||
ui-main {
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
app-root {
|
||||
padding: 15px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
ui-main {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
mat-form-field {
|
||||
display: block;
|
||||
}
|
||||
|
||||
mat-form-field {
|
||||
&.ng-valid {
|
||||
.mat-form-field-wrapper {
|
||||
padding-bottom: 1.25em;
|
||||
}
|
||||
}
|
||||
|
||||
&.ng-invalid,
|
||||
&.mat-form-field-invalid {
|
||||
.mat-form-field-wrapper {
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
&.ng-untouched {
|
||||
.mat-form-field-wrapper {
|
||||
padding-bottom: 1.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-form-field {
|
||||
&-underline {
|
||||
position: static;
|
||||
}
|
||||
|
||||
&-subscript-wrapper {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-mdc-form-field-hint-wrapper,
|
||||
.mat-mdc-form-field-error-wrapper {
|
||||
position: relative !important;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
qrcode {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
qrcode canvas {
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
max-width: 400px !important;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex !important;
|
||||
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&.wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&.fill {
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
min-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
&.center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&.space-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&.space-around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
&.middle {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 576px) {
|
||||
mat-paginator {
|
||||
.mat-mdc-paginator-range-actions {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.scroll-container {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.scroll-x-container {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.scroll-y-container {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.margin {
|
||||
margin: 0 15px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.ellipsis {
|
||||
display: block;
|
||||
max-width: 200px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.mat-drawer-inner-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
mat-sidenav-container {
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-justify {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: $warn;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
display: flex;
|
||||
padding: 21px 0;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.mat-tooltip-trigger {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
mat-card.warn,
|
||||
mat-card.accent {
|
||||
|
||||
padding: 0;
|
||||
|
||||
mat-card-content {
|
||||
padding: 16px;
|
||||
|
||||
}
|
||||
|
||||
mat-card-header {
|
||||
padding: 16px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
mat-card-actions {
|
||||
padding: 16px !important;
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mat-card.warn mat-card-header {
|
||||
background-color: $warn !important;
|
||||
}
|
||||
|
||||
mat-card.accent mat-card-header {
|
||||
background-color: $accent !important;
|
||||
}
|
||||
|
||||
|
||||
.mat-sort-header-content {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
table.default-table {
|
||||
border: 0;
|
||||
border-spacing: 0;
|
||||
width: 100%;
|
||||
background: white;
|
||||
overflow: auto;
|
||||
|
||||
th,
|
||||
td,
|
||||
td {
|
||||
color: rgba(0, 0, 0, 0.87);
|
||||
font-size: 14px;
|
||||
border: 0;
|
||||
padding: 14px;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
th:first-of-type,
|
||||
td:first-of-type,
|
||||
td:first-of-type {
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
thead {
|
||||
tr {
|
||||
height: 56px;
|
||||
|
||||
th {
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a[href*="//"]::after {
|
||||
font-family: "Material Icons";
|
||||
font-size: 10px;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -3px;
|
||||
content: "launch";
|
||||
color: #6e6e6e;
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
|
||||
.dark-theme {
|
||||
|
||||
app-root {
|
||||
background-color: #303030;
|
||||
}
|
||||
|
||||
a {
|
||||
color: $accent;
|
||||
}
|
||||
|
||||
table.default-table {
|
||||
|
||||
background: #424242;
|
||||
|
||||
th,
|
||||
td,
|
||||
td {
|
||||
color: white;
|
||||
border-bottom-color: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
|
||||
thead {
|
||||
tr {
|
||||
th {
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a[href*="//"]::after {
|
||||
color: #aeaeae;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 576px) {
|
||||
.hide-small {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: {
|
||||
context(path: string, deep?: boolean, filter?: RegExp): {
|
||||
keys(): string[];
|
||||
<T>(id: string): T;
|
||||
};
|
||||
};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: false }
|
||||
}
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
@@ -0,0 +1,33 @@
|
||||
@use '@angular/material' as mat;
|
||||
|
||||
$light-primary: mat.m2-define-palette(mat.$m2-grey-palette, 800);
|
||||
$light-accent: mat.m2-define-palette(mat.$m2-grey-palette, A400, A200, A700);
|
||||
$light-warn: mat.m2-define-palette(mat.$m2-red-palette);
|
||||
|
||||
$dark-primary: mat.m2-define-palette(mat.$m2-grey-palette, 900, 500, 700);
|
||||
$dark-accent: mat.m2-define-palette(mat.$m2-grey-palette, A200, A100, A400);
|
||||
$dark-warn: mat.m2-define-palette(mat.$m2-red-palette);
|
||||
|
||||
// Define the palettes for your theme using the Material Design palettes available in palette.scss
|
||||
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
|
||||
// hue. Available color palettes: https://material.io/design/color/
|
||||
$light-theme: mat.m2-define-light-theme((color: (primary: $light-primary,
|
||||
accent: $light-accent,
|
||||
warn: $light-warn,
|
||||
)));
|
||||
|
||||
// Define an alternate dark theme.
|
||||
$dark-theme: mat.m2-define-dark-theme((color: (primary: $dark-primary,
|
||||
accent: $dark-accent,
|
||||
warn: $dark-warn,
|
||||
)));
|
||||
|
||||
$primary: mat.get-theme-color($light-theme, primary, default);
|
||||
$accent: mat.get-theme-color($light-theme, accent, default);
|
||||
$warn: mat.get-theme-color($light-theme, warn, default);
|
||||
|
||||
.dark-theme {
|
||||
$primary: mat.get-theme-color($dark-theme, primary, default);
|
||||
$accent: mat.get-theme-color($dark-theme, accent, default);
|
||||
$warn: mat.get-theme-color($dark-theme, warn, default);
|
||||
}
|
||||