LT-67 Fixing navigation issues and implementing server's removal
This commit is contained in:
parent
16a302e979
commit
1ca585bfb0
@ -3,7 +3,9 @@ Template.serverInformationDimse.onCreated(function() {
|
||||
instance.peers = new ReactiveVar([]);
|
||||
instance.autorun(function() {
|
||||
var currentItem = instance.data.currentItem.get();
|
||||
instance.peers.set(currentItem.peers || []);
|
||||
if (currentItem) {
|
||||
instance.peers.set(currentItem.peers || []);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Template.serverInformationForm.events({
|
||||
console.log('>>>>ERROR', error);
|
||||
}
|
||||
|
||||
instance.data.mode.set('list');
|
||||
instance.data.resetState();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -14,10 +14,10 @@
|
||||
<td>{{this.type}}</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group" role="group" aria-label="Actions">
|
||||
<button class="btn btn-sm btn-default editServer" {{tooltipTop "Edit"}}>
|
||||
<button class="btn btn-sm btn-default js-edit-server" title="Edit">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger removeServer" {{tooltipTop "Remove"}}>
|
||||
<button class="btn btn-sm btn-danger js-remove-server" title="Remove">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -30,7 +30,7 @@
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="btn btn-default addServer">
|
||||
<button class="btn btn-default js-add-server">
|
||||
<i class="fa fa-plus"></i> Add a new server
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@ -1,34 +1,24 @@
|
||||
Template.serverInformationList.onRendered(function() {
|
||||
var instance = Template.instance();
|
||||
instance.$('[data-toggle="tooltip"]').tooltip({
|
||||
container: 'body'
|
||||
});
|
||||
});
|
||||
|
||||
Template.serverInformationList.onDestroyed(function() {
|
||||
var instance = Template.instance();
|
||||
instance.$('[data-toggle="tooltip"]').tooltip('destroy');
|
||||
});
|
||||
|
||||
Template.serverInformationList.helpers({
|
||||
tooltipTop: function(title) {
|
||||
return {
|
||||
'data-toggle': 'tooltip',
|
||||
'data-placement': 'top',
|
||||
title: title
|
||||
};
|
||||
},
|
||||
servers: function() {
|
||||
return Servers.find().fetch();
|
||||
}
|
||||
});
|
||||
|
||||
Template.serverInformationList.events({
|
||||
'click .addServer': function(event, instance) {
|
||||
'click .js-add-server': function(event, instance) {
|
||||
instance.data.mode.set('create');
|
||||
},
|
||||
'click .editServer': function(event, instance) {
|
||||
'click .js-edit-server': function(event, instance) {
|
||||
instance.data.currentItem.set(this);
|
||||
instance.data.mode.set('edit');
|
||||
},
|
||||
'click .js-remove-server': function(event, instance) {
|
||||
var id = this._id;
|
||||
Meteor.call('removeServer', this._id, function(error) {
|
||||
if (error) {
|
||||
// TODO: check for errors: not-authorized, data-write
|
||||
console.log('>>>>ERROR', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -4,14 +4,17 @@ Template.serverInformationModal.onCreated(function() {
|
||||
mode: new ReactiveVar('list'),
|
||||
serverType: new ReactiveVar(null),
|
||||
currentItem: new ReactiveVar(null),
|
||||
$form: null
|
||||
$form: null,
|
||||
resetState: function() {
|
||||
instance.container.mode.set('list');
|
||||
instance.container.serverType.set(null);
|
||||
instance.container.currentItem.set(null);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Template.serverInformationModal.events({
|
||||
'click .js-back': function(event, instance) {
|
||||
var container = instance.container;
|
||||
container.mode.set('list');
|
||||
container.serverType.set(null);
|
||||
'click .js-back, click [data-dismiss=modal]': function(event, instance) {
|
||||
instance.container.resetState();
|
||||
}
|
||||
});
|
||||
|
||||
@ -12,12 +12,13 @@ Meteor.startup(function() {
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
|
||||
saveServer: function(serverSettings) {
|
||||
if (!Meteor.userId()) {
|
||||
throw new Meteor.Error('not-authorized');
|
||||
}
|
||||
|
||||
var criteria = {
|
||||
var query = {
|
||||
_id: serverSettings._id
|
||||
};
|
||||
var options = {
|
||||
@ -35,6 +36,14 @@ Meteor.methods({
|
||||
|
||||
};
|
||||
|
||||
Servers.update(criteria, serverSettings, options, callback);
|
||||
Servers.update(query, serverSettings, options, callback);
|
||||
},
|
||||
|
||||
removeServer: function(serverId) {
|
||||
var query = {
|
||||
_id: serverId
|
||||
};
|
||||
Servers.remove(query, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user