Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- s/components/component - Load the driver name from package.json - Use local npm-installed gulp instead of global - Generate CSS and assets - Update readme with more detail on usage
- Loading branch information
Showing
9 changed files
with
215 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
# ui-custom-driver-composer | ||
A small utility to build custom UI for custom drivers added to the Rancher UI project | ||
# ui-driver-skel | ||
Skeleton Rancher UI driver for custom docker-machine drivers | ||
|
||
## Setup | ||
|
||
## Installation | ||
|
||
* `git clone` this repository | ||
* Fork this repository into your own account as `ui-driver-DRIVERNAME` | ||
* DRIVERNAME should be the name of the driver that you would give to `docker-machine create --driver`, e.g. "mycompany", "digitalocean", "vultr", etc. | ||
* Update the "name" in package.json to match | ||
* You should also update description, URLs, etc, but these aren't strictly required. | ||
* `npm install` | ||
* `bower install` | ||
|
||
## Running/Development | ||
|
||
When developing an addon you may run the following command. Use the generated script as your custom UI script when adding a custom driver. This will allow you to develop locally. | ||
* `gulp server` | ||
* Visit your app at http://localhost:3000. | ||
## Development | ||
|
||
This package contains a small web-server that will serve up the custom driver UI at `https://localhost:3000/component.js`. You can run this while developing and point the Rancher settings there. | ||
* `npm start` | ||
* The driver name can be optionally overridden: `npm start -- --name=DRIVERNAME` | ||
* The compiled files are viewable at http://localhost:3000. | ||
* **Note:** The development server does not currently automatically restart when files are changed. | ||
|
||
## Building | ||
|
||
The script that is generated from the following command will be your custom UI component. Please read the comments in `components/component.js` for notes while working in the component. The script will be placed into the `dist` directory. | ||
* `gulp build --name '<driver-name>'` | ||
* `driver-name` should just be the dasherized name of your driver component and match the name you gave when saving a custom driver in Rancher UI. | ||
For other users to see your driver, you need to build it and host the output on a server accessible from their browsers. GitHub releases are an easy choice. | ||
|
||
* `npm build` | ||
* Copy the contents of `dist` onto a webserver. If your Rancher is configured to use HA or SSL, the server must also be available via HTTPS. | ||
|
||
## Using | ||
|
||
* Add a Machine Driver in Rancher (Admin tab -> Settings -> Machine Drivers) | ||
* Name: Your `DRIVERNAME` (see above). | ||
* Download URL: The URL for the driver binary (e.g. `https://github.com/mycompany/docker-machine-mycompany/releases/download/v1.0.0/docker-machine-driver-mycompany-v1.0.0-linux-amd64.tar.gz`) | ||
* Custom UI URL: The URL you uploaded the `dist` folder to, e.g. `https://github.com/mycompany/ui-driver-mycompany/releases/download/v1.0.0/component.js`) | ||
* Wait for the driver to become "Active" | ||
* Go to Infrastructure -> Hosts -> Add Host, your driver and custom UI should show up. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.machine-driver.%%DRIVERNAME%% { | ||
background-image: url('example.svg'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* v----- Do not change anything between here | ||
* (the DRIVERNAME placeholder will be automatically replaced during build) */ | ||
define('ui/components/drivers/driver-%%DRIVERNAME%%/component', ['exports', 'ember', 'ui/mixins/driver'], function (exports, _ember, _uiMixinsDriver) { | ||
|
||
exports['default'] = _ember['default'].Component.extend(_uiMixinsDriver['default'], { | ||
driverName: 'driver-%%DRIVERNAME%%', | ||
/* ^--- And here */ | ||
|
||
// Write your component here, starting with setting 'model' to a machine with your config populated | ||
bootstrap: function() { | ||
let config = this.get('store').createRecord({ | ||
type : '%%DRIVERNAME%%Config', | ||
size : 512, | ||
}); | ||
|
||
this.set('model', this.get('store').createRecord({ | ||
type: 'machine', | ||
'%%DRIVERNAME%%Config': config, | ||
})); | ||
}.on('init'), | ||
|
||
// Add custom validation beyond what can be done from the config API schema | ||
validate() { | ||
// Get generic API validation errors | ||
this._super(); | ||
var errors = this.get('errors')||[]; | ||
|
||
// Add more specific errors | ||
|
||
// Check something and add an error entry if it fails: | ||
if ( parseInt(this.get('model.%%DRIVERNAME%%Config.size'),10) < 1024 ) | ||
{ | ||
errors.push('Size must be at least 1024 MB'); | ||
} | ||
|
||
// Set the array of errors for display, | ||
// and return true if saving should continue. | ||
if ( errors.get('length') ) | ||
{ | ||
this.set('errors', errors); | ||
return false; | ||
} | ||
else | ||
{ | ||
this.set('errors', null); | ||
return true; | ||
} | ||
}, | ||
|
||
// Any computed properties or custom logic can go here | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<section class="horizontal-form"> | ||
<div class="container-fluid"> | ||
{{!-- This partial contains the quantity, name, and description fields --}} | ||
{{partial "host/add-common"}} | ||
|
||
<div class="over-hr r-mt20 r-mb20"> | ||
<span>My Skeleton Driver</span> | ||
</div> | ||
|
||
{{!-- An example input option --}} | ||
<div class="row"> | ||
<div class="col-sm-12 col-md-2 form-label"> | ||
<label class="form-control-static">Size</label> | ||
</div> | ||
<div class="col-sm-12 col-md-4"> | ||
<div class="input-group"> | ||
{{input type="text" | ||
class="form-control" | ||
value=model.%%DRIVERNAME%%Config.size | ||
}} | ||
<span class="input-group-addon">MB</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{!-- This partial contains the Labels and Advanced Options fields --}} | ||
{{partial "host/add-options"}} | ||
</div> | ||
|
||
{{!-- This component shows errors produced by validate() in the component --}} | ||
{{top-errors errors=errors}} | ||
|
||
{{!-- This component shows the Create and Cancel buttons --}} | ||
{{save-cancel save="save" cancel="cancel"}} | ||
</section> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters