* Improvements to ANSI parser

* Introduction of storage tags for file bases / areas
* Expiration for file web server items
* WIP work on clean ANSI (on hold for a bit while other file base stuff is worked on)
This commit is contained in:
Bryan Ashby
2016-12-06 18:58:56 -07:00
parent a7c0f2b7b0
commit 6da7d557f9
16 changed files with 557 additions and 180 deletions

View File

@@ -30,6 +30,7 @@ const MciViewIds = {
selectedFilterInfo : 10, // { ...filter object ... }
activeFilterInfo : 11, // { ...filter object ... }
error : 12, // validation errors
}
};
@@ -67,7 +68,6 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
this.updateActiveLabel();
// :TODO: Need to update %FN somehow
return cb(null);
},
newFilter : (formData, extraArgs, cb) => {
@@ -92,9 +92,8 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
if(newActive) {
filters.setActive(newActive.uuid);
} else {
// nothing to set active to
// :TODO: is this what we want?
this.client.user.properties.file_base_filter_active_uuid = 'none';
// nothing to set active to
this.client.user.removeProperty('file_base_filter_active_uuid');
}
}
@@ -106,7 +105,23 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
}
return cb(null);
});
}
},
viewValidationListener : (err, cb) => {
const errorView = this.viewControllers.editor.getView(MciViewIds.editor.error);
let newFocusId;
if(errorView) {
if(err) {
errorView.setText(err.message);
err.view.clearText(); // clear out the invalid data
} else {
errorView.clearText();
}
}
return cb(newFocusId);
},
};
}

View File

@@ -8,12 +8,16 @@ const ansi = require('../core/ansi_term.js');
const theme = require('../core/theme.js');
const FileEntry = require('../core/file_entry.js');
const stringFormat = require('../core/string_format.js');
const createCleanAnsi = require('../core/string_util.js').createCleanAnsi;
const FileArea = require('../core/file_area.js');
const Errors = require('../core/enig_error.js').Errors;
const ArchiveUtil = require('../core/archive_util.js');
const Config = require('../core/config.js').config;
const DownloadQueue = require('../core/download_queue.js');
const FileAreaWeb = require('../core/file_area_web.js');
const FileBaseFilters = require('../core/file_base_filter.js');
const cleanControlCodes = require('../core/string_util.js').cleanControlCodes;
// deps
const async = require('async');
@@ -328,15 +332,27 @@ exports.getModule = class FileAreaList extends MenuModule {
function populateViews(callback) {
if(_.isString(self.currentFileEntry.desc)) {
const descView = self.viewControllers.browse.getView(MciViewIds.browse.desc);
if(descView) {
descView.setText(self.currentFileEntry.desc);
if(descView) {
createCleanAnsi(
self.currentFileEntry.desc,
{ height : self.client.termHeight, width : descView.dimens.width },
cleanDesc => {
descView.setText(cleanDesc);
self.updateQueueIndicator();
self.populateCustomLabels('browse', 10);
return callback(null);
}
);
descView.setText( self.currentFileEntry.desc );
}
} else {
self.updateQueueIndicator();
self.populateCustomLabels('browse', 10);
return callback(null);
}
self.updateQueueIndicator();
self.populateCustomLabels('browse', 10);
return callback(null);
}
],
err => {
@@ -442,20 +458,6 @@ exports.getModule = class FileAreaList extends MenuModule {
);
this.updateCustomLabelsWithFilter( 'browse', 10, [ '{isQueued}' ] );
/*
const indicatorView = this.viewControllers.browse.getView(MciViewIds.browse.queueToggle);
if(indicatorView) {
const isQueuedIndicator = this.menuConfig.config.isQueuedIndicator || 'Y';
const isNotQueuedIndicator = this.menuConfig.config.isNotQueuedIndicator || 'N';
indicatorView.setText(stringFormat(
this.dlQueue.isQueued(this.currentFileEntry) ?
isQueuedIndicator :
isNotQueuedIndicator
)
);
}*/
}
cacheArchiveEntries(cb) {
@@ -469,7 +471,7 @@ exports.getModule = class FileAreaList extends MenuModule {
return cb(Errors.Invalid('Invalid area tag'));
}
const filePath = paths.join(areaInfo.storageDirectory, this.currentFileEntry.fileName);
const filePath = this.currentFileEntry.filePath;
const archiveUtil = ArchiveUtil.getInstance();
archiveUtil.listEntries(filePath, this.currentFileEntry.entryInfo.archiveType, (err, entries) => {
@@ -574,9 +576,10 @@ exports.getModule = class FileAreaList extends MenuModule {
}
loadFileIds(cb) {
this.fileListPosition = 0;
this.fileListPosition = 0;
const activeFilter = FileBaseFilters.getActiveFilter(this.client);
FileEntry.findFiles(this.filterCriteria, (err, fileIds) => {
FileEntry.findFiles(activeFilter, (err, fileIds) => {
this.fileList = fileIds;
return cb(err);
});