Skip to content

Commit 1a876c1

Browse files
committed
moved app to webpack
1 parent 8435340 commit 1a876c1

36 files changed

+438
-229
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
bower_components
44
dist
5+
dist1

bower.json

-11
This file was deleted.

package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"publishName": "myApp",
66
"electronVersion": "0.36.9",
77
"scripts": {
8-
"start": "export NODE_ENV='dev'; electron ./dist/main.js",
8+
"start": "export NODE_ENV='dev' && electron ./dist/main.js",
99
"buildMac": "electron-packager ./dist/ easy-learn --platform=darwin --arch=x64 --out ~/Desktop/easy-learn --asar --version 0.36.9 --overwrite --icon=./src/images/app-icon.icns",
1010
"buildwin": "electron-packager ./dist/ easy-learn --platform=win32 --arch=x64 --out ~/Desktop/easy-learn --version 0.36.9 --overwrite --icon=./src/images/app-icon.ico",
11-
"build": "webpack --progress --colors"
11+
"build": "webpack --progress --colors",
12+
"buildProd": "webpack --bail --progress --profile --colors"
1213
},
1314
"devDependencies": {
1415
"babel-core": "^6.7.2",
@@ -56,6 +57,10 @@
5657
"webpack-svgstore-plugin": "^2.1.3"
5758
},
5859
"dependencies": {
59-
"angular": "^1.5.0"
60+
"angular": "^1.5.0",
61+
"angular-animate": "^1.5.0",
62+
"angular-local-storage": "^0.2.6",
63+
"angular-ui-router": "^0.2.18",
64+
"lokijs": "^1.3.16"
6065
}
6166
}

src/package.json src/.package.json

File renamed without changes.

src/app/app.config.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
angular.module('easy-learn')
2-
.config((localStorageServiceProvider, $urlRouterProvider) => {
3-
localStorageServiceProvider.setPrefix('el');
1+
'use strict';
42

5-
$urlRouterProvider.otherwise('/');
6-
});
3+
export default (localStorageServiceProvider, $urlRouterProvider) => {
4+
'ngInject';
5+
6+
localStorageServiceProvider.setPrefix('el');
7+
$urlRouterProvider.otherwise('/');
8+
}

src/app/index.js src/app/app.js

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import './app.less';
2-
import '../svg/close.svg';
2+
import 'images/app-icon.svg';
33

44
import angular from 'angular';
5+
// import ngAnimate from 'angular-animate';
6+
import LocalStorageModule from 'angular-local-storage';
7+
import uiRouter from 'angular-ui-router';
8+
9+
import db from './common/db/db.service';
10+
import route from './app.route';
11+
import config from './app.config';
12+
import sidebar from './sidebar/sidebar';
13+
import list from './list/list';
14+
15+
const deps = [
16+
// ngAnimate,
17+
LocalStorageModule,
18+
uiRouter,
19+
sidebar.name,
20+
list.name,
21+
db.name
22+
];
23+
24+
angular.module('easy-learn', deps)
25+
.config(route)
26+
.config(config);
27+
528

6-
angular.module('easy-learn', [
7-
'ngAnimate',
8-
'LocalStorageModule',
9-
'ui.router',
10-
'lokijs',
11-
'sidebar',
12-
'list',
13-
'db'
14-
]);
1529

1630
//TODO make inputs wider
1731
//TODO make auto translate (by google and yandex)

src/app/app.route.js

+31-28
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
angular.module('easy-learn')
2-
.config($stateProvider => {
3-
$stateProvider
4-
.state('route', {
5-
url: '',
6-
abstract: true,
7-
views: {
8-
'sidebar': {
9-
templateUrl: 'app/sidebar/sidebar.tpl.html',
10-
controller: 'SidebarController',
11-
controllerAs: 'sidebar'
12-
},
13-
'content': {
14-
templateUrl: 'app/app.tpl.html'
15-
}
1+
'use strict';
2+
3+
export default $stateProvider => {
4+
'ngInject';
5+
6+
$stateProvider
7+
.state('route', {
8+
url: '',
9+
abstract: true,
10+
views: {
11+
'sidebar': {
12+
template: require('./sidebar/sidebar.tpl.html'),
13+
controller: 'SidebarController',
14+
controllerAs: 'sidebar'
1615
},
17-
resolve: {
18-
collections(dbService) {
19-
return dbService.getCollections();
20-
}
16+
'content': {
17+
template: require('./app.tpl.html')
18+
}
19+
},
20+
resolve: {
21+
collections(dbService) {
22+
return dbService.getCollections();
2123
}
22-
})
24+
}
25+
})
2326

24-
.state('route.list', {
25-
url: '/',
26-
views: {
27-
'details': {
28-
templateUrl: 'app/welcome/welcome.tpl.html'
29-
}
27+
.state('route.list', {
28+
url: '/',
29+
views: {
30+
'details': {
31+
template: require('./welcome/welcome.tpl.html')
3032
}
31-
})
32-
});
33+
}
34+
})
35+
};

src/app/common/db/db.service.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
angular.module('db', [])
1+
import angular from 'angular';
2+
import LokiIndexedAdapter from 'lokijs/src/loki-indexed-adapter';
3+
import lokijs from 'lokijs/src/loki-angular';
4+
5+
const deps = [
6+
lokijs.name
7+
];
8+
9+
export default angular.module('db', deps)
210
.factory('dbService', function CollectionService($q, Loki) {
11+
'ngInject';
12+
313
let _db;
414
let _collections;
515
initDB();

src/app/common/google-translate/google-translate.service.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
angular.module('googleTranslate', [])
1+
'use strict';
2+
import angular from 'angular';
3+
4+
export default angular.module('googleTranslate', [])
25
.constant('googleTranslateConfig', {
36
domain: 'https://translate.googleapis.com',
47
source: 'en',
58
target: 'ru'
69
})
710

811
.factory('googleTranslateService', function ($http, $timeout, googleTranslateConfig) {
12+
'ngInject';
13+
914
return {
1015
playAudio,
1116
getTranslation

src/app/common/notification/notification.service.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
angular.module('notification', [])
1+
'use strict';
2+
import angular from 'angular';
3+
4+
export default angular.module('notification', [])
25
.factory('notificationService', function () {
36
return {
47
push

src/app/common/timer/timer.service.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
angular.module('timer', [])
1+
'use strict';
2+
import angular from 'angular';
3+
4+
export default angular.module('timer', [])
25
.factory('timerService', function (googleTranslateService, localStorageService, notificationService) {
6+
'ngInject';
7+
38
let timer = {
49
time: localStorageService.get('time') || 1,
510
timerId: undefined
@@ -12,7 +17,7 @@ angular.module('timer', [])
1217
};
1318

1419
/**
15-
* Returned random value
20+
* Returned random value
1621
* @param {int} min
1722
* @param {int} max
1823
* @returns {*}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
import ListFormController from './list-form.ctrl';
4+
5+
let listForm = {
6+
template: require('./list-form.tpl.html'),
7+
bindings: {
8+
addToCollection: '<'
9+
},
10+
controller: ListFormController
11+
};
12+
13+
export default listForm;
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
class ListFormController {
4+
constructor(googleTranslateService, notificationService) {
5+
'ngInject';
6+
7+
this.googleTranslateService = googleTranslateService;
8+
this.notificationService = notificationService;
9+
10+
this.word = {
11+
eng: null,
12+
translate: null
13+
};
14+
}
15+
16+
getTranslation(word) {
17+
if (!word) {
18+
return;
19+
}
20+
21+
this.googleTranslateService.getTranslation(word).then(translation => {
22+
this.word.translate = translation;
23+
});
24+
}
25+
26+
addWord(word) {
27+
this.addToCollection(word);
28+
29+
this.notificationService.push('New word', `${word.eng} - ${word.translate}`);
30+
this.googleTranslateService.playAudio(word.eng, 1000);
31+
this.word = {};
32+
}
33+
}
34+
35+
export default ListFormController;

src/app/list/list-form/list-form.js

+12-35
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,15 @@
1-
class ListFormController {
2-
constructor(googleTranslateService, notificationService) {
3-
this.googleTranslateService = googleTranslateService;
4-
this.notificationService = notificationService;
1+
'use strict';
52

6-
this.word = {
7-
eng: null,
8-
translate: null
9-
};
10-
}
3+
import './list-form.less';
4+
import angular from 'angular';
5+
import listForm from './list-form.component';
6+
import googleTranslate from 'common/google-translate/google-translate.service';
7+
import notification from 'common/notification/notification.service';
118

12-
getTranslation(word) {
13-
if (!word) {
14-
return;
15-
}
9+
const deps = [
10+
googleTranslate.name,
11+
notification.name
12+
];
1613

17-
this.googleTranslateService.getTranslation(word).then(translation => {
18-
this.word.translate = translation;
19-
});
20-
}
21-
22-
addWord(word) {
23-
this.addToCollection(word);
24-
25-
this.notificationService.push('New word', `${word.eng} - ${word.translate}`);
26-
this.googleTranslateService.playAudio(word.eng, 1000);
27-
this.word = {};
28-
}
29-
}
30-
31-
angular.module('list')
32-
.component('listForm', {
33-
templateUrl: 'app/list/list-form/list-form.tpl.html',
34-
bindings: {
35-
addToCollection: '<'
36-
},
37-
controller: ListFormController
38-
});
14+
export default angular.module('list.list-form', deps)
15+
.component('listForm', listForm);

src/app/list/list.controller.js src/app/list/list.ctrl.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
'use strict';
2+
13
class ListController {
24
constructor($scope, collection, dbService) {
5+
'ngInject';
6+
37
this.collection = collection;
48

59
$scope.$watch('list.collection.list', (val, oldVal) => {
@@ -19,4 +23,4 @@ class ListController {
1923
}
2024
}
2125

22-
angular.module('list').controller('ListController', ListController);
26+
export default ListController;

src/app/list/list.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
angular.module('list', ['googleTranslate', 'timer', 'notification']);
1+
'use strict';
2+
3+
import './list.less';
4+
import angular from 'angular';
5+
import ListController from './list.ctrl';
6+
import listService from './list.service';
7+
import route from './list.route';
8+
9+
import listForm from './list-form/list-form';
10+
import timerInput from './timer-input/timer-input';
11+
12+
const deps = [
13+
listForm.name,
14+
timerInput.name
15+
];
16+
17+
export default angular.module('list', deps)
18+
.controller('ListController', ListController)
19+
.factory('listService', listService)
20+
.config(route);

0 commit comments

Comments
 (0)