2021-12-03 19:32:21 +08:00
|
|
|
import 'External/ko';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2024-03-07 08:16:58 +08:00
|
|
|
import { SettingsGet, SettingsAdmin } from 'Common/Globals';
|
2023-03-18 06:20:42 +08:00
|
|
|
import { initThemes } from 'Stores/Theme';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/Admin/Fetch';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { SettingsAdminScreen } from 'Screen/Admin/Settings';
|
|
|
|
import { LoginAdminScreen } from 'Screen/Admin/Login';
|
2016-07-07 07:11:13 +08:00
|
|
|
|
2020-09-17 05:19:34 +08:00
|
|
|
import { startScreens } from 'Knoin/Knoin';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { AbstractApp } from 'App/Abstract';
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2024-03-18 19:25:24 +08:00
|
|
|
import { AskPopupView } from 'View/Popup/Ask';
|
|
|
|
|
2022-03-31 23:39:53 +08:00
|
|
|
export class AdminApp extends AbstractApp {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2015-11-19 01:32:29 +08:00
|
|
|
super(Remote);
|
2021-03-16 21:15:05 +08:00
|
|
|
this.weakPassword = ko.observable(false);
|
2015-11-19 01:32:29 +08:00
|
|
|
}
|
|
|
|
|
2022-03-31 23:39:53 +08:00
|
|
|
refresh() {
|
2023-03-18 06:20:42 +08:00
|
|
|
initThemes();
|
2022-03-31 23:39:53 +08:00
|
|
|
this.start();
|
|
|
|
}
|
|
|
|
|
2021-11-01 18:24:11 +08:00
|
|
|
start() {
|
2024-03-07 08:16:58 +08:00
|
|
|
// if (!Settings.app('adminAllowed')) {
|
|
|
|
if (!SettingsAdmin('allowed')) {
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.root();
|
|
|
|
setTimeout(() => location.href = '/', 1);
|
2021-03-16 21:15:05 +08:00
|
|
|
} else if (SettingsGet('Auth')) {
|
2023-02-21 18:52:50 +08:00
|
|
|
this.weakPassword(SettingsGet('weakPassword'));
|
2021-03-16 21:15:05 +08:00
|
|
|
startScreens([SettingsAdminScreen]);
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2021-03-16 21:15:05 +08:00
|
|
|
startScreens([LoginAdminScreen]);
|
2015-11-19 01:32:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-18 19:25:24 +08:00
|
|
|
|
|
|
|
AskPopupView.credentials = function(sAskDesc, btnText) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
this.showModal([
|
|
|
|
sAskDesc,
|
|
|
|
view => resolve({username:view.username(), password:view.passphrase()}),
|
|
|
|
() => resolve(null),
|
|
|
|
true,
|
|
|
|
3,
|
|
|
|
btnText
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
};
|