diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..84eb9b1
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+node_modules/
+nginx/
+doc/
+build/
diff --git a/COPYING.md b/COPYING.md
new file mode 100644
index 0000000..5f8b06f
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,675 @@
+### GNU GENERAL PUBLIC LICENSE
+
+Version 3, 29 June 2007
+
+Copyright (C) 2007 Free Software Foundation, Inc.
+
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+### Preamble
+
+The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is 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. We, the Free Software Foundation, use
+the GNU General Public License for most of our software; it applies
+also to any other work released this way by its authors. You can apply
+it to your programs, too.
+
+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.
+
+To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you
+have certain responsibilities if you distribute copies of the
+software, or if you modify it: responsibilities to respect the freedom
+of others.
+
+For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the
+manufacturer can do so. This is fundamentally incompatible with the
+aim of protecting users' freedom to change the software. The
+systematic pattern of such abuse occurs in the area of products for
+individuals to use, which is precisely where it is most unacceptable.
+Therefore, we have designed this version of the GPL to prohibit the
+practice for those products. If such problems arise substantially in
+other domains, we stand ready to extend this provision to those
+domains in future versions of the GPL, as needed to protect the
+freedom of users.
+
+Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish
+to avoid the special danger that patents applied to a free program
+could make it effectively proprietary. To prevent this, the GPL
+assures that patents cannot be used to render the program non-free.
+
+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 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. Use with the GNU Affero General Public License.
+
+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 Affero 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 special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+#### 14. Revised Versions of this License.
+
+The Free Software Foundation may publish revised and/or new versions
+of the GNU 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 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 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 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.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper
+mail.
+
+If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands \`show w' and \`show c' should show the
+appropriate parts of the General Public License. Of course, your
+program's commands might be different; for a GUI interface, you would
+use an "about box".
+
+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 GPL, see .
+
+The GNU General Public License does not permit incorporating your
+program into proprietary programs. If your program is a subroutine
+library, you may consider it more useful to permit linking proprietary
+applications with the library. If this is what you want to do, use the
+GNU Lesser General Public License instead of this License. But first,
+please read .
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b014976
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+FROM node:latest
+
+RUN mkdir /react
+RUN mkdir /result
+
+VOLUME /result
+
+WORKDIR /react
+
+CMD npm install && npm run build && cp -R /react/build/* /result/
diff --git a/README.md b/README.md
index d05a9a5..172ff40 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ Additional libraries are used, for a complete list see package.json.
To start the website locally run `npm start`. This will open a local webserver serving the _frontend_. To make the website work, you still need to start at least the VILLASweb-backend (See repository for information).
+The default user and password are configured in the `config.js` file of the _backend_. By default they are: __admin__ / __admin__.
+
## Copyright
2017, Institute for Automation of Complex Power Systems, EONERC
@@ -55,4 +57,4 @@ For other licensing options please consult [Prof. Antonello Monti](mailto:amonti
[Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de)
[EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de)
-[RWTH University Aachen, Germany](http://www.rwth-aachen.de)
\ No newline at end of file
+[RWTH University Aachen, Germany](http://www.rwth-aachen.de)
diff --git a/docker-compose.yml b/docker-compose.yml
index 684f66c..13dd4c2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,6 +10,7 @@ services:
ports:
- "80:80"
- "443:443"
+ restart: always
backend:
build: VILLASweb-backend
@@ -19,9 +20,12 @@ services:
- NODE_ENV=production
ports:
- "4000:4000"
+ restart: always
database:
image: mongo:latest
user: mongodb
volumes:
- /opt/database:/data/db
+ restart: always
+ user: mongodb
diff --git a/nginx/villas.conf b/nginx/villas.conf
index f3417de..7fd9ee9 100644
--- a/nginx/villas.conf
+++ b/nginx/villas.conf
@@ -7,10 +7,10 @@ server {
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
+
# rewrite url to exclude /api on context broker side
- rewrite ^/api/?(.*) /api/v1/$1 break;
-
+ rewrite ^/api/?(.*) /api/$1 break;
+
proxy_pass http://backend:4000/;
}
diff --git a/package.json b/package.json
index 0116f0a..aa1e73c 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
"name": "villasweb-frontend",
"version": "0.1.0",
"private": true,
+ "proxy": "http://localhost:4000",
"dependencies": {
"bootstrap": "^3.3.7",
"classnames": "^2.2.5",
@@ -19,9 +20,13 @@
"react-notification-system": "^0.2.13",
"react-rnd": "^4.2.2",
"react-router": "^3.0.2",
- "superagent": "^3.5.0"
+ "superagent": "^3.5.0",
+ "gaugeJS": "^1.3.2",
+ "d3-scale": "^1.0.5",
+ "rc-slider": "^7.0.1"
},
"devDependencies": {
+ "chai": "^3.5.0",
"react-scripts": "0.9.3"
},
"scripts": {
diff --git a/public/index.html b/public/index.html
index aab5e3b..2775a2d 100644
--- a/public/index.html
+++ b/public/index.html
@@ -13,7 +13,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
- React App
+ VILLASweb
diff --git a/src/__tests__/components/dialog/edit-widget-control-creator.js b/src/__tests__/components/dialog/edit-widget-control-creator.js
new file mode 100644
index 0000000..fea0b2a
--- /dev/null
+++ b/src/__tests__/components/dialog/edit-widget-control-creator.js
@@ -0,0 +1,42 @@
+
+import { expect } from 'chai';
+
+import createControls from '../../../components/dialog/edit-widget-control-creator';
+import EditWidgetTextControl from '../../../components/dialog/edit-widget-text-control';
+import EditWidgetColorControl from '../../../components/dialog/edit-widget-color-control';
+import EditWidgetTimeControl from '../../../components/dialog/edit-widget-time-control';
+import EditImageWidgetControl from '../../../components/dialog/edit-widget-image-control';
+import EditWidgetSimulatorControl from '../../../components/dialog/edit-widget-simulator-control';
+import EditWidgetSignalControl from '../../../components/dialog/edit-widget-signal-control';
+import EditWidgetSignalsControl from '../../../components/dialog/edit-widget-signals-control';
+import EditWidgetOrientation from '../../../components/dialog/edit-widget-orientation';
+
+describe('edit widget control creator', () => {
+ it('should not return null', () => {
+ let controls = createControls('Value', null, null, null, null, null, null);
+ expect(controls).to.be.defined;
+ });
+
+ var runs = [
+ { args: { widgetType: 'Value' }, result: { controlNumber: 2, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalControl] } },
+ { args: { widgetType: 'Plot' }, result: { controlNumber: 4, controlTypes: [EditWidgetTimeControl, EditWidgetSimulatorControl, EditWidgetSignalsControl, EditWidgetTextControl] } },
+ { args: { widgetType: 'Table' }, result: { controlNumber: 1, controlTypes: [EditWidgetSimulatorControl] } },
+ { args: { widgetType: 'Image' }, result: { controlNumber: 1, controlTypes: [EditImageWidgetControl] } },
+ { args: { widgetType: 'Gauge' }, result: { controlNumber: 2, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalControl] } },
+ { args: { widgetType: 'PlotTable' }, result: { controlNumber: 3, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalsControl, EditWidgetTextControl] } },
+ { args: { widgetType: 'Slider' }, result: { controlNumber: 1, controlTypes: [EditWidgetOrientation] } },
+ { args: { widgetType: 'Button' }, result: { controlNumber: 2, controlTypes: [EditWidgetColorControl] } },
+ { args: { widgetType: 'Box' }, result: { controlNumber: 1, controlTypes: [EditWidgetColorControl] } },
+ ];
+
+ runs.forEach( (run) => {
+ let itMsg = run.args.widgetType + ' widget edit model should have correct controls';
+ it(itMsg, () => {
+ let controls = createControls(run.args.widgetType, null, null, null, null, null, null);
+
+ expect(controls).to.have.lengthOf(run.result.controlNumber);
+
+ controls.forEach( (control) => expect(control.type).to.be.oneOf(run.result.controlTypes))
+ });
+ });
+});
\ No newline at end of file
diff --git a/src/api/rest-api.js b/src/api/rest-api.js
index be14376..6a79598 100644
--- a/src/api/rest-api.js
+++ b/src/api/rest-api.js
@@ -2,13 +2,55 @@
* File: rest-api.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import request from 'superagent/lib/client';
import Promise from 'es6-promise';
+import NotificationsDataManager from '../data-managers/notifications-data-manager';
+
+
+// TODO: Add this to a central pool of notifications
+const SERVER_NOT_REACHABLE_NOTIFICATION = {
+ title: 'Server not reachable',
+ message: 'The server could not be reached. Please try again later.',
+ level: 'error'
+ };
+
+const REQUEST_TIMEOUT_NOTIFICATION = {
+ title: 'Request timeout',
+ message: 'Request timed out. Please try again later.',
+ level: 'error'
+ };
+
+// Check if the error was due to network failure, timeouts, etc.
+// Can be used for the rest of requests
+function isNetworkError(err) {
+ let result = false;
+
+ // If not status nor response fields, it is a network error. TODO: Handle timeouts
+ if (err.status == null || err.response == null) {
+ result = true;
+
+ let notification = err.timeout? REQUEST_TIMEOUT_NOTIFICATION : SERVER_NOT_REACHABLE_NOTIFICATION;
+ NotificationsDataManager.addNotification(notification);
+ }
+ return result;
+}
class RestAPI {
get(url, token) {
@@ -31,14 +73,17 @@ class RestAPI {
post(url, body, token) {
return new Promise(function (resolve, reject) {
- var req = request.post(url).send(body);
+ var req = request.post(url).send(body).timeout({ response: 5000 }); // Simple response start timeout (3s)
if (token != null) {
req.set('x-access-token', token);
}
-
+
req.end(function (error, res) {
if (res == null || res.status !== 200) {
+
+ error.handled = isNetworkError(error);
+
reject(error);
} else {
resolve(JSON.parse(res.text));
diff --git a/src/api/websocket-api.js b/src/api/websocket-api.js
index c5cad2c..ff866e2 100644
--- a/src/api/websocket-api.js
+++ b/src/api/websocket-api.js
@@ -2,10 +2,22 @@
* File: websocket-api.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
class WebsocketAPI {
addSocket(endpoint, callbacks) {
diff --git a/src/app-dispatcher.js b/src/app-dispatcher.js
index 52ba2af..ee54eb5 100644
--- a/src/app-dispatcher.js
+++ b/src/app-dispatcher.js
@@ -2,10 +2,22 @@
* File: app-dispatcher.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import { Dispatcher } from 'flux';
diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js
index e3c774d..b0dff93 100644
--- a/src/components/dialog/dialog.js
+++ b/src/components/dialog/dialog.js
@@ -2,10 +2,22 @@
* File: dialog.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { Modal, Button } from 'react-bootstrap';
diff --git a/src/components/dialog/edit-project.js b/src/components/dialog/edit-project.js
index b4facfb..74391f5 100644
--- a/src/components/dialog/edit-project.js
+++ b/src/components/dialog/edit-project.js
@@ -2,10 +2,22 @@
* File: edit-project.js
* Author: Markus Grigull
* Date: 07.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/edit-simulation-model.js b/src/components/dialog/edit-simulation-model.js
index e51380c..3de81dd 100644
--- a/src/components/dialog/edit-simulation-model.js
+++ b/src/components/dialog/edit-simulation-model.js
@@ -2,10 +2,22 @@
* File: edit-simulation-model.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
@@ -58,7 +70,7 @@ class EditSimulationModelDialog extends Component {
this.setState({ [e.target.id]: e.target.value });
}
-
+
handleMappingChange(event, row, column) {
var mapping = this.state.mapping;
diff --git a/src/components/dialog/edit-simulation.js b/src/components/dialog/edit-simulation.js
index af9dfa4..b12699c 100644
--- a/src/components/dialog/edit-simulation.js
+++ b/src/components/dialog/edit-simulation.js
@@ -2,10 +2,22 @@
* File: new-simulation.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/edit-simulator.js b/src/components/dialog/edit-simulator.js
index 2ed14fb..1fdcc09 100644
--- a/src/components/dialog/edit-simulator.js
+++ b/src/components/dialog/edit-simulator.js
@@ -2,10 +2,22 @@
* File: new-simulator.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js
new file mode 100644
index 0000000..594492a
--- /dev/null
+++ b/src/components/dialog/edit-user.js
@@ -0,0 +1,111 @@
+/**
+ * File: edit-user.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 02.05.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
+
+import React, { Component, PropTypes } from 'react';
+import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
+
+import Dialog from './dialog';
+
+class EditUserDialog extends Component {
+ static propTypes = {
+ show: PropTypes.bool.isRequired,
+ onClose: PropTypes.func.isRequired,
+ user: PropTypes.object.isRequired
+ };
+
+ valid: true;
+
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ username: '',
+ mail: '',
+ role: '',
+ _id: ''
+ }
+ }
+
+ onClose(canceled) {
+ if (canceled === false) {
+ this.props.onClose(this.state);
+ } else {
+ this.props.onClose();
+ }
+ }
+
+ handleChange(e) {
+ this.setState({ [e.target.id]: e.target.value });
+ }
+
+ resetState() {
+ this.setState({
+ username: this.props.user.username,
+ mail: this.props.user.mail,
+ role: this.props.user.role,
+ _id: this.props.user._id
+ });
+ }
+
+ validateForm(target) {
+ // check all controls
+ var username = true;
+
+ if (this.state.username === '') {
+ username = false;
+ }
+
+ this.valid = username;
+
+ // return state to control
+ if (target === 'username') return username ? "success" : "error";
+
+ return "success";
+ }
+
+ render() {
+ return (
+
+ );
+ }
+}
+
+export default EditUserDialog;
diff --git a/src/components/dialog/edit-visualization.js b/src/components/dialog/edit-visualization.js
index e31f96a..d9520d4 100644
--- a/src/components/dialog/edit-visualization.js
+++ b/src/components/dialog/edit-visualization.js
@@ -2,10 +2,22 @@
* File: new-visualization.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/edit-widget-color-control.js b/src/components/dialog/edit-widget-color-control.js
new file mode 100644
index 0000000..1b50f44
--- /dev/null
+++ b/src/components/dialog/edit-widget-color-control.js
@@ -0,0 +1,70 @@
+/**
+ * File: edit-widget-color-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 24.04.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, Col, Row, Radio, ControlLabel } from 'react-bootstrap';
+import classNames from 'classnames';
+import { scaleOrdinal, schemeCategory20 } from 'd3-scale';
+
+class EditWidgetColorControl extends Component {
+
+ static get ColorPalette() {
+ let colorCount = 0;
+ const colors = [];
+ const colorScale = scaleOrdinal(schemeCategory20);
+ while (colorCount < 20) { colors.push(colorScale(colorCount)); colorCount++; }
+ colors.unshift('#000', '#FFF'); // include black and white
+
+ return colors;
+ }
+
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {}
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ render() {
+
+ return (
+
+
+
+ { this.props.label }
+
+
+ {
+ EditWidgetColorControl.ColorPalette.map( (color, idx ) => {
+ let colorStyle = {
+ background: color,
+ borderColor: color
+ };
+
+ let checkedClass = classNames({
+ 'checked': idx === this.state.widget[this.props.controlId]
+ });
+
+ return ( this.props.handleChange({target: { id: this.props.controlId, value: idx}})} />)
+ }
+ )
+ }
+
+
+ )
+ }
+}
+
+export default EditWidgetColorControl;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-control-creator.js b/src/components/dialog/edit-widget-control-creator.js
new file mode 100644
index 0000000..455ca2f
--- /dev/null
+++ b/src/components/dialog/edit-widget-control-creator.js
@@ -0,0 +1,109 @@
+/**
+ * File: edit-widget-control-creator.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 23.05.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React from 'react';
+
+import EditWidgetTextControl from './edit-widget-text-control';
+import EditWidgetColorControl from './edit-widget-color-control';
+import EditWidgetTimeControl from './edit-widget-time-control';
+import EditImageWidgetControl from './edit-widget-image-control';
+import EditWidgetSimulatorControl from './edit-widget-simulator-control';
+import EditWidgetSignalControl from './edit-widget-signal-control';
+import EditWidgetSignalsControl from './edit-widget-signals-control';
+import EditWidgetOrientation from './edit-widget-orientation';
+
+export default function createControls(widgetType = null, widget = null, sessionToken = null, files = null, validateForm, simulation, handleChange) {
+ // Use a list to concatenate the controls according to the widget type
+ var dialogControls = [];
+
+ switch(widgetType) {
+ case 'Value': {
+ let valueBoundOnChange = (e) => {
+ handleChange([e, {target: {id: 'signal', value: 0}}]);
+ }
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />,
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />
+ )
+ }
+ break;
+ case 'Plot': {
+ let plotBoundOnChange = (e) => {
+ handleChange([e, {target: {id: 'signals', value: []}}]);
+ }
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />,
+ validateForm(id)} simulation={simulation} handleChange={(e) => plotBoundOnChange(e)} />,
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />,
+ handleChange(e)} />)
+ }
+ break;
+ case 'Table': {
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ case 'Image': {
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ case 'Gauge': {
+ let gaugeBoundOnChange = (e) => {
+ handleChange([e, {target: {id: 'signal', value: ''}}]);
+ }
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => gaugeBoundOnChange(e) } />,
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ case 'PlotTable': {
+ let plotTableBoundOnChange = (e) => {
+ handleChange([e, {target: {id: 'preselectedSignals', value: []}}]);
+ }
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => plotTableBoundOnChange(e)} />,
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />,
+ handleChange(e)} />)
+ }
+ break;
+ case 'Slider': {
+ dialogControls.push(
+ validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ case 'Button': {
+ dialogControls.push(
+ validateForm(id)} handleChange={(e) => handleChange(e)} />,
+ validateForm(id)} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ case 'Box': {
+ dialogControls.push(
+ validateForm(id)} handleChange={(e) => handleChange(e)} />)
+ }
+ break;
+ default:
+ console.log('Non-valid widget type');
+ }
+
+ return dialogControls;
+}
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-image.js b/src/components/dialog/edit-widget-image-control.js
similarity index 52%
rename from src/components/dialog/edit-widget-image.js
rename to src/components/dialog/edit-widget-image-control.js
index f7b06e4..56ae8f0 100644
--- a/src/components/dialog/edit-widget-image.js
+++ b/src/components/dialog/edit-widget-image-control.js
@@ -1,18 +1,30 @@
/**
- * File: edit-widget-value.js
+ * File: edit-widget-image-control.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { FormGroup, FormControl, ControlLabel, Button } from 'react-bootstrap';
import AppDispatcher from '../../app-dispatcher';
-class EditImageWidget extends Component {
+class EditImageWidgetControl extends Component {
constructor(props) {
super(props);
@@ -37,11 +49,12 @@ class EditImageWidget extends Component {
formData.append(key, this.state.fileList[key]);
}
}
-
+
// upload files
AppDispatcher.dispatch({
type: 'files/start-upload',
- data: formData
+ data: formData,
+ token: this.props.sessionToken
});
}
@@ -51,9 +64,18 @@ class EditImageWidget extends Component {
Image this.props.handleChange(e)}>
- {this.props.files.map((file, index) => (
-
- ))}
+ {
+ this.props.files.length === 0? (
+
+ ) : (
+ this.props.files.reduce( (entries, file, index) => {
+ entries.push();
+ return entries;
+ }, [
+
+ ])
+ )
+ }
@@ -68,4 +90,4 @@ class EditImageWidget extends Component {
}
}
-export default EditImageWidget;
+export default EditImageWidgetControl;
diff --git a/src/components/dialog/edit-widget-orientation.js b/src/components/dialog/edit-widget-orientation.js
new file mode 100644
index 0000000..9f3e67f
--- /dev/null
+++ b/src/components/dialog/edit-widget-orientation.js
@@ -0,0 +1,73 @@
+/**
+ * File: edit-widget-orientation.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 10.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, Col, Row, Radio, ControlLabel } from 'react-bootstrap';
+
+import WidgetSlider from '../widget-slider';
+
+class EditWidgetOrientation extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {}
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ handleOrientationChange(orientation) {
+ this.props.handleChange({ target: { id: 'orientation', value: orientation } });
+ }
+
+ render() {
+
+ // The tag shouldn't be necessary, but it gives height to the row while combining horizontal and vertical forms
+ return (
+
+
+
+ Orientation
+
+
+ {
+ Object.keys(WidgetSlider.OrientationTypes).map( (type) => {
+ let value = WidgetSlider.OrientationTypes[type].value;
+ let name = WidgetSlider.OrientationTypes[type].name;
+
+ return (
+ this.handleOrientationChange(value)}>
+ { name }
+ )
+ })
+ }
+
+
+
+ );
+ }
+}
+
+export default EditWidgetOrientation;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-plot.js b/src/components/dialog/edit-widget-plot.js
deleted file mode 100644
index a2371e3..0000000
--- a/src/components/dialog/edit-widget-plot.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * File: edit-widget-plot.js
- * Author: Markus Grigull
- * Date: 13.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
-
-import React, { Component } from 'react';
-import { FormGroup, FormControl, ControlLabel, Checkbox, HelpBlock } from 'react-bootstrap';
-
-class EditPlotWidget extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- widget: {
- simulator: '',
- signals: [],
- time: 0
- }
- };
- }
-
- componentWillReceiveProps(nextProps) {
- this.setState({ widget: nextProps.widget });
- }
-
- handleSignalChange(e, index) {
- var signals = this.state.widget.signals;
-
- if (e.target.checked) {
- // add signal
- signals.push(index);
- } else {
- // remove signal
- const pos = signals.indexOf(index);
- if (pos > -1) {
- signals.splice(pos, 1);
- }
- }
-
- this.props.handleChange({ target: { id: 'signals', value: signals } });
- }
-
- render() {
- // get selected simulation model
- var simulationModel = {};
-
- if (this.props.simulation) {
- this.props.simulation.models.forEach((model) => {
- if (model.simulation === this.state.widget.simulation) {
- simulationModel = model;
- }
- });
- }
-
- return (
-
- );
- }
-}
-
-export default EditPlotWidget;
diff --git a/src/components/dialog/edit-widget-signal-control.js b/src/components/dialog/edit-widget-signal-control.js
new file mode 100644
index 0000000..623b416
--- /dev/null
+++ b/src/components/dialog/edit-widget-signal-control.js
@@ -0,0 +1,71 @@
+/**
+ * File: edit-widget-signal-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 03.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
+
+class EditWidgetSignalControl extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {
+ simulator: ''
+ }
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ render() {
+ let signalsToRender = [];
+
+ if (this.props.simulation) {
+ // get selected simulation model
+ const simulationModel = this.props.simulation.models.find( model => model.simulator === this.state.widget.simulator );
+
+ // If simulation model update the signals to render
+ signalsToRender = simulationModel? simulationModel.mapping : [];
+ }
+
+ return (
+
+ Signal
+ this.props.handleChange(e)}>
+ {
+ signalsToRender.length === 0 ? (
+
+ ) : (
+ signalsToRender.map((signal, index) => (
+
+ ))
+ )
+ }
+
+
+ );
+ }
+}
+
+export default EditWidgetSignalControl;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-signals-control.js b/src/components/dialog/edit-widget-signals-control.js
new file mode 100644
index 0000000..76b832b
--- /dev/null
+++ b/src/components/dialog/edit-widget-signals-control.js
@@ -0,0 +1,84 @@
+/**
+ * File: edit-widget-signals-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 03.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, Checkbox, ControlLabel, FormControl } from 'react-bootstrap';
+
+class EditWidgetSignalsControl extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {
+ simulator: ''
+ }
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ handleSignalChange(checked, index) {
+ var signals = this.state.widget[this.props.controlId];
+ var new_signals;
+
+ if (checked) {
+ // add signal
+ new_signals = signals.concat(index);
+ } else {
+ // remove signal
+ new_signals = signals.filter( (idx) => idx !== index );
+ }
+
+ this.props.handleChange({ target: { id: this.props.controlId, value: new_signals } });
+ }
+
+ render() {
+ let signalsToRender = [];
+
+ if (this.props.simulation) {
+ // get selected simulation model
+ const simulationModel = this.props.simulation.models.find( model => model.simulator === this.state.widget.simulator );
+
+ // If simulation model update the signals to render
+ signalsToRender = simulationModel? simulationModel.mapping : [];
+ }
+
+ return (
+
+ Signals
+ {
+ signalsToRender.length === 0 || !this.state.widget.hasOwnProperty(this.props.controlId)? (
+ No signals available.
+ ) : (
+ signalsToRender.map((signal, index) => (
+ this.handleSignalChange(e.target.checked, index)}>{signal.name}
+ ))
+ )
+ }
+
+ );
+ }
+}
+
+export default EditWidgetSignalsControl;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-simulator-control.js b/src/components/dialog/edit-widget-simulator-control.js
new file mode 100644
index 0000000..48186ef
--- /dev/null
+++ b/src/components/dialog/edit-widget-simulator-control.js
@@ -0,0 +1,61 @@
+/**
+ * File: edit-widget-simulator-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 03.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
+
+class EditWidgetSimulatorControl extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {
+ simulator: ''
+ }
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ render() {
+
+ return (
+
+ Simulator
+ this.props.handleChange(e)}>
+ {
+ this.props.simulation.models.length === 0? (
+
+ ) : (
+ this.props.simulation.models.map((model, index) => (
+
+ )))
+ }
+
+
+ );
+ }
+}
+
+export default EditWidgetSimulatorControl;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-table.js b/src/components/dialog/edit-widget-table.js
deleted file mode 100644
index 0388ebd..0000000
--- a/src/components/dialog/edit-widget-table.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * File: edit-widget-table.js
- * Author: Markus Grigull
- * Date: 14.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
-
- import React, { Component } from 'react';
- import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
-
- class EditTableWidget extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- widget: {
- simulator: ''
- }
- };
- }
-
- componentWillReceiveProps(nextProps) {
- this.setState({ widget: nextProps.widget });
- }
-
- render() {
- return (
-
- );
- }
- }
-
- export default EditTableWidget;
diff --git a/src/components/dialog/edit-widget-text-control.js b/src/components/dialog/edit-widget-text-control.js
new file mode 100644
index 0000000..b9eef66
--- /dev/null
+++ b/src/components/dialog/edit-widget-text-control.js
@@ -0,0 +1,51 @@
+/**
+ * File: edit-widget-text-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 21.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
+
+class EditWidgetTextControl extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {}
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update state's widget with props
+ this.setState({ widget: nextProps.widget });
+ }
+
+ render() {
+
+ return (
+
+ { this.props.label }
+ this.props.handleChange(e)} />
+
+
+ );
+ }
+}
+
+export default EditWidgetTextControl;
\ No newline at end of file
diff --git a/src/components/dialog/edit-widget-time-control.js b/src/components/dialog/edit-widget-time-control.js
new file mode 100644
index 0000000..8f6434d
--- /dev/null
+++ b/src/components/dialog/edit-widget-time-control.js
@@ -0,0 +1,52 @@
+/**
+ * File: edit-widget-time-control.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 13.04.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap';
+
+class EditWidgetTimeControl extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ widget: {
+ time: 0
+ }
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ this.setState({ widget: nextProps.widget });
+ }
+
+ render() {
+
+ return (
+
+ Time
+ this.props.handleChange(e)} />
+ Time in seconds
+
+ );
+ }
+}
+
+export default EditWidgetTimeControl;
diff --git a/src/components/dialog/edit-widget-value.js b/src/components/dialog/edit-widget-value.js
deleted file mode 100644
index 7f16a03..0000000
--- a/src/components/dialog/edit-widget-value.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * File: edit-widget-value.js
- * Author: Markus Grigull
- * Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
-
-import React, { Component } from 'react';
-import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
-
-class EditValueWidget extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- widget: {
- simulator: '',
- signal: 0
- }
- };
- }
-
- componentWillReceiveProps(nextProps) {
- this.setState({ widget: nextProps.widget });
- }
-
- render() {
- // get selected simulation model
- var simulationModel = {};
-
- if (this.props.simulation) {
- this.props.simulation.models.forEach((model) => {
- if (model.simulation === this.state.widget.simulation) {
- simulationModel = model;
- }
- });
- }
-
- return (
-
- );
- }
-}
-
-export default EditValueWidget;
diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js
index 2b7a21e..8c2277f 100644
--- a/src/components/dialog/edit-widget.js
+++ b/src/components/dialog/edit-widget.js
@@ -2,23 +2,33 @@
* File: edit-widget.js
* Author: Markus Grigull
* Date: 08.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import Dialog from './dialog';
-import EditValueWidget from './edit-widget-value';
-import EditPlotWidget from './edit-widget-plot';
-import EditTableWidget from './edit-widget-table';
-import EditImageWidget from './edit-widget-image';
+import createControls from './edit-widget-control-creator';
class EditWidgetDialog extends Component {
static propTypes = {
+ sessionToken: PropTypes.string.isRequired,
show: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired
};
@@ -45,12 +55,16 @@ class EditWidgetDialog extends Component {
}
}
- handleChange(e, index) {
- var update = this.state.temporal;
- update[e.target.id] = e.target.value;
- this.setState({ temporal: update });
-
- //console.log(this.state.widget);
+ handleChange(e) {
+ if (e.constructor === Array) {
+ // Every property in the array will be updated
+ let changes = e.reduce( (changesObject, event) => { changesObject[event.target.id] = event.target.value; return changesObject }, {});
+ this.setState({ temporal: Object.assign({}, this.state.temporal, changes ) });
+ } else {
+ let changeObject = {};
+ changeObject[e.target.id] = e.target.value;
+ this.setState({ temporal: Object.assign({}, this.state.temporal, changeObject ) });
+ }
}
resetState() {
@@ -73,19 +87,17 @@ class EditWidgetDialog extends Component {
}
render() {
- // get widget part
- var widgetDialog = null;
-
+
+ let controls = null;
if (this.props.widget) {
- if (this.props.widget.type === 'Value') {
- widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />;
- } else if (this.props.widget.type === 'Plot') {
- widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />;
- } else if (this.props.widget.type === 'Table') {
- widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />;
- } else if (this.props.widget.type === 'Image') {
- widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />;
- }
+ controls = createControls(
+ this.props.widget.type,
+ this.state.temporal,
+ this.props.sessionToken,
+ this.props.files,
+ (id) => this.validateForm(id),
+ this.props.simulation,
+ (e) => this.handleChange(e));
}
return (
@@ -96,8 +108,7 @@ class EditWidgetDialog extends Component {
this.handleChange(e)} />
-
- {widgetDialog}
+ { controls || '' }
);
diff --git a/src/components/dialog/new-project.js b/src/components/dialog/new-project.js
index ae08024..02c1550 100644
--- a/src/components/dialog/new-project.js
+++ b/src/components/dialog/new-project.js
@@ -2,10 +2,22 @@
* File: new-project.js
* Author: Markus Grigull
* Date: 07.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/new-simulation-model.js b/src/components/dialog/new-simulation-model.js
index e8cf8aa..5789e51 100644
--- a/src/components/dialog/new-simulation-model.js
+++ b/src/components/dialog/new-simulation-model.js
@@ -2,10 +2,22 @@
* File: new-simulation-model.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap';
@@ -74,7 +86,7 @@ class NewSimulationModelDialog extends Component {
resetState() {
this.setState({
name: '',
- simulator: this.props.simulators[0] != null ? this.props.simulators[0]._id : '',
+ simulator: this.props.simulators[0] != null ? this.props.simulators[0]._id : '',
length: '1',
mapping: [ { name: 'Signal', type: 'Type' } ]
});
diff --git a/src/components/dialog/new-simulation.js b/src/components/dialog/new-simulation.js
index 617f00b..e0d6313 100644
--- a/src/components/dialog/new-simulation.js
+++ b/src/components/dialog/new-simulation.js
@@ -2,10 +2,22 @@
* File: new-simulation.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/new-simulator.js b/src/components/dialog/new-simulator.js
index 7726e85..395cf9e 100644
--- a/src/components/dialog/new-simulator.js
+++ b/src/components/dialog/new-simulator.js
@@ -2,10 +2,22 @@
* File: new-simulator.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js
new file mode 100644
index 0000000..fd01f99
--- /dev/null
+++ b/src/components/dialog/new-user.js
@@ -0,0 +1,119 @@
+/**
+ * File: new-user.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 02.05.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
+
+import React, { Component, PropTypes } from 'react';
+import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap';
+
+import Dialog from './dialog';
+
+class NewUserDialog extends Component {
+ static propTypes = {
+ show: PropTypes.bool.isRequired,
+ onClose: PropTypes.func.isRequired
+ };
+
+ valid: false;
+
+ constructor(props) {
+ super(props);
+
+ this.state =Â {
+ username: '',
+ mail: '',
+ role: 'admin',
+ password: ''
+ };
+ }
+
+ onClose(canceled) {
+ if (canceled === false) {
+ this.props.onClose(this.state);
+ } else {
+ this.props.onClose();
+ }
+ }
+
+ handleChange(e) {
+ this.setState({ [e.target.id]: e.target.value });
+ }
+
+ resetState() {
+ this.setState({
+ username: '',
+ mail: '',
+ role: 'admin',
+ password: ''
+ });
+ }
+
+ validateForm(target) {
+ // check all controls
+ let username = this.state.username !== '' && this.state.username.length >= 3;
+ let password = this.state.password !== '';
+
+ this.valid = username && password;
+
+ // return state to control
+ switch(target) {
+ case 'username':
+ return username ? "success" : "error";
+ case 'password':
+ return password ? "success" : "error";
+ default:
+ return "success";
+ }
+ }
+
+ render() {
+ return (
+
+ );
+ }
+}
+
+export default NewUserDialog;
diff --git a/src/components/dialog/new-visualization.js b/src/components/dialog/new-visualization.js
index 06b3c73..5d04baf 100644
--- a/src/components/dialog/new-visualization.js
+++ b/src/components/dialog/new-visualization.js
@@ -2,10 +2,22 @@
* File: new-visualization.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
diff --git a/src/components/dropzone.js b/src/components/dropzone.js
index 18815e2..5f8bf0d 100644
--- a/src/components/dropzone.js
+++ b/src/components/dropzone.js
@@ -2,10 +2,22 @@
* File: dropzone.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { DropTarget } from 'react-dnd';
@@ -19,6 +31,19 @@ const dropzoneTarget = {
position.x -= dropzoneRect.left;
position.y -= dropzoneRect.top;
+ // Z-Index is one more the top most children
+ let foundZ = props.children.reduce( (maxZ, currentChildren) => {
+ // Is there a simpler way? Is not easy to expose a getter in a Container.create(Component)
+ let widget = currentChildren.props.data;
+ if (widget && widget.z) {
+ if (widget.z > maxZ) {
+ return widget.z;
+ }
+ }
+ return maxZ;
+ }, 0);
+ position.z = foundZ >= 100? foundZ : ++foundZ;
+
props.onDrop(monitor.getItem(), position);
}
};
diff --git a/src/components/footer.js b/src/components/footer.js
index 77b7136..31d29ed 100644
--- a/src/components/footer.js
+++ b/src/components/footer.js
@@ -2,10 +2,22 @@
* File: footer.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
diff --git a/src/components/header.js b/src/components/header.js
index b246f9d..2268cb5 100644
--- a/src/components/header.js
+++ b/src/components/header.js
@@ -2,10 +2,22 @@
* File: header.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
diff --git a/src/components/login-form.js b/src/components/login-form.js
index e4e329f..62840d4 100644
--- a/src/components/login-form.js
+++ b/src/components/login-form.js
@@ -2,10 +2,22 @@
* File: login-form.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Form, Button, FormGroup, FormControl, ControlLabel, Col } from 'react-bootstrap';
diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js
index 12ed741..152644a 100644
--- a/src/components/menu-sidebar.js
+++ b/src/components/menu-sidebar.js
@@ -2,10 +2,22 @@
* File: menu-sidebar.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Link } from 'react-router';
@@ -17,11 +29,14 @@ class SidebarMenu extends Component {
Menu
-
Home
-
Projects
-
Simulations
-
Simulators
-
Logout
+
Home
+
Projects
+
Simulations
+
Simulators
+ { this.props.currentRole === 'admin' ?
+
User Management
: ''
+ }
+
Logout
);
diff --git a/src/components/table-column.js b/src/components/table-column.js
index 634910d..2867754 100644
--- a/src/components/table-column.js
+++ b/src/components/table-column.js
@@ -2,10 +2,22 @@
* File: table-column.js
* Author: Markus Grigull
* Date: 06.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
diff --git a/src/components/table.js b/src/components/table.js
index 26bec32..f0798c5 100644
--- a/src/components/table.js
+++ b/src/components/table.js
@@ -2,10 +2,22 @@
* File: table.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Table, Button, Glyphicon, FormControl, Label } from 'react-bootstrap';
@@ -17,6 +29,7 @@ class CustomTable extends Component {
constructor(props) {
super(props);
+ this.activeInput = null;
this.state = {
rows: [],
editCell: [ -1, -1 ]
@@ -113,6 +126,23 @@ class CustomTable extends Component {
this.setState({ rows: rows });
}
+ componentDidUpdate() {
+ // A cell will not be selected at initial render, hence no need to call this in 'componentDidMount'
+ if (this.activeInput) {
+ this.activeInput.focus();
+ }
+ }
+
+ onCellFocus(index) {
+ // When a cell focus is detected, update the current state in order to uncover the input element
+ this.setState({ editCell: [ index.cell, index.row ]});
+ }
+
+ cellLostFocus() {
+ // Reset cell selection state
+ this.setState({ editCell: [ -1, -1 ] });
+ }
+
render() {
// get children
var children = this.props.children;
@@ -128,23 +158,41 @@ class CustomTable extends Component {
- {this.state.rows.map((row, rowIndex) => (
-
))
+ }
);
diff --git a/src/components/toolbox-item.js b/src/components/toolbox-item.js
index 4cc0144..8d253f3 100644
--- a/src/components/toolbox-item.js
+++ b/src/components/toolbox-item.js
@@ -2,10 +2,22 @@
* File: toolbox-item.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component, PropTypes } from 'react';
import { DragSource } from 'react-dnd';
diff --git a/src/components/widget-box.js b/src/components/widget-box.js
new file mode 100644
index 0000000..b917b65
--- /dev/null
+++ b/src/components/widget-box.js
@@ -0,0 +1,33 @@
+/**
+ * File: widget-box.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 25.04.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+
+import EditWidgetColorControl from './dialog/edit-widget-color-control';
+
+class WidgetBox extends Component {
+ render() {
+
+ let colors = EditWidgetColorControl.ColorPalette;
+
+ let colorStyle = {
+ borderColor: colors[this.props.widget.border_color]
+ }
+
+ return (
+
+
+ { }
+
+
+ );
+ }
+}
+
+export default WidgetBox;
diff --git a/src/components/widget-button.js b/src/components/widget-button.js
new file mode 100644
index 0000000..98ced0d
--- /dev/null
+++ b/src/components/widget-button.js
@@ -0,0 +1,44 @@
+/**
+ * File: widget-button.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 29.03.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+
+import EditWidgetColorControl from './dialog/edit-widget-color-control';
+
+class WidgetButton extends Component {
+
+ action(e) {
+ e.target.blur(); // Remove focus
+ console.log('Button widget action');
+ }
+
+ render() {
+
+ let colors = EditWidgetColorControl.ColorPalette;
+
+ let colorStyle = {
+ background: colors[this.props.widget.background_color],
+ color: colors[this.props.widget.font_color],
+ borderColor: colors[this.props.widget.font_color]
+ }
+
+ return (
+
+ { this.props.editing ? (
+
+ ) : (
+
+ )
+ }
+
+ );
+ }
+}
+
+export default WidgetButton;
\ No newline at end of file
diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js
new file mode 100644
index 0000000..364562a
--- /dev/null
+++ b/src/components/widget-factory.js
@@ -0,0 +1,120 @@
+/**
+ * File: widget-factory.js
+ * Description: A factory to create and pre-configure widgets
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 02.03.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import WidgetSlider from './widget-slider';
+
+class WidgetFactory {
+
+ static createWidgetOfType(type, position, defaultSimulator = null) {
+
+ let widget = {
+ name: 'Name',
+ type: type,
+ width: 100,
+ height: 100,
+ x: position.x,
+ y: position.y,
+ z: position.z
+ };
+
+ // set type specific properties
+ switch(type) {
+ case 'Value':
+ widget.simulator = defaultSimulator;
+ widget.signal = 0;
+ widget.minWidth = 70;
+ widget.minHeight = 20;
+ widget.width = 120;
+ widget.height = 70;
+ break;
+ case 'Plot':
+ widget.simulator = defaultSimulator;
+ widget.signals = [ 0 ];
+ widget.ylabel = '';
+ widget.time = 60;
+ widget.minWidth = 400;
+ widget.minHeight = 200;
+ widget.width = 400;
+ widget.height = 200;
+ break;
+ case 'Table':
+ widget.simulator = defaultSimulator;
+ widget.minWidth = 300;
+ widget.minHeight = 200;
+ widget.width = 400;
+ widget.height = 200;
+ break;
+ case 'Label':
+ widget.minWidth = 70;
+ widget.minHeight = 20;
+ break;
+ case 'PlotTable':
+ widget.simulator = defaultSimulator;
+ widget.preselectedSignals = [];
+ widget.signals = []; // initialize selected signals
+ widget.ylabel = '';
+ widget.minWidth = 400;
+ widget.minHeight = 300;
+ widget.width = 500;
+ widget.height = 500;
+ widget.time = 60;
+ break;
+ case 'Image':
+ widget.minWidth = 100;
+ widget.minHeight = 100;
+ widget.width = 200;
+ widget.height = 200;
+ break;
+ case 'Button':
+ widget.minWidth = 100;
+ widget.minHeight = 50;
+ widget.width = 100;
+ widget.height = 100;
+ widget.background_color = 1;
+ widget.font_color = 0;
+ break;
+ case 'NumberInput':
+ widget.minWidth = 200;
+ widget.minHeight = 50;
+ widget.width = 200;
+ widget.height = 50;
+ break;
+ case 'Slider':
+ widget.minWidth = 380;
+ widget.minHeight = 30;
+ widget.width = 400;
+ widget.height = 50;
+ widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation
+ break;
+ case 'Gauge':
+ widget.simulator = defaultSimulator;
+ widget.signal = 0;
+ widget.minWidth = 200;
+ widget.minHeight = 150;
+ widget.width = 200;
+ widget.height = 150;
+ break;
+ case 'Box':
+ widget.minWidth = 50;
+ widget.minHeight = 50;
+ widget.width = 100;
+ widget.height = 100;
+ widget.border_color = 0;
+ widget.z = 0;
+ break;
+ default:
+ widget.width = 100;
+ widget.height = 100;
+ }
+ return widget;
+ }
+}
+
+export default WidgetFactory;
\ No newline at end of file
diff --git a/src/components/widget-gauge.js b/src/components/widget-gauge.js
new file mode 100644
index 0000000..b4365fe
--- /dev/null
+++ b/src/components/widget-gauge.js
@@ -0,0 +1,119 @@
+/**
+ * File: widget-gauge.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 31.03.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { Gauge } from 'gaugeJS';
+
+class WidgetGauge extends Component {
+ constructor(props) {
+ super(props);
+
+ this.gaugeCanvas = null;
+ this.gauge = null;
+
+ this.state = {
+ value: 0
+ };
+ }
+
+ staticLabels(widget_height) {
+ let label_font_size = Math.floor(widget_height * 0.055); // font scaling factor, integer for performance
+ return {
+ font: label_font_size + 'px "Helvetica Neue"',
+ labels: [0.0, 0.1, 0.5, 0.9, 1.0],
+ color: "#000000",
+ fractionDigits: 1
+ }
+ }
+
+ computeGaugeOptions(widget_height) {
+ return {
+ angle: -0.25,
+ lineWidth: 0.2,
+ pointer: {
+ length: 0.6,
+ strokeWidth: 0.035
+ },
+ radiusScale: 0.9,
+ colorStart: '#6EA2B0',
+ colorStop: '#6EA2B0',
+ strokeColor: '#E0E0E0',
+ highDpiSupport: true,
+ staticLabels: this.staticLabels(widget_height)
+ };
+ }
+
+ componentDidMount() {
+ const opts = this.computeGaugeOptions(this.props.widget.height);
+ this.gauge = new Gauge(this.gaugeCanvas).setOptions(opts);
+ this.gauge.maxValue = 1;
+ this.gauge.setMinValue(0);
+ this.gauge.animationSpeed = 30;
+ this.gauge.set(this.state.value);
+ }
+
+ shouldComponentUpdate(nextProps, nextState) {
+
+ // Check if size changed, resize labels if it did (the canvas itself is scaled with css)
+ if (this.props.widget.height !== nextProps.widget.height) {
+ this.updateAfterResize(nextProps.widget.height);
+ }
+
+ // signal component update only if the value changed
+ return this.state.value !== nextState.value;
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // update value
+ const simulator = nextProps.widget.simulator;
+
+ if (nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].values == null) {
+ this.setState({ value: 0 });
+ return;
+ }
+
+ // check if value has changed
+ const signal = nextProps.data[simulator].values[nextProps.widget.signal];
+ // Take just 3 decimal positions
+ // Note: Favor this method over Number.toFixed(n) in order to avoid a type conversion, since it returns a String
+ const new_value = Math.round( signal[signal.length - 1].y * 1e3 ) / 1e3;
+ if (this.state.value !== new_value) {
+ this.setState({ value: new_value });
+
+ // update gauge's value
+ this.gauge.set(new_value);
+ }
+ }
+
+ updateAfterResize(newHeight) {
+ // Update labels after resize
+ this.gauge.setOptions({ staticLabels: this.staticLabels(newHeight) });
+ }
+
+ render() {
+ var componentClass = this.props.editing ? "gauge-widget editing" : "gauge-widget";
+ var signalType = null;
+
+ if (this.props.simulation) {
+ var simulationModel = this.props.simulation.models.filter((model) => model.simulator === this.props.widget.simulator)[0];
+ signalType = simulationModel && simulationModel.length > 0? simulationModel.mapping[this.props.widget.signal].type : '';
+ }
+
+ return (
+
+
{ this.props.widget.name }
+
+ );
+ }
+}
+
+export default WidgetGauge;
diff --git a/src/components/widget-image.js b/src/components/widget-image.js
index c04a4a1..2bbba8c 100644
--- a/src/components/widget-image.js
+++ b/src/components/widget-image.js
@@ -2,44 +2,52 @@
* File: widget-image.js
* Author: Markus Grigull
* Date: 14.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
-const API_URL = 'http://localhost:4000/';
+import AppDispatcher from '../app-dispatcher';
+import config from '../config';
class WidgetImage extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- file: null
- };
- }
componentWillReceiveProps(nextProps) {
- // check if file is set
- if (nextProps.widget.file == null) {
- this.setState({ file: null });
- return;
- }
- // get file by id
- nextProps.files.forEach(file => {
- if (file._id === nextProps.widget.file) {
- this.setState({ file: file });
- }
- });
+ // Query the image referenced by the widget (public request, no token required)
+ let widgetFile = nextProps.widget.file;
+ if (widgetFile && !nextProps.files.find( file => file._id === widgetFile ) ) {
+
+ AppDispatcher.dispatch({
+ type: 'files/start-load',
+ data: widgetFile
+ });
+
+ }
}
render() {
+
+ let file = this.props.files.find( (file) => file._id === this.props.widget.file );
+
return (
-
- {this.state.file &&
-
+
+ {file &&
+ e.preventDefault() } />
}
);
diff --git a/src/components/widget-label.js b/src/components/widget-label.js
index 2c29650..5c81a84 100644
--- a/src/components/widget-label.js
+++ b/src/components/widget-label.js
@@ -2,17 +2,31 @@
* File: widget-label.js
* Author: Markus Grigull
* Date: 14.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
class WidgetLabel extends Component {
render() {
return (
-
{this.props.widget.name}
+
+
{this.props.widget.name}
+
);
}
}
diff --git a/src/components/widget-number-input.js b/src/components/widget-number-input.js
new file mode 100644
index 0000000..13061bb
--- /dev/null
+++ b/src/components/widget-number-input.js
@@ -0,0 +1,69 @@
+/**
+ * File: widget-number-input.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 29.03.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import { Form, FormGroup, Col, ControlLabel, FormControl } from 'react-bootstrap';
+
+class WidgetNumberInput extends Component {
+
+ static whichValidationStateIs( condition ) {
+ switch(condition) {
+ case 'ok': return null;
+ case 'error': return 'error';
+ default: return 'error';
+ }
+ }
+
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ value: '',
+ validationState: WidgetNumberInput.whichValidationStateIs('ok')
+ };
+ }
+
+ validateInput(e) {
+ if (e.target.value === '' || e.target.value.endsWith('.')) {
+ this.setState({
+ validationState: WidgetNumberInput.whichValidationStateIs('ok'),
+ value: e.target.value });
+ } else {
+ var num = Number(e.target.value);
+ if (Number.isNaN(num)) {
+ this.setState({ validationState: WidgetNumberInput.whichValidationStateIs('error'),
+ value: e.target.value });
+ } else {
+ this.setState({
+ validationState: WidgetNumberInput.whichValidationStateIs('ok'),
+ value: num });
+ }
+ }
+ }
+
+ render() {
+ return (
+
+
+
+ );
+ }
+}
+
+export default WidgetNumberInput;
\ No newline at end of file
diff --git a/src/components/widget-plot-table.js b/src/components/widget-plot-table.js
index 5305ff8..0507b3f 100644
--- a/src/components/widget-plot-table.js
+++ b/src/components/widget-plot-table.js
@@ -2,115 +2,156 @@
* File: widget-plot-table.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
-import { LineChart } from 'rd3';
+import classNames from 'classnames';
+import { FormGroup, Checkbox } from 'react-bootstrap';
-import { ButtonGroup, Button } from 'react-bootstrap';
+import Plot from './widget-plot/plot';
+import PlotLegend from './widget-plot/plot-legend';
class WidgetPlotTable extends Component {
constructor(props) {
super(props);
this.state = {
- size: { w: 0, h: 0 },
- signal: 0,
- firstTimestamp: 0,
- latestTimestamp: 0,
- sequence: null,
- rows: [],
- values: []
+ preselectedSignals: [],
+ signals: []
};
}
componentWillReceiveProps(nextProps) {
- // check data
+
+ // Update internal selected signals state with props (different array objects)
+ if (this.props.widget.signals !== nextProps.widget.signals) {
+ this.setState( {signals: nextProps.widget.signals});
+ }
+
+ // Identify if there was a change in the preselected signals
+ if (nextProps.simulation && (JSON.stringify(nextProps.widget.preselectedSignals) !== JSON.stringify(this.props.widget.preselectedSignals) || this.state.preselectedSignals.length === 0)) {
+
+ // Update the currently selected signals by intersecting with the preselected signals
+ // Do the same with the plot values
+ var intersection = this.computeIntersection(nextProps.widget.preselectedSignals, nextProps.widget.signals);
+ this.setState({ signals: intersection });
+
+ this.updatePreselectedSignalsState(nextProps);
+ return;
+ }
+
+ }
+
+ // Perform the intersection of the lists, alternatively could be done with Sets ensuring unique values
+ computeIntersection(preselectedSignals, selectedSignals) {
+ return preselectedSignals.filter( s => selectedSignals.includes(s));
+ }
+
+ updatePreselectedSignalsState(nextProps) {
const simulator = nextProps.widget.simulator;
- // plot size
- this.setState({ size: { w: this.props.widget.width - 100, h: this.props.widget.height - 20 }});
-
- if (nextProps.simulation == null || nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].length === 0 || nextProps.data[simulator].values[0].length === 0) {
- // clear values
- this.setState({ values: [], sequence: null, rows: [] });
- return;
- }
-
- // check if new data, otherwise skip
- if (this.state.sequence >= nextProps.data[simulator].sequence) {
- return;
- }
-
// get simulation model
const simulationModel = nextProps.simulation.models.find((model) => {
return (model.simulator === simulator);
});
- // get rows
- var rows = [];
+ let preselectedSignals = [];
+ // Proceed if a simulation model is available
+ if (simulationModel) {
+ // Create checkboxes using the signal indices from simulation model
+ preselectedSignals = simulationModel.mapping.reduce(
+ // Loop through simulation model signals
+ (accum, model_signal, signal_index) => {
+ // Append them if they belong to the current selected type
+ if (nextProps.widget.preselectedSignals.indexOf(signal_index) > -1) {
+ accum.push(
+ {
+ index: signal_index,
+ name: model_signal.name
+ }
+ )
+ }
+ return accum;
+ }, []);
+ }
+
+ this.setState({ preselectedSignals: preselectedSignals });
+ }
- simulationModel.mapping.forEach((signal) => {
- rows.push({ name: signal.name })
+ updateSignalSelection(signal_index, checked) {
+ // Update the selected signals and propagate to parent component
+ var new_widget = Object.assign({}, this.props.widget, {
+ signals: checked? this.state.signals.concat(signal_index) : this.state.signals.filter( (idx) => idx !== signal_index )
});
+ this.props.onWidgetChange(new_widget);
+ }
- // get timestamps
- var latestTimestamp = nextProps.data[simulator].values[0][nextProps.data[simulator].values[0].length - 1].x;
- var firstTimestamp = latestTimestamp - nextProps.widget.time * 1000;
- var firstIndex;
+ render() {
+ var checkBoxes = [];
- if (nextProps.data[simulator].values[0][0].x < firstTimestamp) {
- // find element index representing firstTimestamp
- firstIndex = nextProps.data[simulator].values[0].findIndex((value) => {
- return value.x >= firstTimestamp;
- });
- } else {
- firstIndex = 0;
- firstTimestamp = nextProps.data[simulator].values[0][0].x;
- latestTimestamp = firstTimestamp + nextProps.widget.time * 1000;
+ // Data passed to plot
+ let simulator = this.props.widget.simulator;
+ let simulatorData = this.props.data[simulator];
+
+ if (this.state.preselectedSignals && this.state.preselectedSignals.length > 0) {
+ // Create checkboxes using the signal indices from simulation model
+ checkBoxes = this.state.preselectedSignals.map( (signal) => {
+ var checked = this.state.signals.indexOf(signal.index) > -1;
+ var chkBxClasses = classNames({
+ 'btn': true,
+ 'btn-default': true,
+ 'active': checked
+ });
+ return this.updateSignalSelection(signal.index, e.target.checked) } > { signal.name }
+ });
}
- // copy all values for each signal in time region
- var values = [{
- values: nextProps.data[simulator].values[this.state.signal].slice(firstIndex, nextProps.data[simulator].values[this.state.signal].length - 1)
- }];
+ // Prepare an array with the signals to show in the legend
+ var legendSignals = this.state.preselectedSignals.reduce( (accum, signal, i) => {
+ if (this.state.signals.includes(signal.index)) {
+ accum.push({
+ index: signal.index,
+ name: signal.name
+ })
+ }
+ return accum;
+ }, []);
- this.setState({ values: values, firstTimestamp: firstTimestamp, latestTimestamp: latestTimestamp, sequence: nextProps.data[simulator].sequence, rows: rows });
- }
-
- render() {
- console.log("Signal: " + this.state.signal);
return (
-
);
diff --git a/src/components/widget-plot.js b/src/components/widget-plot.js
index 96de856..ff0b1b1 100644
--- a/src/components/widget-plot.js
+++ b/src/components/widget-plot.js
@@ -2,87 +2,62 @@
* File: widget-plot.js
* Author: Markus Grigull
* Date: 08.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
-import { LineChart } from 'rd3';
+
+import Plot from './widget-plot/plot';
+import PlotLegend from './widget-plot/plot-legend';
class WidgetPlot extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- values: [],
- firstTimestamp: 0,
- latestTimestamp: 0,
- sequence: null
- };
- }
-
- componentWillReceiveProps(nextProps) {
- // check data
- const simulator = nextProps.widget.simulator;
-
- if (nextProps.simulation == null || nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].length === 0 || nextProps.data[simulator].values[0].length === 0) {
- // clear values
- this.setState({ values: [], sequence: null });
- return;
- }
-
- // check if new data, otherwise skip
- if (this.state.sequence >= nextProps.data[simulator].sequence) {
- return;
- }
-
- // get timestamps
- var latestTimestamp = nextProps.data[simulator].values[0][nextProps.data[simulator].values[0].length - 1].x;
- var firstTimestamp = latestTimestamp - nextProps.widget.time * 1000;
- var firstIndex;
-
- if (nextProps.data[simulator].values[0][0].x < firstTimestamp) {
- // find element index representing firstTimestamp
- firstIndex = nextProps.data[simulator].values[0].findIndex((value) => {
- return value.x >= firstTimestamp;
- });
- } else {
- firstIndex = 0;
- firstTimestamp = nextProps.data[simulator].values[0][0].x;
- latestTimestamp = firstTimestamp + nextProps.widget.time * 1000;
- }
-
- // copy all values for each signal in time region
- var values = [];
-
- nextProps.widget.signals.forEach((signal) => {
- values.push({
- values: nextProps.data[simulator].values[signal].slice(firstIndex, nextProps.data[simulator].values[signal].length - 1)
- });
- });
-
- this.setState({ values: values, firstTimestamp: firstTimestamp, latestTimestamp: latestTimestamp, sequence: nextProps.data[simulator].sequence });
- }
render() {
- if (this.state.sequence == null) {
- return (
Empty
);
+
+ const simulator = this.props.widget.simulator;
+ const simulation = this.props.simulation;
+ let legendSignals = [];
+ let simulatorData = [];
+
+ // Proceed if a simulation with models and a simulator are available
+ if (simulator && simulation && simulation.models.length > 0) {
+
+ const model = simulation.models.find( (model) => model.simulator === simulator );
+ const chosenSignals = this.props.widget.signals;
+
+ simulatorData = this.props.data[simulator];
+
+ // Query the signals that will be displayed in the legend
+ legendSignals = model.mapping.reduce( (accum, model_signal, signal_index) => {
+ if (chosenSignals.includes(signal_index)) {
+ accum.push({ index: signal_index, name: model_signal.name });
+ }
+ return accum;
+ }, []);
}
return (
-
+ );
+ }
+
+}
+
+export default Plot;
\ No newline at end of file
diff --git a/src/components/widget-slider.js b/src/components/widget-slider.js
new file mode 100644
index 0000000..2ea720c
--- /dev/null
+++ b/src/components/widget-slider.js
@@ -0,0 +1,100 @@
+/**
+ * File: widget-slider.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 30.03.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+import React, { Component } from 'react';
+import classNames from 'classnames';
+import Slider from 'rc-slider';
+import 'rc-slider/assets/index.css';
+
+class WidgetSlider extends Component {
+
+ static get OrientationTypes() {
+ return ({
+ HORIZONTAL: {value: 0, name: 'Horizontal'},
+ VERTICAL: {value: 1, name: 'Vertical'}
+ })
+ }
+
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ value: 50
+ };
+ }
+
+ componentWillReceiveProps(nextProps) {
+ // Update value
+ if (nextProps.widget.value && this.state.value !== nextProps.widget.value) {
+ this.setState({ value: nextProps.widget.value })
+ }
+ // Check if the orientation changed, update the size if it did
+ if (this.props.widget.orientation !== nextProps.widget.orientation) {
+ let baseWidget = nextProps.widget;
+ // Exchange dimensions and constraints
+ let newWidget = Object.assign({}, baseWidget, {
+ width: baseWidget.height,
+ height: baseWidget.width,
+ minWidth: baseWidget.minHeight,
+ minHeight: baseWidget.minWidth,
+ maxWidth: baseWidget.maxHeight,
+ maxHeight: baseWidget.maxWidth
+ });
+ nextProps.onWidgetChange(newWidget);
+ }
+ }
+
+ valueIsChanging(newValue) {
+ this.setState({ value: newValue });
+ }
+
+ valueChanged(newValue) {
+ // Enable to propagate action
+ // let newWidget = Object.assign({}, this.props.widget, {
+ // value: newValue
+ // });
+ // this.props.onWidgetChange(newWidget);
+ }
+
+ render() {
+
+ let isVertical = this.props.widget.orientation === WidgetSlider.OrientationTypes.VERTICAL.value;
+
+ let fields = {
+ 'name': this.props.widget.name,
+ 'control': this.valueIsChanging(v) } onAfterChange={ (v) => this.valueChanged(v) }/>,
+ 'value': this.state.value
+ }
+
+ var widgetClasses = classNames({
+ 'slider-widget': true,
+ 'full': true,
+ 'vertical': isVertical,
+ 'horizontal': !isVertical
+ });
+
+ return (
+ this.props.widget.orientation === WidgetSlider.OrientationTypes.HORIZONTAL.value? (
+
+
+
{ fields.control }
+ { fields.value }
+
+ ) : (
+
+
+ { fields.control }
+ { fields.value }
+
+ )
+ );
+ }
+}
+
+export default WidgetSlider;
\ No newline at end of file
diff --git a/src/components/widget-table.js b/src/components/widget-table.js
index 071c084..9c48a00 100644
--- a/src/components/widget-table.js
+++ b/src/components/widget-table.js
@@ -2,10 +2,22 @@
* File: widget-table.js
* Author: Markus Grigull
* Date: 14.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
@@ -48,7 +60,7 @@ class WidgetTable extends Component {
nextProps.data[simulator].values.forEach((signal, index) => {
rows.push({
name: simulationModel.mapping[index].name,
- value: signal[signal.length - 1].y
+ value: signal[signal.length - 1].y.toFixed(3)
})
});
@@ -57,7 +69,7 @@ class WidgetTable extends Component {
render() {
return (
-
+
{this.props.widget.name}
diff --git a/src/components/widget-value.js b/src/components/widget-value.js
index c096695..eeceeed 100644
--- a/src/components/widget-value.js
+++ b/src/components/widget-value.js
@@ -2,10 +2,22 @@
* File: widget-value.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
@@ -35,9 +47,10 @@ class WidgetValue extends Component {
}
render() {
+ var value_to_render = Number(this.state.value);
return (
-
- {this.props.widget.name}: {this.state.value}
+
+ {this.props.widget.name}{ Number.isNaN(value_to_render)? NaN : value_to_render.toFixed(3) }
);
}
diff --git a/src/config.js b/src/config.js
new file mode 100644
index 0000000..4ade8ce
--- /dev/null
+++ b/src/config.js
@@ -0,0 +1,6 @@
+
+const config = {
+ publicPathBase: 'public/'
+}
+
+export default config
\ No newline at end of file
diff --git a/src/containers/app.js b/src/containers/app.js
index 61f4d16..2af248e 100644
--- a/src/containers/app.js
+++ b/src/containers/app.js
@@ -2,10 +2,22 @@
* File: app.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -64,9 +76,11 @@ class App extends Component {
}
}
+ let currentUser = UserStore.getState().currentUser;
+
return {
simulations: SimulationStore.getState(),
- currentUser: UserStore.getState().currentUser,
+ currentRole: currentUser? currentUser.role : '',
token: UserStore.getState().token,
runningSimulators: simulators
@@ -108,7 +122,7 @@ class App extends Component {
localStorage.setItem('token', '');
this.props.router.push('/login');
-
+
return;
}
@@ -171,10 +185,12 @@ class App extends Component {
-
-
- {children}
+
+
+
+ {children}
+
diff --git a/src/containers/home.js b/src/containers/home.js
index ae74541..22e6782 100644
--- a/src/containers/home.js
+++ b/src/containers/home.js
@@ -2,10 +2,22 @@
* File: home.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
diff --git a/src/containers/login.js b/src/containers/login.js
index 9453900..d568bc7 100644
--- a/src/containers/login.js
+++ b/src/containers/login.js
@@ -2,10 +2,22 @@
* File: login.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
diff --git a/src/containers/logout.js b/src/containers/logout.js
index 91dc617..5e246bb 100644
--- a/src/containers/logout.js
+++ b/src/containers/logout.js
@@ -2,10 +2,22 @@
* File: logout.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
diff --git a/src/containers/project.js b/src/containers/project.js
index 5ba98bd..33099a4 100644
--- a/src/containers/project.js
+++ b/src/containers/project.js
@@ -2,10 +2,22 @@
* File: project.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -29,7 +41,7 @@ class Visualizations extends Component {
let currentProjects = ProjectStore.getState();
let currentVisualizations = VisualizationStore.getState();
-
+
if (prevState) {
var projectUpdate = prevState.project;
@@ -62,7 +74,7 @@ class Visualizations extends Component {
if (initialProject && (!currentVisualizations || currentVisualizations.length === 0)) {
Visualizations.loadVisualizations(initialProject.visualizations);
}
-
+
return {
projects: currentProjects,
visualizations: currentVisualizations,
@@ -136,7 +148,7 @@ class Visualizations extends Component {
// get visualizations for this project
var visualizations = [];
if (this.state.visualizations && this.state.project.visualizations) {
- visualizations = this.state.visualizations.filter(
+ visualizations = this.state.visualizations.filter(
(visualization) => this.state.project.visualizations.includes(visualization._id)
).sort(
(visA, visB) => visA.name.localeCompare(visB.name)
@@ -144,7 +156,7 @@ class Visualizations extends Component {
}
return (
-
+
{this.state.project.name}
diff --git a/src/containers/projects.js b/src/containers/projects.js
index 4e6a4b6..6dd97b8 100644
--- a/src/containers/projects.js
+++ b/src/containers/projects.js
@@ -2,10 +2,22 @@
* File: projects.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -90,7 +102,7 @@ class Projects extends Component {
render() {
return (
-
+
Projects
diff --git a/src/containers/simulation.js b/src/containers/simulation.js
index b6f6c97..59e37c5 100644
--- a/src/containers/simulation.js
+++ b/src/containers/simulation.js
@@ -2,10 +2,22 @@
* File: simulation.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -119,7 +131,7 @@ class Simulation extends Component {
render() {
return (
-
+
{this.state.simulation.name}
diff --git a/src/containers/simulations.js b/src/containers/simulations.js
index dd80a71..5c445d0 100644
--- a/src/containers/simulations.js
+++ b/src/containers/simulations.js
@@ -2,10 +2,22 @@
* File: simulations.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -100,7 +112,7 @@ class Simulations extends Component {
render() {
return (
-
+
Simulations
diff --git a/src/containers/simulators.js b/src/containers/simulators.js
index a913f73..e9a2af8 100644
--- a/src/containers/simulators.js
+++ b/src/containers/simulators.js
@@ -2,10 +2,22 @@
* File: simulators.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
@@ -84,7 +96,7 @@ class Simulators extends Component {
render() {
return (
-
+
Simulators
diff --git a/src/containers/users.js b/src/containers/users.js
new file mode 100644
index 0000000..288c4f4
--- /dev/null
+++ b/src/containers/users.js
@@ -0,0 +1,141 @@
+/**
+ * File: users.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 02.05.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
+
+import React, { Component } from 'react';
+import { Container } from 'flux/utils';
+import { Button, Modal, Glyphicon } from 'react-bootstrap';
+
+import AppDispatcher from '../app-dispatcher';
+import UserStore from '../stores/user-store';
+import UsersStore from '../stores/users-store';
+
+import Table from '../components/table';
+import TableColumn from '../components/table-column';
+import NewUserDialog from '../components/dialog/new-user';
+import EditUserDialog from '../components/dialog/edit-user';
+
+class Users extends Component {
+ static getStores() {
+ return [ UserStore, UsersStore ];
+ }
+
+ static calculateState(prevState, props) {
+
+ let tokenState = UserStore.getState().token;
+
+ // If there is a token available and this method was called as a result of loading users
+ if (!prevState && tokenState) {
+ AppDispatcher.dispatch({
+ type: 'users/start-load',
+ token: tokenState
+ });
+ }
+
+ return {
+ token: tokenState,
+ users: UsersStore.getState(),
+
+ newModal: false,
+ editModal: false,
+ deleteModal: false,
+ modalData: {}
+ };
+ }
+
+ closeNewModal(data) {
+ this.setState({ newModal: false });
+
+ if (data) {
+ AppDispatcher.dispatch({
+ type: 'users/start-add',
+ data: data,
+ token: this.state.token
+ });
+ }
+ }
+
+ confirmDeleteModal() {
+ this.setState({ deleteModal: false });
+
+ AppDispatcher.dispatch({
+ type: 'users/start-remove',
+ data: this.state.modalData,
+ token: this.state.token
+ });
+ }
+
+ closeEditModal(data) {
+ this.setState({ editModal: false });
+
+ if (data) {
+ AppDispatcher.dispatch({
+ type: 'users/start-edit',
+ data: data,
+ token: this.state.token
+ });
+ }
+ }
+
+ getHumanRoleName(role_key) {
+ const HUMAN_ROLE_NAMES = {admin: 'Administrator', user: 'User', guest: 'Guest'};
+
+ return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : '';
+ }
+
+ render() {
+
+ return (
+
);
diff --git a/src/containers/widget.js b/src/containers/widget.js
index 7aa540f..18e3d12 100644
--- a/src/containers/widget.js
+++ b/src/containers/widget.js
@@ -2,17 +2,31 @@
* File: widget.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Container } from 'flux/utils';
import { ContextMenuTrigger } from 'react-contextmenu';
import Rnd from 'react-rnd';
+import classNames from 'classnames';
import AppDispatcher from '../app-dispatcher';
+import UserStore from '../stores/user-store';
import SimulatorDataStore from '../stores/simulator-data-store';
import FileStore from '../stores/file-store';
@@ -22,17 +36,26 @@ import WidgetTable from '../components/widget-table';
import WidgetLabel from '../components/widget-label';
import WidgetPlotTable from '../components/widget-plot-table';
import WidgetImage from '../components/widget-image';
+import WidgetButton from '../components/widget-button';
+import WidgetNumberInput from '../components/widget-number-input';
+import WidgetSlider from '../components/widget-slider';
+import WidgetGauge from '../components/widget-gauge';
+import WidgetBox from '../components/widget-box';
import '../styles/widgets.css';
class Widget extends Component {
static getStores() {
- return [ SimulatorDataStore, FileStore ];
+ return [ SimulatorDataStore, FileStore, UserStore ];
}
static calculateState(prevState) {
+
+ let tokenState = UserStore.getState().token;
+
if (prevState) {
return {
+ sessionToken: tokenState,
simulatorData: SimulatorDataStore.getState(),
files: FileStore.getState(),
@@ -40,6 +63,7 @@ class Widget extends Component {
}
} else {
return {
+ sessionToken: tokenState,
simulatorData: SimulatorDataStore.getState(),
files: FileStore.getState(),
@@ -54,11 +78,15 @@ class Widget extends Component {
// Reference to the context menu element
this.contextMenuTriggerViaDraggable = null;
}
-
+
componentWillMount() {
- AppDispatcher.dispatch({
- type: 'files/start-load'
- });
+ // If loading for the first time
+ if (this.state.sessionToken) {
+ AppDispatcher.dispatch({
+ type: 'files/start-load',
+ token: this.state.sessionToken
+ });
+ }
}
dragStop(event, ui) {
@@ -72,7 +100,7 @@ class Widget extends Component {
resizeStop(direction, styleSize, clientSize, delta) {
// update widget
- var widget = this.props.data;
+ let widget = Object.assign({}, this.props.data);
// resize depends on direction
if (direction === 'left' || direction === 'topLeft' || direction === 'bottomLeft') {
@@ -100,8 +128,8 @@ class Widget extends Component {
}
render() {
-
-
+
+
//console.log('render widget ' + this.props.data.z + this.props.data.type);
@@ -113,6 +141,7 @@ class Widget extends Component {
// get widget element
const widget = this.props.data;
+ var borderedWidget = false;
var element = null;
// dummy is passed to widgets to keep updating them while in edit mode
@@ -120,16 +149,35 @@ class Widget extends Component {
element =
} else if (widget.type === 'Plot') {
element =
+ borderedWidget = true;
} else if (widget.type === 'Table') {
element =
} else if (widget.type === 'Label') {
element =
+ borderedWidget = true;
} else if (widget.type === 'PlotTable') {
- element =
+ element = this.props.onWidgetStatusChange(w, this.props.index) } />
+ borderedWidget = true;
} else if (widget.type === 'Image') {
element =
+ } else if (widget.type === 'Button') {
+ element =
+ } else if (widget.type === 'NumberInput') {
+ element =
+ } else if (widget.type === 'Slider') {
+ element = this.props.onWidgetStatusChange(w, this.props.index) } />
+ } else if (widget.type === 'Gauge') {
+ element =
+ } else if (widget.type === 'Box') {
+ element =
}
+ let widgetClasses = classNames({
+ 'widget': !this.props.editing,
+ 'editing-widget': this.props.editing,
+ 'border': borderedWidget
+ });
+
if (this.props.editing) {
return (
this.borderWasClicked(event) }
onResizeStop={(direction, styleSize, clientSize, delta) => this.resizeStop(direction, styleSize, clientSize, delta)}
onDragStop={(event, ui) => this.dragStop(event, ui)}
@@ -153,7 +202,7 @@ class Widget extends Component {
);
} else {
return (
-
+
{element}
);
diff --git a/src/data-managers/files-data-manager.js b/src/data-managers/files-data-manager.js
index 385c778..f5edb37 100644
--- a/src/data-managers/files-data-manager.js
+++ b/src/data-managers/files-data-manager.js
@@ -2,10 +2,22 @@
* File: files-data-manager.js
* Author: Markus Grigull
* Date: 16.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
import RestAPI from '../api/rest-api';
@@ -16,13 +28,16 @@ class FilesDataManager extends RestDataManager {
super('file', '/files');
}
- upload(file) {
- RestAPI.upload(this.makeURL('/upload'), file).then(response => {
+ upload(file, token = null) {
+ RestAPI.upload(this.makeURL('/upload'), file, token).then(response => {
AppDispatcher.dispatch({
type: 'files/uploaded'
});
-
- console.log(response);
+ // Trigger a files reload
+ AppDispatcher.dispatch({
+ type: 'files/start-load',
+ token: token
+ });
}).catch(error => {
AppDispatcher.dispatch({
type: 'files/upload-error',
diff --git a/src/data-managers/notifications-data-manager.js b/src/data-managers/notifications-data-manager.js
index b5798bb..f463fcd 100644
--- a/src/data-managers/notifications-data-manager.js
+++ b/src/data-managers/notifications-data-manager.js
@@ -2,10 +2,22 @@
* File: notifications-data-manager.js
* Author: Markus Grigull
* Date: 21.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
class NotificationsDataManager {
_notificationSystem = null;
diff --git a/src/data-managers/notifications-factory.js b/src/data-managers/notifications-factory.js
new file mode 100644
index 0000000..56c095c
--- /dev/null
+++ b/src/data-managers/notifications-factory.js
@@ -0,0 +1,24 @@
+/**
+ * File: notifications-factory.js
+ * Description: An unique source of pre-defined notifications that are displayed
+ * throughout the application.
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 13.04.2017
+ * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
+ * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ **********************************************************************************/
+
+class NotificationsFactory {
+
+ static get NO_SIM_MODEL_AVAILABLE() {
+ return {
+ title: 'No simulation model available',
+ message: 'Consider defining a simulation model in the simulators section.',
+ level: 'warning'
+ };
+ }
+
+}
+
+export default NotificationsFactory;
\ No newline at end of file
diff --git a/src/data-managers/projects-data-manager.js b/src/data-managers/projects-data-manager.js
index a85801d..e1b8167 100644
--- a/src/data-managers/projects-data-manager.js
+++ b/src/data-managers/projects-data-manager.js
@@ -2,10 +2,22 @@
* File: projects-data-manager.js
* Author: Markus Grigull
* Date: 07.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
diff --git a/src/data-managers/rest-data-manager.js b/src/data-managers/rest-data-manager.js
index 0d5508e..6ebe72d 100644
--- a/src/data-managers/rest-data-manager.js
+++ b/src/data-managers/rest-data-manager.js
@@ -2,15 +2,26 @@
* File: rest-data-manager.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestAPI from '../api/rest-api';
import AppDispatcher from '../app-dispatcher';
-const backend = process.env.REACT_APP_BACKEND || 'ghvillas.westeurope.cloudapp.azure.com:4000'
-const API_URL = 'http://' + backend + '/api/v1';
+const API_URL = '/api/v1';
class RestDataManager {
constructor(type, url, keyFilter) {
@@ -39,10 +50,10 @@ class RestDataManager {
return object;
}
- load(id) {
+ load(id, token = null) {
if (id != null) {
// load single object
- RestAPI.get(this.makeURL(this.url + '/' + id)).then(response => {
+ RestAPI.get(this.makeURL(this.url + '/' + id), token).then(response => {
const data = this.filterKeys(response[this.type]);
AppDispatcher.dispatch({
@@ -57,7 +68,7 @@ class RestDataManager {
});
} else {
// load all objects
- RestAPI.get(this.makeURL(this.url)).then(response => {
+ RestAPI.get(this.makeURL(this.url), token).then(response => {
const data = response[this.type + 's'].map(element => {
return this.filterKeys(element);
});
@@ -75,11 +86,11 @@ class RestDataManager {
}
}
- add(object) {
+ add(object, token = null) {
var obj = {};
obj[this.type] = this.filterKeys(object);
- RestAPI.post(this.makeURL(this.url), obj).then(response => {
+ RestAPI.post(this.makeURL(this.url), obj, token).then(response => {
AppDispatcher.dispatch({
type: this.type + 's/added',
data: response[this.type]
@@ -92,8 +103,8 @@ class RestDataManager {
});
}
- remove(object) {
- RestAPI.delete(this.makeURL(this.url + '/' + object._id)).then(response => {
+ remove(object, token = null) {
+ RestAPI.delete(this.makeURL(this.url + '/' + object._id), token).then(response => {
AppDispatcher.dispatch({
type: this.type + 's/removed',
data: response[this.type],
@@ -107,11 +118,11 @@ class RestDataManager {
});
}
- update(object) {
+ update(object, token = null) {
var obj = {};
obj[this.type] = this.filterKeys(object);
- RestAPI.put(this.makeURL(this.url + '/' + object._id), obj).then(response => {
+ RestAPI.put(this.makeURL(this.url + '/' + object._id), obj, token).then(response => {
AppDispatcher.dispatch({
type: this.type + 's/edited',
data: response[this.type]
diff --git a/src/data-managers/simulations-data-manager.js b/src/data-managers/simulations-data-manager.js
index d5a606e..d5756cb 100644
--- a/src/data-managers/simulations-data-manager.js
+++ b/src/data-managers/simulations-data-manager.js
@@ -2,10 +2,22 @@
* File: simulation-data-manager.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
diff --git a/src/data-managers/simulator-data-data-manager.js b/src/data-managers/simulator-data-data-manager.js
index 57dc126..22f443b 100644
--- a/src/data-managers/simulator-data-data-manager.js
+++ b/src/data-managers/simulator-data-data-manager.js
@@ -2,10 +2,22 @@
* File: simulator-data-data-manager.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import WebsocketAPI from '../api/websocket-api';
import AppDispatcher from '../app-dispatcher';
@@ -78,23 +90,20 @@ class SimulatorDataDataManager {
// parse incoming message into usable data
var data = new DataView(blob);
- let OFFSET_ENDIAN = 1;
let OFFSET_TYPE = 2;
let OFFSET_VERSION = 4;
var bits = data.getUint8(0);
- var endian = (bits >> OFFSET_ENDIAN) & 0x1 ? 0 : 1;
- var length = data.getUint16(0x02, endian);
+ var length = data.getUint16(0x02, 1);
var values = new Float32Array(data.buffer, data.byteOffset + 0x10, length);
return {
- endian: endian,
version: (bits >> OFFSET_VERSION) & 0xF,
type: (bits >> OFFSET_TYPE) & 0x3,
length: length,
- sequence: data.getUint32(0x04, endian),
- timestamp: data.getUint32(0x08, endian) * 1e3 + data.getUint32(0x0C, endian) * 1e-6,
+ sequence: data.getUint32(0x04, 1),
+ timestamp: data.getUint32(0x08, 1) * 1e3 + data.getUint32(0x0C, 1) * 1e-6,
values: values
};
}
diff --git a/src/data-managers/simulators-data-manager.js b/src/data-managers/simulators-data-manager.js
index f9c2c97..535f1e2 100644
--- a/src/data-managers/simulators-data-manager.js
+++ b/src/data-managers/simulators-data-manager.js
@@ -2,10 +2,22 @@
* File: simulators-data-manager.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
import RestAPI from '../api/rest-api';
@@ -14,20 +26,26 @@ import AppDispatcher from '../app-dispatcher';
function isRunning(simulator) {
// get path to nodes.json and simulator name
var path = simulator.endpoint.substring(0, simulator.endpoint.lastIndexOf('/'));
- path += '/nodes.json';
-
var name = simulator.endpoint.substring(simulator.endpoint.lastIndexOf('/') + 1);
+ var url = 'http://' + path + '/api/v1';
+ var body = {
+ action: 'nodes',
+ id: '1234' /// @todo use random generated id
+ };
+
// send request
- RestAPI.get('http://' + path).then(response => {
+ RestAPI.post(url, body).then(response => {
// check if simulator is running
simulator.running = false;
- response.forEach(sim => {
- if (sim.name === name) {
- simulator.running = true;
- }
- });
+ if (response.id === body.id) {
+ response.response.forEach(sim => {
+ if (sim.name === name) {
+ simulator.running = true;
+ }
+ });
+ }
AppDispatcher.dispatch({
type: 'simulators/running',
diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js
index 7ba1723..f5db8f8 100644
--- a/src/data-managers/users-data-manager.js
+++ b/src/data-managers/users-data-manager.js
@@ -2,10 +2,22 @@
* File: users-data-manager.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
import RestAPI from '../api/rest-api';
@@ -34,7 +46,7 @@ class UsersDataManager extends RestDataManager {
RestAPI.get(this.makeURL('/users/me'), token).then(response => {
AppDispatcher.dispatch({
type: 'users/current-user',
- user: response
+ user: response.user
});
}).catch(error => {
AppDispatcher.dispatch({
@@ -43,6 +55,7 @@ class UsersDataManager extends RestDataManager {
});
});
}
+
}
export default new UsersDataManager();
diff --git a/src/data-managers/visualizations-data-manager.js b/src/data-managers/visualizations-data-manager.js
index 10210bc..b141880 100644
--- a/src/data-managers/visualizations-data-manager.js
+++ b/src/data-managers/visualizations-data-manager.js
@@ -2,10 +2,22 @@
* File: visualizations-data-manager.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import RestDataManager from './rest-data-manager';
diff --git a/src/index.js b/src/index.js
index c7cccd4..a853c12 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,10 +2,22 @@
* File: index.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React from 'react';
import ReactDOM from 'react-dom';
diff --git a/src/router.js b/src/router.js
index aff704e..85bbe78 100644
--- a/src/router.js
+++ b/src/router.js
@@ -2,10 +2,22 @@
* File: router.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import React, { Component } from 'react';
import { Router, Route, hashHistory } from 'react-router';
@@ -18,6 +30,7 @@ import Simulators from './containers/simulators';
import Visualization from './containers/visualization';
import Simulations from './containers/simulations';
import Simulation from './containers/simulation';
+import Users from './containers/users';
import Login from './containers/login';
import Logout from './containers/logout';
@@ -38,6 +51,8 @@ class Root extends Component {
+
+
diff --git a/src/stores/array-store.js b/src/stores/array-store.js
index 20c006b..ccd9689 100644
--- a/src/stores/array-store.js
+++ b/src/stores/array-store.js
@@ -2,10 +2,22 @@
* File: array-store.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import { ReduceStore } from 'flux/utils';
@@ -57,10 +69,10 @@ class ArrayStore extends ReduceStore {
case this.type + '/start-load':
if (Array.isArray(action.data)) {
action.data.forEach((id) => {
- this.dataManager.load(id);
+ this.dataManager.load(id, action.token);
});
} else {
- this.dataManager.load(action.data);
+ this.dataManager.load(action.data, action.token);
}
return state;
@@ -76,7 +88,7 @@ class ArrayStore extends ReduceStore {
return state;
case this.type + '/start-add':
- this.dataManager.add(action.data);
+ this.dataManager.add(action.data, action.token);
return state;
case this.type + '/added':
@@ -87,7 +99,7 @@ class ArrayStore extends ReduceStore {
return state;
case this.type + '/start-remove':
- this.dataManager.remove(action.data);
+ this.dataManager.remove(action.data, action.token);
return state;
case this.type + '/removed':
@@ -100,7 +112,7 @@ class ArrayStore extends ReduceStore {
return state;
case this.type + '/start-edit':
- this.dataManager.update(action.data);
+ this.dataManager.update(action.data, action.token);
return state;
case this.type + '/edited':
diff --git a/src/stores/file-store.js b/src/stores/file-store.js
index 57bf1c9..09266dd 100644
--- a/src/stores/file-store.js
+++ b/src/stores/file-store.js
@@ -2,10 +2,22 @@
* File: file-store.js
* Author: Markus Grigull
* Date: 16.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import ArrayStore from './array-store';
import FilesDataManager from '../data-managers/files-data-manager';
@@ -18,7 +30,7 @@ class FileStore extends ArrayStore {
reduce(state, action) {
switch (action.type) {
case 'files/start-upload':
- FilesDataManager.upload(action.data);
+ FilesDataManager.upload(action.data, action.token);
return state;
case 'files/uploaded':
diff --git a/src/stores/project-store.js b/src/stores/project-store.js
index 405820f..0df9380 100644
--- a/src/stores/project-store.js
+++ b/src/stores/project-store.js
@@ -2,10 +2,22 @@
* File: project-store.js
* Author: Markus Grigull
* Date: 07.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import ArrayStore from './array-store';
import ProjectsDataManager from '../data-managers/projects-data-manager';
diff --git a/src/stores/simulation-store.js b/src/stores/simulation-store.js
index 89854f5..87f4676 100644
--- a/src/stores/simulation-store.js
+++ b/src/stores/simulation-store.js
@@ -2,10 +2,22 @@
* File: simulation-store.js
* Author: Markus Grigull
* Date: 04.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import ArrayStore from './array-store';
import SimulationsDataManager from '../data-managers/simulations-data-manager';
diff --git a/src/stores/simulator-data-store.js b/src/stores/simulator-data-store.js
index 741c339..d52ac1d 100644
--- a/src/stores/simulator-data-store.js
+++ b/src/stores/simulator-data-store.js
@@ -2,10 +2,22 @@
* File: simulator-data-store.js
* Author: Markus Grigull
* Date: 03.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import { ReduceStore } from 'flux/utils';
diff --git a/src/stores/simulator-store.js b/src/stores/simulator-store.js
index 9f430ef..4f8d6bd 100644
--- a/src/stores/simulator-store.js
+++ b/src/stores/simulator-store.js
@@ -2,10 +2,22 @@
* File: villas-store.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import ArrayStore from './array-store';
import SimulatorsDataManager from '../data-managers/simulators-data-manager';
@@ -28,7 +40,7 @@ class SimulatorStore extends ArrayStore {
case 'simulators/removed':
SimulatorsDataManager.stopRunningDetection(action.original);
-
+
return super.reduce(state, action);
case 'simulators/start-edit':
@@ -40,7 +52,7 @@ class SimulatorStore extends ArrayStore {
case 'simulators/edited':
// The update was done, resume the 'runningDetection'
SimulatorsDataManager.startRunningDetection(action.data);
-
+
return super.reduce(state, action);
case 'simulators/loaded':
diff --git a/src/stores/user-store.js b/src/stores/user-store.js
index c3467d2..0c3a70a 100644
--- a/src/stores/user-store.js
+++ b/src/stores/user-store.js
@@ -2,10 +2,22 @@
* File: user-store.js
* Author: Markus Grigull
* Date: 15.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import { ReduceStore } from 'flux/utils';
@@ -55,13 +67,19 @@ class UserStore extends ReduceStore {
return Object.assign({}, state, { currentUser: null, token: null });
case 'users/login-error':
- // server offline
- NotificationsDataManager.addNotification({
- title: 'Server offline',
- message: 'The server is offline. Please try again later.',
- level: 'error'
- });
- return state;
+
+ if (action.error && !action.error.handled) {
+ // If it was an error and hasn't been handled, the credentials must have been wrong.
+ const WRONG_CREDENTIALS_NOTIFICATION = {
+ title: 'Incorrect credentials',
+ message: 'Please modify and try again.',
+ level: 'error'
+ }
+ NotificationsDataManager.addNotification(WRONG_CREDENTIALS_NOTIFICATION);
+
+ }
+
+ return state;
default:
return state;
diff --git a/src/stores/users-store.js b/src/stores/users-store.js
new file mode 100644
index 0000000..e42b1ed
--- /dev/null
+++ b/src/stores/users-store.js
@@ -0,0 +1,67 @@
+/**
+ * File: users-store.js
+ * Author: Markus Grigull
+ * Date: 15.03.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
+
+import ArrayStore from './array-store';
+import UsersDataManager from '../data-managers/users-data-manager';
+import NotificationsDataManager from '../data-managers/notifications-data-manager';
+
+class UsersStore extends ArrayStore {
+ constructor() {
+ super('users', UsersDataManager);
+ }
+
+ reduce(state, action) {
+ switch (action.type) {
+
+ case this.type + '/add-error':
+ if (action.error && !action.error.handled && action.error.response) {
+ // If it was an error and hasn't been handled, user could not be added
+ const USER_ADD_ERROR_NOTIFICATION = {
+ title: 'Failed to add new user',
+ message: action.error.response.body.message,
+ level: 'error'
+ }
+ NotificationsDataManager.addNotification(USER_ADD_ERROR_NOTIFICATION);
+
+ }
+ return super.reduce(state, action);
+
+ case this.type + '/edit-error':
+ if (action.error && !action.error.handled && action.error.response) {
+ // If it was an error and hasn't been handled, user couldn't not be updated
+ const USER_EDIT_ERROR_NOTIFICATION = {
+ title: 'Failed to edit user',
+ message: action.error.response.body.message,
+ level: 'error'
+ }
+ NotificationsDataManager.addNotification(USER_EDIT_ERROR_NOTIFICATION);
+
+ }
+ return super.reduce(state, action);
+
+ default:
+ return super.reduce(state, action);
+ }
+ }
+
+}
+
+export default new UsersStore();
diff --git a/src/stores/villas-store.js b/src/stores/villas-store.js
index 3fc05bf..b553101 100644
--- a/src/stores/villas-store.js
+++ b/src/stores/villas-store.js
@@ -2,10 +2,22 @@
* File: villas-store.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import { ReduceStore } from 'flux/utils';
diff --git a/src/stores/visualization-store.js b/src/stores/visualization-store.js
index 5b5c83f..ba69682 100644
--- a/src/stores/visualization-store.js
+++ b/src/stores/visualization-store.js
@@ -2,10 +2,22 @@
* File: visualization-store.js
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
import ArrayStore from './array-store';
import VisualizationsDataManager from '../data-managers/visualizations-data-manager';
diff --git a/src/styles/app.css b/src/styles/app.css
index f1972a0..33b3280 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -2,10 +2,22 @@
* File: app.css
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
/**
* Application container
@@ -29,7 +41,6 @@ body {
.app-header {
width: 100%;
height: 60px;
-
padding: 10px 0 0 0;
color: #527984;
@@ -38,7 +49,6 @@ body {
.app-header h1 {
width: 100%;
-
margin: 0;
text-align: center;
@@ -47,8 +57,8 @@ body {
.app-footer {
width: 100%;
height: 60px;
- position: absolute;
- bottom: 0px;
+ /* Float below body */
+ float: right;
padding-top: 20px;
text-align: center;
@@ -56,15 +66,24 @@ body {
clear: both;
}
-.app-content {
- position: absolute;
- bottom: 0px;
- top: 60px;
- right: 0px;
- left: 200px;
- min-height: 400px;
+.app-body {
+ /* Let sidebar grow and content occupy rest of the space */
+ display: flex;
+ float: right;
+ width: 100%;
+ /* Fit between header and footer */
+ min-height: calc(100vh - 140px);
- margin: 20px 20px 60px 20px;
+ padding: 15px 5px 0px 5px;
+}
+
+.app-body > div {
+ margin-left: 7px;
+ margin-right: 7px;
+}
+
+.app-content {
+ flex: 1 1 auto;
padding: 15px 20px;
background-color: #fff;
@@ -76,11 +95,7 @@ body {
* Menus
*/
.menu-sidebar {
- float: left;
-
- width: 160px;
-
- margin: 20px 0 0 20px;
+ display: inline-table;
padding: 20px 25px 20px 25px;
background-color: #fff;
@@ -90,6 +105,11 @@ body {
.menu-sidebar a {
color: #4d4d4d;
+ text-decoration:none;
+}
+
+.menu-sidebar a:hover, .menu-sidebar a:focus {
+ text-decoration:none;
}
.active {
@@ -98,10 +118,21 @@ body {
.menu-sidebar ul {
padding-top: 10px;
-
list-style: none;
+ white-space: nowrap;
}
+.menu-sidebar a::after {
+ /* Trick to make menu items to be as wide as in bold */
+ display:block;
+ content:attr(title);
+ font-weight:bold;
+ height:1px;
+ color:transparent;
+ overflow:hidden;
+ visibility:hidden;
+ margin-bottom:-1px;
+}
/**
* Login form
*/
@@ -207,7 +238,8 @@ body {
}
.section {
- height: 100%;
+ min-height: 100%;
+ width: 100%;
}
.section-header div {
@@ -236,4 +268,4 @@ body {
.section-header .glyphicon {
font-size: 0.8em;
-}
\ No newline at end of file
+}
diff --git a/src/styles/index.css b/src/styles/index.css
index 830576d..dde0352 100644
--- a/src/styles/index.css
+++ b/src/styles/index.css
@@ -1,3 +1,24 @@
+/**
+ * File: index.css
+ * Author: Markus Grigull
+ * Date: 17.03.2017
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
+
* {
margin: 0;
padding: 0;
diff --git a/src/styles/widgets.css b/src/styles/widgets.css
index c6a9c91..7e72ad0 100644
--- a/src/styles/widgets.css
+++ b/src/styles/widgets.css
@@ -2,20 +2,45 @@
* File: widgets.css
* Author: Markus Grigull
* Date: 02.03.2017
- * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
- * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
- **********************************************************************************/
+ *
+ * This file is part of VILLASweb.
+ *
+ * VILLASweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * VILLASweb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VILLASweb. If not, see .
+ ******************************************************************************/
.widget {
- border: 1px solid lightgray;
- padding: 3px 6px;
- background-color: #fff;
+ background-color: #fff;
+ overflow: auto;
+}
+
+.border {
+ border: 1px solid lightgray;
}
.editing-widget {
- border: 1px solid lightgray;
- background-color: #fff;
+ background-color: #fff;
+}
+
+/* Firefox-specific rules */
+@-moz-document url-prefix() {
+ .editing-widget:not(.border):hover {
+ outline-offset: -10px;
+ }
+}
+
+.editing-widget:not(.border):hover {
+ outline: 1px solid lightgray;
}
/* Area to trigger the context menu */
@@ -25,7 +50,7 @@
position: absolute;
top: 0px;
left: 0px;
- padding: 3px 6px;
+ overflow: auto;
}
.react-contextmenu {
@@ -96,21 +121,15 @@
right: 7px;
}
-.plot-table-widget .content {
- display: -webkit-flex;
- display: flex;
-}
-
-.plot-table-widget .widget-table {
- min-width: 100px;
- display: flex;
- flex-direction: column;
- justify-content: center;
-}
-
/* Reset Bootstrap styles to "disable" while editing */
-.plot-table-widget .widget-table .btn[disabled] {
+div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input[disabled], .form-control[disabled], .checkbox.disabled label {
cursor: inherit;
+ pointer-events: none;
+}
+
+.editing-widget .btn-default.active {
+ background-color: #abcfd8;
+ border-color: #ccc;
}
.btn-default[disabled]:hover {
@@ -123,8 +142,334 @@
border-color: #adadad;
}
/* End reset */
-
+
+ /* Match Bootstrap's them to VILLAS */
+.widget .btn-default.active {
+ background-color: #abcfd8;
+}
+
+.widget .btn-default.active:hover, .widget .btn-default.active:hover {
+ background-color: #89b3bd;
+}
+
+.widget .btn-default:hover {
+ background-color: #abcfd8;
+}
+/* End match */
+
+/* Begin edit menu: Colors */
+.color-control input[type="radio"] {
+ display: none;
+}
+
+.color-control .radio-inline.checked {
+ border-color: #000 !important;
+}
+
+.color-control .radio-inline {
+ height: 24px;
+ flex: 1 1 auto;
+ border: 2px solid;
+ /* Reset bootstrap padding */
+ padding-left: 0px;
+}
+
+.color-control .radio-inline + .radio-inline {
+ /* Reset bootstrap margin */
+ margin-left: 0px;
+}
+
+.color-control .radio-inline:hover {
+ border-color: #444 !important;
+}
+
+.color-control div[class*="colors-column-"] {
+ display: flex;
+ padding: 2px 20px;
+}
+
+/* End edit menu: Colors */
+
+/* PlotTable widget */
+.plot-table-widget, .plot-widget, .value-widget, .image-widget, .label-widget {
+ width: 100%;
+ height: 100%;
+ padding: 3px 6px;
+}
+
+.plot-table-widget {
+ display: -webkit-flex;
+ display: flex;
+ flex-direction: column;
+}
+
+.plot-table-widget .content {
+ -webkit-flex: 1 0 auto;
+ flex: 1 0 auto;
+ display: -webkit-flex;
+ display: flex;
+ flex-direction: column;
+}
+
+.table-plot-row {
+ -webkit-flex: 1 0 auto;
+ flex: 1 0 auto;
+ display: -webkit-flex;
+ display: flex;
+}
+
+.plot-table-widget .widget-table {
+ -webkit-flex: 1 0 auto;
+ flex: 1 0 auto;
+ flex-basis: 90px;
+ max-width: 50%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+}
+
+.plot-table-widget small {
+ text-align: center;
+}
+
+.plot-table-widget .checkbox label {
+ height: 100%;
+ width: 100%;
+ padding: 6px 12px;
+ overflow-x: hidden;
+}
+
+.plot-table-widget .btn {
+ padding: 0px;
+}
+
+.plot-table-widget input[type="checkbox"] {
+ display: none;
+}
+/* End PlotTable Widget */
+
+/* Plot Widget */
+.plot-widget {
+ display: -webkit-flex;
+ display: flex;
+ flex-direction: column;
+}
+/* End Plot Widget */
+
+/* Plots */
+/* The plot container, in order to avoid 100% height/width */
+.widget-plot {
+ display: flex;
+ -webkit-flex: 1 1 auto;
+ flex: 1 1 auto;
+}
+
+.chart-wrapper {
+ width: 100%;
+ padding-left: 10px;
+}
+
+.plot-legend {
+ display: -webkit-flex;
+ display: flex;
+ flex-basis: 20px; /* Enough to allocate one row */
+ max-height: 40px; /* Allocate up to two rows */
+ flex-shrink: 0;
+ flex-wrap: wrap;
+ justify-content: space-around;
+ margin-bottom: 5px;
+}
+
+.signal-legend {
+ font-size: 0.8em;
+ font-weight: 700;
+ padding-left: 5px;
+ padding-right: 5px;
+ overflow: hidden;
+}
+
+.legend-color {
+ height: 50%;
+ display: inline-block;
+ vertical-align: middle;
+}
+
+/* End Plots */
+
+.single-value-widget {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.single-value-widget > * {
+ width: 50%;
+ float: left;
+ margin: 5px;
+ font-size: 1vw;
+}
+
+/* Button widget styling */
+.button-widget button {
+ border-radius: 25px;
+ border-style: double;
+ border-width: 4px;
+ overflow-x: hidden;
+ font-weight: 500;
+ font-size: 1.2em;
+}
+
+.button-widget button:hover {
+ border-style: double;
+}
+/* End button widget styling */
+
+.full {
+ width: 100%;
+ height: 100%;
+}
+
+/* Number input widget */
+div[class*="-widget"] label {
+ cursor: inherit;
+}
+
+.number-input-widget {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+}
+
+.number-input-widget .form-horizontal .form-group {
+ margin: 0px;
+}
+/* End number input widget */
+
+/* Begin Slider widget */
+.slider-widget {
+ display: flex;
+ align-items: center;
+ justify-content: space-around;
+}
+
+.slider-widget label {
+ flex: 0 0 auto;
+ text-align: center;
+}
+
+.slider-widget span {
+ text-align: center;
+ font-size: 1.5em;
+ font-weight: 600;
+}
+
+.slider-widget.horizontal .slider {
+ flex: 1 1 auto;
+}
+
+.slider-widget.horizontal span {
+ flex: 0 0 50pt;
+}
+
+.slider-widget.horizontal label {
+ padding-right: 10px;
+}
+
+.slider-widget.vertical {
+ flex-direction: column;
+}
+
+.slider-widget.vertical span {
+ padding-top: 10px;
+}
+
+.slider-widget.vertical label {
+ padding-bottom: 10px;
+}
+
+/* Begin Slider customization */
+.rc-slider-track {
+ background-color: #6EA2B0;
+}
+
+.rc-slider-handle, .rc-slider-handle:hover {
+ border-color: #6EA2B0;
+}
+
+.rc-slider-disabled {
+ background-color: inherit;
+}
+
+.rc-slider-disabled .rc-slider-handle {
+ cursor: inherit;
+}
+
+.rc-slider-disabled .rc-slider-handle:hover {
+ border-color:#ccc;
+}
+/* End Slider customization */
+
+/* End slider widget */
+
+/* Gauge widget */
+.gauge-widget {
+ width: 100%;
+ height: 100%;
+}
+
+.gauge-widget canvas {
+ width: 100%;
+ height: 87%;
+}
+
+.gauge-name {
+ height: 10%;
+ width: 100%;
+ text-align: center;
+ font-weight: bold;
+}
+
+.gauge-unit {
+ position: absolute;
+ width: 100%;
+ font-size: 1.0em;
+ bottom: 25%;
+ text-align: center;
+}
+
+.gauge-value {
+ position: absolute;
+ width: 100%;
+ font-weight: bold;
+ font-size: 1.5em;
+ bottom: 10%;
+ text-align: center;
+}
+/* End gauge widget */
+
+/* Begin label widget */
+.label-widget {
+ text-align: center;
+}
+/* End label widget */
+
+/* Begin table widget */
+.table-widget td, .table-widget th {
+ text-align: center;
+}
+/* End table widget*/
+
+/* Begin box widget */
+.box-widget .border {
+ width: 100%;
+ height: 100%;
+ border: 2px solid;
+}
+/* End box widget */
+
.plot-table-widget .widget-plot {
-webkit-flex: 1 0 auto;
flex: 1 0 auto;
-}
\ No newline at end of file
+}