Skip to content

Instantly share code, notes, and snippets.

View travist's full-sized avatar

Travis Tidwell travist

View GitHub Profile
@travist
travist / mongodump.sh
Last active January 12, 2024 16:01
MongoDump for DocumentDB
wget https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
mongodump --ssl \
--host="<cluster-name>.<region>.docdb.amazonaws.com:27017" \
--db=formio \
--archive=formio.gz --gzip \
--username="<yourUsername>" \
--password="<yourPassword>" \
--sslCAFile global-bundle.pem
@travist
travist / delete.js
Last active July 31, 2023 14:49
Mongo Delete multiple projects and resources within it.
db.projects.find({_id: {$in: [
ObjectId('63ebe4e2902342342db152a8'),
ObjectId('642324234234a13675034017'),
ObjectId('642c68506234234234241869'),
]}}).forEach(function(project) {
print('Deleting project ' + project.name);
db.submissions.deleteMany({project: project._id});
db.actions.deleteMany({project: project._id});
db.formrevisions.deleteMany({project: project._id});
db.forms.deleteMany({project: project._id});
@travist
travist / changeowner.js
Created July 24, 2023 21:43
Mongo - Change ownership to portal base project owner.
db.projects.find({name: 'formio'}).forEach(project => {
db.projects.updateMany({}, {$set: {owner: project.owner}});
db.forms.updateMany({}, {$set: {owner: project.owner}});
db.submissions.updateMany({}, {$set: {owner: project.owner}});
db.actions.updateMany({}, {$set: {owner: project.owner}});
db.tags.updateMany({}, {$set: {owner: project.owner}});
});
@travist
travist / controller.ts
Last active July 12, 2023 14:56
Enable Save As Draft in Angular.
import debounce from 'lodash/debounce';
@Component({
...
})
export class MyController {
public submission = {};
ngAfterViewInit() {
var currentSubmission = localStorage.getItem('currentSubmission-' + this.route.params.formId);
if (currentSubmission) {
this.submission = JSON.parse(currentSubmission);

Clone a project from either OSS to Enterprise or from an Enterprise project to another Enterprise project.

Installation

Download the ZIP of this Gist, then install using

npm install

Usage

@travist
travist / .env
Created May 11, 2023 13:24
Resquel + Form.io Example
PORT=3010
FORM=http://localhost:3000/sql/routes
DB_TYPE=mysql
DB_HOST=localhost
DB_NAME=formio
DB_USER=root
DB_PASS=CHANGEME
@travist
travist / README.md
Last active April 17, 2023 16:17
Convert XML to Passport Configurations

Usage

Copy contents of your Passport XML into the config.xml file, then run the following.

node index.js

Take the result of the console, and then add the following to the top of the JSON it provides to you.

@travist
travist / app.component.ts
Last active April 12, 2023 16:45
Angular SSO Init
import { Formio } from 'formiojs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements AfterViewInit, OnInit {
constructor(public auth: FormioAuthService) {}
ngOnInit() {
<formio-alerts [alerts]="service.alerts"></formio-alerts>
<formio-grid
[src]="gridSrc"
[query]="myQuery"
[onForm]="service.formLoaded"
(rowSelect)="onSelect($event)"
(error)="service.onError($event)"
(createItem)="onCreateItem()"
[createText]="createText"
></formio-grid>
@travist
travist / cleanup.js
Created February 9, 2023 21:19
Cleanup a Form.io database with many projects.
/**
* Cleanup the database. This script does the following.
*
* Run this using
* node cleanupdb.js --NODE_CONFIG='{"src": "mongodb://localhost:27017/formio"}'
*/
const config = require('config');
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;