irods-contrib / irods-cloud-browser

DFC Web Based cloud browser
BSD 2-Clause "Simplified" License
18 stars 13 forks source link

code mirror 'edit' page for qualifying files #129

Closed michael-conway closed 8 years ago

michael-conway commented 8 years ago

Add in place editing of certain file types (e.g. text, csv) as a tab in the home page for data objects

This mirrors the iPlant Discovery Environment implementation that uses code mirror

https://codemirror.net/

michael-conway commented 8 years ago

/**
     * GET operation gets a file as a String
     * parms 
     *   irodsPath - irods path
     * @return
     */
    def show() {
        log.info("index() gets content of a file")
        def irodsAccount = request.irodsAccount
        def irodsPath = params.irodsPath
        if (!irodsAccount) throw new IllegalArgumentException("no irodsAccount in request")
        if (!irodsPath) throw new IllegalArgumentException("no irodsPath in request")
        log.info("irodsPath:${irodsPath}")
        String responseData = fileService.stringFromFile(irodsPath)
        render responseData
    }

    /**
     * POST handling file upload from a string
     * parms
     *  data - string contents
     *  irodsPath - file path
     */
    def save() {
        log.info("save action in file controller")
        def irodsAccount = request.irodsAccount
        if (!irodsAccount) throw new IllegalStateException("no irodsAccount in request")
        def irodsPath = params.irodsPath
        if (!irodsPath) throw new IllegalArgumentException("no irodsPath in request")
        log.info("irodsPath:${irodsPath}")
        def data = params.data
        if (!irodsPath) throw new IllegalArgumentException("no irodsPath in request")
        fileService.stringToFile(data, irodsPath, irodsAccount)
        render(status:200)
    }