Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
# How start the project
## Cotize

## Prerequises
Also known as "Bons comptes" is a java web app that helps friends to collect pledges in order to buy gift for birthday or other events.
- Cotize do not collect any money, just pledges. So make sure your friends are trustworthy :)
- Cotize is released under a derivate licence of the [WTFPL](http://www.wtfpl.net). So you can do anything you want to with it

- Java 8
### Installation
#### Prerequises
- JDK8
- Maven
- MongoDB

## Actions
#### Get, Build, Run
1. Get: `git clone https://github.com/barmic/cotize.git`
2. Go to main folder: `cd cotize`
3. Configure by editing file: `./infra/run-config.json` (See below for config examples)
4. Buid: `mvn clean package`
5. Run: `java -jar target/BonsComptes-jar-with-dependencies.jar -conf run-config.json`
6. Test by accessing: http://localhost:5000/

- Require : JDK8, Apache Maven
- To build run : mvn clean package
- Run application : java -jar target/BonsComptes-jar-with-dependencies.jar -conf run-config.json
- Access http://localhost:5000/

### Example of run-config.json
#### Example of run-config.json

```json
{
"root_secret" : "abcdefghijkl",
"root_secret" : "abcdefghijkl",
"base_url": "http://localhost:5000",
"mail" : {
"user" : "user@example.com",
"password" : "<password>",
"port" : 465,
"host" : "smtp.example.com"
"host" : "smtp.example.com",
"use_ssl" : true
},
"mongo" : {
"host" : "localhost",
"port" : 27017,
"collection" : "CotizeEvents",
"dbname" : "bonscomptes"
"host" : "localhost",
"port" : 27017,
"collection" : "CotizeEvents",
"dbname" : "bonscomptes"
}
}
```
Expand All @@ -37,3 +44,16 @@
- base_url : url used for link send by mail
- mail : informations for send email
- mongo : informations to access to mongodb

#### Mail settings in run-config.js

| | Gmail | Lilo |
|----------|----------------|---------------|
| user | user@gmail.com | user@lilo.org |
| password | password | password |
| port | 465 | 587 |
| host | smtp.gmail.com | mail.lilo.org |
| use_ssl | true | false |

### Install Cotize as a Linux service
TODO
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ MongoClient provideMongoClient(Vertx vertx) {
MailClient provideMailClient() {
JsonObject mailConfig = this.config.getJsonObject("mail");
MailConfig config = new MailConfig().setHostname(mailConfig.getString("host"))
.setSsl(true)
.setPort(mailConfig.getInteger("port"))
.setSsl(mailConfig.getBoolean("use_ssl", true))
.setPort(mailConfig.getInteger("port", 587))
.setUsername(mailConfig.getString("user"))
.setPassword(mailConfig.getString("password"));

Expand Down
75 changes: 75 additions & 0 deletions backend/src/main/resources/cotize-js/event_store-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

/** @module cotize-js/event_store */
!function (factory) {
if (typeof require === 'function' && typeof module !== 'undefined') {
factory();
} else if (typeof define === 'function' && define.amd) {
// AMD loader
define('cotize-js/event_store-proxy', [], factory);
} else {
// plain old include
EventStore = factory();
}
}(function () {

/**
@class
*/
var EventStore = function(eb, address) {

var j_eb = eb;
var j_address = address;
var closed = false;
var that = this;
var convCharCollection = function(coll) {
var ret = [];
for (var i = 0;i < coll.length;i++) {
ret.push(String.fromCharCode(coll[i]));
}
return ret;
};

/**

@public
@param projectId {string}
@param resultHandler {function}
*/
this.loadEvents = function(projectId, resultHandler) {
var __args = arguments;
if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') {
if (closed) {
throw new Error('Proxy is closed');
}
j_eb.send(j_address, {"projectId":__args[0]}, {"action":"loadEvents"}, function(err, result) { __args[1](err, result &&result.body); });
return;
} else throw new TypeError('function invoked with invalid arguments');
};

};

if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = EventStore;
} else {
exports.EventStore = EventStore;
}
} else {
return EventStore;
}
});
59 changes: 59 additions & 0 deletions backend/src/main/resources/cotize-js/event_store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

/** @module cotize-js/event_store */
var utils = require('vertx-js/util/utils');

var io = Packages.io;
var JsonObject = io.vertx.core.json.JsonObject;
var JEventStore = net.bons.comptes.service.EventStore;
var DecisionProjectionProject = net.bons.comptes.service.model.DecisionProjectionProject;

/**
@class
*/
var EventStore = function(j_val) {

var j_eventStore = j_val;
var that = this;

/**

@public
@param projectId {string}
@param resultHandler {function}
*/
this.loadEvents = function(projectId, resultHandler) {
var __args = arguments;
if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') {
j_eventStore["loadEvents(java.lang.String,io.vertx.core.Handler)"](projectId, function(ar) {
if (ar.succeeded()) {
resultHandler(utils.convReturnDataObject(ar.result()), null);
} else {
resultHandler(null, ar.cause());
}
});
} else throw new TypeError('function invoked with invalid arguments');
};

// A reference to the underlying Java delegate
// NOTE! This is an internal API and must not be used in user code.
// If you rely on this property your code is likely to break if we change it / remove it without warning.
this._jdel = j_eventStore;
};

// We export the Constructor function
module.exports = EventStore;
Binary file added backend/src/main/resources/public/fav.ico
Binary file not shown.
27 changes: 14 additions & 13 deletions backend/src/main/resources/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html data-ng-app="cotizeApp">
<html lang="fr" data-ng-app="cotizeApp">
<head>
<!--
Licence Public Barmic
Expand All @@ -13,27 +13,28 @@
<meta name="author" content="Michel Barret">

<title>Cotize</title>
<link rel="icon" href="fav.ico" />

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<!--<link rel="stylesheet" href="static/css/styles.css" />-->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/trix/1.0.0/trix.css">

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular-sanitize.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular-route.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/trix/1.0.0/trix.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>

<script src="//code.angularjs.org/1.4.7/angular.js" ></script>
<script src="//code.angularjs.org/1.4.7/angular-route.js" ></script>
<script src="js/cotizeModule.js" ></script>
<script src="js/cotizeServices.js" ></script>
<script src="js/cotizeControllers.js" ></script>
<script src="js/angular-trix.min.js" ></script>

<!-- Grab jQuery from a CDN, fall back to local if necessary -->
<script src="//code.jquery.com/jquery-2.2.1.min.js"></script>
<script type="text/javascript">/* <![CDATA[ */
!window.jQuery && document.write('<script type="text/javascript" src="/javascripts/jquery.min.js"><\/script>')
/* ]]> */</script>
</head>
<body role="document" data-ng-cloak>
<div class="container">
<div class="row">
<header class="col-sm-8 col-sm-offset-2 page-header">
<header class="col-sm-9 col-sm-offset-2 page-header">
<h1><a href="/#/" title="Accueil">Cotize</a>
<small>Les projets de cadeaux participatifs !</small>
</h1>
Expand All @@ -43,4 +44,4 @@ <h1><a href="/#/" title="Accueil">Cotize</a>
<div data-ng-view></div>
</div>
</body>
</html>
</html>
4 changes: 4 additions & 0 deletions backend/src/main/resources/public/js/angular-trix.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion backend/src/main/resources/public/js/cotizeModule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var cotizeModule = angular.module('cotizeApp', [
'ngRoute',
'ngSanitize',
'angularTrix',
'cotizeControllers'
]);

Expand Down Expand Up @@ -29,4 +31,4 @@ cotizeModule.config(['$routeProvider',
otherwise({
redirectTo: '/index'
});
}]);
}]);
24 changes: 13 additions & 11 deletions backend/src/main/resources/public/partials/contribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
-->
<div id="project">
<h2>{{ project.content.name }}</h2>
<p>{{ project.content.description }}</p>
<p ng-bind-html="project.content.description"></p>

<h3>Contribution de {{ contribution.author }}</h3>
<h3>Contributions</h3>
<p>Le projet a déjà réunis {{ project.content.amount }} € !</p>

<div class="alert alert-danger" role="alert" data-ng-if="newcontrib.state == 'error' || loadingdata.error">
Expand All @@ -22,17 +22,19 @@ <h3>Erreur !</h3>
<h3>Votre contribution a était mise à jour !</h3>
</div>

<div role="form" data-ng-if="isUndefined(contribution.payed) || !contribution.payed">
<div class="form-horizontal" role="form" data-ng-if="isUndefined(contribution.payed) || !contribution.payed">
<h3>{{ contribution.author }}, participez</h3>
<fieldset>
<div class="control-group">
<label for="amount" class="control-label">{{ !contribution.payed ? "Changez votre participation ?" : "Votre contribution a déjà était payée, vous ne pouvez l'éditer."}}</label>
<div class="input-controls">
<input type="number" min="1" class="form-control" name="amount" placeholder="{{contribution.amount}} €" data-ng-model="contribution.amount" data-ng-readonly="contribution.payed" required />
<span class="input-group-addon">€</span>
<div class="container">
<div class="form-group">
<div class="col-sm-4 col-lg-3 control-group">
<label for="amount" class="control-label">{{ !contribution.payed ? "Changez votre participation ?" : "Votre contribution a déjà était payée, vous ne pouvez l'éditer."}}</label>
<div class="input-group">
<input id="amount" type="number" min="1" class="form-control" name="amount" placeholder="{{contribution.amount}} €" data-ng-model="contribution.amount" data-ng-readonly="contribution.payed" required />
<span class="input-group-addon">€</span>
</div>
</div>
</div>
</div>
<br/>
<div class="form-action">
<button data-ng-disabled="contribution.payed" data-ng-click="contrib.update()" type="submit" class="btn btn-primary">Participer</button>
</div>
</fieldset>
Expand Down
Loading