Commit Graph

2825 Commits

Author SHA1 Message Date
Pascal Precht 64d8fa3368
feat(core/processManager): introduce `processes:stop` handlers
So far, `ProcessManager` was able to only register a `process:launch` handler.
There was no way to tell `ProcessManager` how to stop processes. This hasn't
been a problem so far as most of the service processes can be started without the usage
of the `ProcessManager`, but turns out to be necessary if we want Embark UI to be able
to pick up running services.

A good example is the webserver process, which until now bypasses the `ProcessManager`
all together. The webserver sets up two event handlers to start and stop it respectively:

```
this.events.setCommandHandler('start-webserver', () => this.server.start());
this.events.setCommandHandler('stop-webserver', () => this.server.stop());
```

In the future, this should happen through the `ProcessManager` instead, so the webserver
process can be picked up by Embark UI, like this:

```
this.request('process:register', 'webserver', () => {
  this.server.start();
});

// and then

this.request('process:launch', 'webserver', () => {
  // server started
});
```

Notice that the given callback to registering a process is actually the function that
gets called to launch the process.

Having that in mind, and considering that we also need a way to stop the process through
`ProcessManager, so we don't introduce a regression, we need a way to register a stop
call back as well.

The new API introduced in this commit looks like this:

```
this.request('process:register', 'webserver', {
  launchFn: (callback) => { this.server.start(callback) },
  stopFn: (callback) => this.server.stop(callback) }
});

// and then

this.request('process:launch', 'webserver', (err, message, port) => {
  // server started
});

this.request('process:stop', 'webserver', err => {
  // server stopped
});
```

Notice that `process:register` works exactly the same way as before as well.

Another thing to notice is that all parameters emitted by the underlying process
are propagated to the outside caller, which is why `err`, `message` and `port` are
available inside the launch callback.
2018-10-23 10:57:05 +02:00
Anthony Laibe de009db74f
Use process log ids 2018-10-23 10:57:05 +02:00
emizzle 46511bcfe8
Rebase updates
After the code was rebased, there were some additional changes for getting websockets logs that needed to be catered for.

When there is a call to get all logs for a process, the state entity is updated with a new array item containing all the logs (this is then reduced and selected for rendering). In the case of a websocket log that simply returns only one log item, the latest full log for the process is found in the state entities, and it’s logs are appending to with the data from the websocket.

Additionally, log limits were updated to be passed in as a parameter to the API calls from the frontend. Parameter validation (for `limit`) was also added in this commit.
2018-10-23 10:57:04 +02:00
emizzle d4d7e3b8ac
Addressed PR comments
*Console.js*
- Moved `DEFAULT_PROCESS` const to outside of the `Console` class (but inside the module).
- Removed `(` and `)` from `.filter` in `getProcessLogs()`.
- Updated comments

*logger.js*
- Moved `dateFormat` and `logRegex` to constants outside of `Logger` class
- Moved the `parseLogFile` method inside of the `Logger` class (ES6 style)
- Added a log limit to the `parseLogFile` method
- Added the log path to the constants file and used inside of `Logger`

*cmd_controller.js*
- Defaulted `this.context` to `[constants.context.any]` in the constructor.
- Changed `’embark’` to split modules`coreProcess` and `loggerApi`.

*engine.js*
- Changed `’embark’` to split modules`coreProcess` and `loggerApi`.
2018-10-23 10:57:04 +02:00
emizzle 0760965bda
Overwrite log file so .embark doesn’t bloat
The embark log file is being overwritten each time embark is run. There is a separate log file for each context, so that running, for example, `embark run` then `embark console` doesn’t get the `run` log overwritten with the `console` log.
2018-10-23 10:54:35 +02:00
emizzle 7de72cb474
Addressed PR feedback
- Created an “embark” module so that an “embark” process could be registered in the correct way. This service is only used on `embark run` (can be extended to other commands if needed).

- extracted “embark” to a const `DEFAULT_PROCESS` param in the `Console` component.

- extracted commands result rendering to it’s own function to keep the `renderTabs` function from getting cluttered

- Added sorting of logs by timestamp

- Added milliseconds to the log file data (which helps in sorting log messages).
2018-10-23 10:53:25 +02:00
emizzle 42cc9b559f
Fills embark logs tabs with existing embark logs
A logfile is now generated by default, in the format `.embark/embark-log__YYYY-MM-DD_HH-mm-ss.log`.

When the home tab is loaded, the process logs are fetched for all the processes. The list of processes returned now includes `embark`, and when `/embark-api/process-logs/embark` is fetched, the logFile is parsed and an array of log messages are returned.
2018-10-23 10:52:26 +02:00
Anthony Laibe 41eb23df82
Adding file contracts 2018-10-23 10:51:24 +02:00
Pascal Precht de901b73fc
chore(modules/storage): make process launcher callback optional
We aren't always interested in calling a function after the storage
process has been launched, so passing a callback should be optional.
2018-10-23 10:50:41 +02:00
Anthony Laibe 41176f0f70
Add id to process logs 2018-10-23 10:50:41 +02:00
emizzle aa4bc0fe4d
Fix for logs showing a string as an array
Some strings were being logged as
```
[w,r,i,t,i,n,g, ,f,i,l,e, ,,[,2,m,,[,1,m,.,e,m,b,a,r,k,/,s,t,a,t,s,.,r,e,p,o,r,t,,[,2,2,m,,[,2,2,m]
```
The fix was applied to the `normalizeInput` method which simply returns if the input was a `typeof` string.
2018-10-23 10:50:40 +02:00
Anthony Laibe 5967aa3dc5
Initial version of deployment manager 2018-10-23 10:50:39 +02:00
emizzle 72a796c11b
Moved `fileTreeSort()` to `utils` 2018-10-23 10:50:39 +02:00
emizzle 35a701fb90
Addressed PR comments
Updated comments in `FileExplorer.js`

Moved `isFolder()`, `isNotFolder()`, and `byName()` outside of `fileTreeSort()` in `lib/pipeline/pipeline.js`.
2018-10-23 10:50:39 +02:00
emizzle f3431eecbd
File editor tree improvements
Sort files and folders by type, then by name

Hide hidden files/folders (starting with “.”) - WIP
2018-10-23 10:50:39 +02:00
Anthony Laibe 0e4248cca8
Stop and limit fetch process logs 2018-10-23 10:50:38 +02:00
Iuri Matias fd2e979f06
remove unneded console logs 2018-10-23 10:50:37 +02:00
Richard Ramos 2c0644b5cb
Changed scaffolding to service 2018-10-23 10:50:37 +02:00
Richard Ramos e5e8d21765
Installing react packages automatically 2018-10-23 10:50:04 +02:00
Richard Ramos deb9c9a838
Changed state handling on template and engine initialization 2018-10-23 10:50:03 +02:00
Richard Ramos d3961783b4
Changing promises to async and created consts 2018-10-23 10:50:03 +02:00
Richard Ramos b93d2d1145
Error handling, added overwrite, fixed duplication of components 2018-10-23 10:50:03 +02:00
Jonathan Rainville 13160e622f
fix ALL of the spaces 2018-10-23 10:50:02 +02:00
Jonathan Rainville 211321a914
fix event 2018-10-23 10:48:36 +02:00
Jonathan Rainville 328d9c7c07
remove blockcing if 2018-10-23 10:48:36 +02:00
Andre Medeiros 31476cf2b8
Address feedback 2018-10-23 10:48:36 +02:00
Richard Ramos c8d357e601
Fix scaffolding command logic so it works with Embark 3.2.2 2018-10-23 10:48:36 +02:00
Jonathan Rainville 844e2ed5b0
add back tokens 2018-10-23 10:48:36 +02:00
Jonathan Rainville 58ce56684d
fix double startng the server 2018-10-23 10:48:35 +02:00
Jonathan Rainville 324e148fa6
resolve conflict in api and saga 2018-10-23 10:48:35 +02:00
Jonathan Rainville feea4c27fc
log message after connecting in case of disconnect 2018-10-23 10:47:26 +02:00
Andre Medeiros 3b45128f20
Fix the way messages are appended in logs 2018-10-23 10:47:25 +02:00
Andre Medeiros 1f7e434632
Pass logger to webserver 2018-10-23 10:47:25 +02:00
Anthony Laibe 572cd20482
Fix backend tab request cached:
- Add no cache via helmet
- Fix linting (no-return-else)
- Rebase Fix: Use option.name for process log to avoid endpoint being called
blockchainProcess.js
- Rebase Fix: use option when compiling solidity
2018-10-23 10:47:24 +02:00
emizzle 25297027c8
Moved ‘authenticator’ module startup to console service 2018-10-23 10:45:51 +02:00
Anthony Laibe feb59655cc
Fix race condition 2018-10-23 10:45:51 +02:00
Anthony Laibe 0e87d21b12
Pass plugin as options 2018-10-23 10:44:14 +02:00
Anthony Laibe b4054a01fa
Remove duplicate declaration 2018-10-23 10:44:14 +02:00
Anthony Laibe 00c6b0029d
Fix start without webserver 2018-10-23 10:44:14 +02:00
emizzle 199aa18c07
Fix solidity compilation
Issues introduced in rebase.
2018-10-23 10:44:14 +02:00
Iuri Matias b12856fe2d
rebase fixes 2018-10-23 10:44:14 +02:00
Iuri Matias 2843303d8c
rebase fixes 2018-10-23 10:44:13 +02:00
Anthony Laibe 2fb5d907ec
Add ability to logout 2018-10-23 10:42:00 +02:00
Jonathan Rainville ae3185d96f
rename event 2018-10-23 10:42:00 +02:00
Jonathan Rainville 749853be32
use port and host from config 2018-10-23 10:42:00 +02:00
Jonathan Rainville 3495f9fbb8
authorize each request through header 2018-10-23 10:41:59 +02:00
Jonathan Rainville 6125329cae
show authorize form when auth error 2018-10-23 10:41:23 +02:00
Jonathan Rainville e68feb81af
add console command to get token 2018-10-23 10:41:23 +02:00
Jonathan Rainville faf09b7d39
use local cache to store the token 2018-10-23 10:41:23 +02:00
Jonathan Rainville 422a98e172
add basic authentication 2018-10-23 10:41:22 +02:00
Jonathan Rainville b196a54a30
fix linting 2018-10-23 10:41:22 +02:00
Jonathan Rainville 7fa186b636
fix avergae not calculated correctly 2018-10-23 10:41:20 +02:00
Anthony Laibe 592ce4773c
Deploy contract 2018-10-23 10:41:20 +02:00
Anthony Laibe a08690ef43
File Editor 2018-10-23 10:41:20 +02:00
Jonathan Rainville d3c5407441
remove old transactions to lighten the memory 2018-10-23 10:40:13 +02:00
Jonathan Rainville 5690c2e054
conflict in saga 2018-10-23 10:40:13 +02:00
Jonathan Rainville 9d262e6a25
watch oracle changes 2018-10-23 10:40:13 +02:00
Jonathan Rainville 198b3c5cc1
conflicts in reducer and saga 2018-10-23 10:39:57 +02:00
Jonathan Rainville dd0ae5023d
fix ws ping and add wait calculation 2018-10-23 10:39:57 +02:00
Jonathan Rainville 3a6ed745f6
add transactionTracker to track transactions and their time 2018-10-23 10:38:13 +02:00
Jonathan Rainville 8ff13b09f1
add gasPrice to transactions for contracts 2018-10-23 10:38:12 +02:00
Anthony Laibe b945b87d4d
File explorer 2018-10-23 10:38:11 +02:00
Anthony Laibe e31f4778ac
Handle string 2018-10-23 10:37:28 +02:00
Anthony Laibe e4fd9ab3ba
All command available in backend tab console 2018-10-23 10:37:28 +02:00
Anthony Laibe eb86bd7fbf
Fix profile command (rebase issue) 2018-10-23 10:37:28 +02:00
Anthony Laibe c453a85dde
Add back console command 2018-10-23 10:37:28 +02:00
emizzle ae029a5959
Small fixes
Fixed issue with contract deploying for first time and having no gasLimit specified.

Optimised/refactored looping of compiled contracts.

Added body parameter type checking for `/embark-api/contract/deploy` endpoint
2018-10-23 10:37:01 +02:00
emizzle 859d78eb41
Remove lodash 2018-10-23 10:37:00 +02:00
emizzle 05b324dffe
Fiddle use cases fixed
Handle use cases:

1) handle case when temp.sol doesn’t exist - due to the new saga updates, the response from retreiving a temp fiddle from the filesystem (even if it doesn’t exist) is forward to the compilation endpoint, which returns an ENOENT, and this is handled in the selector.
2) delete all code - shouldn’t return last fiddle and should compile an empty string.
3) Switch to different tab (ie contracts) then back to fiddle - previous fiddle should remain.

Also fixed an issue (most likely due to latest rebase) when deploying fiddle contracts. The gasLimit was not being specified.

Handled issue where entities stored in the state were not being put in the correct order, so a timestamp was sent with the requests and then sorted when the response was returned.
2018-10-23 10:37:00 +02:00
Anthony Laibe 4ecb092ed3
Remove last fiddle, and use code to compile 2018-10-23 10:37:00 +02:00
emizzle cd176a5f95
Handle use cases that were failing
1) hanlde case when temp.sol doesn’t exist
2) delete all code - shouldn’t return last fiddle
3) Switch to different tab (ie contracts) then back to fiddle - fiddle should now remain.
2018-10-23 10:37:00 +02:00
emizzle 68957f5dc8
change registerAPICall to hang off embark 2018-10-23 10:36:59 +02:00
emizzle b8b98cd6c4
Remove ‘async’ from function name and remove comments 2018-10-23 10:36:59 +02:00
emizzle cba4e9fb91
Fiddle file stored in filesystem
Fiddles are now stored in the filesystem so they can be preserved across page reloads, but also so that contracts deployed via fiddles can have their source code shown.

Fiddles deployed as contracts now fully work with existing contract list UI and functionality. Fiddle deployed contracts are listed in a separate section in the UI.

Current limitation is that only single contracts per file are supported. If the fiddle contains multiple contracts, it’s currently not supported.
2018-10-23 10:36:59 +02:00
emizzle 59d3a3be83
Fiddle deploy integration
Fiddle is properly deploying now, except the source code needs to be saved to the filesystem in order to be recalled later.

Fixes for handling errors on deploy and compilation.

Update contract state UI for determining state / interface / deployed.
2018-10-23 10:36:58 +02:00
emizzle 609d4eb762
Fix Tabler browser errors
Fixed browser errors caused by tabler (bodyItems and headerItems complaints) as well as staticContext issues caused by using withRoute(NavLink)

Also added a response to fiddler deployment.

Added loading states to fiddler results, that shows the errors/warnings as having a loading state when compiling/deploying
2018-10-23 10:36:58 +02:00
emizzle bf46b91166
concat deployed fiddle contracts with existing contracts 2018-10-23 10:36:57 +02:00
emizzle fec740ad6f
Initial commit for deployment of fiddle
API call set up for contract deploy which deploys the contract(s) sent from the fiddle.

Frontend UI button calls API to deploy the fiddle code.
2018-10-23 10:36:57 +02:00
emizzle 2800e347de
add contract class for assisted construction
# Conflicts:
#	package-lock.json
2018-10-23 10:36:57 +02:00
Jonathan Rainville c844338c8a
add back return all errors 2018-10-23 10:36:57 +02:00
Jonathan Rainville 56d541fb8d
fix most rebase issues 2018-10-23 10:36:57 +02:00
Iuri Matias 5c5715d480
rebase fixes 2018-10-23 10:34:46 +02:00
Iuri Matias 7532562e28
rebase fixes 2018-10-23 10:34:46 +02:00
Anthony Laibe d9ae5cbfc7
PR feedback: Use request 2018-10-23 10:34:18 +02:00
Anthony Laibe 6038da4339
Deploy contract 2018-10-23 10:34:18 +02:00
Anthony Laibe 870efbcf20
Show result 2018-10-23 10:34:18 +02:00
Anthony Laibe 3c9cea594c
Make call successfully 2018-10-23 10:34:17 +02:00
Anthony Laibe c234a850e3
Call Function API 2018-10-23 10:34:17 +02:00
Anthony Laibe 788db99a0e
Display error + lint 2018-10-23 10:34:02 +02:00
Anthony Laibe 2fd52c2be3
Client fixes 2018-10-23 10:33:41 +02:00
Anthony Laibe f569767788
Lookup/Resolver between EmbarkJS and Embark 2018-10-23 10:33:40 +02:00
Anthony Laibe 83d6130259
Add plugins and versions to backend tab 2018-10-23 10:32:02 +02:00
emizzle 23a1cf57c2
Removed the contract compile event
(really did it this time)
2018-10-23 10:31:36 +02:00
emizzle 6f8f9a14d9
Addressed PR comments
Changed `fiddle` to an entity and removed unneeded fiddle reducer.

Added a selector for getting the entity.

Changed fiddle saga to `doRequest`.

Changed fiddle api call to the `post` method (did not see beofre the rebase).

Added `CompilerError` presentation component to handle displaying compiler errors and warnings.

Added spaces to css (as requested).

Removed extra space after function in solidity compiler (as requested).

Removed the compile contract event from the solidity compiler (as requested).

Handling of fatal api error in the UI.

Changed fiddle action to the one created with `createRequestTypes`.

Moved `Fiddle` nav tab before `Documentation`.

Changed `FiddleResults` DOM manipulation to be controlled via React state instead.
2018-10-23 10:31:36 +02:00
emizzle 8caa478968
Annotations, click to error, UI improvements
Compiler annotations added to editor gutter for errors and warnings

Clicking an error now scrolls editor to offending line and scrolls page to the top of the editor

Added Compiling… loader.
2018-10-23 10:31:35 +02:00
emizzle 70f5a09d47
Fiddle now showing compilation warnings and errors 2018-10-23 10:31:35 +02:00
Anthony Laibe 52cec0a29e
Display compilation result 2018-10-23 10:31:35 +02:00
emizzle 1d13c71d83
Code compilation API working, but not updating state 2018-10-23 10:31:34 +02:00
emizzle ddcccb3c2d
Initial compile API and Fiddle container/pres components 2018-10-23 10:31:34 +02:00
Jonathan Rainville aaa5a6fd58
put as one line 2018-10-23 10:31:33 +02:00