-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
116 lines (99 loc) · 2.98 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const mainApp = angular.module('mainApp', ['ngFileUpload', 'ui.router', 'ngToast']);
mainApp.config(function ($stateProvider, $locationProvider, $urlRouterProvider, ngToastProvider) {
// $locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/');
var welcomePage = {
name: 'welcome',
url: '/',
templateUrl: 'welcome/welcome.html'
}
var sampler = {
name: 'sampler',
url: '/sampler',
templateUrl: 'sampler/main.html'
}
var synthesizer = {
name: 'synthesizer',
url: '/synthesizer',
templateUrl: 'synthesizerV2/main.html'
}
$stateProvider.state(welcomePage);
$stateProvider.state(sampler);
$stateProvider.state(synthesizer);
ngToastProvider.configure({
verticalPosition: 'top',
horizontalPosition: 'right',
animation: 'slide'
});
});
mainApp.run(($rootScope) => {
$rootScope.appName = 'Green Studio';
$rootScope.keyNotes = {};
// Load notes JSON
$.getJSON("assets/notes.json", function (json) {
$rootScope.keyNotes = json;
});
});
mainApp.controller('MainCtrl', ($rootScope, $scope, $http, $state, ngToast) => {
// $scope.appMode = 'Sounds';
// $scope.appMode = 'Editor';
// $scope.appMode = 'MainLine';
// $scope.appMode = 'Synth';
$scope.projectMode = null;
$scope.allProjects = [];
$scope.startProject = function (name) {
if (!name) {
return;
}
$http.post('/api/project', {
projectName: name,
configuration: {}
}).then(() => {
ngToast.create({
className: 'success',
content: 'Project is created.'
});
window.localStorage.setItem('currentProject', name);
$state.go('sampler');
}).catch(() => {
ngToast.create({
className: 'danger',
content: 'Problem while creating the project.'
});
});
};
$scope.loadProject = function (name) {
if (!name) {
return;
}
$http.get('/api/project/load', {
params: {
projectName: name
}
}).then((response) => {
ngToast.create({
className: 'success',
content: 'Project is loaded.'
});
window.localStorage.setItem('currentProject', name);
$state.go('sampler');
}).catch(() => {
ngToast.create({
className: 'danger',
content: 'Problem while loading the project.'
});
})
};
function _init() {
//Fetch projects
$http.get('/api/project', {}).then((response) => {
$scope.allProjects = response.data;
}).catch(() => {
ngToast.create({
className: 'danger',
content: 'Problem while fetching projects.'
});
})
}
_init();
});