WebInterface: переносим весь AngularJS App в один файл
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
<groupId>asys</groupId>
|
||||
<artifactId>webinterface</artifactId>
|
||||
<version>0.5-SNAPSHOT</version>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<title>ASys: Web interface</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>
|
||||
<script src="/static/app.js"></script>
|
||||
<script src="/static/bundle-list.component.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ASys: Web interface</h1>
|
||||
|
||||
@@ -1,2 +1,39 @@
|
||||
'use strict';
|
||||
angular.module('asysApp', []);
|
||||
var app = angular.module('asysApp', []);
|
||||
|
||||
// filtres
|
||||
app.filter('stateFormat', function() {
|
||||
return function(state) {
|
||||
if (state == 1) {return 'UNINSTALLED';}
|
||||
else if (state == 2) {return 'INSTALLED';}
|
||||
else if (state == 4) {return 'RESOLVED';}
|
||||
else if (state == 8) {return 'STARTING';}
|
||||
else if (state == 16) {return 'STOPPING';}
|
||||
else if (state == 32) {return 'ACTIVE';}
|
||||
else {return 'UNKNOW('+state+')'}
|
||||
}
|
||||
});
|
||||
|
||||
/* --- [bundle-list] --- */
|
||||
app.component('bundleList', {
|
||||
template:
|
||||
'<table width="100%">' +
|
||||
'<thead><tr>' +
|
||||
'<th>ID</th><th>Name</th><th>State</th><th>Version</th><th>Last modified</th>' +
|
||||
'</tr></thead>' +
|
||||
'<tbody>' +
|
||||
'<tr ng-repeat="bundle in $ctrl.bundles">' +
|
||||
'<td>{{bundle.id}}</td>' +
|
||||
'<td>{{bundle.name}}</td>' +
|
||||
'<td>{{bundle.state | stateFormat}}</td>' +
|
||||
'<td>{{bundle.version}}</td>' +
|
||||
'<td>{{bundle.lastModified | date:"dd/MM/yyyy HH:mm"}}</td>' +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>',
|
||||
controller: function BundleListController($http) {
|
||||
var self = this;
|
||||
$http.get('/ajax/bundles.json').then(function(response) {
|
||||
self.bundles = response.data;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,38 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
angular.
|
||||
module('asysApp').
|
||||
component('bundleList', {
|
||||
template:
|
||||
'<table width="100%">' +
|
||||
'<thead><tr>' +
|
||||
'<th>ID</th><th>Name</th><th>State</th><th>Version</th><th>Last modified</th>' +
|
||||
'</tr></thead>' +
|
||||
'<tbody>' +
|
||||
'<tr ng-repeat="bundle in $ctrl.bundles">' +
|
||||
'<td>{{bundle.id}}</td>' +
|
||||
'<td>{{bundle.name}}</td>' +
|
||||
'<td>{{bundle.state | stateFormat}}</td>' +
|
||||
'<td>{{bundle.version}}</td>' +
|
||||
'<td>{{bundle.lastModified | date:"dd/MM/yyyy HH:mm"}}</td>' +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>',
|
||||
controller: function PhoneListController($http) {
|
||||
var self = this;
|
||||
$http.get('/ajax/bundles.json').then(function(response) {
|
||||
self.bundles = response.data;
|
||||
});
|
||||
}
|
||||
}).
|
||||
filter('stateFormat', function() {
|
||||
return function(state) {
|
||||
if (state == 1) {return 'UNINSTALLED';}
|
||||
else if (state == 2) {return 'INSTALLED';}
|
||||
else if (state == 4) {return 'RESOLVED';}
|
||||
else if (state == 8) {return 'STARTING';}
|
||||
else if (state == 16) {return 'STOPPING';}
|
||||
else if (state == 32) {return 'ACTIVE';}
|
||||
else {return 'UNKNOW('+state+')'}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user