Merge branch 'master' of ssh.dev.azure.com:v3/HackKu/HackKu%202020/backend
This commit is contained in:
commit
89a3386e97
29
app/controllers/Export.controller.js
Normal file
29
app/controllers/Export.controller.js
Normal file
@ -0,0 +1,29 @@
|
||||
const Controller = require('libflitter/controller/Controller')
|
||||
|
||||
/*
|
||||
* Export Controller
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Export extends Controller {
|
||||
static get services() {
|
||||
return [...super.services, 'models']
|
||||
}
|
||||
/*
|
||||
* Serve the main page.
|
||||
*/
|
||||
async json_export(req, res){
|
||||
const Page = this.models.get('api:Page')
|
||||
const user = req.user
|
||||
const pages = await Page.find({OrgUserId:user._id})
|
||||
|
||||
const ExportData = {}
|
||||
for (const page of pages ) {
|
||||
const PageData = {...page}
|
||||
ExportData[page.Name] = PageData
|
||||
}
|
||||
return res.api(ExportData)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Export
|
@ -24,8 +24,8 @@ class Home extends Controller {
|
||||
return res.page('welcome', {user: req.user})
|
||||
}
|
||||
async get_login(req, res){
|
||||
const app_name = this.configs.get('app.name')
|
||||
return res.page('login', {app_name})
|
||||
const AppName = this.configs.get('app.name')
|
||||
return res.page('login', {AppName})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ class Example extends Model {
|
||||
*/
|
||||
static get schema() {
|
||||
return {
|
||||
name: String,
|
||||
create_date: {type: Date, default: () => new Date},
|
||||
Name: String,
|
||||
CreateDate: {type: Date, default: () => new Date},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ const index = {
|
||||
// your own route protected by 'middleware::auth:UserOnly'
|
||||
'/dash': [ 'controller::Home.welcome' ],
|
||||
'/login': [ 'middleware::auth:GuestOnly', 'controller::Home.get_login' ],
|
||||
'/test-export' : ['controller::Export.json_export' ],
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -61,7 +61,7 @@ html
|
||||
body
|
||||
.container#intro
|
||||
h1 Hi, Welcome to
|
||||
span#name #{app_name}.
|
||||
span#name #{AppName}.
|
||||
h2 Choose your login method.
|
||||
|
||||
.container#login
|
||||
|
Loading…
Reference in New Issue
Block a user