mirror of https://gitee.com/bigwinds/arangodb
Cleanup foxxActiveView
This commit is contained in:
parent
111b89f1c6
commit
89b2283423
|
@ -3,86 +3,17 @@
|
||||||
/*global Backbone, $, window, EJS, arangoHelper, _, templateEngine, Joi*/
|
/*global Backbone, $, window, EJS, arangoHelper, _, templateEngine, Joi*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
"use strict";
|
'use strict';
|
||||||
var checkMount = function(mount) {
|
|
||||||
var regex = /^(\/[^\/\s]+)+$/;
|
|
||||||
if (!regex.test(mount)){
|
|
||||||
arangoHelper.arangoError("Please give a valid mount point, e.g.: /myPath");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.FoxxActiveView = Backbone.View.extend({
|
window.FoxxActiveView = Backbone.View.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
className: "tile",
|
className: 'tile',
|
||||||
template: templateEngine.createTemplate("foxxActiveView.ejs"),
|
template: templateEngine.createTemplate('foxxActiveView.ejs'),
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click' : 'openAppDetailView'
|
'click' : 'openAppDetailView'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(){
|
|
||||||
this._show = true;
|
|
||||||
var mount = this.model.get("mount");
|
|
||||||
var isSystem = (
|
|
||||||
this.model.get("isSystem") &&
|
|
||||||
mount.charAt(0) === '/' &&
|
|
||||||
mount.charAt(1) === '_'
|
|
||||||
);
|
|
||||||
if (isSystem) {
|
|
||||||
this.buttonConfig = [];
|
|
||||||
} else {
|
|
||||||
this.buttonConfig = [
|
|
||||||
window.modalView.createDeleteButton(
|
|
||||||
"Uninstall", this.uninstall.bind(this)
|
|
||||||
),
|
|
||||||
window.modalView.createSuccessButton(
|
|
||||||
"Save", this.changeFoxx.bind(this)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
this.showMod = window.modalView.show.bind(
|
|
||||||
window.modalView,
|
|
||||||
"modalTable.ejs",
|
|
||||||
"Modify Application"
|
|
||||||
);
|
|
||||||
this.appsView = this.options.appsView;
|
|
||||||
_.bindAll(this, 'render');
|
|
||||||
},
|
|
||||||
|
|
||||||
changeFoxx: function() {
|
|
||||||
var mount = $("#change-mount-point").val();
|
|
||||||
var failed = false;
|
|
||||||
var app = this.model.get("app");
|
|
||||||
var prefix = this.model.get("options").collectionPrefix;
|
|
||||||
if (mount !== this.model.get("mount")) {
|
|
||||||
if (checkMount(mount)) {
|
|
||||||
$.ajax("foxx/move/" + this.model.get("_key"), {
|
|
||||||
async: false,
|
|
||||||
type: "PUT",
|
|
||||||
data: JSON.stringify({
|
|
||||||
mount: mount,
|
|
||||||
app: app,
|
|
||||||
prefix: prefix
|
|
||||||
}),
|
|
||||||
dataType: "json",
|
|
||||||
error: function(data) {
|
|
||||||
failed = true;
|
|
||||||
arangoHelper.arangoError(data.responseText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TO_DO change version
|
|
||||||
if (!failed) {
|
|
||||||
window.modalView.hide();
|
|
||||||
this.appsView.reload();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
openAppDetailView: function() {
|
openAppDetailView: function() {
|
||||||
// var url = window.location.origin + "/_db/" +
|
// var url = window.location.origin + "/_db/" +
|
||||||
// encodeURIComponent(arangoHelper.currentDatabase()) +
|
// encodeURIComponent(arangoHelper.currentDatabase()) +
|
||||||
|
@ -92,10 +23,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(){
|
render: function(){
|
||||||
if (this._show) {
|
|
||||||
$(this.el).html(this.template.render(this.model));
|
$(this.el).html(this.template.render(this.model));
|
||||||
}
|
|
||||||
|
|
||||||
return $(this.el);
|
return $(this.el);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue