[sdvx] v1.0

This commit is contained in:
Freddie
2020-06-02 02:28:11 +01:00
parent 0a35d3f544
commit 052d669ffe
12 changed files with 325 additions and 87 deletions

View File

@@ -0,0 +1,139 @@
//DATA//
mixes: DB.Find({ collection: 'mix' })
-
const mixes_reversed = _.reverse(mixes)
const DIFF = ['NOV', 'ADV', 'EXH', 'INF', 'MXM']
const editing = query.edit
const sharing = query.share
function formatCode(code) {
return `${code.slice(0,4)}-${code.slice(4,8)}-${code.slice(8)}`
}
function shortenParam(param) {
const data = JSON.parse(param);
const gParam = JSON.parse(data.gene.params);
return [
data.dbVer,
gParam.minorVer,
gParam.seed,
data.gene.ver,
data.voxdj.params,
data.voxdj.ver,
].concat(...data.musics.map(m=>[m.id, m.grade]))
}
//----------------
Editing
//----------------
if editing
- const mix = mixes_reversed.filter(m=>m.code == editing)[0]
if mix
.card
.card-header
p.card-header-title
span.icon
i.mdi.mdi-music
| #{formatCode(mix.code)}
.card-content
form(method="post" action="/emit/updateMix")
input.input(type="hidden" name="code", value=mix.code readonly)
.field
label.label Mix Name
.control
input.input(type="text" name="name", placeholder=mix.name)
.field
label.label By
.control
input.input(type="text" name="creator", placeholder=mix.creator)
.field.buttons
a.button(href="?")
span.icon
i.mdi.mdi-chevron-left
span Back
button.button.is-primary(type="submit")
span.icon
i.mdi.mdi-check
span Submit
else
p Mix not found
a.button(href="?")
span.icon
i.mdi.mdi-chevron-left
span Back
//----------------
Sharing
//----------------
else if sharing
-
const mix = mixes_reversed.filter(m=>m.code == sharing)[0]
if mix
.card
.card-header
p.card-header-title
span.icon
i.mdi.mdi-music
| #{formatCode(mix.code)}
.card-content
.notification.is-info.is-light Double click and copy the code
.field
input.input.is-small.is-size-7(type='text' onClick="this.setSelectionRange(0, this.value.length)" value=`\`${JSON.stringify([mix.code,mix.name,mix.creator].concat(shortenParam(mix.param)))}\`` readonly)
.field
a.button(href="?")
span.icon
i.mdi.mdi-chevron-left
span Back
else
p Mix not found
a.button(href="?")
span.icon
i.mdi.mdi-chevron-left
span Back
//----------------
Main Page
//----------------
else
div.content
.buttons
form(method="post" action="/emit/importMix")
.field.has-addons
.control.is-expanded
input.input(placeholder="Paste code here" name='json')
.control
button.button.is-info(type="submit")
span.icon
i.mdi.mdi-import
span Import Mix
.columns.is-multiline
each mix in mixes_reversed
.column.is-half
.card
.card-header
p.card-header-title
span.icon
i.mdi.mdi-music
| #{formatCode(mix.code)}
.card-content
p #{mix.name}
p <b>by</b> #{mix.creator}
- let param = JSON.parse(mix.param)
- let musics = param.musics.map(m=>`${m.id}(${DIFF[m.grade]})`).join('+')
p #{param.musics.length}-SONGS
span.has-tooltip-right(data-tooltip=musics) MIX
.buttons
a.button.is-primary(href=`?share=${mix.code}`)
span.icon
i.mdi.mdi-export
span Share
a.button.is-info.is-outlined(href=`?edit=${mix.code}`)
span.icon
i.mdi.mdi-pencil
span Edit
button.button.is-danger.is-outlined(onClick=`emit('deleteMix', {code: '${mix.code}'}).then(()=>location.reload(true))`)
span.icon
i.mdi.mdi-trash-can
span Delete

View File

@@ -1,3 +0,0 @@
#change-name-button {
background-color: rgb(245, 147, 0);
}

View File

@@ -1,29 +0,0 @@
//-
Custom web component for plugin page
The following frontend components are already avaliable:
* Bulma [https://bulma.io/]
* MaterialDesignIcons [https://materialdesignicons.com/]
* jQuery [https://jquery.com/]
* axios [https://github.com/axios/axios]
* GeoPattern [https://github.com/btmills/geopattern]
* jdenticon [https://jdenticon.com/]
You can include your own js, css or images as well.
To request data from database, use //DATA// to indicate a comment block for capture and follow:
fieldName: expression
Then fieldName will be avaliable for the template engine when rendering.
//DATA//
data: DB.FindOne({ clicked: { $exists: true } })
.content
h3 Custom Page
p Clicked: #{data.clicked}
p
button.button.is-primary#plugin-click
| Send "click" event and refresh
//- You can include custom javascripts and send data back to plugin using emit()
see profile_name.pug for sending data using form
script(src="static/js/custom_page.js")

View File

@@ -1,5 +0,0 @@
$('#plugin-click').on('click', () => {
emit('click', {}).then(() => {
location.reload();
});
});

View File

@@ -0,0 +1,45 @@
//DATA//
profile: DB.FindOne(refid, { collection: 'profile' })
-
const padded = _.padStart(profile.id.toString(), 8);
const sdvxid = `${padded.slice(0, 4)}-${padded.slice(4)}`;
div
.card
.card-header
p.card-header-title
span.icon
i.mdi.mdi-account-edit
| Detail Change
.card-content
form(method="post" action="/emit/updateProfile")
.field
label.label ID
.control
input.input(type="text" name="refid", value=refid readonly)
.field
label.label SDVX ID
.control
input.input(type="text" name="sdvxid", value=sdvxid readonly)
.field
label.label Name
.control
input.input(type="text" name="name", placeholder=profile.name)
.field
label.label AppealCardID
span.icon.has-tooltip-right(data-tooltip="Check \"data/others/appeal_card.xml\"")
i.mdi.mdi-help-circle
.control
input.input(type="number" step=1 name="appeal", placeholder=profile.appeal)
.field
label.label AkanameID
span.icon.has-tooltip-right(data-tooltip="Check \"data/others/akaname_parts.xml\"")
i.mdi.mdi-help-circle
.control
input.input(type="number" step=1 name="akaname", placeholder=profile.akaname)
.field
button.button.is-primary(type="submit")
span.icon
i.mdi.mdi-check
span Submit

View File

@@ -1,42 +0,0 @@
//-
Custom web component for individual user profile
The following frontend components are already avaliable:
* Bulma [https://bulma.io/]
* MaterialDesignIcons [https://materialdesignicons.com/]
* jQuery [https://jquery.com/]
* axios [https://github.com/axios/axios]
* GeoPattern [https://github.com/btmills/geopattern]
* jdenticon [https://jdenticon.com/]
You can include your own js/css as well
To request data from database, use //DATA// to indicate a comment block for capture and follow:
fieldName: expression
Then fieldName will be avaliable for the template engine when rendering.
WebUI file with prefix "profile_" is different from other pug file:
* This page have a "refid" local variable, you can request data with it or use it during render.
* User can access these page by editing a profile.
//DATA//
profile: DB.FindOne(refid, { login_count: { $exists: true } })
//-
You can include your own stylesheet
link(rel="stylesheet" href="static/css/profile_name.css")
div
h3 Hi #{profile.name}
section.section
//-
You can send data back to plugin using post method in form
see custom_page.pug for sending data using emit() function
form(method="post" action="/emit/change")
input(type="hidden" name="refid" value=refid)
.field
label.label Change Name
.field
input.input(type="text" name="name", value=profile.name)
.field
button.button.is-primary#change-name-button(type="submit") Submit