Feature: add routes

This commit is contained in:
2015-10-27 13:21:04 +00:00
parent ee9cc9b002
commit 4a3a6a5260
5 changed files with 81 additions and 30 deletions

View File

@@ -19,3 +19,5 @@ ecmascript # Enable ECMAScript2015+ syntax in app code
insecure # Allow all DB writes from clients (for prototyping) insecure # Allow all DB writes from clients (for prototyping)
twbs:bootstrap-noglyph twbs:bootstrap-noglyph
fortawesome:fontawesome fortawesome:fontawesome
iron:router
zenorocha:clipboard

View File

@@ -30,6 +30,14 @@ htmljs@1.0.5
http@1.1.1 http@1.1.1
id-map@1.0.4 id-map@1.0.4
insecure@1.0.4 insecure@1.0.4
iron:controller@1.0.12
iron:core@1.0.11
iron:dynamic-template@1.0.12
iron:layout@1.0.12
iron:location@1.0.11
iron:middleware-stack@1.0.11
iron:router@1.0.12
iron:url@1.0.11
jquery@1.11.4 jquery@1.11.4
launch-screen@1.0.4 launch-screen@1.0.4
livedata@1.0.15 livedata@1.0.15
@@ -65,3 +73,4 @@ underscore@1.0.4
url@1.0.5 url@1.0.5
webapp@1.2.2 webapp@1.2.2
webapp-hashing@1.0.5 webapp-hashing@1.0.5
zenorocha:clipboard@1.4.2

View File

@@ -2,21 +2,42 @@
<title>project-deployer</title> <title>project-deployer</title>
</head> </head>
<body> <template name="layout">
{{> nav}}
<div class="container-fluid">
{{> yield }}
</div>
</template>
<template name="nav">
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-brand" href="#"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
Project deployer <span class="sr-only">Toggle navigation</span>
</a> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Project deployer</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">
<a href="/management">Projects <span class="sr-only">(current)</span></a>
</li>
</ul>
</div> </div>
</div> </div>
</nav> </nav>
<div class="container-fluid"> </template>
<header>
</header> <template name="home">
<h1>Welcome to Project deployer</h1>
</template>
<template name="management">
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<h2>Register or edit a project</h2> <h2>Register or edit a project</h2>
@@ -31,8 +52,7 @@
</ul> </ul>
</div> </div>
</div> </div>
</div> </template>
</body>
<template name="projectForm"> <template name="projectForm">
<form class="new-project form-horizontal"> <form class="new-project form-horizontal">
@@ -90,10 +110,12 @@
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" disabled value="{{deployLink}}"/> <input type="text" id="deployLink" class="form-control" readonly="readonly" title="{{deployLink}}" value="{{deployLink}}"/>
<div class="input-group-addon"> <span class="input-group-btn">
<a class="btn btn-default clipboard" data-clipboard-target="#deployLink">
<i class="fa fa-fw fa-clipboard copy"></i> <i class="fa fa-fw fa-clipboard copy"></i>
</div> </a>
</span>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -3,16 +3,21 @@ Projects = new Mongo.Collection('projects');
if (Meteor.isClient) { if (Meteor.isClient) {
Meteor.subscribe('projects'); Meteor.subscribe('projects');
Template.body.helpers({ Template.management.helpers({
projects: function () { projects: function () {
return Projects.find({}, {sort: {label: 1}}); return Projects.find({}, {sort: {label: 1}});
} }
}); });
Template.projectForm.onRendered(function() {
new Clipboard('.btn.clipboard');
});
Template.projectForm.events({ Template.projectForm.events({
'submit .new-project': function (event) { 'submit .new-project': function (event) {
event.preventDefault(); event.preventDefault();
var form = event.target; var form = event.target;
console.log('handled', form.id.value);
if( form.id.value ) { if( form.id.value ) {
Meteor.call('editProject',form.id.value, form.label.value, form.git_url.value, form.public_url.value, form.commands.value); Meteor.call('editProject',form.id.value, form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
form.id.value = ''; form.id.value = '';
@@ -51,7 +56,7 @@ if (Meteor.isClient) {
}, },
deployLink: function() { deployLink: function() {
return Meteor.absoluteUrl('/deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id); return Meteor.absoluteUrl('deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id);
} }
}); });
@@ -82,15 +87,17 @@ Meteor.methods({
}, },
addProject: function(label, git_url, public_url ,commands) { addProject: function(label, git_url, public_url ,commands) {
console.log('addProjects', arguments);
Projects.insert({ Projects.insert({
label: label, label: label,
git_url: git_url, git_url: git_url,
public_url: public_url, public_url: public_url,
commands: commands commands: commands
}) });
}, },
editProject: function(id, label, git_url, public_url ,commands) { editProject: function(id, label, git_url, public_url ,commands) {
console.log('editProjects', arguments);
Projects.update( Projects.update(
id, id,
{ $set: { { $set: {

11
routes.js Normal file
View File

@@ -0,0 +1,11 @@
Router.configure({
layoutTemplate: 'layout' //can be any template name
});
Router.map(function () {
this.route('home', {
path: '/',
});
this.route('management');
});