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
|
"use strict";
const api = require("../api.js");
const config = require("../config.js");
const Info = require("../models/info.js");
const topNavigation = require("../models/top_navigation.js");
const HomeView = require("../views/home_view.js");
class HomeController {
constructor() {
topNavigation.activate("home");
topNavigation.setTitle("Home");
this._homeView = new HomeView({
name: api.getName(),
version: config.meta.version,
buildDate: config.meta.buildDate,
canListSnapshots: api.hasPrivilege("snapshots:list"),
canListPosts: api.hasPrivilege("posts:list"),
isDevelopmentMode: config.environment == "development",
});
Info.get().then(
(info) => {
this._homeView.setStats({
diskUsage: info.diskUsage,
postCount: info.postCount,
});
this._homeView.setFeaturedPost({
featuredPost: info.featuredPost,
featuringUser: info.featuringUser,
featuringTime: info.featuringTime,
});
},
(error) => this._homeView.showError(error.message)
);
}
showSuccess(message) {
this._homeView.showSuccess(message);
}
showError(message) {
this._homeView.showError(message);
}
}
module.exports = (router) => {
router.enter([], (ctx, next) => {
ctx.controller = new HomeController();
});
};
|