mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
List missions
This commit is contained in:
parent
7b863098a9
commit
92e2c02b8d
15
public/js/app/collections/missions.js
Normal file
15
public/js/app/collections/missions.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone'),
|
||||||
|
Mission = require('app/models/mission');
|
||||||
|
|
||||||
|
return Backbone.Collection.extend({
|
||||||
|
model: Mission,
|
||||||
|
url: '/api/missions/'
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
32
public/js/app/forms/mission.js
Normal file
32
public/js/app/forms/mission.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone'),
|
||||||
|
Marionette = require('marionette'),
|
||||||
|
FormView = require('marionette-formview'),
|
||||||
|
Settings = require('app/models/settings'),
|
||||||
|
tpl = require('text!tpl/forms/settings.html');
|
||||||
|
|
||||||
|
return FormView.extend({
|
||||||
|
template: _.template(tpl),
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
path: {
|
||||||
|
el: ".mission",
|
||||||
|
required: "Please select a file."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
var self = this;
|
||||||
|
new Mission().fetch({success: function (model, response, options) {
|
||||||
|
self.model = model;
|
||||||
|
self.runInitializers();
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -25,10 +25,6 @@ define(function (require) {
|
|||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
new Settings().fetch({success: function (model, response, options) {
|
|
||||||
self.model = model;
|
|
||||||
self.runInitializers();
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
15
public/js/app/models/mission.js
Normal file
15
public/js/app/models/mission.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone');
|
||||||
|
|
||||||
|
return Backbone.Model.extend({
|
||||||
|
defaults: {
|
||||||
|
title: ''
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -7,22 +7,27 @@ define(function (require) {
|
|||||||
LayoutView = require('app/views/layout'),
|
LayoutView = require('app/views/layout'),
|
||||||
NavigationView = require('app/views/navigation'),
|
NavigationView = require('app/views/navigation'),
|
||||||
HomeView = require('app/views/home'),
|
HomeView = require('app/views/home'),
|
||||||
|
MissionsListView= require('app/views/missions/list'),
|
||||||
ModsListView = require('app/views/mods/list'),
|
ModsListView = require('app/views/mods/list'),
|
||||||
ServerView = require('app/views/servers/view'),
|
ServerView = require('app/views/servers/view'),
|
||||||
|
Missions = require('app/collections/missions'),
|
||||||
Mods = require('app/collections/mods'),
|
Mods = require('app/collections/mods'),
|
||||||
Servers = require('app/collections/servers'),
|
Servers = require('app/collections/servers'),
|
||||||
|
|
||||||
$body = $('body'),
|
$body = $('body'),
|
||||||
|
missions = new Missions(),
|
||||||
mods = new Mods(),
|
mods = new Mods(),
|
||||||
servers = new Servers(),
|
servers = new Servers(),
|
||||||
layoutView = new LayoutView({el: $body}).render(),
|
layoutView = new LayoutView({el: $body}).render(),
|
||||||
navigationView = new NavigationView({servers: servers}),
|
navigationView = new NavigationView({servers: servers}),
|
||||||
homeView = new HomeView({servers: servers}),
|
homeView = new HomeView({servers: servers}),
|
||||||
|
missionsListView = new MissionsListView({collection: missions}),
|
||||||
modsListView = new ModsListView({collection: mods});
|
modsListView = new ModsListView({collection: mods});
|
||||||
|
|
||||||
return Backbone.Router.extend({
|
return Backbone.Router.extend({
|
||||||
|
|
||||||
routes: {
|
routes: {
|
||||||
|
"missions": "missions",
|
||||||
"mods": "mods",
|
"mods": "mods",
|
||||||
"servers/:id": "server",
|
"servers/:id": "server",
|
||||||
"": "home",
|
"": "home",
|
||||||
@ -30,6 +35,7 @@ define(function (require) {
|
|||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
layoutView.navigation.show(navigationView);
|
layoutView.navigation.show(navigationView);
|
||||||
|
missions.fetch();
|
||||||
mods.fetch();
|
mods.fetch();
|
||||||
servers.fetch();
|
servers.fetch();
|
||||||
},
|
},
|
||||||
@ -39,6 +45,11 @@ define(function (require) {
|
|||||||
homeView.delegateEvents();
|
homeView.delegateEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
missions: function () {
|
||||||
|
layoutView.content.show(missionsListView);
|
||||||
|
missionsListView.delegateEvents();
|
||||||
|
},
|
||||||
|
|
||||||
mods: function () {
|
mods: function () {
|
||||||
layoutView.content.show(modsListView);
|
layoutView.content.show(modsListView);
|
||||||
modsListView.delegateEvents();
|
modsListView.delegateEvents();
|
||||||
|
15
public/js/app/views/missions/list.js
Normal file
15
public/js/app/views/missions/list.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone'),
|
||||||
|
Marionette = require('marionette'),
|
||||||
|
ListItemView = require('app/views/missions/list_item');
|
||||||
|
|
||||||
|
return Marionette.CollectionView.extend({
|
||||||
|
tagName: 'ul',
|
||||||
|
itemView: ListItemView,
|
||||||
|
});
|
||||||
|
});
|
17
public/js/app/views/missions/list_item.js
Normal file
17
public/js/app/views/missions/list_item.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone'),
|
||||||
|
Marionette = require('marionette'),
|
||||||
|
tpl = require('text!tpl/missions/list_item.html'),
|
||||||
|
|
||||||
|
template = _.template(tpl);
|
||||||
|
|
||||||
|
return Marionette.ItemView.extend({
|
||||||
|
tagName: "li",
|
||||||
|
template: template
|
||||||
|
});
|
||||||
|
});
|
8
public/js/tpl/forms/mission.html
Normal file
8
public/js/tpl/forms/mission.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<form class="form-horizontal" role="form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="file" class="col-sm-2 control-label">File</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="file" class="form-control path" id="file" data-field="file" placeholder="Mission to upload">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
1
public/js/tpl/missions/list_item.html
Normal file
1
public/js/tpl/missions/list_item.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href='#missions/<%-name%>'><%-name%></a>
|
@ -12,6 +12,7 @@
|
|||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li><a href="#" id="dashboard">Dashboard</a></li>
|
<li><a href="#" id="dashboard">Dashboard</a></li>
|
||||||
|
<li><a href="#missions" id="missions">Missions</a></li>
|
||||||
<li><a href="#mods" id="mods">Mods</a></li>
|
<li><a href="#mods" id="mods">Mods</a></li>
|
||||||
<li><a href="#" id="settings">Settings</a></li>
|
<li><a href="#" id="settings">Settings</a></li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
|
@ -8,13 +8,25 @@ exports.index = function(req, res){
|
|||||||
if (err) {
|
if (err) {
|
||||||
res.send(err);
|
res.send(err);
|
||||||
} else {
|
} else {
|
||||||
res.send(files);
|
var missions = files.map(function (filename) {
|
||||||
|
return { name: filename }
|
||||||
|
});
|
||||||
|
res.send(missions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.create = function(req, res){
|
exports.create = function(req, res){
|
||||||
res.send('create mission');
|
res.send('create mission');
|
||||||
|
|
||||||
|
var missionFile = req.files.mission;
|
||||||
|
|
||||||
|
fs.readFile(missionFile.path, function (err, data) {
|
||||||
|
var newPath = config.path + '/mpmissions' + missionFile.name;
|
||||||
|
fs.writeFile(newPath, data, function (err) {
|
||||||
|
res.json(missionFile);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.show = function(req, res){
|
exports.show = function(req, res){
|
||||||
|
Loading…
Reference in New Issue
Block a user