浏览代码

init

master
Robin Thoni 9 年前
当前提交
145d709d16
共有 6 个文件被更改,包括 229 次插入0 次删除
  1. 3
    0
      .gitmodules
  2. 146
    0
      Gruntfile_app.js
  3. 1
    0
      README
  4. 32
    0
      app/controllers/login.controller.js
  5. 46
    0
      app/controllers/navbar.controller.js
  6. 1
    0
      luticate

+ 3
- 0
.gitmodules 查看文件

@@ -0,0 +1,3 @@
1
+[submodule "luticate"]
2
+	path = luticate
3
+	url = https://git.rthoni.com/repos/luticate-front/front.git

+ 146
- 0
Gruntfile_app.js 查看文件

@@ -0,0 +1,146 @@
1
+/**
2
+ * Created by robin on 11/10/15.
3
+ */
4
+
5
+module.exports = function(grunt) {
6
+
7
+    grunt.loadNpmTasks('grunt-contrib-clean');
8
+    grunt.loadNpmTasks('grunt-usemin');
9
+    grunt.loadNpmTasks('grunt-contrib-concat');
10
+    grunt.loadNpmTasks('grunt-contrib-uglify');
11
+    grunt.loadNpmTasks('grunt-contrib-copy');
12
+    grunt.loadNpmTasks('grunt-contrib-cssmin');
13
+    grunt.loadNpmTasks('grunt-contrib-less');
14
+
15
+    var path = require('path');
16
+
17
+    grunt.initConfig({
18
+        globals: {
19
+            releasePath: 'build/release/camotion',
20
+            appFolder: 'camotion',
21
+            staticFiles: [
22
+                'views/**/*.html',
23
+                'index.html',
24
+                'img/**',
25
+                'fonts/**'
26
+            ]
27
+        },
28
+        useminPrepare: {
29
+            release: '<%= globals.appFolder %>/index.html',
30
+            options: {
31
+                flow: {
32
+                    release: {
33
+                        steps: {
34
+                            'js': [
35
+                                'concat',
36
+                                {
37
+                                    name: 'uglify',
38
+                                    createConfig: function (context, block) {
39
+                                        var cfg = {files: []},
40
+                                            filesDef = {};
41
+
42
+
43
+                                        filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
44
+                                        filesDef.src = [];
45
+                                        context.inFiles.forEach(function (inFile) {
46
+                                            filesDef.src.push(path.join(context.inDir, inFile));
47
+                                        });
48
+
49
+                                        cfg.files.push(filesDef);
50
+                                        return cfg;
51
+                                    }
52
+                                }
53
+                            ],
54
+                            'css': ['concat',
55
+                                {
56
+                                    name: 'cssmin',
57
+                                    createConfig: function (context, block) {
58
+                                        var cfg = {files: []},
59
+                                            filesDef = {};
60
+
61
+
62
+                                        filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
63
+                                        filesDef.src = [];
64
+                                        context.inFiles.forEach(function (inFile) {
65
+                                            filesDef.src.push(path.join(context.inDir, inFile));
66
+                                        });
67
+
68
+                                        cfg.files.push(filesDef);
69
+                                        return cfg;
70
+                                    }
71
+                                }],
72
+                            'less': [
73
+                                {
74
+                                    name: 'less',
75
+                                    createConfig: function (context, block) {
76
+                                        var cfg = {files: []},
77
+                                            filesDef = {};
78
+
79
+                                        context.options.generated.options = {
80
+                                            cleancss: true
81
+                                        };
82
+
83
+                                        filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
84
+                                        filesDef.src = [];
85
+                                        context.inFiles.forEach(function (inFile) {
86
+                                            filesDef.src.push(path.join(context.inDir, inFile));
87
+                                        });
88
+
89
+                                        cfg.files.push(filesDef);
90
+                                        return cfg;
91
+                                    }
92
+                                }
93
+                            ]
94
+                        },
95
+                        post: {
96
+
97
+                        }
98
+                    }
99
+                }
100
+            }
101
+        },
102
+        usemin: {
103
+            html: '<%= globals.releasePath %>/index.html',
104
+            options: {
105
+                blockReplacements: {
106
+                    less: function (block) {
107
+                        return '<link rel=\"stylesheet\" href=\"' + block.dest + '\"/>';
108
+                    }
109
+                }
110
+            }
111
+        },
112
+        copy: {
113
+            release: {
114
+                files: [
115
+                    {
116
+                        expand: true,
117
+                        cwd:'<%= globals.appFolder %>/',
118
+                        src: ['<%= globals.staticFiles %>'],
119
+                        dest: '<%= globals.releasePath %>'
120
+                    },
121
+                    {
122
+                        expand: true,
123
+                        cwd:'<%= globals.appFolder %>/../bower_components/flat-ui/dist/fonts/',
124
+                        src: ['**'],
125
+                        dest: '<%= globals.releasePath %>/fonts/'
126
+                    }
127
+                ]
128
+            }
129
+        },
130
+        clean: {
131
+            release: ['<%= globals.releasePath %>/*']
132
+        }
133
+    });
134
+    grunt.registerTask('release', [
135
+        'clean:release',
136
+        'useminPrepare:release',
137
+        'concat:generated',
138
+        'uglify:generated',
139
+        'copy:release',
140
+        'cssmin:generated',
141
+        'less:generated',
142
+        'usemin'
143
+    ]);
144
+
145
+
146
+};

+ 1
- 0
README 查看文件

@@ -0,0 +1 @@
1
+init

+ 32
- 0
app/controllers/login.controller.js 查看文件

@@ -0,0 +1,32 @@
1
+angular.module('camotion')
2
+    .controller('LoginController', ['$scope', '$state', 'luticateAuthUsers', 'luticateAuthCache',
3
+        function($scope, $state, luticateAuthUsers, luticateAuthCache) {
4
+            $scope.username = "";
5
+            $scope.password = "";
6
+            $scope.errorString = null;
7
+
8
+            var promiseLogin = {
9
+                id: "promiseLogin",
10
+                loaderGroups: ["loginForm"]
11
+            };
12
+
13
+            var user = luticateAuthCache.getUser();
14
+            if (user != null) {
15
+                $state.go('home');
16
+                return;
17
+            }
18
+
19
+            $scope.login = function()
20
+            {
21
+                $scope.errorString = null;
22
+                luticateAuthUsers.login({username: $scope.username, password: $scope.password}, promiseLogin)
23
+                    .then(function(user)
24
+                    {
25
+                        $state.go('home');
26
+                    }, function(error)
27
+                    {
28
+                        $scope.errorString = error.Data;
29
+                    });
30
+            };
31
+        }
32
+    ]);

+ 46
- 0
app/controllers/navbar.controller.js 查看文件

@@ -0,0 +1,46 @@
1
+/**
2
+ * Created by robin on 11/1/15.
3
+ */
4
+
5
+angular.module('camotion')
6
+    .controller('NavBarController', ['$scope', 'luticateAuthCache', 'luticateAuthUsers', '$state',
7
+        function($scope, luticateAuthCache, luticateAuthUsers, $state) {
8
+
9
+
10
+            $scope.logout = function()
11
+            {
12
+                var promiseLogout = {
13
+                    id: "promiseLogout",
14
+                    loaderGroups: ["body"]
15
+                };
16
+                luticateAuthUsers.logout(promiseLogout).finally(function()
17
+                {
18
+                    $state.go('login');
19
+                });
20
+            };
21
+
22
+            $scope.isLogged = function()
23
+            {
24
+                var user = luticateAuthCache.getUser();
25
+                return user != null && user.Id != 0;
26
+            };
27
+
28
+            $scope.getUsername = function()
29
+            {
30
+                var user = luticateAuthCache.getUser();
31
+                if (user != null) {
32
+                    return user.Username;
33
+                }
34
+                return "";
35
+            };
36
+
37
+            $scope.canSeeAdmin = function()
38
+            {
39
+                return luticateAuthCache.hasOneEffectivePermission([
40
+                    "LU_USER_GET",
41
+                    "LU_GROUP_GET",
42
+                    "LU_PERM_GET",
43
+                    "CAMOTION_HOST_GET"
44
+                ]);
45
+            };
46
+        }]);

+ 1
- 0
luticate

@@ -0,0 +1 @@
1
+Subproject commit d61de68cb37c386d540d2077677541fe1dc980a6

正在加载...
取消
保存