<commit_before>import {Component} from 'angular2/core';
import {UserService} from "./user.service";
import {ModuleService} from "./module.service";
import {ModuleEditor} from "./module-editor.component";
import {Module} from "./module";

@Component({
    selector: 'home',
    styles: [`
.list .active.item {
    color: #2185d0!important;
}

.modules {
    padding: 0;
}

.modules .item {
    padding: 1rem;
}
`],
    template: `
<div class="ui grid" *ngIf="isLoggedIn">
    <div class="row">
        <div class="four wide column">
            <div class="ui fluid blue basic button" (click)="newModule()">
                <i class="ui edit icon"></i>
                New module&hellip;
            </div>
            <div style="margin-top:1rem">
                <h5 class="ui top attached header">
                    Modules
                </h5>
                <div class="ui bottom attached segment modules">
                    <div class="ui center aligned basic segment" *ngIf="modules.length==0">
                        Use the editor to create your very first module.
                    </div>
                    <div class="ui list" *ngIf="modules.length>0">
                        <div class="item" *ngFor="#m of modules" (click)="module=m" style="cursor:pointer" [ngClass]="{active: m==module}">
                            <i class="code icon"></i>
                            <div class="content">{{m.name}}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="twelve wide column">
            <module-editor [module]="module" (moduleSaved)="saveModule($event)"></module-editor>
            <button class="ui red basic right floated mini button" *ngIf="module!=null" (click)="deleteModule()" style="margin-top:1rem">
                Delete module
            </button>
        </div>
    </div>
</div>
<div class="ui middle aligned center aligned grid" *ngIf="!isLoggedIn">
  <div class="column" style="max-width:400px;padding-top:100px;">
    <h2 class="ui header">
      <div class="content">
        Log-in to your account
      </div>
    </h2>
    <form class="ui large form">
      <div class="ui stacked segment">
        <div class="ui fluid large dark blue basic button" (click)="login('craftenforum')">Login via Craften Forum</div>
      </div>

      <div class="ui error message"></div>

    </form>

    <div class="ui message">
      New here? <a href="https://forum.craften.de" target="_blank">Sign Up</a>
    </div>
  </div>
</div>
`,
    directives: [ModuleEditor],
})
export class Home {
    public isLoggedIn:boolean = false;
    public user;
    public modules:Module[] = [];
    public module:Module;

    constructor(private _userService:UserService, private _moduleService:ModuleService) {
        _userService.getUser().subscribe(user => {
            this.user = user;
            this.isLoggedIn = user != null
        });
        _moduleService.getModules().subscribe(modules => this.modules = modules);
    }

    login(provider:string) {
        location.href = '/auth/' + provider;
    }

    newModule() {
        this.module = null;
    }

    saveModule(module:Module) {
        if (this.module == null) {
            this._moduleService.createModule(module.name, module.code).subscribe(module => {
                this.modules.push(module)
                this.module = module;
            });
        } else {
            this._moduleService.updateModule(this.module.name, module.name, module.code).subscribe(module => {
                this.module.name = module.name;
                this.module.code = module.code;
                this.module.lastModified = module.lastModified;
            });
        }
    }

    deleteModule() {
        if (this.module != null) {
            this._moduleService.deleteModule(this.module.name).subscribe(() => {
                this.modules = this.modules.filter(m => m.name != this.module.name);
                this.module = null;
            })
        }
    }
}<commit_msg>Add a button to open the raw module.<commit_after>import {Component} from 'angular2/core';
import {UserService} from "./user.service";
import {ModuleService} from "./module.service";
import {ModuleEditor} from "./module-editor.component";
import {Module} from "./module";

@Component({
    selector: 'home',
    styles: [`
.list .active.item {
    color: #2185d0!important;
}

.modules {
    padding: 0;
}

.modules .item {
    padding: 1rem;
}
`],
    template: `
<div class="ui grid" *ngIf="isLoggedIn">
    <div class="row">
        <div class="four wide column">
            <div class="ui fluid blue basic button" (click)="newModule()">
                <i class="ui edit icon"></i>
                New module&hellip;
            </div>
            <div style="margin-top:1rem">
                <h5 class="ui top attached header">
                    Modules
                </h5>
                <div class="ui bottom attached segment modules">
                    <div class="ui center aligned basic segment" *ngIf="modules.length==0">
                        Use the editor to create your very first module.
                    </div>
                    <div class="ui list" *ngIf="modules.length>0">
                        <div class="item" *ngFor="#m of modules" (click)="module=m" style="cursor:pointer" [ngClass]="{active: m==module}">
                            <i class="code icon"></i>
                            <div class="content">{{m.name}}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="twelve wide column">
            <module-editor [module]="module" (moduleSaved)="saveModule($event)"></module-editor>
            <button class="ui basic mini button" *ngIf="module!=null" (click)="openRawModule()" style="margin-top:1rem">
            <i class="ui text file outline icon"></i>
                Open raw file
            </button>
            <button class="ui red basic right floated mini button" *ngIf="module!=null" (click)="deleteModule()" style="margin-top:1rem">
                Delete module
            </button>
        </div>
    </div>
</div>
<div class="ui middle aligned center aligned grid" *ngIf="!isLoggedIn">
  <div class="column" style="max-width:400px;padding-top:100px;">
    <h2 class="ui header">
      <div class="content">
        Log-in to your account
      </div>
    </h2>
    <form class="ui large form">
      <div class="ui stacked segment">
        <div class="ui fluid large dark blue basic button" (click)="login('craftenforum')">Login via Craften Forum</div>
      </div>

      <div class="ui error message"></div>

    </form>

    <div class="ui message">
      New here? <a href="https://forum.craften.de" target="_blank">Sign Up</a>
    </div>
  </div>
</div>
`,
    directives: [ModuleEditor],
})
export class Home {
    public isLoggedIn:boolean = false;
    public user;
    public modules:Module[] = [];
    public module:Module;

    constructor(private _userService:UserService, private _moduleService:ModuleService) {
        _userService.getUser().subscribe(user => {
            this.user = user;
            this.isLoggedIn = user != null
        });
        _moduleService.getModules().subscribe(modules => this.modules = modules);
    }

    login(provider:string) {
        location.href = '/auth/' + provider;
    }

    newModule() {
        this.module = null;
    }

    saveModule(module:Module) {
        if (this.module == null) {
            this._moduleService.createModule(module.name, module.code).subscribe(module => {
                this.modules.push(module)
                this.module = module;
            });
        } else {
            this._moduleService.updateModule(this.module.name, module.name, module.code).subscribe(module => {
                this.module.name = module.name;
                this.module.code = module.code;
                this.module.lastModified = module.lastModified;
            });
        }
    }

    deleteModule() {
        if (this.module != null) {
            this._moduleService.deleteModule(this.module.name).subscribe(() => {
                this.modules = this.modules.filter(m => m.name != this.module.name);
                this.module = null;
            })
        }
    }

    openRawModule() {
        if (this.module != null) {
            window.open('/modules/' + this.user.username + '/' + this.module.name);
        }
    }
}
{'fraction_non_alphanumeric': 0.1475486746422707, 'fraction_numerical': 0.005277973258268825, 'mean_word_length': 1.977304469273743, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 125, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7614761', 'n_tokens_mistral': 2467, 'n_tokens_neox': 2370, 'n_words': 558}