add articles panel
This commit is contained in:
parent
3a1b0d9dbc
commit
aa1f6e072b
|
@ -38,6 +38,11 @@ Article.structure = {
|
||||||
gpgsign: {
|
gpgsign: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
allowNull: true
|
allowNull: true
|
||||||
|
},
|
||||||
|
hidden: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ class User extends Model {
|
||||||
* @returns User
|
* @returns User
|
||||||
*/
|
*/
|
||||||
static async bySession(session) {
|
static async bySession(session) {
|
||||||
if (!session.user.user_id) return;
|
if (session.user == undefined) return;
|
||||||
|
if (session.user.user_id == undefined) return;
|
||||||
const user = await User.findOne({where: {id: session.user.user_id}});
|
const user = await User.findOne({where: {id: session.user.user_id}});
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
|
.control_panel {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 5px;
|
||||||
|
}
|
||||||
.cp_panel_panel {
|
.cp_panel_panel {
|
||||||
border: 1px solid #c2c4c2;
|
border: 1px solid #c2c4c2;
|
||||||
padding: 4px;
|
border-radius: 2px;
|
||||||
|
padding: 4px 8px;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
|
max-width: 386px;
|
||||||
|
box-shadow: 0 2px 1px #20202010;
|
||||||
}
|
}
|
||||||
.cp_panel_panel h5 {
|
.cp_panel_panel h5 {
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
|
|
|
@ -39,6 +39,8 @@ async function panel(req, res) {
|
||||||
order: [['id', 'DESC']]
|
order: [['id', 'DESC']]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const articles = await db.Article.findAll({where: {hidden: true}});
|
||||||
|
|
||||||
res.send(await Helpers.ViewLoader.load('admin/panel.pug', {
|
res.send(await Helpers.ViewLoader.load('admin/panel.pug', {
|
||||||
current_route: req.originalUrl,
|
current_route: req.originalUrl,
|
||||||
gb_records,
|
gb_records,
|
||||||
|
|
|
@ -13,7 +13,7 @@ block content
|
||||||
| Warning: Your access level is unkown, so everything is displayed and some funtions may not work.
|
| Warning: Your access level is unkown, so everything is displayed and some funtions may not work.
|
||||||
hr
|
hr
|
||||||
- access_level = 4
|
- access_level = 4
|
||||||
table
|
table(class='control_panel')
|
||||||
tr
|
tr
|
||||||
td(class='cp_panel_panel')
|
td(class='cp_panel_panel')
|
||||||
h5 Guestbook panel
|
h5 Guestbook panel
|
||||||
|
@ -25,19 +25,26 @@ block content
|
||||||
a(href='/admin/panel/guestbook.csv') Download data (.CSV)
|
a(href='/admin/panel/guestbook.csv') Download data (.CSV)
|
||||||
br
|
br
|
||||||
a(href='/admin/panel/guestbook.csv') Download data (SQL)
|
a(href='/admin/panel/guestbook.csv') Download data (SQL)
|
||||||
form(action='/admin/panel/gb_api')
|
if (access_level >= 4)
|
||||||
h5 Import from file
|
div(style='padding-left:4px')
|
||||||
label(for='filetype') File type:
|
form(action='/admin/panel/gb_api')
|
||||||
select(name='filetype')
|
h5 Import from file
|
||||||
option(value='csv') .CSV
|
p
|
||||||
option(value='sql') SQL
|
b WARNING:
|
||||||
br
|
| All the records will be removed and replaced with your values!
|
||||||
input(type='file' name='file')
|
label(for='filetype') File type:
|
||||||
br
|
select(name='filetype')
|
||||||
input(type='submit' name='import' value='Send')
|
option(value='csv') .CSV
|
||||||
|
option(value='sql') .TSV
|
||||||
|
br
|
||||||
|
input(type='file' name='file')
|
||||||
|
br
|
||||||
|
input(type='submit' name='import' value='Send')
|
||||||
hr
|
hr
|
||||||
div(style='max-height:160px;overflow-y:scroll')
|
div(style='max-height:160px;overflow-y:scroll')
|
||||||
table
|
table
|
||||||
|
if (!gb_records || gb_records.length == 0)
|
||||||
|
p Nothing to show.
|
||||||
each record of gb_records
|
each record of gb_records
|
||||||
tr(class='' + (record.hidden ? 'cp_gb_entry_hidden' : ''))
|
tr(class='' + (record.hidden ? 'cp_gb_entry_hidden' : ''))
|
||||||
form(action='/admin/panel/gb_api' method='POST')
|
form(action='/admin/panel/gb_api' method='POST')
|
||||||
|
@ -56,4 +63,23 @@ block content
|
||||||
input(type='submit' name='hide' value='Hide')
|
input(type='submit' name='hide' value='Hide')
|
||||||
else
|
else
|
||||||
input(type='submit' name='hide' value='Unhide')
|
input(type='submit' name='hide' value='Unhide')
|
||||||
|
td(class='cp_panel_panel')
|
||||||
|
h5 Articles
|
||||||
|
hr
|
||||||
|
p
|
||||||
|
a(href='/admin/article/new') Create new article
|
||||||
|
if (access_level >= 4)
|
||||||
|
br
|
||||||
|
a(href='/admin/articles.csv') Download data (.CSV)
|
||||||
|
br
|
||||||
|
a(href='/admin/articles.sql') Download data (SQL)
|
||||||
|
div(style='padding-left:4px')
|
||||||
|
form(action='/admin/panel/article_api' method='POST')
|
||||||
|
h5 Import from file
|
||||||
|
p
|
||||||
|
b WARNING:
|
||||||
|
| All the records will be removed and replaced with your values!
|
||||||
|
hr
|
||||||
|
if (!articles)
|
||||||
|
p Nothing to show.
|
||||||
|
|
Loading…
Reference in New Issue