Skip to content

Commit 35779f6

Browse files
committed
initial import
0 parents  commit 35779f6

22 files changed

+857
-0
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "public/components"
3+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/nbproject/
2+
/node_modules/
3+
/public/components/
4+
/store/

bower.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "adf-dynamic-example",
3+
"dependencies": {
4+
"angular": "1.2.25",
5+
"angular-route": "1.2.25",
6+
"angular-dashboard-framework": "0.3.0"
7+
},
8+
"resolutions": {
9+
"angular": "1.2.25"
10+
}
11+
}

package.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "adf-dynamic-example",
3+
"version": "0.1.0-SNAPSHOT",
4+
"dependencies": {
5+
"body-parser": "^1.9.0",
6+
"compression": "^1.1.0",
7+
"express": "4.x"
8+
}
9+
}

public/index.html

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<!DOCTYPE html>
2+
<!--*
3+
The MIT License
4+
5+
Copyright (c) 2014, Sebastian Sdorra
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
-->
25+
<html lang="en">
26+
<head>
27+
<meta charset="utf-8">
28+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
29+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
30+
<meta name="description" content="dashboard sample app">
31+
<meta name="author" content="Sebastian Sdorra">
32+
33+
<title>Dashboard</title>
34+
35+
<!-- font awesome -->
36+
<link href="components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
37+
38+
<!-- build:css css/sample.min.css -->
39+
<!-- Bootstrap core CSS -->
40+
<link href="components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
41+
42+
<!-- dashboard style -->
43+
<link href="components/angular-dashboard-framework/dist/angular-dashboard-framework.min.css" rel="stylesheet">
44+
<!-- endbuild -->
45+
46+
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
47+
<!--[if lt IE 9]>
48+
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
49+
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
50+
<![endif]-->
51+
52+
<!--[if lte IE 8]>
53+
<script>
54+
document.createElement('adf-dashboard');
55+
document.createElement('adf-widget');
56+
document.createElement('adf-widget-content');
57+
</script>
58+
<![endif]-->
59+
</head>
60+
61+
<body ng-app="adfDynamicSample">
62+
63+
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
64+
<div class="container" ng-controller="navigationCtrl as nav">
65+
<div class="navbar-header">
66+
<button type="button" class="navbar-toggle" ng-click="nav.toggleNav()">
67+
<span class="sr-only">Toggle navigation</span>
68+
<span class="icon-bar"></span>
69+
<span class="icon-bar"></span>
70+
<span class="icon-bar"></span>
71+
</button>
72+
<a class="navbar-brand" href="#">ADF Dynamic Sample</a>
73+
</div>
74+
<div collapse="nav.navCollapsed" class="collapse navbar-collapse">
75+
<ul class="nav navbar-nav">
76+
<li ng-class="nav.navClass('boards/' + item.id)" ng-repeat="item in nav.items | orderBy: title">
77+
<a ng-href="#/boards/{{item.id}}">{{item.title}}</a>
78+
</li>
79+
<li>
80+
<a style="cursor: pointer;" ng-click="nav.create()">Create</a>
81+
</li>
82+
</ul>
83+
</div><!--/.nav-collapse -->
84+
</div>
85+
</div>
86+
87+
<div class="container">
88+
89+
<ng-view />
90+
91+
</div>
92+
93+
<!-- components -->
94+
<script type="text/javascript" src="components/jquery/jquery.min.js"></script>
95+
<script type="text/javascript" src="components/jquery-ui/ui/minified/jquery.ui.core.min.js"></script>
96+
<script type="text/javascript" src="components/jquery-ui/ui/minified/jquery.ui.widget.min.js"></script>
97+
<script type="text/javascript" src="components/jquery-ui/ui/minified/jquery.ui.mouse.min.js"></script>
98+
<script type="text/javascript" src="components/jquery-ui/ui/minified/jquery.ui.sortable.min.js"></script>
99+
<script type="text/javascript" src="components/angular/angular.min.js"></script>
100+
<script type="text/javascript" src="components/angular-route/angular-route.min.js"></script>
101+
<script type="text/javascript" src="components/angular-bootstrap/ui-bootstrap.min.js"></script>
102+
<script type="text/javascript" src="components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
103+
<script type="text/javascript" src="components/angular-dashboard-framework/dist/angular-dashboard-framework.min.js"></script>
104+
105+
<!-- scripts -->
106+
<script type="text/javascript" src="scripts/app.js"></script>
107+
<script type="text/javascript" src="scripts/structures.js"></script>
108+
109+
<!-- widgets -->
110+
<script type="text/javascript" src="scripts/widgets/linklist/linklist.js"></script>
111+
<script type="text/javascript" src="scripts/widgets/news/news.js"></script>
112+
<script type="text/javascript" src="scripts/widgets/randommsg/randommsg.js"></script>
113+
<script type="text/javascript" src="scripts/widgets/weather/weather.js"></script>
114+
</body>
115+
</html>

public/partials/dashboard.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div>
2+
<adf-dashboard name="{{dashboard.name}}" structure="4-8" adf-model="dashboard.model" />
3+
</div>
4+
5+
<button class="btn btn-warning" ng-click="dashboard.delete(dashboard.name)">Delete</button>

public/partials/default.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Default</h1>

public/scripts/app.js

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright (c) 2014, Sebastian Sdorra
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
'use strict';
26+
27+
angular.module('adfDynamicSample', [
28+
'adf', 'ngRoute', 'structures',
29+
'sample.widgets.news', 'sample.widgets.weather',
30+
'sample.widgets.linklist', 'sample.widgets.randommsg'
31+
])
32+
.config(function($routeProvider){
33+
$routeProvider
34+
.when('/boards', {
35+
templateUrl: 'partials/default.html'
36+
})
37+
.when('/boards/:id', {
38+
controller: 'dashboardCtrl',
39+
controllerAs: 'dashboard',
40+
templateUrl: 'partials/dashboard.html',
41+
resolve: {
42+
data: function($route, storeService){
43+
return storeService.get($route.current.params.id);
44+
}
45+
}
46+
})
47+
.otherwise({
48+
redirectTo: '/boards'
49+
});
50+
})
51+
.service('storeService', function($http, $q){
52+
return {
53+
getAll: function(){
54+
var deferred = $q.defer();
55+
$http.get('/v1/store')
56+
.success(function(data){
57+
deferred.resolve(data.dashboards);
58+
})
59+
.error(function(){
60+
deferred.reject();
61+
});
62+
return deferred.promise;
63+
},
64+
get: function(id){
65+
var deferred = $q.defer();
66+
$http.get('/v1/store/' + id)
67+
.success(function(data){
68+
deferred.resolve(data);
69+
})
70+
.error(function(){
71+
deferred.reject();
72+
});
73+
return deferred.promise;
74+
},
75+
set: function(id, data){
76+
var deferred = $q.defer();
77+
$http.post('/v1/store/' + id, data)
78+
.success(function(data){
79+
deferred.resolve();
80+
})
81+
.error(function(){
82+
deferred.reject();
83+
});
84+
return deferred.promise;
85+
},
86+
delete: function(id){
87+
var deferred = $q.defer();
88+
$http.delete('/v1/store/' + id)
89+
.success(function(data){
90+
deferred.resolve(data);
91+
})
92+
.error(function(){
93+
deferred.reject();
94+
});
95+
return deferred.promise;
96+
}
97+
};
98+
})
99+
.controller('navigationCtrl', function($scope, $q, $location, storeService){
100+
var nav = this;
101+
nav.navCollapsed = true;
102+
103+
this.toggleNav = function(){
104+
nav.navCollapsed = ! nav.navCollapsed;
105+
};
106+
107+
this.navClass = function(page) {
108+
var currentRoute = $location.path().substring(1);
109+
return page === currentRoute || new RegExp(page).test(currentRoute) ? 'active' : '';
110+
};
111+
112+
this.create = function(){
113+
var id = '_' + new Date().getTime();
114+
var q = storeService.set(id, {
115+
"title": "New Sample",
116+
"structure": "4-8",
117+
"rows": [{
118+
"columns": [{
119+
"styleClass": "col-md-4",
120+
"widgets": []
121+
},{
122+
"styleClass": "col-md-8",
123+
"widgets": []
124+
}]
125+
}]
126+
});
127+
128+
$q.all([q, storeService.getAll()]).then(function(values){
129+
nav.items = values[1];
130+
});
131+
};
132+
133+
storeService.getAll().then(function(data){
134+
nav.items = data;
135+
});
136+
137+
$scope.$on('navChanged', function(){
138+
storeService.getAll().then(function(data){
139+
nav.items = data;
140+
});
141+
});
142+
})
143+
.controller('dashboardCtrl', function($location, $rootScope, $scope, $routeParams, storeService, data){
144+
this.name = $routeParams.id;
145+
this.model = data;
146+
147+
this.delete = function(id){
148+
storeService.delete(id);
149+
$location.path('/');
150+
$rootScope.$broadcast('navChanged');
151+
};
152+
153+
$scope.$on('adfDashboardChanged', function(event, name, model) {
154+
storeService.set(name, model);
155+
});
156+
});

0 commit comments

Comments
 (0)