parent
40181db27c
commit
769f4fa42c
@ -0,0 +1,18 @@ |
||||
Template.adminImport.helpers |
||||
isAdmin: -> |
||||
return RocketChat.authz.hasRole(Meteor.userId(), 'admin') |
||||
isImporters: -> |
||||
return Object.keys(RocketChat.importTool.importers).length > 0 |
||||
importers: -> |
||||
importers = [] |
||||
_.each RocketChat.importTool.importers, (importer, key) -> |
||||
importer.key = key |
||||
importers.push importer |
||||
console.log importers |
||||
return importers |
||||
|
||||
Template.adminImport.events |
||||
'click .start-import': (event) -> |
||||
importer = @ |
||||
|
||||
console.log importer |
||||
@ -0,0 +1,34 @@ |
||||
<template name="adminImport"> |
||||
<section class="page-container page-home page-static page-settings"> |
||||
<head class="fixed-title"> |
||||
{{> burger}} |
||||
<h2> |
||||
<span class="room-title">Import</span> |
||||
</h2> |
||||
</head> |
||||
<div class="content"> |
||||
{{#unless isAdmin}} |
||||
<p>You are not authorized to view this page.</p> |
||||
{{else}} |
||||
{{#if isImporters}} |
||||
<div class="rocket-form"> |
||||
<fieldset> |
||||
{{#each importers}} |
||||
<div class="section"> |
||||
<h1>{{name}}</h1> |
||||
<div class="section-content"> |
||||
<div>{{description}}</div> |
||||
<button class="button start-import">Start</button> |
||||
|
||||
</div> |
||||
</div> |
||||
{{/each}} |
||||
</fieldset> |
||||
</div> |
||||
{{else}} |
||||
No Importers Available |
||||
{{/if}} |
||||
{{/unless}} |
||||
</div> |
||||
</section> |
||||
</template> |
||||
@ -0,0 +1,19 @@ |
||||
### |
||||
# Invite is a named function that will replace /invite commands |
||||
# @param {Object} message - The message object |
||||
### |
||||
if Meteor.isClient |
||||
Test = undefined |
||||
else |
||||
class Test |
||||
constructor: () -> |
||||
console.log 'Importer Test initialized' |
||||
prepare: -> |
||||
console.log 'test' |
||||
doImport: (data) -> |
||||
console.log data |
||||
|
||||
RocketChat.importTool.add 'test', Test, |
||||
name: '[Platform X] Import' |
||||
fileType: 'application/zip' |
||||
description: 'Imports [Platform X] data into Rocket.Chat' |
||||
@ -0,0 +1,22 @@ |
||||
Package.describe({ |
||||
name: 'rocketchat:importer-test', |
||||
version: '0.0.1', |
||||
summary: 'Importer for test', |
||||
git: '' |
||||
}); |
||||
|
||||
Package.onUse(function(api) { |
||||
api.versionsFrom('1.0'); |
||||
|
||||
api.use([ |
||||
'coffeescript', |
||||
'check', |
||||
'rocketchat:lib@0.0.1' |
||||
]); |
||||
|
||||
api.addFiles('main.coffee'); |
||||
}); |
||||
|
||||
Package.onTest(function(api) { |
||||
|
||||
}); |
||||
@ -0,0 +1,48 @@ |
||||
RocketChat.importTool = |
||||
importers: {} |
||||
|
||||
RocketChat.importTool.add = (name, importer, options) -> |
||||
if not RocketChat.importTool.importers[name]? |
||||
RocketChat.importTool.importers[name] = |
||||
name: options?.name |
||||
importer: importer |
||||
fileType: options?.fileType |
||||
description: options?.description |
||||
|
||||
return |
||||
|
||||
RocketChat.importTool.setup = (name) -> |
||||
if RocketChat.importTool.importers[name]?.importer? |
||||
importer = RocketChat.importTool.importers[name]?.importer() |
||||
RocketChat.importTool.importers[name].importerInstance = importer |
||||
|
||||
# Takes name and a file stream |
||||
RocketChat.importTool.prepare = (name, file) -> |
||||
if RocketChat.importTool.importers[name]?.importerInstance? |
||||
prepare = RocketChat.importTool.importers[name].importerInstance.prepare |
||||
prepare name, file |
||||
|
||||
# Takes name and object with users / channels selected to import |
||||
RocketChat.importTool.import = (name, input) -> |
||||
if RocketChat.importTool.importers[name]?.importerInstance? |
||||
importer = RocketChat.importTool.importers[name].importerInstance.import |
||||
importer name, input |
||||
|
||||
Meteor.methods |
||||
setupImport: (name) -> |
||||
if not Meteor.userId() |
||||
throw new Meteor.Error 203, t('User_logged_out') |
||||
|
||||
RocketChat.importTool.setup name |
||||
|
||||
prepareImport: (name, file) -> |
||||
if not Meteor.userId() |
||||
throw new Meteor.Error 203, t('User_logged_out') |
||||
|
||||
RocketChat.importTool.prepare name, file |
||||
|
||||
startImport: (name, input) -> |
||||
if not Meteor.userId() |
||||
throw new Meteor.Error 203, t('User_logged_out') |
||||
|
||||
RocketChat.importTool.import name, input |
||||
Loading…
Reference in new issue