Skip to content

Commit 149c2cc

Browse files
committed
awesome directive
1 parent e530ce7 commit 149c2cc

21 files changed

+1818
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ coverage
1818

1919
# Compiled binary addons (http://nodejs.org/api/addons.html)
2020
build/Release
21+
dist
2122

2223
# Dependency directory
2324
# Commenting this out is preferred by some people, see
2425
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
2526
node_modules
2627

28+
node-server
29+
2730
# Users Environment Variables
2831
.lock-wscript
32+
33+
# java ignore stuff
34+
.settings
35+
target
36+
.classpath
37+
.project
38+
39+

Gruntfile.js

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*global module:false*/
2+
module.exports = function(grunt) {
3+
// Project configuration.
4+
grunt.initConfig({
5+
// Metadata.
6+
pkg: grunt.file.readJSON('package.json'),
7+
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
8+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
9+
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
10+
'* Copyright (c) <%= pkg.author %> <%= grunt.template.today("yyyy") %>;' +
11+
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
12+
13+
config: {
14+
temp: './temp',
15+
dist: './dist',
16+
src: './src',
17+
server: './java-server/src/main/webapp',
18+
js: [
19+
'<%= config.src %>/**/*.js', //source files
20+
'!<%= config.src %>/**/*.spec.js' //unit testing
21+
],
22+
tpl: '<%= config.src %>/**/*.tpl.html'
23+
},
24+
25+
clean: {
26+
dist: {
27+
src: ['<%= config.dist %>']
28+
},
29+
temp: {
30+
src: ['<%= config.temp %>']
31+
}
32+
},
33+
34+
copy: {
35+
deploy: {
36+
files: [
37+
{ expand: true, src: ['<%= config.dist %>/*'], dest: '<%= config.server %>'},
38+
{ expand:true, src: ['./index.html'], dest: '<%= config.server %>'}
39+
]
40+
}
41+
},
42+
43+
// Task configuration.
44+
concat: {
45+
options: {
46+
banner: '<%= banner %>',
47+
stripBanners: true
48+
},
49+
dist: {
50+
src: ['<%= config.temp %>/<%= pkg.name %>.html.js', '<%= config.js %>'],
51+
dest: '<%= config.dist %>/<%= pkg.name %>.js'
52+
}
53+
},
54+
55+
less: {
56+
development: {
57+
options: {
58+
paths: ["<%= config.src %>"]
59+
},
60+
files: {
61+
"<%= config.dist %>/<%= pkg.name %>.css": "<%= config.src %>/<%= pkg.name %>.less"
62+
}
63+
}
64+
},
65+
66+
watch: {
67+
gruntfile: {
68+
files: '<%= jshint.gruntfile.src %>',
69+
tasks: ['build']
70+
},
71+
js: {
72+
files: ['<%= config.js %>', '<%= config.tpl %>', '<%= config.src %>/*.less'],
73+
tasks: ['build']
74+
},
75+
index: {
76+
files: './index.html',
77+
tasks: ['copy:deploy']
78+
}
79+
},
80+
81+
html2js: {
82+
options: {
83+
module: 'angular.crud.grid', // no bundle module for all the html2js templates
84+
singleModule: true
85+
//module:false,
86+
/*rename: function() {
87+
return 'angular.crud.grid';
88+
}*/
89+
},
90+
main: {
91+
src: ['<%= config.tpl %>'],
92+
dest: '<%= config.temp %>/<%= pkg.name %>.html.js'
93+
}
94+
},
95+
96+
jshint: {
97+
options: {
98+
curly: true,
99+
eqeqeq: true,
100+
immed: true,
101+
latedef: true,
102+
newcap: true,
103+
noarg: true,
104+
sub: true,
105+
undef: true,
106+
unused: true,
107+
boss: true,
108+
eqnull: true,
109+
browser: true,
110+
globals: {
111+
angular: true
112+
}
113+
},
114+
gruntfile: {
115+
src: 'Gruntfile.js'
116+
}
117+
}
118+
119+
});
120+
121+
grunt.loadNpmTasks('grunt-contrib-clean');
122+
grunt.loadNpmTasks('grunt-contrib-concat');
123+
grunt.loadNpmTasks('grunt-contrib-jshint');
124+
grunt.loadNpmTasks('grunt-contrib-less');
125+
grunt.loadNpmTasks('grunt-html2js');
126+
grunt.loadNpmTasks('grunt-contrib-copy');
127+
grunt.loadNpmTasks('grunt-contrib-watch');
128+
129+
grunt.registerTask('build',
130+
'Compiles all of the assets and copies the files to the build directory & deply them into java server.',
131+
['clean', 'jshint', 'less', 'html2js', 'concat', 'clean:temp', 'copy:deploy']
132+
);
133+
134+
//grunt.registerTask('default', 'Watches the project for changes, automatically builds them and runs a server.', [ 'build', 'connect', 'watch' ]);
135+
grunt.registerTask('default', ['build', 'watch']);
136+
137+
};

bower.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "angular-crud-rest",
3+
"version": "0.0.1",
4+
"authors": [
5+
"Florin Adochiei <Florin.Adochiei@gmail.com>"
6+
],
7+
"description": "Angular CRUD Grid built for String Data REST",
8+
"main": "src/crud-grid.js",
9+
"keywords": [
10+
"angular",
11+
"grid",
12+
"spring-data-rest"
13+
],
14+
"license": "MIT",
15+
"homepage": "https://github.com/flado/angular-crud-rest",
16+
"ignore": [
17+
"**/.*",
18+
"node_modules",
19+
"bower_components",
20+
"test",
21+
"tests"
22+
]
23+
}

index.html

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>angular-crud-grid</title>
5+
6+
<link href='//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.min.css' rel='stylesheet' type='text/css'>
7+
8+
<link href='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/css/bootstrap.css' rel='stylesheet' type='text/css'>
9+
10+
<link href='http://daneden.github.io/animate.css/animate.min.css' rel='stylesheet' type='text/css'>
11+
12+
<!-- <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/css/bootstrap-theme.css" rel='stylesheet' type='text/css'> -->
13+
14+
<!-- grid CSS must be defined after Bootstrap css because of -->
15+
<link href='./dist/crud-grid.css' rel='stylesheet' type='text/css'>
16+
17+
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
18+
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.min.js"></script> <!-- optional -->
19+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>
20+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-animate.min.js"></script>
21+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.min.js"></script>
22+
23+
<style type="text/css">
24+
body {
25+
padding-top: 60px;
26+
padding-bottom: 20px;
27+
}
28+
29+
.navbar {
30+
margin-bottom: 20px;
31+
}
32+
33+
34+
/* .blink-add, .blink-remove {
35+
color:#555555;
36+
-o-transition:.7s;
37+
-ms-transition:.7s;
38+
-moz-transition:.7s;
39+
-webkit-transition:.7s;
40+
transition:2s;
41+
}
42+
43+
.blink,
44+
.blink-add.blink-add-active {
45+
color:#ffffff;
46+
background-color:#333333;
47+
}
48+
49+
.blink-remove.blink-remove-active {
50+
51+
}*/
52+
53+
/*
54+
.blink:hover {
55+
color:#ffffff;
56+
background-color:#333333;
57+
}*/
58+
59+
60+
</style>
61+
62+
<script src="./dist/crud-grid.js"></script>
63+
64+
<script>
65+
66+
angular.module('demo', ['angular.crud.grid', 'ui.bootstrap']) // ui.bootstrap is MANDATORY dependency for crud grid
67+
68+
.controller('DemoController1', function($scope,$log, DemoNotificationService) {
69+
$log.debug('>> DemoController1 <<');
70+
$scope.gridReadOnly = false; //may be determine using an external Authorization service
71+
$scope.notificationService = DemoNotificationService;
72+
})
73+
74+
.controller('DemoController2', function($scope) {
75+
76+
})
77+
.factory('DemoNotificationService', function ($log) {
78+
toastr.options.closeButton = true;
79+
return {
80+
notify: function(operation, status, data) {
81+
$log.debug('## notify - operation:', operation, ' ## status: ', status, ' ## data: ', data);
82+
if (operation == 'ADD') {
83+
if (status == 201) {
84+
toastr.success('Record added OK', "Success");
85+
} else {
86+
toastr.error('Error adding record', "Error");
87+
}
88+
} else if (operation == 'UPDATE') {
89+
if (status == 204) {
90+
toastr.success('Record updated', "Success");
91+
} else if (status == 409) {
92+
toastr.info('Could not update this record because it is being used in some existing TPP rules', "Info");
93+
} else {
94+
toastr.error('Error updating record', "Error");
95+
}
96+
} else if (operation == 'DELETE') {
97+
if (status == 204) {
98+
toastr.success('Record deleted', "Success");
99+
} else if (status == 409) {
100+
toastr.info('Could not delete this record because it is being used in some existing TPP rules', "Info");
101+
} else {
102+
toastr.error('Error deleting record', "Error");
103+
}
104+
} else if (operation == "FORM_INVALID") {
105+
toastr.warning('Invalid input! Please check again and complete highlighted fields', "Warning");
106+
} else throw new Error('unknown opration type', result);
107+
108+
}
109+
};
110+
});
111+
112+
</script>
113+
<head>
114+
115+
<body ng-app="demo">
116+
117+
118+
<div class="container">
119+
120+
<!-- Static navbar -->
121+
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
122+
<div class="navbar-header">
123+
<div class="navbar-brand ">&lt; angular-crud-grid &gt; built for <a href="http://projects.spring.io/spring-data-rest/">Spring Data REST</a> backend - DEMO</div>
124+
125+
<a href="https://github.com/flado/angular-crud-grid">
126+
<img style="position: absolute; top: 0px; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
127+
</a>
128+
</div>
129+
</div>
130+
131+
<div ng-controller="DemoController1">
132+
<div ng-form="myForm">
133+
<div crud-grid read-only = "gridReadOnly"
134+
notification-service = "notificationService"
135+
grid-options="{
136+
baseUrl: 'api',
137+
resourceName: 'stream',
138+
columnDefs: [
139+
{field: 'key', displayName: 'ID', width:'col-md-1', readOnly: true},
140+
{field: 'code', displayName: 'Stream Number', width:'col-md-2', searchable: true, required: true, validPattern: '/^[0-9]{1,10}$/' },
141+
{field: 'desc', displayName: 'Description', searchable: true, required: true, validPattern: '/^[_ \'0-9A-Za-z/]{1,50}$/' }
142+
],
143+
orderBy: [{ field: 'id', sort: 'asc' }],
144+
searchFilterUrl: '/findByCodeOrDesc',
145+
itemsPerPage: 5 }"></div>
146+
</div>
147+
</div>
148+
149+
</div>
150+
151+
152+
<!--
153+
<p>
154+
<input type="button" value="set" ng-click="myCssVar='animated flash'">
155+
<input type="button" value="clear" ng-click="myCssVar=''">
156+
<br>
157+
<table>
158+
<tbody>
159+
<tr >
160+
<div>
161+
<td ng-class="myCssVar">Col 1</td>
162+
<td ng-class="myCssVar">Col 2</td>
163+
<td ng-class="myCssVar">Col 3</td>
164+
</div>
165+
</tr>
166+
</tbody>
167+
168+
</table>
169+
<br/>
170+
<span >CSS-Animated Text</span>
171+
</p>
172+
173+
-->
174+
175+
176+
</body>
177+
</html>

0 commit comments

Comments
 (0)