GithubHelp home page GithubHelp logo

pegasus8 / piworker Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 2.85 MB

Let your Raspberry Pi work for you.

License: GNU General Public License v3.0

Go 78.05% HTML 0.21% JavaScript 6.78% Vue 11.71% Shell 3.24%
automation golang privacy raspberry-pi vuejs

piworker's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar pegasus8 avatar

piworker's Issues

Change on configs 's model

To delete:

To modify:

API usage from the WebUI

When displaying existing tasks created by the user (in the Management view) it is necessary to use two APIs (at least):

  • One that obtains the information of the elements (triggers and actions)
  • Another that obtains user data

The difference between the two is the next: the API that grants the information of the elements has only that, information, which is used to guide the user in the creation of the tasks (among other things), while the API that returns the data of the user only provides the data. Both are complementary to each other, since you cannot display loose parameters on the WebUI, because the user would not understand where each one comes from.

What is needed: fetch the data of the API that provides the info at the start of the WebUI, and when needed fetch the data of the API that provides the user data.

REST API of logs

Must provide logs of: tasks (of each separately) and global logs.

Related with #2.

Communicate the stats loop with the active websockets

Must be by using a channel. This channel whould be instantiated on main() and sended as an arg to the server and the loop of statistics.
Usage: the statistics loop will be responsible of sent the statistics by the channel to the websockets active connections.

Usage of only one user data variable

For less usage and better management of resources.
Current situation: the user data file is readed multiple times by different functions. Maybe this does not consume much resources but is not the best choice.
What I want: only one variable what contains the user data and use this variable on all the functions by using pointers. How to update the data of this variable? Easy, on the loop of the engine.

Https support check

Before start the server, it's needed check if the files server.key and server.crt exists (theorically are generated on the install script's execution). If the files are found, then start it using TLS.

Better representation of types

Right now, the way that PiWorker manages the types of chained results is a bit inconsitent. The package reflect does not fit to much with the needed types to manage the content.

As global solution the best I can do is make a package with the content of all the posible types (like I already do it with uservariables package).

Improvements on elements development

Right now is a mess: a lot of local variables, redundant code everywhere, etc.

Improvements highly needed:

  • Sintetize code, the repeated code (like args parsing) must be on one function and used from there on the required places.
  • Prevent the usage of variables outside of the definition of each element (like IDs), to keep more ordenated the package.

I think that probably the best solution for creation of new elements is using a python script or something like that, which would prevent typo errors or things of that kind.

Layout problem on WebUI - Management view

Inconsistency between the columns "Args" and "Logs". Both should have the same size, and in the case of logs, must have a scroll.
Can be solved inside the PR #29 but isn't a priority for now.

Var CurrentConfigs null

When the configs file already exists, the content of it must be readed and placed into the CurrentConfigs variable.
For some reason, when the method ReadFromFile() is executed, the content of the file is readed correctly, but not saved into the CurrentConfigs var. The value of this variable remain null.
As I see, the bug is on the method itself.

Dynamic Engine

Description

Dynamic processing engine. It's the responsible for executing tasks and actions of the most optimal way.

To-do list

  • Data reading on every round of loop. Reason: keep working with fresh data. Can be optimized but isn't a priority
  • Usage of pointers for lowest usage of memory possible (carefully)
  • Execution queue: when a task is on process of execution (triggered) keep it on a queue, out of the rest of active tasks for prevention of multiple execution. Change the state when the task starts the execution and when the execution ends (usage of on-execution state).
  • Actions execution on another goroutine
  • Chained actions (tasks) (#12)
  • Ignore tasks with the state completed, inactive and on-execution

Reorganization of WebUI directory

Instead of have the backend inside the ./webui/ directory, it must be inside a new folder called backend. The new directory would be: ./webui/backend/*.
To-do before merge of p.r. #29

Bad implementation of trigger "Variation of a File's Size"

The issue is if there are multiple tasks using the same trigger, due to that allways the trigger is using the same variable as reference (previousFileSize), it will be constantly activated. Obviusly, the problem here is these shared variable which has no sense.

How to solve the issue?

I think the best way to do this is saving the last size of the objective file on a file (with the name of the task which is running it), and once the file is created, on every check only read the content of the file with the previous size, if the numbers variate, the trigger is activated and the content of the file updated.

Conflict with task state after execution

After task execution, the state of that task returns to the original so that never will have a different state because if an action changes the state it will be overwritten at the end.

Repeated execution of actions when trigger condition's active

The mistake here is the continous execution of an action while the condition of the trigger in question continues on the same satate. For example, if a task has as the trigger ByDate the actions will be executed over and over until the day changes.

Chained actions

An action can give arguments to the next action.

  • Type of the arguments returned: ?
  • How to communicate between actions: by using channels

Fusion of "By Date" and "By Hour" triggers

There is no reason for having both. Must be only one trigger where the date and the hour will be chosen directly.
Additionally must have a prevention of past dates selection.

Files permissions

Check if the files generated by PiWorker have the correct permissions.

Fix UserData struct

Bad implementation:

UserData{
   []UserTasks{
      UserTasks{
         UserTask{}
      }
   }
}

This works fine but is very ugly and have no sense.

Trigger implementation: EveryXTime

Not implemented by default (#15) due to conflicts with the way the triggers are executed. It will be implemented in the future but it is not a priority.

Handle syscall.SIGINT and syscall.SIGTERM

Right now PiWorker only stops when it's forced to do it, which is not correct. The best way to do it is handling the signals syscall.SIGINT and syscall.SIGTERM provided by the system to shutdown correctly.

A good project to understand and learn how to manage this is AGHome.

Related with issue #42.

Args cloned (WebUI)

For some reason when the user is selecting args for one action, on the new task dialog, this args are cloned on posterior actions (of the same type).
I think that this problem is because both objects are referencing to the same space on memory.

Development of Triggers

Triggers's list

  • By hour
  • By date
  • Raspberry's temperature
  • Every x time
  • Variation of a file's size
  • New file on a directory

Usage of packr

Packr can be used to compile the VueJS and index.html files and summarize all to only one executable file.

Users's password change

This is needed because the password itself is not stored, instead is stored the hash. So, if the user lost it, there is no way to recover it.
The best way to do this is by using flags.

WebUI

To-do list

  • Design
  • Visual development
    • General development
    • Compatibility
      • Add normalize.css
      • Add modernizr.js
      • Bootstrap
  • Live statistics
    • WebSocket
    • Web elements update
    • Animations on update
  • Login (#3)
  • General animations

Service must be generated by PiWorker itself

The PiWorker.service file must be generated and placed (on /etc/systemd/system/) from the executable itself.
Maybe can add a flag like the next one: PiWorker --service install. Another adjacent flags can be:

  • PiWorker --service delete
  • PiWorker --service start
  • PiWorker --service stop

With this we will have the advantage of being able to execute the installation from the installation script itself (after download of resources and dependencies, of course).

Related with P.R. #41.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.