improvement (config): enable/disable features from config.json

This commit is contained in:
Mickael KERJEAN 2018-11-15 12:49:34 +11:00
parent 81a0f1484d
commit 453fb902df
5 changed files with 28 additions and 19 deletions

View file

@ -103,7 +103,7 @@ export const onDelete = function(path, type){
};
export const onUpload = function(path, e){
const MAX_POOL_SIZE = 50;
const MAX_POOL_SIZE = 15;
let PRIOR_STATUS = {};
extract_upload_directory_the_way_that_works_but_non_official(e.dataTransfer.items || [], [])
.then((files) => {

View file

@ -130,19 +130,21 @@ export class Submenu extends React.Component {
</DropdownList>
</Dropdown>
<div className="view list-grid" onClick={this.onViewChange.bind(this)}><Icon name={this.props.view === "grid" ? "list" : "grid"}/></div>
<form onSubmit={(e) => this.onSearchKeypress(this.state.search_keyword, false, e)} className="view" style={{display: this.state.search_enabled === true ? "block" : "none"}}>
<label className="view search" onClick={this.onSearchToggle.bind(this, null)}>
<NgIf cond={this.state.search_input_visible !== true}>
<Icon name="search_dark"/>
<NgIf cond={window.CONFIG.enable_search === true} className="view" style={{display: this.state.search_enabled === true ? "block" : "none"}}>
<form onSubmit={(e) => this.onSearchKeypress(this.state.search_keyword, false, e)}>
<label className="view search" onClick={this.onSearchToggle.bind(this, null)}>
<NgIf cond={this.state.search_input_visible !== true}>
<Icon name="search_dark"/>
</NgIf>
<NgIf cond={this.state.search_input_visible === true}>
<Icon name="close_dark"/>
</NgIf>
</label>
<NgIf cond={this.state.search_input_visible !== null} type="inline">
<input ref="$input" onBlur={this.closeIfEmpty.bind(this, false)} style={{"width": this.state.search_input_visible ? "180px" : "0px"}} value={this.state.search_keyword} onChange={(e) => this.onSearchKeypress(e.target.value, true)} type="text" id="search" placeholder="search" name="search" autoComplete="off" />
</NgIf>
<NgIf cond={this.state.search_input_visible === true}>
<Icon name="close_dark"/>
</NgIf>
</label>
<NgIf cond={this.state.search_input_visible !== null} type="inline">
<input ref="$input" onBlur={this.closeIfEmpty.bind(this, false)} style={{"width": this.state.search_input_visible ? "180px" : "0px"}} value={this.state.search_keyword} onChange={(e) => this.onSearchKeypress(e.target.value, true)} type="text" id="search" placeholder="search" name="search" autoComplete="off" />
</NgIf>
</form>
</form>
</NgIf>
</div>
</Container>
</div>

View file

@ -214,12 +214,13 @@ export class ExistingThing extends React.Component {
return connectDragSource(connectDropNativeFile(connectDropFile(
<div className={"component_thing view-"+this.props.view}>
<Link to={this.props.file.link + location.search}>
<Link to={this.props.file.link + window.location.search}>
<Card ref="$card"className={this.state.hover} className={className}>
<Image preview={this.state.preview} icon={this.props.file.icon || this.props.file.type} view={this.props.view} path={path.join(this.props.path, this.props.file.name)} />
<Filename filename={this.props.file.name} filesize={this.props.file.size} filetype={this.props.file.type} onRename={this.onRename.bind(this)} is_renaming={this.state.is_renaming} onRenameCancel={this.onRenameRequest.bind(this, false)}/>
<DateTime show={this.state.icon !== 'loading'} timestamp={this.props.file.time} />
<ActionButton onClickRename={this.onRenameRequest.bind(this)} onClickDelete={this.onDeleteRequest.bind(this)} onClickShare={this.onShareRequest.bind(this)} is_renaming={this.state.is_renaming} can_rename={this.props.metadata.can_rename !== false} can_delete={this.props.metadata.can_delete !== false} can_share={this.props.metadata.can_share !== false} />
<ActionButton onClickRename={this.onRenameRequest.bind(this)} onClickDelete={this.onDeleteRequest.bind(this)} onClickShare={this.onShareRequest.bind(this)} is_renaming={this.state.is_renaming}
can_rename={this.props.metadata.can_rename !== false} can_delete={this.props.metadata.can_delete !== false} can_share={this.props.metadata.can_share !== false && window.CONFIG.enable_share === true} />
</Card>
</Link>
</div>

View file

@ -34,8 +34,10 @@ func init() {
// OAuth credentials
c.Get("oauth").Default("")
// Share
c.Get("share.enable").Default(true)
// Features
c.Get("feature.share.enable").Default(true)
c.Get("feature.search.enable").Default(true)
// Log
c.Get("log.telemetry").Default(true)
@ -183,6 +185,8 @@ func (this Config) Export() (string, error) {
Name string `json:"name"`
RememberMe bool `json:"remember_me"`
Connections interface{} `json:"connections"`
EnableSearch bool `json:"enable_search"`
EnableShare bool `json:"enable_share"`
MimeTypes map[string]string `json:"mime"`
}{
Editor: this.Get("general.editor").String(),
@ -192,6 +196,8 @@ func (this Config) Export() (string, error) {
Name: this.Get("general.name").String(),
RememberMe: this.Get("general.remember_me").Bool(),
Connections: this.Get("connections").Interface(),
EnableSearch: this.Get("feature.search.enable").Bool(),
EnableShare: this.Get("geature.share.enable").Bool(),
MimeTypes: AllMimeTypes(),
}
j, err := json.Marshal(publicConf)

View file

@ -24,7 +24,7 @@ func Init(a *App) {
session := r.PathPrefix("/api/session").Subrouter()
session.HandleFunc("", APIHandler(SessionGet, *a)).Methods("GET")
session.HandleFunc("", APIHandler(SessionAuthenticate, *a)).Methods("POST")
session.HandleFunc("", APIHandler(SessionLogout, *a)).Methods("DELETE")
session.HandleFunc("", CtxInjector(SessionLogout, *a)).Methods("DELETE")
session.Handle("/auth/{service}", APIHandler(SessionOAuthBackend, *a)).Methods("GET")
files := r.PathPrefix("/api/files").Subrouter()
@ -46,7 +46,7 @@ func Init(a *App) {
r.PathPrefix("/s/{share}").Handler(CtxInjector(WebdavHandler, *a))
// APP
r.HandleFunc("/api/config", APIHandler(ConfigHandler, *a)).Methods("GET")
r.HandleFunc("/api/config", CtxInjector(ConfigHandler, *a)).Methods("GET")
r.PathPrefix("/assets").Handler(StaticHandler(FILE_ASSETS, *a)).Methods("GET")
r.PathPrefix("/").Handler(DefaultHandler(FILE_INDEX, *a)).Methods("GET")