mirror of https://gitee.com/bigwinds/arangodb
preparation for work monitor, added some dev test view
This commit is contained in:
parent
3d91d54af9
commit
0fe9818807
|
@ -0,0 +1,17 @@
|
|||
/*jshint browser: true */
|
||||
/*jshint unused: false */
|
||||
/*global window, Backbone, $ */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.WorkMonitorCollection = Backbone.Collection.extend({
|
||||
|
||||
model: window.workMonitorModel,
|
||||
|
||||
url: "/_admin/work-monitor",
|
||||
|
||||
parse: function(response) {
|
||||
return response.work;
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
|
@ -0,0 +1,15 @@
|
|||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.workMonitorModel = Backbone.Model.extend({
|
||||
|
||||
defaults: {
|
||||
name: "",
|
||||
number: "",
|
||||
status: "",
|
||||
type: ""
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
|
@ -17,6 +17,7 @@
|
|||
"shell": "shell",
|
||||
"query": "query",
|
||||
"queryManagement": "queryManagement",
|
||||
"workMonitor": "workMonitor",
|
||||
"databases": "databases",
|
||||
"applications": "applications",
|
||||
"applications/:mount": "applicationDetail",
|
||||
|
@ -237,6 +238,25 @@
|
|||
this.testView.render();
|
||||
},
|
||||
|
||||
workMonitor: function () {
|
||||
if (!this.checkUser()) {
|
||||
return;
|
||||
}
|
||||
if (!this.workMonitorCollection) {
|
||||
this.workMonitorCollection = new window.WorkMonitorCollection();
|
||||
this.workMonitorCollection.fetch({
|
||||
async: false
|
||||
});
|
||||
}
|
||||
if (!this.workMonitorView) {
|
||||
this.workMonitorView = new window.workMonitorView({
|
||||
collection: this.workMonitorCollection
|
||||
});
|
||||
}
|
||||
this.workMonitorView.render();
|
||||
this.naviView.selectMenuItem('tools-menu');
|
||||
},
|
||||
|
||||
queryManagement: function () {
|
||||
if (!this.checkUser()) {
|
||||
return;
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
<li class="dropdown-item">
|
||||
<a id="queryManagement" class="tab" href="#queryManagement">Query Management</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a id="workMonitor" class="tab" href="#workMonitor">Work Monitor</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown" id="linkDropdown">
|
||||
|
@ -62,11 +65,13 @@
|
|||
<% } %>
|
||||
|
||||
<option value="#collections">Collections</option>
|
||||
<option value="#demo">Demo</option>
|
||||
<option value="#applications">Services</option>
|
||||
<option value="#graph">Graph</option>
|
||||
<option value="#query">AQL Editor</option>
|
||||
<option value="#shell">JS Shell</option>
|
||||
<option value="#userManagement">User Management</option>
|
||||
<option value="#queryManagement">Query Management</option>
|
||||
<option value="#workMonitor">Work Monitor</option>
|
||||
|
||||
<% if(currentDB.get('isSystem')) { %>
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<script id="workMonitorView.ejs" type="text/template">
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Work Monitor</a>
|
||||
</div>
|
||||
|
||||
<div id="workMonitorContent" class="innerContent">
|
||||
</div>
|
||||
</script>
|
|
@ -0,0 +1,82 @@
|
|||
/*jshint browser: true */
|
||||
/*jshint unused: false */
|
||||
/*global Backbone, EJS, $, window, _ */
|
||||
/*global _, arangoHelper, templateEngine, jQuery, Joi*/
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
window.workMonitorView = Backbone.View.extend({
|
||||
|
||||
el: '#content',
|
||||
id: '#workMonitorContent',
|
||||
|
||||
template: templateEngine.createTemplate("workMonitorView.ejs"),
|
||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||
|
||||
initialize: function () {
|
||||
},
|
||||
|
||||
events: {
|
||||
},
|
||||
|
||||
tableDescription: {
|
||||
id: "workMonitorTable",
|
||||
titles: [
|
||||
"Type", "Database", "Task ID", "Started", "Url", "User", "Description", "Method"
|
||||
],
|
||||
rows: [],
|
||||
unescaped: [false, false, false, false, false, false, false, false]
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template.render({}));
|
||||
this.parseTableData();
|
||||
$(this.id).append(this.table.render({content: this.tableDescription}));
|
||||
},
|
||||
|
||||
parseTableData: function() {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.collection.each(function(model) {
|
||||
if (model.get('type') === 'AQL query') {
|
||||
|
||||
var parent = model.get('parent');
|
||||
if (parent) {
|
||||
try {
|
||||
console.log(parent);
|
||||
|
||||
self.tableDescription.rows.push([
|
||||
model.get('type'),
|
||||
"(p) " + parent.database,
|
||||
"(p) " + parent.taskId,
|
||||
"(p) " + parent.startTime,
|
||||
"(p) " + parent.url,
|
||||
"(p) " + parent.user,
|
||||
model.get('description'),
|
||||
"(p) " + parent.method
|
||||
]);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("some parse error");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (model.get('type') !== 'thread') {
|
||||
self.tableDescription.rows.push([
|
||||
model.get('type'),
|
||||
model.get('database'),
|
||||
model.get('taskId'),
|
||||
model.get('startTime'),
|
||||
model.get('url'),
|
||||
model.get('user'),
|
||||
model.get('description'),
|
||||
model.get('method')
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
Loading…
Reference in New Issue