mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 10:06:26 +00:00
Initial commit
This commit is contained in:
62
manager/src/frontend/js/app/access/main.js
Normal file
62
manager/src/frontend/js/app/access/main.js
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
import Mn from 'backbone.marionette';
|
||||
|
||||
const Api = require('../api');
|
||||
const template = require('./main.ejs');
|
||||
const Controller = require('../controller');
|
||||
const RowView = require('./row');
|
||||
const AccessListModel = require('../../models/access');
|
||||
const EmptyView = require('./empty');
|
||||
|
||||
const TableBody = Mn.CollectionView.extend({
|
||||
tagName: 'tbody',
|
||||
childView: RowView
|
||||
});
|
||||
|
||||
module.exports = Mn.View.extend({
|
||||
template: template,
|
||||
id: 'access',
|
||||
|
||||
regions: {
|
||||
list_region: {
|
||||
el: 'tbody',
|
||||
replaceElement: true
|
||||
}
|
||||
},
|
||||
|
||||
ui: {
|
||||
'create': 'th button'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click @ui.create': function (e) {
|
||||
e.preventDefault();
|
||||
Controller.showAccessListForm(new AccessListModel.Model);
|
||||
}
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
let view = this;
|
||||
|
||||
Api.Access.getAll()
|
||||
.then(response => {
|
||||
if (!view.isDestroyed()) {
|
||||
if (response && response.length) {
|
||||
view.showChildView('list_region', new TableBody({
|
||||
collection: new AccessListModel.Collection(response)
|
||||
}));
|
||||
} else {
|
||||
view.showChildView('list_region', new EmptyView());
|
||||
}
|
||||
|
||||
view.trigger('loaded');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
Controller.showError(err, 'Could not fetch Access Lists');
|
||||
view.trigger('loaded');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user