mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Initial calls to api.fetchConfig() in quick succession would launch multiple requests. This should be implemented in Info tbh not outside of it.
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
const api = require("../api.js");
|
|
const config = require("../config.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",
|
|
});
|
|
|
|
api.fetchConfig().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();
|
|
});
|
|
};
|