Reviewers: mp+162691_code.launchpad.net,
Message: Please take a look.
Description: Drag out to export
Dragging the environment icon in the nav to another supporting GUI app will create DnD export/import chain.
https://code.launchpad.net/~bcsaller/juju-gui/export-ui/+merge/162691
(do not edit description out of merge proposal)
Please review this at https://codereview.appspot.com/9252043/
Affected files: A [revision details] M app/index.html M app/views/topology/importexport.js
Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: <email address hidden> +New revision: <email address hidden>
Index: app/index.html === modified file 'app/index.html' --- app/index.html 2013-05-04 20:11:20 +0000 +++ app/index.html 2013-05-06 20:31:34 +0000 @@ -83,8 +83,8 @@ </span> <span class="nav-container"> <span class="nav-section"> - <i class="sprite environment_icon"></i> - <span id="environment-name"></span> + <i class="sprite environment_icon"> </i> + <span id="environment-name" draggable="true"></span> <span id="provider-type" class="provider-type"></span> </span> </span>
Index: app/views/topology/importexport.js === modified file 'app/views/topology/importexport.js' --- app/views/topology/importexport.js 2013-05-02 20:13:10 +0000 +++ app/views/topology/importexport.js 2013-05-07 00:32:53 +0000 @@ -55,24 +55,52 @@ notifications = topo.get('db').notifications, env = topo.get('env'), fileSources = evt._event.dataTransfer.files; - - Y.Array.each(fileSources, function(file) { - var reader = new FileReader(); - reader.onload = (function(fileData) { - return function(e) { - // Import each into the environment - env.importEnvironment(e.target.result); - notifications.add({ - title: 'Imported Environment', - message: 'Import from "' + file.name + '" successful', - level: 'important' - }); - }; - })(file); - reader.readAsText(file); - }); + if (fileSources.length) { + Y.Array.each(fileSources, function(file) { + var reader = new FileReader(); + reader.onload = (function(fileData) { + return function(e) { + // Import each into the environment + env.importEnvironment(e.target.result); + notifications.add({ + title: 'Imported Environment', + message: 'Import from "' + file.name + '" successful', + level: 'important' + }); + }; + })(file); + reader.readAsText(file); + }); + } else { + env.importEnvironment(evt._event.dataTransfer.getData('Text')); + } evt.preventDefault(); evt.stopPropagation(); + }, + + /** + * Update lifecycle phase + * @method update + */ + update: function() { + if (!this._dragHandle) { + var env = this.get('component').get('env'); + this._dragHandle = Y.one('#environment-name') + .on('dragstart', function(evt) { + env.exportEnvironment(function(r) { + var ev = evt._event; + ev.dataTransfer.dragEffect = 'copy'; + var json = JSON.stringify(r.result); + ev.dataTransfer.setData('Text', json); + }); + evt.stopPropagation(); + }, this); + + this.get('component') + .recordSubscription(this, this._dragHandle); + + } + ImportExportModule.superclass.update.call(this); } }, { ATTRS: {}
« Back to merge proposal
Reviewers: mp+162691_ code.launchpad. net,
Message:
Please take a look.
Description:
Drag out to export
Dragging the environment icon in the nav to another supporting
GUI app will create DnD export/import chain.
https:/ /code.launchpad .net/~bcsaller/ juju-gui/ export- ui/+merge/ 162691
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/9252043/
Affected files: topology/ importexport. js
A [revision details]
M app/index.html
M app/views/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: app/index.html
</span>
<span class=" nav-container" >
< span class=" nav-section" > icon">< /i> -name"> </span> -name" draggable= "true"> </span>
<span id="provider-type" class=" provider- type">< /span>
< /span>
</span>
=== modified file 'app/index.html'
--- app/index.html 2013-05-04 20:11:20 +0000
+++ app/index.html 2013-05-06 20:31:34 +0000
@@ -83,8 +83,8 @@
- <i class="sprite environment_
- <span id="environment
+ <i class="sprite environment_icon"> </i>
+ <span id="environment
Index: app/views/ topology/ importexport. js topology/ importexport. js' topology/ importexport. js 2013-05-02 20:13:10 +0000 topology/ importexport. js 2013-05-07 00:32:53 +0000
notifications = topo.get( 'db').notificat ions,
fileSources = evt._event. dataTransfer. files; each(fileSource s, function(file) { onment( e.target. result) ; readAsText( file); length) { each(fileSource s, function(file) { onment( e.target. result) ; readAsText( file); onment( evt._event. dataTransfer. getData( 'Text') );
evt. preventDefault( );
evt. stopPropagation (); 'component' ).get(' env'); #environment- name') onment( function( r) { .dragEffect = 'copy'; r.result) ; .setData( 'Text', json); tion(); 'component' ) tion(this, this._dragHandle); ule.superclass. update. call(this) ;
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -55,24 +55,52 @@
env = topo.get('env'),
-
- Y.Array.
- var reader = new FileReader();
- reader.onload = (function(fileData) {
- return function(e) {
- // Import each into the environment
- env.importEnvir
- notifications.add({
- title: 'Imported Environment',
- message: 'Import from "' + file.name + '" successful',
- level: 'important'
- });
- };
- })(file);
- reader.
- });
+ if (fileSources.
+ Y.Array.
+ var reader = new FileReader();
+ reader.onload = (function(fileData) {
+ return function(e) {
+ // Import each into the environment
+ env.importEnvir
+ notifications.add({
+ title: 'Imported Environment',
+ message: 'Import from "' + file.name + '" successful',
+ level: 'important'
+ });
+ };
+ })(file);
+ reader.
+ });
+ } else {
+ env.importEnvir
+ }
+ },
+
+ /**
+ * Update lifecycle phase
+ * @method update
+ */
+ update: function() {
+ if (!this._dragHandle) {
+ var env = this.get(
+ this._dragHandle = Y.one('
+ .on('dragstart', function(evt) {
+ env.exportEnvir
+ var ev = evt._event;
+ ev.dataTransfer
+ var json = JSON.stringify(
+ ev.dataTransfer
+ });
+ evt.stopPropaga
+ }, this);
+
+ this.get(
+ .recordSubscrip
+
+ }
+ ImportExportMod
}
}, {
ATTRS: {}