Optim: multi files organisation

This commit is contained in:
2015-10-29 13:39:28 +00:00
parent e4022bf5bd
commit 37908bdb9f
10 changed files with 99 additions and 111 deletions

10
client/body.html Normal file
View File

@@ -0,0 +1,10 @@
<template name="layout">
{{> nav}}
<div class="container-fluid">
{{> yield }}
</div>
</template>
<template name="home">
<h1>Welcome to Project deployer</h1>
</template>

3
client/head.html Normal file
View File

@@ -0,0 +1,3 @@
<head>
<title>project-deployer</title>
</head>

23
client/nav.html Normal file
View File

@@ -0,0 +1,23 @@
<template name="nav">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<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>
</nav>
</template>

102
client/projects.html Normal file
View File

@@ -0,0 +1,102 @@
<template name="management">
<div class="row">
<div class="col-sm-6">
<h2>Register or edit a project</h2>
{{> projectForm}}
</div>
<div class="col-sm-6">
<h2>Your projects</h2>
<ul>
{{#each projects}}
{{> project}}
{{/each}}
</ul>
</div>
</div>
</template>
<template name="projectForm">
<form class="new-project form-horizontal">
<input type="hidden" name="id" value="{{project._id}}" />
<div class="form-group">
<label for="label" class="col-sm-2 control-label">
<i class="fa fa-fw fa-tag fa-2x" title="Label"></i>
</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="label" placeholder="Label" value="{{project.label}}" required/>
</div>
</div>
<div class="form-group">
<label for="git_url" class="col-sm-2 control-label">
<i class="fa fa-fw fa-github fa-2x" title="Git clone URL"></i>
</label>
<div class="col-sm-10">
<input type="url" class="form-control" name="git_url" placeholder="Git clone URL" value="{{project.git_url}}" required/>
</div>
</div>
<div class="form-group">
<label for="public_url" class="col-sm-2 control-label">
<i class="fa fa-fw fa-external-link fa-2x" title="Public URL"></i>
</label>
<div class="col-sm-10">
<input type="url" class="form-control" name="public_url" placeholder="Public URL" value="{{project.public_url}}" required/>
</div>
</div>
<div class="form-group">
<label for="commands" class="col-sm-2 control-label">
<i class="fa fa-fw fa-terminal fa-2x" title="Commands"></i>
</label>
<div class="col-sm-10">
<textarea class="form-control" cols="25" rows="5" placeholder="Commands" value="{{project.commands}}" name="commands"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">
<i class="fa fa-fw fa-floppy-o"></i>
</button>
<a href="#" class="btn btn-default cancel">
<i class="fa fa-fw fa-ban"></i>
</a>
<a href="#" class="btn btn-danger trash {{editionMode}}">
<i class="fa fa-fw fa-trash"></i>
</a>
</div>
</div>
{{#with project}}
<div class="form-group ">
<label class="col-sm-2 control-label">
<i class="fa fa-fw fa-cog fa-2x" title="Link to provide to CI (Travis)"></i>
</label>
<div class="col-sm-10">
<div class="input-group">
<input type="text" id="deployLink" class="form-control" readonly="readonly" title="{{deployLink}}" value="{{deployLink}}"/>
<span class="input-group-btn">
<a class="btn btn-default clipboard" data-clipboard-target="#deployLink">
<i class="fa fa-fw fa-clipboard copy"></i>
</a>
</span>
</div>
</div>
</div>
{{/with}}
</form>
</template>
<template name="project">
<li>
{{label}}
<a href="{{public_url}}" target="_blank" title="Go to the deployed project">
<i class="fa fa-fw fa-external-link"></i>
</a>
<a href="{{git_url}}" target="_blank" title="Go to the Github repository">
<i class="fa fa-fw fa-github"></i>
</a>
<a href="#" class="edit" title="Edit the project">
<i class="fa fa-fw fa-pencil"></i>
</a>
</li>
</template>

64
client/projects.js Normal file
View File

@@ -0,0 +1,64 @@
Template.management.helpers({
projects: function () {
return ProjectService.list();
}
});
Template.projectForm.onRendered(function() {
new Clipboard('.btn.clipboard');
});
Template.projectForm.events({
'submit .new-project': function (event) {
event.preventDefault();
var form = event.target;
if( form.id.value ) {
Meteor.call('editProject',form.id.value, form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
form.id.value = '';
} else {
Meteor.call('addProject', form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
}
Session.set('projectToEdit', undefined);
form.label.value = '';
form.git_url.value = '';
form.public_url.value = '';
form.commands.value = '';
},
'click .cancel': function(event) {
event.preventDefault();
Session.set('projectToEdit', undefined);
},
'click .trash': function(event) {
event.preventDefault();
Meteor.call('deleteProject', Session.get('projectToEdit')._id);
Session.set('projectToEdit', undefined);
}
});
Template.projectForm.helpers({
project: function() {
return Session.get('projectToEdit');
},
editionMode: function() {
return Session.get('projectToEdit') ? '' : 'hidden';
},
deployLink: function() {
return Meteor.absoluteUrl('deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id);
}
});
Template.project.events({
'click .edit': function(event) {
event.preventDefault();
return Meteor.call('getProject', this._id, function(error, result) {
Session.set('projectToEdit', result);
});
},
});

1
client/style.css Normal file
View File

@@ -0,0 +1 @@
/* CSS declarations go here */

1
client/subscriptions.js Normal file
View File

@@ -0,0 +1 @@
Meteor.subscribe('projects');