Skip to content

Commit

Permalink
version 5.1.0: added register form
Browse files Browse the repository at this point in the history
  • Loading branch information
akless committed Apr 17, 2024
1 parent 52f94e1 commit e7234a4
Show file tree
Hide file tree
Showing 6 changed files with 731 additions and 11 deletions.
43 changes: 41 additions & 2 deletions ccm.dms.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* @overview ccmjs-based web component for a digital makerspace
* @author André Kless <[email protected]> 2018-2022
* @author André Kless <[email protected]> 2018-2022, 2024
* @license The MIT License (MIT)
* @version latest (5.0.0)
* @version latest (5.1.0)
* @changes
* version 5.1.0 (17.04.2024): added register form
* version 5.0.0 (03.03.2022): reimplementation
* (for older version changes see ccm.dms-4.5.0.js)
*/
Expand Down Expand Up @@ -247,6 +248,37 @@
* @type {Object.<string,Function>}
*/
this.events = {
onRegister: async () => {
$.params( { view: 'register' }, true, true );
await this.refresh();
},
onRegisterSubmit: async () => {
const store = await this.ccm.store( { url: 'https://ccm2.inf.h-brs.de', name: 'dms-user' } );
const { name, username, password } = $.formData( element.querySelector( '#register_form' ) );
try {
await store.set( {
key: username,
user: username,
name,
realm: 'cloud',
token: this.user.hash.md5( password ),
_: {
creator: username,
realm: 'cloud',
access: {
get: 'creator',
set: 'creator',
del: 'creator'
}
},
} );
alert(this.lang.translate('register_success'));
$.params( { view: 'home' }, true, true );
await this.refresh();
} catch (e) {
alert(this.lang.translate('register_failed'));
}
},
onLogin: async () => {
await this.user.login();
await this.start();
Expand Down Expand Up @@ -449,6 +481,8 @@
case 'app':
case 'component':
return this.render.item( params.view, params.id );
case 'register':
return this.render.register();
}
if ( params.edit ) return this.render.edit( params.edit, params.id );
if ( params.editor ) return this.render.editor( params.editor, params.template );
Expand Down Expand Up @@ -578,6 +612,11 @@
tool: tool_meta.path,
url: ( component, config ) => this.url + '?app=' + config[ 2 ].toString()
} );
},
register: async () => {
this.render.header();
this.html.render( this.html.register(), element );
this.lang && this.lang.translate();
}
};

Expand Down
2 changes: 0 additions & 2 deletions ccm.dms.min.js

This file was deleted.

6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="André Kless <[email protected]> 2022">
<meta name="author" content="André Kless <[email protected]> 2022, 2024">
<meta name="license" content="The MIT License (MIT)">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<title>Digital Makerspace</title>
<style>body { margin: 0; background-color: rgb( 248, 249, 250 ) }</style>
<script src="https://ccmjs.github.io/digital-makerspace/versions/ccm.dms-5.0.0.min.js"></script>
<ccm-dms-5-0-0 src='["ccm.load","https://ccmjs.github.io/digital-makerspace/resources/resources.mjs#live"]'></ccm-dms-5-0-0>
<script src="https://ccmjs.github.io/digital-makerspace/versions/ccm.dms-5.1.0.js"></script>
<ccm-dms-5-1-0 src='["ccm.load","https://ccmjs.github.io/digital-makerspace/resources/resources.mjs#live"]'></ccm-dms-5-1-0>
Loading

0 comments on commit e7234a4

Please sign in to comment.