sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This commit is contained in:
Martin Geno 2016-08-14 13:37:26 +02:00
commit 669faeae87
22 changed files with 769 additions and 0 deletions

3
.bowerrc Normal file
View File

@ -0,0 +1,3 @@
{
"directory": "public/bower_components"
}

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
node_modules
public/bower_components
build
tmp
.tmp
*.log
public/translations.js

411
Gruntfile.js Normal file
View File

@ -0,0 +1,411 @@
'use strict';
module.exports = function (grunt) {
// Load grunt tasks automatically, when needed
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
injector: 'grunt-asset-injector',
cdnify: 'grunt-google-cdn'
});
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
connect:{
public:{
options:{
port:8081,
hostname:"*",
base:['.tmp','public']
}
}
},
watch: {
injectJS: {
files: [
'public/{app,components}/**/*.js',
'!public/app/app.js'],
tasks: ['injector:scripts']
},
injectCss: {
files: [
'public/{app,components}/**/*.css'
],
tasks: ['injector:css']
},
injectStylus: {
files: [
'public/{app,components}/**/*.styl'],
tasks: ['injector:stylus']
},
stylus: {
files: [
'public/{app,components}/**/*.styl'],
tasks: ['stylus', 'autoprefixer']
},
jade: {
files: [
'public/{app,components}/*',
'public/{app,components}/**/*.jade'],
tasks: ['jade']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
files: [
'{.tmp,public}/{app,components}/**/*.css',
'{.tmp,public}/{app,components}/**/*.html',
'{.tmp,public}/{app,components}/**/*.js',
'public/img/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: true
}
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: 'public/.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'public/{app,components}/**/*.js',
]
},
// Empties folders to start fresh
clean: {
build: {
files: [{
dot: true,
src: [
'.tmp',
'tmp',
'build/*',
'!build/.git*',
'!build/.openshift',
'!build/Procfile'
]
}]
}
},
// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 1 version']
},
build: {
files: [{
expand: true,
cwd: '.tmp/',
src: '{,*/}*.css',
dest: '.tmp/'
}]
}
},
// Automatically inject Bower components into the app
wiredep: {
target: {
src: 'public/index.html',
ignorePath: 'public/',
exclude: ['/json3/', '/es5-shim/' ]
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: ['public/index.html'],
options: {
dest: 'build'
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['build/{,*/}*.html'],
css: ['build/{,*/}*.css'],
js: ['build/{,*/}*.js'],
options: {
assetsDirs: [
'build',
'build/img'
],
// This is so we update image references in our ng-templates
patterns: {
js: [
[/(img\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
}
},
// The following *-min tasks produce minified files in the dist folder
imagemin: {
build: {
files: [{
expand: true,
cwd: 'public/img',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: 'build/img'
}]
}
},
svgmin: {
build: {
files: [{
expand: true,
cwd: 'public/img',
src: '{,*/}*.svg',
dest: 'build/img'
}]
}
},
// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngAnnotate: {
build: {
files: [{
expand: true,
cwd: '.tmp/concat',
src: '*/**.js',
dest: '.tmp/concat'
}]
}
},
// Package all the html partials into a single javascript payload
ngtemplates: {
options: {
// This should be the name of your apps angular module
module: 'warehost',
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
},
usemin: 'app/app.js'
},
main: {
cwd: 'public',
src: ['{app,components}/**/*.html'],
dest: '.tmp/templates.js'
},
tmp: {
cwd: '.tmp',
src: ['{app,components}/**/*.html'],
dest: '.tmp/tmp-templates.js'
}
},
// Replace Google CDN references
cdnify: {
build: {
html: ['build/*.html']
}
},
// Copies remaining files to places other tasks can use
copy: {
build: {
files: [{
expand: true,
dot: true,
cwd: 'public',
dest: 'build',
src: [
'*.{ico,png,txt}',
'.htaccess',
//'bower_components/**/*',
'img/{,*/}*.{webp}',
'fonts/**/*',
'img/*.png',
'index.html'
]
},
{
expand: true,
cwd: 'public/bower_components/leaflet/dist/images',
dest: 'build/app/images',
src: [
'*.*'
]
},
{
expand: true,
cwd: 'public/bower_components/bootstrap/fonts',
dest: 'build/fonts',
src: [
'*.*'
]
},
{
expand: true,
cwd: '.tmp/img',
dest: 'build/img',
src: ['generated/*']
}]
},
styles: {
expand: true,
cwd: 'public',
dest: '.tmp/',
src: ['{app,components}/**/*.css']
}
},
// Run some tasks in parallel to speed up the build process
concurrent: {
all: [
'jade',
'stylus',
'imagemin',
'svgmin'
]
},
// Compiles Jade to html
jade: {
compile: {
options: {
data: {
debug: false
}
},
files: [{
expand: true,
cwd: 'public',
src: [
'{app,components}/**/*.jade'
],
dest: '.tmp',
ext: '.html'
}]
}
},
// Compiles Stylus to CSS
stylus: {
build: {
options: {
paths: [
'public/bower_components',
'public/app',
'public/components'
],
"include css": true
},
files: {
'.tmp/app/app.css' : 'public/app/app.styl'
}
}
},
injector: {
options: {
},
// Inject application script files into index.html (doesn't include bower)
scripts: {
options: {
transform: function(filePath) {
filePath = filePath.replace('/public/', '');
filePath = filePath.replace('/.tmp/', '');
return '<script src="' + filePath + '"></script>';
},
starttag: '<!-- injector:js -->',
endtag: '<!-- endinjector -->'
},
files: {
'public/index.html': [
['{.tmp,public}/{app,components}/**/*.js',
'!{.tmp,public}/app/app.js']
]
}
},
// Inject component styl into app.styl
stylus: {
options: {
transform: function(filePath) {
filePath = filePath.replace('/public/app/', '');
filePath = filePath.replace('/public/components/', '');
return '@import \'' + filePath + '\';';
},
starttag: '// injector',
endtag: '// endinjector'
},
files: {
'public/app/app.styl': [
'public/{app,components}/**/*.styl',
'!public/app/app.styl'
]
}
},
// Inject component css into index.html
css: {
options: {
transform: function(filePath) {
filePath = filePath.replace('/public/', '');
filePath = filePath.replace('/.tmp/', '');
return '<link rel="stylesheet" href="' + filePath + '">';
},
starttag: '<!-- injector:css -->',
endtag: '<!-- endinjector -->'
},
files: {
'public/index.html': [
'public/{app,components}/**/*.css'
]
}
}
}
});
grunt.registerTask('serve', [
'clean:build',
'injector:stylus',
'concurrent:all',
'injector',
'wiredep',
'autoprefixer',
'connect:public',
'watch'
]);
grunt.registerTask('build', [
'newer:jshint',
'clean:build',
'injector:stylus',
'concurrent:all',
'injector',
'wiredep',
'useminPrepare',
'autoprefixer',
'ngtemplates',
'concat',
'ngAnnotate',
'copy:build',
'cssmin',
'uglify',
'usemin'
]);
grunt.registerTask('default', [
'serve'
]);
};

22
bower.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "warehost client",
"authors": [
"Martin Geno <geno+dev@fireorbit.de>"
],
"description": "",
"main": "",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular-ui-router": "^0.3.1",
"angular-bootstrap": "^1.3.3",
"bootstrap": "^3.3.6",
"bootswatch": "^3.3.7"
}
}

35
package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "freifunkmanager",
"version": "1.0.0",
"description": "Eventmanager for respond-collector",
"main": "Gruntfile.js",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-angular-templates": "^0.5.9",
"grunt-ng-annotate": "^1.0.1",
"grunt-autoprefixer": "^3.0.3",
"grunt-concurrent": "^2.1.0",
"grunt-contrib-clean": "^0.7.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.2",
"grunt-contrib-cssmin": "^0.14.0",
"grunt-contrib-htmlmin": "^0.6.0",
"grunt-contrib-imagemin": "^1.0.0",
"grunt-contrib-jade": "^0.15.0",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-stylus": "^0.22.0",
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-google-cdn": "^0.4.3",
"grunt-newer": "^1.1.1",
"grunt-svgmin": "^3.1.0",
"grunt-usemin": "^3.1.1",
"grunt-wiredep": "^2.0.0",
"jit-grunt": "^0.9.1",
"jshint-stylish": "^2.1.0",
"time-grunt": "^1.2.2"
},
"scripts": {
"start": "grunt serve"
}
}

41
public/.jshintrc Normal file
View File

@ -0,0 +1,41 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"globals": {
"jQuery": true,
"angular": true,
"L": true,
"lvector": true,
"sypOn": true,
"console": true,
"$": true,
"_": true,
"moment": true,
"describe": true,
"beforeEach": true,
"module": true,
"inject": true,
"it": true,
"expect": true,
"browser": true,
"element": true,
"by": true
}
}

16
public/app/app.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
angular.module('warehost', [
'ui.router',
'ui.bootstrap',
'config',
'session'
])
.config(['$urlRouterProvider','$httpProvider',function($urlRouterProvider,$httpProvider){
$urlRouterProvider.otherwise('/');
$httpProvider.defaults.withCredentials = true;
}]).run(function(session,config,$http) {
$http.get(config.api+'/status').then(function(res){
session.set(res);
});
});

7
public/app/app.styl Normal file
View File

@ -0,0 +1,7 @@
.navbar-brand
padding 13.5px 15px 12.5px
> img
display inline
margin 0 10px
height 100%

5
public/app/home.jade Normal file
View File

@ -0,0 +1,5 @@
.container
h1 Welcome on Warehost
p We offer a lot of free Services here!
p Feel free to test and use them.

25
public/app/index.js Normal file
View File

@ -0,0 +1,25 @@
'use strict';
angular.module('warehost')
.config(['$stateProvider',function ($stateProvider) {
$stateProvider
.state('app', {
templateUrl: 'app/main.html',
controller: 'MainCtrl'
})
.state('app.index', {
url:'/',
templateUrl: 'app/home.html'
})
.state('app.L', {
templateUrl: 'app/loggedin.html'
})
.state('app.L.settings', {
url:'/settings',
templateUrl: 'app/settings.html',
controller: 'SettingsCtrl'
})
.state('app.L.invites', {
url:'/invites',
templateUrl: 'app/invites.html'
});
}]);

2
public/app/invites.jade Normal file
View File

@ -0,0 +1,2 @@
.container
h1 Invites

5
public/app/loggedin.jade Normal file
View File

@ -0,0 +1,5 @@
div(ng-if="session.login.active",ui-view="")
div(ng-if="!session.login.active")
.container
h1 Not Loggedin
.alert.alert-danger This area is only for a loggedin person visible!

41
public/app/main.jade Normal file
View File

@ -0,0 +1,41 @@
.navbar.navbar-default.navbar-fixed-top
.container-fluid
.navbar-header
a.navbar-brand(ui-sref="app.index")
img(src="/favicon.ico")
| Warehost
button.navbar-toggle.collapsed(ng-click="toggleOpen()")
span.sr-only Toggle navigation
span.icon-bar
span.icon-bar
span.icon-bar
.navbar-collapse.collapse(uib-collapse="!isOpen")
ui.nav.navbar-nav
li(ng-if="session.profil.shift",ui-sref="app.shift.index",ng-class="{ active: $state.includes('app.shift') }")
a(nav navbar-nav) Shift
li(ng-if="session.profil.host",ui-sref="app.host.index",ng-class="{ active: $state.includes('app.host') }")
a(nav navbar-nav) Hosting
ui.nav.navbar-nav.navbar-right(ng-if="session.login.active")
li
a(ui-sref="app.L.invites",ui-sref-active="active")
span.glyphicon.glyphicon-send
| &nbsp;Invites
li(ng-if="session.login.superadmin")
a(ui-sref="app.A.admin",ui-sref-active="active")
span.glyphicon.glyphicon-cog
| &nbsp;Admin
.navbar-text(ng-class="{ 'active': $state.includes('app.L.settings') }")
| Welcome
a(ui-sref="app.L.settings",ui-sref-active="active") {{session.login.username}}
| &nbsp;
span.glyphicon.glyphicon-user
.navbar-text
span.glyphicon.glyphicon-log-out(ng-click="logout()")
form.navbar-form.navbar-right(ng-if="!session.login.active",ng-class="{'has-warning':globals.currentUser.authdata}",ng-submit="login()")
input.form-control(ng-model="obj.username",placeholder="Username")
.input-group
input.form-control(type="password",ng-model="obj.password",placeholder="Password")
.input-group-btn
button.btn.btn-default(type="submit")
span.glyphicon.glyphicon-log-in
div(ui-view="",style="margin-top:53px;")

23
public/app/main.js Normal file
View File

@ -0,0 +1,23 @@
'use strict';
angular.module('warehost')
.controller('MainCtrl',function($scope,$http,$state,config,session){
$scope.isOpen = false;
$scope.obj = {};
$scope.$state = $state;
$scope.toggleOpen = function(){
$scope.isOpen = !$scope.isOpen;
};
$scope.logout = function(){
$http.get(config.api+'/logout').then(function(res){
session.set(res);
});
};
$scope.login = function(){
$http.post(config.api+'/login',$scope.obj).then(function(res){
session.set(res);
$scope.obj = {};
});
};
});

29
public/app/settings.jade Normal file
View File

@ -0,0 +1,29 @@
.container
h1 Settings
.row
.col-md-6
h2 Global
form.well.well-sm(ng-submit="submit()")
.form-group
label(for="globalUsername") Username
input.form-control(id="globalUsername",ng-model="session.login.username",readonly)
.form-group
label(for="currentPassword") Current Password
input.form-control(id="currentPassword",type="password",ng-model="obj.currentPassword")
.form-group
label(for="newPassword") New Password
input.form-control(id="newPassword",type="password",ng-model="obj.newPassword")
.form-group
label(for="repeatPassword") Again Password
input.form-control(id="repeatPassword",type="password",ng-model="obj.repeatPassword")
.row
.col-xs-6
button.btn.btn-primary(type="submit")
span.glyphicon.glyphicon-floppy-disk
| Save
.col-xs-6.text-right
a.btn.btn-danger(ng-click="delete()")
span.glyphicon.glyphicon-trash
| Delete
.col-md-6
h2 Profiles

19
public/app/settings.js Normal file
View File

@ -0,0 +1,19 @@
'use strict';
angular.module('warehost')
.controller('SettingsCtrl',function(session,config,$scope,$http){
$scope.obj = {};
$scope.submit = function(){
$http.post(config.api+'/password',$scope.obj).then(function(res){
session.set(res);
$scope.obj = {};
});
};
$scope.delete = function(){
if(confirm("realy delete your login and everything else on warehost?")){
$http.get(config.api+'/delete').then(function(res){
session.set(res);
});
}
}
});

View File

View File

@ -0,0 +1,7 @@
'use strict';
angular.module('config', [])
.factory('config', function() {
return {
api: 'http://[::1]:8080',
};
});

View File

@ -0,0 +1,13 @@
'use strict';
angular.module('session', [])
.factory('session', ['$rootScope',function($rootScope) {
return {
get: function (){
return $rootScope.session;
},
set: function (res){
$rootScope.session = res.data.session;
console.log(res,$rootScope.session);
}
};
}]);

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

56
public/index.html Normal file
View File

@ -0,0 +1,56 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title>Warehost v2</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<!-- build:css(public) app/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/lumen/bootstrap.min.css" />
<!-- endbuild -->
<!-- build:css({.tmp,public}) app/app.css -->
<link rel="stylesheet" href="app/app.css">
<!-- injector:css -->
<!-- endinjector -->
<!-- endbuild -->
</head>
<body ng-app="warehost">
<!--[if lt IE 9]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<div ui-view=""></div>
<!-- build:js(public) app/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,public}) app/app.js -->
<script src="app/app.js"></script>
<!-- injector:js -->
<script src="app/index.js"></script>
<script src="app/main.js"></script>
<script src="app/settings.js"></script>
<script src="app/shift/index.js"></script>
<script src="components/config.js"></script>
<script src="components/session.js"></script>
<!-- endinjector -->
<!-- endbuild -->
</body>
</html>

0
tests/index.coffee Normal file
View File