Skip to content

Commit

Permalink
Merge branch 'admin.data.types.vue' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Jun 27, 2018
2 parents a13bcd1 + ae81a14 commit 2b55e3a
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 71 deletions.
10 changes: 9 additions & 1 deletion client/galaxy/scripts/apps/admin.js
Expand Up @@ -10,6 +10,7 @@ import Router from "layout/router";
import Utils from "utils/utils";
import Page from "layout/page";
import DataTables from "components/admin/DataTables.vue";
import DataTypes from "components/admin/DataTypes.vue";
import Vue from "vue";

window.app = function app(options, bootstrapped) {
Expand All @@ -27,7 +28,8 @@ window.app = function app(options, bootstrapped) {
"(/)admin(/)repositories": "show_repositories",
"(/)admin(/)forms": "show_forms",
"(/)admin(/)form(/)(:form_id)": "show_form",
"(/)admin/data_tables": "show_data_tables"
"(/)admin/data_tables": "show_data_tables",
"(/)admin/data_types": "show_data_types"
},

authenticate: function() {
Expand Down Expand Up @@ -94,6 +96,12 @@ window.app = function app(options, bootstrapped) {
new Vue(DataTables).$mount(vueMount);
},

show_data_types: function() {
var vueMount = document.createElement("div");
this.page.display(vueMount);
new Vue(DataTypes).$mount(vueMount);
},

show_forms: function() {
this.page.display(
new GridView({
Expand Down
3 changes: 2 additions & 1 deletion client/galaxy/scripts/apps/panels/admin-panel.js
Expand Up @@ -18,7 +18,8 @@ var AdminPanel = Backbone.View.extend({
items: [
{
title: _l("Data types"),
url: "admin/view_datatypes_registry",
url: "admin/data_types",
target: "__use_router__",
id: "admin-link-datatypes"
},
{
Expand Down
7 changes: 5 additions & 2 deletions client/galaxy/scripts/components/DataDialog.vue
Expand Up @@ -92,7 +92,9 @@ export default {
optionsShow: false
};
},
created: function() {this.load()},
created: function() {
this.load();
},
methods: {
filtered: function(items) {
this.nItems = items.length;
Expand All @@ -113,7 +115,8 @@ export default {
})
.catch(e => {
if (e.response) {
this.errorMessage = e.response.data.err_msg || `${e.response.statusText} (${e.response.status})`;
this.errorMessage =
e.response.data.err_msg || `${e.response.statusText} (${e.response.status})`;
} else {
this.errorMessage = "Server unavailable.";
}
Expand Down
102 changes: 102 additions & 0 deletions client/galaxy/scripts/components/admin/DataTypes.vue
@@ -0,0 +1,102 @@
<template>
<div>
<Message :message="message" :status="status" />
<BaseGrid v-if="status !== 'error'"
:columns="columns"
:rows="dataTypes"
:isLoaded="isDataLoaded"
id="data-types-grid">
<template slot="title">
<p>Current data types registry contains {{ dataTypes.length }} data types.</p>
<input type="checkbox"
id="showAllColumns"
v-model="showAllColumns">
<label for="showAllColumns">Show all columns</label>
</template>
</BaseGrid>
</div>
</template>

<script>
import axios from "axios";
import Message from "../Message.vue";
import BaseGrid from "./BaseGrid.vue";
export default {
components: {
Message,
BaseGrid
},
data() {
return {
// Show all columns when user wants to
showAllColumns: false,
keys: [],
dataTypes: [],
message: "",
status: ""
};
},
methods: {
// Predefined columns with pretty headers (entries are optional)
prettyColumns() {
return [
{ text: "Extension", dataIndex: "extension" },
{ text: "Type", dataIndex: "type" },
{ text: "MIME Type", dataIndex: "mimetype" },
{ text: "Display in Upload", dataIndex: "display_in_upload" }
];
}
},
computed: {
// Return predefined column headers merged
// with all other column headers returned by the api
columns() {
var columns = this.prettyColumns();
// We have keys to look at
if (this.keys.length > 0) {
// Additional column headers only when option is selected
if (this.showAllColumns) {
var keys = this.keys;
// Filter out the predefined column headers
for (var c of columns) {
keys = keys.filter(k => k !== c["dataIndex"]);
}
// Create column headers from each remaining key and merge
// with predefined column headers
columns = keys.reduce(function(m, k) {
var text = k[0].toUpperCase();
text += k.slice(1).replace(/_/g, " ");
m.push({
text: text,
dataIndex: k
});
return m;
}, columns);
}
}
return columns;
},
isDataLoaded() {
return status !== "" || this.dataTypes.length > 0;
}
},
created() {
axios
.get(`${Galaxy.root}admin/data_types_list`)
.then(response => {
this.keys = response.data.keys;
this.dataTypes = response.data.data;
this.message = response.data.message;
this.status = response.data.status;
})
.catch(error => {
console.error(error);
});
}
};
</script>
6 changes: 3 additions & 3 deletions client/galaxy/scripts/layout/data.js
Expand Up @@ -9,11 +9,11 @@ export default class Data {
dialog(callback) {
var instance = Vue.extend(DataDialog);
var vm = document.createElement("div");
$('body').append(vm);
new instance(({
$("body").append(vm);
new instance({
propsData: {
callback: callback
}
})).$mount(vm);
}).$mount(vm);
}
}
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/buildapp.py
Expand Up @@ -100,6 +100,7 @@ def app_factory(global_conf, load_app_kwds={}, **kwargs):
# base analysis interface at which point the application takes over.

webapp.add_client_route('/admin/data_tables', 'admin')
webapp.add_client_route('/admin/data_types', 'admin')
webapp.add_client_route('/admin/users', 'admin')
webapp.add_client_route('/admin/roles', 'admin')
webapp.add_client_route('/admin/forms', 'admin')
Expand Down
21 changes: 14 additions & 7 deletions lib/galaxy/webapps/galaxy/controllers/admin.py
Expand Up @@ -573,6 +573,20 @@ def data_tables_list(self, trans, **kwd):

return {'data': data, 'message': message, 'status': status}

@web.expose
@web.json
@web.require_admin
def data_types_list(self, trans, **kwd):
datatypes = []
keys = set()
message = kwd.get('message', '')
status = kwd.get('status', 'done')
for dtype in sorted(trans.app.datatypes_registry.datatype_elems,
key=lambda dtype: dtype.get('extension')):
datatypes.append(dtype.attrib)
keys |= set(dtype.attrib)
return {'keys': list(keys), 'data': datatypes, 'message': message, 'status': status}

@web.expose
@web.json
@web.require_admin
Expand Down Expand Up @@ -894,13 +908,6 @@ def review_tool_migration_stages(self, trans, **kwd):
def tool_errors(self, trans, **kwd):
return trans.fill_template('admin/tool_errors.mako', tool_errors=global_tool_errors.error_stack)

@web.expose
@web.require_admin
def view_datatypes_registry(self, trans, **kwd):
message = escape(util.restore_text(kwd.get('message', '')))
status = util.restore_text(kwd.get('status', 'done'))
return trans.fill_template('admin/view_datatypes_registry.mako', message=message, status=status)

@web.expose
@web.require_admin
def display_applications(self, trans, **kwd):
Expand Down
57 changes: 0 additions & 57 deletions templates/admin/view_datatypes_registry.mako

This file was deleted.

0 comments on commit 2b55e3a

Please sign in to comment.