Archived
0

WebInterface: переносим весь AngularJS App в один файл

This commit is contained in:
2016-12-17 01:20:45 +03:00
parent d9fb538407
commit f29ed38289
4 changed files with 40 additions and 42 deletions

View File

@@ -19,7 +19,7 @@
<groupId>asys</groupId> <groupId>asys</groupId>
<artifactId>webinterface</artifactId> <artifactId>webinterface</artifactId>
<version>0.5-SNAPSHOT</version> <version>0.6-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<dependencies> <dependencies>

View File

@@ -5,7 +5,6 @@
<title>ASys: Web interface</title> <title>ASys: Web interface</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script> <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/app.js"></script>
<script src="/static/bundle-list.component.js"></script>
</head> </head>
<body> <body>
<h1>ASys: Web interface</h1> <h1>ASys: Web interface</h1>

View File

@@ -1,2 +1,39 @@
'use strict'; var app = angular.module('asysApp', []);
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;
});
}
});

View File

@@ -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+')'}
}
});