moving files added since the big move
This commit is contained in:
parent
fc7f5be3a1
commit
fa4d88830c
18 changed files with 3 additions and 3 deletions
151
plugins/cockpit/ui/requestView.js
Normal file
151
plugins/cockpit/ui/requestView.js
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Walker (jwalker@mozilla.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
|
||||
var util = require('pilot/util');
|
||||
|
||||
var requestViewCss = require("text!cockpit/ui/requestView.css");
|
||||
var dom = require("pilot/dom");
|
||||
dom.importCssString(requestViewCss);
|
||||
|
||||
var requestViewHtml = require("text!cockpit/ui/requestView.html");
|
||||
var Templater = require("pilot/domtemplate").Templater;
|
||||
|
||||
/**
|
||||
* Pull the HTML into the DOM, but don't add it to the document
|
||||
*/
|
||||
var templates = document.createElement('div');
|
||||
templates.innerHTML = requestViewHtml;
|
||||
var row = templates.querySelector('.cptRow');
|
||||
|
||||
/**
|
||||
* Adds a row to the CLI output display
|
||||
*/
|
||||
function RequestView(request, cliView) {
|
||||
this.request = request;
|
||||
this.cliView = cliView;
|
||||
|
||||
this.imagePath = '/plugins/ace/plugins/cockpit/lib/ui/images';
|
||||
|
||||
// Elements attached to this by the templater. For info only
|
||||
this.rowin = null;
|
||||
this.rowout = null;
|
||||
this.output = null;
|
||||
this.hide = null;
|
||||
this.show = null;
|
||||
this.duration = null;
|
||||
this.throb = null;
|
||||
|
||||
new Templater().processNode(row.cloneNode(true), this);
|
||||
|
||||
this.cliView.output.appendChild(this.rowin);
|
||||
this.cliView.output.appendChild(this.rowout);
|
||||
|
||||
this.request.addEventListener('output', this.onRequestChange.bind(this));
|
||||
};
|
||||
|
||||
RequestView.prototype = {
|
||||
/**
|
||||
* A single click on an invocation line in the console copies the command to
|
||||
* the command line
|
||||
*/
|
||||
copyToInput: function() {
|
||||
this.cliView.element.value = this.request.typed;
|
||||
},
|
||||
|
||||
/**
|
||||
* A double click on an invocation line in the console executes the command
|
||||
*/
|
||||
executeRequest: function(ev) {
|
||||
this.cliView.cli.update({
|
||||
typed: this.request.typed,
|
||||
cursor: { start:0, end:0 }
|
||||
});
|
||||
this.cliView.cli.exec();
|
||||
},
|
||||
|
||||
hideOutput: function(ev) {
|
||||
this.output.style.display = 'none';
|
||||
util.addClass(this.hide, 'cmd_hidden');
|
||||
util.removeClass(this.show, 'cmd_hidden');
|
||||
|
||||
ev.stopPropagation();
|
||||
},
|
||||
|
||||
showOutput: function(ev) {
|
||||
this.output.style.display = 'block';
|
||||
util.removeClass(this.hide, 'cmd_hidden');
|
||||
util.addClass(this.show, 'cmd_hidden');
|
||||
|
||||
ev.stopPropagation();
|
||||
},
|
||||
|
||||
remove: function(ev) {
|
||||
this.cliView.output.removeChild(this.rowin);
|
||||
this.cliView.output.removeChild(this.rowout);
|
||||
ev.stopPropagation();
|
||||
},
|
||||
|
||||
onRequestChange: function(ev) {
|
||||
this.duration.innerHTML = this.request.duration ?
|
||||
'completed in ' + (this.request.duration / 1000) + ' sec ' :
|
||||
'';
|
||||
|
||||
this.output.innerHTML = '';
|
||||
this.request.outputs.forEach(function(output) {
|
||||
var node;
|
||||
if (typeof output == 'string') {
|
||||
node = document.createElement('p');
|
||||
node.innerHTML = output;
|
||||
} else {
|
||||
node = output;
|
||||
}
|
||||
this.output.appendChild(node);
|
||||
}, this);
|
||||
this.cliView.scrollOutputToBottom();
|
||||
|
||||
util.setClass(this.output, 'cmd_error', this.request.error);
|
||||
|
||||
this.throb.style.display = this.request.completed ? 'none' : 'block';
|
||||
}
|
||||
};
|
||||
exports.RequestView = RequestView;
|
||||
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue