Sha256: e6c2a32a1377d8edb364a320bd0a7eab29d48b9dc3dfd97e2f635f27d5d1ab79

Contents?: true

Size: 2 KB

Versions: 8

Compression:

Stored size: 2 KB

Contents

App.Views.Doc = Backbone.View.extend({
	events: {
		"click a#clear"	: "clear"
	},
	
    initialize: function() {
		var dbkey = this.model.get('dbkey');
		this.render(dbkey);
		this.model.get_doc(dbkey,'none');
    },

	clear: function(e){
		e.preventDefault();
		dbkey = this.model.get('dbkey');
		var dt   = 'hash';
		var data = [];
		token = this.model.get('api_token');
 		if(dbkey.search(/token/i) > 0 || dbkey.search(/size/i) > 0){
			data = '';
		}
		var self = this;
		$.ajax({
			type: 'POST',
			url: '/rc/v1/store/' + dbkey,
			data: {data : data},
			beforeSend: function (HttpRequest) {
			            HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token);
			},
			success: function(){
				data = "<tr><th colspan=3><h3 style='display:inline'>Data</h3><div class='pull-right'>" + 
						"<a class='btn btn-danger'>clear document</a></div></th></tr>" +
						"<tr><td></td></tr>";
				$('#docdata-table').find("tr:gt(0)").remove();
				$('#docdata-table tr:last').after(data);
				self.delegateEvents();
			},
			error: function(resp){
				if(resp.status == 422){
					 new App.Views.Index()
				}
				$('#docalert')[0].innerHTML = resp.responseText;
		        $('#docalert').css('display','block');
			}
		})
	},

    
    render: function(dbkey) {
        $('#secondary-nav').css('display','block');
		out  = "<div class='page-header'><h2>Document&nbsp;"+dbkey+"</h2></div>";
		out += "<div id='docalert' class='alert alert-error' style='display:none'></div>";
		//out += "<form 'string_s' class='form-horizontal'>";
		//out += "<input type='text' name='data' value='' class='input-xlarge' placeholder='Upload string'/>";
		//out += "<input type='submit' value='Submit' class='btn btn-primary' style='margin-left:10px'>";
		//out += "</form>";
		out += "<table id='docdata-table' class='table table-bordered'><tr></tr>";
		out += "<tr class='remove-tr-doc'><td colspan='2' style='text-align:center'>Loading...</td></tr>"
		out += "</table>"
		
        $(this.el).html(out);
        $('#main_content').html(this.el);
    }
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhoconnect-3.3.6 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.5 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.4 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.3 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.2 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.1 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.1.beta4 lib/rhoconnect/web-console/views/doc.js
rhoconnect-3.3.1.beta3 lib/rhoconnect/web-console/views/doc.js