Revision 2a4126d7

b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/tag.js
1 1
App.TagController = Ember.ObjectController.extend({
2 2
    actions: {
3
        createTag: function() {
4
            alert('edw eimai?');
3
        createTag: function(data, model) {
4
            var tag = this.store.createRecord('tag', data);
5
            tag.save();
5 6

  
6
            var name = 'anna';
7
            if (!name.trim()) { return; }
7
            // model can be any model class instance which 
8
            // shares the tags interface used below.
9
            if (model) {
10
              model.get('tags').addObject(tag);
11
            }
12
        }
13
    },
14
});
8 15

  
9
            var color = 'pink';
10
            if (!color.trim()) { return; }
11 16

  
12
            var tag = this.store.createRecord('tag', {
13
                name: name,
14
                color: color,
15
            });
17
var _defaultNewTagColor = 'cornflowerblue';
16 18

  
17
            tag.save();
18
        }
19
App.AddTagController = App.TagController.extend({
20
  newTagName: '',
21
  newTagColor: _defaultNewTagColor,
22
  closed: false,
23
  actions: {
24
    handleSubmit: function() {
25
      // resolve form params
26
      var tagDetails = {
27
        name: this.get('newTagName'),
28
        color: this.get('newTagColor')
29
      };
30
      
31
      // validate ???
32
      // failed validation messages ???
33
      
34
      // do create tag
35
      this.send('createTag', tagDetails, this.get('model'));
36
  
37
      // hide form (view should use this attr)
38
      this.set('closed', true);
39

  
40
      // reset the newTagXXX shit
41
      this.set('newTagName', '');
42
      this.set('newTagColor', _defaultNewTagColor);
19 43
    }
44
  }
20 45
});
21

  
22

  
23
App.AddTagController = App.TagController.extend();
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js
76 76
});
77 77

  
78 78

  
79
App.VmInfoController = App.VmController.extend();
79
App.VmInfoController = App.VmController.extend({
80
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates.js
182 182
Ember.TEMPLATES["add-tag"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
183 183
this.compilerInfo = [4,'>= 1.0.0'];
184 184
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
185
  var buffer = '', escapeExpression=this.escapeExpression;
185
  var buffer = '', helper, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
186 186

  
187 187

  
188
  data.buffer.push("<div class=\"buttons\">\n    <a href=\"\" class=\"btn1 show-add-tag wrap-a\" id=\"show-add-tag\"><span>add new tag</span></a>\n</div>\n<div class=\"snf-color-picker\">\n    <h3>Select color:</h3>\n    <form action=\"#\" method=\"post\">\n        <div id=\"picker-2\">\n            <div class=\"farbtastic\">\n                <div class=\"color\" style=\"background-color: rgb(255, 0, 21);\"></div>\n                <div class=\"wheel\"></div>\n                <div class=\"overlay\"></div>\n                <div class=\"h-marker marker\" style=\"left: 90px; top: 13px;\"></div>\n                <div class=\"sl-marker marker\" style=\"left: 87px; top: 114px;\"></div>\n            </div>\n        </div>\n        \n        <div class=\"form-item\">\n            <input type=\"text\" id=\"color-2\" class=\"color-preview \"name=\"color\" value=\"#16C1E9\" disabled>\n            <span class=\"input\"><input class=\"tag_name\" type=\"text\" placeholder=\"My Tag\"></span>\n        </div>\n    </form>    \n    <div class=\"btns\">\n        <a class=\"btn1 wrap-a\" href=\"\" ");
189
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "createTag", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data})));
188
  data.buffer.push("<div class=\"buttons\">\n    <a href=\"\" class=\"btn1 show-add-tag wrap-a\" id=\"show-add-tag\"><span>add new tag</span></a>\n</div>\n\n<div class=\"snf-color-picker\">\n    <h3>Select color:</h3>\n    <form action=\"#\" method=\"post\">\n        <div id=\"picker-2\">\n            <div class=\"farbtastic\">\n                <div class=\"color\" style=\"background-color: rgb(255, 0, 21);\"></div>\n                <div class=\"wheel\"></div>\n                <div class=\"overlay\"></div>\n                <div class=\"h-marker marker\" style=\"left: 90px; top: 13px;\"></div>\n                <div class=\"sl-marker marker\" style=\"left: 87px; top: 114px;\"></div>\n            </div>\n        </div>\n        \n        <div class=\"form-item\">\n            <input type=\"text\" id=\"color-2\" class=\"color-preview \"name=\"color\" value=\"#16C1E9\" disabled>\n            <span class=\"input\">\n                ");
189
  data.buffer.push(escapeExpression((helper = helpers.input || (depth0 && depth0.input),options={hash:{
190
    'value': ("newTagName"),
191
    'class': ("tag_name"),
192
    'type': ("text"),
193
    'placeholder': ("My Tag")
194
  },hashTypes:{'value': "ID",'class': "STRING",'type': "STRING",'placeholder': "STRING"},hashContexts:{'value': depth0,'class': depth0,'type': depth0,'placeholder': depth0},contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "input", options))));
195
  data.buffer.push("\n            </span>\n        </div>\n    </form>    \n    <div class=\"btns\">\n        <a class=\"btn1 wrap-a\" href=\"\" ");
196
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "handleSubmit", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data})));
190 197
  data.buffer.push("><span>OK</span></a>\n        <a class=\"btn1 hide-add-tag wrap-a\" href=\"\"><span>CANCEL</span></a>\n    </div>\n</div>\n");
191 198
  return buffer;
192 199
  
......
221 228
  
222 229
});
223 230

  
231
Ember.TEMPLATES["components/resource-tags"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
232
this.compilerInfo = [4,'>= 1.0.0'];
233
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
234
  var buffer = '', stack1, escapeExpression=this.escapeExpression, self=this;
235

  
236
function program1(depth0,data) {
237
  
238
  var buffer = '', stack1;
239
  data.buffer.push("\n<");
240
  data.buffer.push(escapeExpression(helpers.unbound.call(depth0, "entryTag", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
241
  data.buffer.push(">\n<a href=\"#\" ");
242
  data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
243
    'title': ("tag.name"),
244
    'style': ("style")
245
  },hashTypes:{'title': "ID",'style': "ID"},hashContexts:{'title': depth0,'style': depth0},contexts:[],types:[],data:data})));
246
  data.buffer.push(" class=\"has-tip tag\">&nbsp;</a>\n<span>");
247
  stack1 = helpers._triageMustache.call(depth0, "tag.name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
248
  if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
249
  data.buffer.push("</span>\n<a class=\"delete\" ");
250
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "deleteTag", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data})));
251
  data.buffer.push(" title=\"remove this tag from this vm\"><span class=\"snf-trash-outline\"></span></a>\n</");
252
  data.buffer.push(escapeExpression(helpers.unbound.call(depth0, "entryTag", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
253
  data.buffer.push(">\n");
254
  return buffer;
255
  }
256

  
257
  stack1 = helpers.each.call(depth0, "tag", "in", "tags", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(1, program1, data),contexts:[depth0,depth0,depth0],types:["ID","ID","ID"],data:data});
258
  if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
259
  data.buffer.push("\n");
260
  return buffer;
261
  
262
});
263

  
224 264
Ember.TEMPLATES["components/reveal-modal"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
225 265
this.compilerInfo = [4,'>= 1.0.0'];
226 266
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
......
295 335
Ember.TEMPLATES["details/info"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
296 336
this.compilerInfo = [4,'>= 1.0.0'];
297 337
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
298
  var stack1, helper, options, escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing, self=this;
338
  var buffer = '', stack1, helper, options, escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing, self=this;
299 339

  
300 340
function program1(depth0,data) {
301 341
  
302 342
  var buffer = '', helper, options;
303 343
  data.buffer.push("\n\n	<section class=\"info-block\">\n		<h2>info</h2>\n		<dl>\n			<dt><span class=\"snf-font snf-pc-full\"></span>Name</dt>\n			<dd>\n				<div class=\"editable\">\n			        <span class=\"input-txt\">My Opensuse Desktop Server 1</span>\n			        <input type=\"text\">\n			        <span class=\"editbuttons\">\n						<a href=\"#\" class=\"edit\"><span class=\"snf-edit\"></span></a>\n						<a href=\"#\" class=\"save\"><span class=\"snf-ok-sign\"></span></a>\n						<a href=\"#\" class=\"cancel\"><span class=\"snf-cancel-circled\"></span></a>\n					</span>\n			    </div>\n			</dd>\n			<dt><span class=\"snf-font snf-dashboard-outline\"></span>Assigned Project</dt>\n			<dd>Basic Project</dd>\n			<dt><span class=\"snf-chip-outline snf-font\"></span>CPUs</dt>\n			<dd>4</dd>\n			<dt><span class=\"snf-ram-full snf-font\"></span>RAM</dt>\n			<dd>512 MB</dd>\n			<dt><span class=\"snf-volume-full snf-font\"></span>System Disk Size</dt>\n			<dd>4GB</dd>\n			<dt><span class=\"snf-volume-full snf-font\"></span>Storage Type</dt>\n			<dd>Archipelago</dd>\n			<dt><span class=\"snf-image-full snf-font\"></span>Image Name</dt>\n			<dd>Fedora</dd>\n			<dt><span class=\"snf-image-full snf-font\"></span>Image Size</dt>\n			<dd>3.68 GB</dd>\n			<dt><span class=\"snf-nic-full snf-font\"></span>IPv4</dt>\n			<dd>83.212.96.152</dd>\n			<dt><span class=\"snf-nic-full snf-font\"></span>IPv4</dt>\n			<dd>83.212.96.153</dd>\n			<dt><span class=\"snf-nic-full snf-font\"></span>IPv6</dt>\n			<dd>2001:648:2ffc:1112:a80c:eaff:fec2:8cd9</dd>\n		</dl>\n	</section>\n\n	<section class=\"info-block\">\n		<h2>tags</h2>\n		");
304 344
  data.buffer.push(escapeExpression(helpers.view.call(depth0, "App.tagsListView", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
305
  data.buffer.push("\n		");
306
  data.buffer.push(escapeExpression((helper = helpers.render || (depth0 && depth0.render),options={hash:{},hashTypes:{},hashContexts:{},contexts:[depth0,depth0],types:["STRING","ID"],data:data},helper ? helper.call(depth0, "add-tag", "tag", options) : helperMissing.call(depth0, "render", "add-tag", "tag", options))));
345
  data.buffer.push("\n        \n		");
346
  data.buffer.push(escapeExpression((helper = helpers.render || (depth0 && depth0.render),options={hash:{},hashTypes:{},hashContexts:{},contexts:[depth0,depth0],types:["STRING","ID"],data:data},helper ? helper.call(depth0, "add-tag", "model", options) : helperMissing.call(depth0, "render", "add-tag", "model", options))));
307 347
  data.buffer.push("\n	</section>\n\n\n\n	<section class=\"info-block charts\">\n		<div>\n			<h2>CPU utilization</h2>\n			<div class=\"graph_container\">\n				<img src=\"images/cpu-ts.png\" alt=\"CPU utilization graph\">\n			</div>\n		</div>\n		<div>\n			<h2>Network utilization</h2>\n			<div class=\"graph_container\">\n				<img src=\"images/net-ts.png\" alt=\"network utilization graph\">\n			</div>\n		</div>\n	</section>\n");
308 348
  return buffer;
309 349
  }
......
313 353
    'class': ("info-simple")
314 354
  },hashTypes:{'id': "STRING",'class': "STRING"},hashContexts:{'id': depth0,'class': depth0},inverse:self.noop,fn:self.program(1, program1, data),contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "details-content", options));
315 355
  if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
316
  else { data.buffer.push(''); }
356
  data.buffer.push("\n");
357
  return buffer;
317 358
  
318 359
});
319 360

  
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/add-tag.hbs
1 1
<div class="buttons">
2 2
    <a href="" class="btn1 show-add-tag wrap-a" id="show-add-tag"><span>add new tag</span></a>
3 3
</div>
4

  
4 5
<div class="snf-color-picker">
5 6
    <h3>Select color:</h3>
6 7
    <form action="#" method="post">
......
16 17
        
17 18
        <div class="form-item">
18 19
            <input type="text" id="color-2" class="color-preview "name="color" value="#16C1E9" disabled>
19
            <span class="input"><input class="tag_name" type="text" placeholder="My Tag"></span>
20
            <span class="input">
21
                {{ input value=newTagName class="tag_name" type="text" placeholder="My Tag" }}
22
            </span>
20 23
        </div>
21 24
    </form>    
22 25
    <div class="btns">
23
        <a class="btn1 wrap-a" href="" {{action 'createTag'}}><span>OK</span></a>
26
        <a class="btn1 wrap-a" href="" {{action 'handleSubmit'}}><span>OK</span></a>
24 27
        <a class="btn1 hide-add-tag wrap-a" href=""><span>CANCEL</span></a>
25 28
    </div>
26 29
</div>
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/components/resource-tags.hbs
1
{{#each tag in tags }}
2
<{{ unbound entryTag}}>
3
<a href="#" {{bind-attr title=tag.name style=style}} class="has-tip tag">&nbsp;</a>
4
<span>{{tag.name}}</span>
5
<a class="delete" {{action 'deleteTag'}} title="remove this tag from this vm"><span class="snf-trash-outline"></span></a>
6
</{{ unbound entryTag}}>
7
{{/each}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/details/info.hbs
41 41
	<section class="info-block">
42 42
		<h2>tags</h2>
43 43
		{{view App.tagsListView}}
44
		{{render "add-tag" tag}}
44
        {{! notice that we pass the current controller model (vm/network etc.) as model to the AddTagController }}
45
		{{render "add-tag" model }}
45 46
	</section>
46 47

  
47 48

  
......
60 61
			</div>
61 62
		</div>
62 63
	</section>
63
{{/details-content}}
64
{{/details-content}}

Also available in: Unified diff