forked from rancher/ui-driver-skel
-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from westlywright/2.0
Rancher 2.0 & Ember 3.3 Compatability Updates
- Loading branch information
Showing
6 changed files
with
7,123 additions
and
107 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,68 +1,71 @@ | ||
/* v----- Do not change anything between here | ||
* (the DRIVERNAME placeholder will be automatically replaced during build) */ | ||
define('ui/components/node-driver/driver-%%DRIVERNAME%%/component', ['exports', 'ember', 'shared/components/node-driver/driver-%%DRIVERNAME%%/component'], function (exports, _ember, _component) { | ||
exports['default'] = _component['default']; | ||
}); | ||
/*!!!!!!!!!!!Do not change anything between here (the DRIVERNAME placeholder will be automatically replaced at buildtime)!!!!!!!!!!!*/ | ||
|
||
import NodeDriver from 'shared/mixins/node-driver'; | ||
|
||
const LAYOUT; | ||
const computed = Ember.computed; | ||
const get = Ember.get; | ||
const set = Ember.set; | ||
const alias = Ember.computed.alias; | ||
const service = Ember.inject.service; | ||
const defaultRadix = 10; | ||
const defaultBase = 1024; | ||
|
||
export default Ember.Component.extend(NodeDriver, { | ||
/*!!!!!!!!!!!DO NOT CHANGE END!!!!!!!!!!!*/ | ||
driverName: '%%DRIVERNAME%%', | ||
config: alias('model.%%DRIVERNAME%%Config'), | ||
app: service(), | ||
|
||
init() { | ||
/*!!!!!!!!!!!DO NOT CHANGE START!!!!!!!!!!!*/ | ||
// This does on the fly template compiling, if you mess with this :cry: | ||
const decodedLayout = window.atob(LAYOUT); | ||
const template = Ember.HTMLBars.compile(decodedLayout, { | ||
moduleName: 'nodes/components/driver-interoutevdc/template' | ||
}); | ||
set(this,'layout', template); | ||
|
||
this._super(...arguments); | ||
/*!!!!!!!!!!!DO NOT CHANGE END!!!!!!!!!!!*/ | ||
|
||
define('shared/components/node-driver/driver-%%DRIVERNAME%%/component', ['exports', 'ember', 'shared/mixins/node-driver', 'shared/components/node-driver/driver-%%DRIVERNAME%%/template'], function (exports, _ember, _uiMixinsDriver, _template) { | ||
/* ^--- And here */ | ||
const config = get(this, 'globalStore').createRecord({ | ||
type: '%%DRIVERNAME%%Config', | ||
cpuCount: 2, | ||
memorySize: 2048, | ||
}); | ||
|
||
// You can put embmer object here | ||
var computed = Ember.computed; | ||
var get = Ember.get; | ||
var set = Ember.set; | ||
var alias = Ember.computed.alias; | ||
set(this, 'model.%%DRIVERNAME%%Config', config); | ||
|
||
/* v----- Do not change anything between here | ||
* (the DRIVERNAME placeholder will be automatically replaced during build) */ | ||
exports['default'] = _ember['default'].Component.extend(_uiMixinsDriver['default'], { | ||
layout: _template.default, | ||
driverName: '%%DRIVERNAME%%', | ||
config: alias('model.%%DRIVERNAME%%Config'), | ||
/* ^--- And here */ | ||
}, | ||
|
||
// Write your component here, starting with setting 'model' to a machine with your config populated | ||
bootstrap: function() { | ||
let config = get(this, 'globalStore').createRecord({ | ||
type: '%%DRIVERNAME%%Config', | ||
cpuCount: 2, | ||
memorySize: 2048, | ||
}); | ||
// Add custom validation beyond what can be done from the config API schema | ||
validate() { | ||
// Get generic API validation errors | ||
this._super(); | ||
|
||
set(this, 'model.%%DRIVERNAME%%Config', config); | ||
}, | ||
var errors = get(this, 'errors')||[]; | ||
|
||
// Add custom validation beyond what can be done from the config API schema | ||
validate() { | ||
// Get generic API validation errors | ||
this._super(); | ||
var errors = get(this, 'errors')||[]; | ||
if ( !get(this, 'model.name') ) { | ||
errors.push('Name is required'); | ||
} | ||
if ( !get(this, 'model.name') ) { | ||
errors.push('Name is required'); | ||
} | ||
|
||
// Add more specific errors | ||
// Add more specific errors | ||
|
||
// Check something and add an error entry if it fails: | ||
if ( parseInt(get(this, 'config.memorySize'),10) < 1024 ) | ||
{ | ||
errors.push('Memory Size must be at least 1024 MB'); | ||
} | ||
// Check something and add an error entry if it fails: | ||
if ( parseInt(get(this, 'config.memorySize'), defaultRadix) < defaultBase ) { | ||
errors.push('Memory Size must be at least 1024 MB'); | ||
} | ||
|
||
// Set the array of errors for display, | ||
// and return true if saving should continue. | ||
if ( get(errors, 'length') ) | ||
{ | ||
set(this, 'errors', errors); | ||
return false; | ||
} | ||
else | ||
{ | ||
set(this, 'errors', null); | ||
return true; | ||
} | ||
}, | ||
// Set the array of errors for display, | ||
// and return true if saving should continue. | ||
if ( get(errors, 'length') ) { | ||
set(this, 'errors', errors); | ||
return false; | ||
} else { | ||
set(this, '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 @@ | ||
export { default } from 'nodes/components/driver-%%DRIVERNAME%%/component'; |
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
Oops, something went wrong.